-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update for 1-10 mp image tool release
- Loading branch information
Showing
6 changed files
with
302 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
km0_boot_all.bin address 0x08000000 | ||
km4_boot_all.bin address 0x08004000 | ||
km0_km4_image2.bin address 0x08006000 |
Binary file added
BIN
+1.11 MB
Ameba_misc/Image_Releated/Realtek_Ameba_MP_Tool_Application_Note_v2.0.pdf
Binary file not shown.
110 changes: 110 additions & 0 deletions
110
Arduino_package/ameba_d_tools_linux/tools/linux/src/upload_image_tool_linux.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/* | ||
Compile: | ||
linux: | ||
g++ -o upload_image_tool_linux tools/linux/src/upload_image_tool_linux.cpp -static | ||
g++ -std=c++11 -o upload_image_tool_linux upload_image_tool_linux.cpp -static | ||
g++ -std=c++11 -o upload_image_tool_linux upload_image_tool_linux.cpp -lpthread | ||
*/ | ||
|
||
#include <iostream> | ||
#include <sstream> | ||
#include <vector> | ||
#include <cstring> | ||
#include <cstdlib> | ||
#include <string> | ||
#include <cstdio> | ||
#include <sys/stat.h> | ||
#include <fstream> | ||
#include <unistd.h> | ||
|
||
//#include <windows.h> | ||
|
||
#include <thread> | ||
//#include <mutex> | ||
|
||
#include <time.h> | ||
#include <errno.h> | ||
|
||
using namespace std; | ||
|
||
//mutex mu; | ||
int check_image_upload = 0; | ||
|
||
int msleep(long msec) { | ||
struct timespec ts; | ||
int res; | ||
|
||
if (msec < 0) { | ||
errno = EINVAL; | ||
return -1; | ||
} | ||
|
||
ts.tv_sec = msec / 1000; | ||
ts.tv_nsec = (msec % 1000) * 1000000; | ||
|
||
do { | ||
res = nanosleep(&ts, &ts); | ||
} while (res && errno == EINTR); | ||
|
||
return res; | ||
} | ||
|
||
void image_tool_thread(char* t1_com) { | ||
stringstream t1_cmdss; | ||
string t1_cmd; | ||
|
||
t1_cmdss.clear(); | ||
// run image tool with serial port as argument | ||
t1_cmdss << "./tools/linux/image_tool/amebad_image_tool " << t1_com; | ||
|
||
// copy command in cmdss to cmd | ||
t1_cmd = t1_cmdss.str(); | ||
system(t1_cmd.c_str()); | ||
|
||
// mu.lock(); | ||
check_image_upload = 100; | ||
// mu.unlock(); | ||
} | ||
|
||
void image_tool_progress() { | ||
cout << "Uploading." << flush; | ||
while (1) { | ||
msleep(500); | ||
// mu.lock(); | ||
if (check_image_upload != 0) { | ||
break; | ||
} else { | ||
cout << "." << flush; | ||
} | ||
// mu.unlock(); | ||
} | ||
cout << " Upload Image done. " << endl; | ||
} | ||
|
||
int main(int argc, char *argv[]) { | ||
string cmd; | ||
|
||
// change directory to {runtime.tools.ameba_d_tools.path} | ||
chdir(argv[1]); | ||
|
||
// 5 seconds count down to allow user setting ameba D to UART download mode | ||
cmd = "Please enter the upload mode (wait 5s)"; | ||
cout << cmd << endl; | ||
for (int i = 5; i > 0; i--) { | ||
sleep(1); | ||
cmd = to_string(i); | ||
cout << " 0" << cmd << endl; | ||
} | ||
|
||
thread t2(image_tool_progress); | ||
thread t1(image_tool_thread, argv[2]); | ||
|
||
// t2.detach(); | ||
// t1.detach(); | ||
t2.join(); | ||
t1.join(); | ||
|
||
return 0; | ||
} |
107 changes: 107 additions & 0 deletions
107
Arduino_package/ameba_d_tools_macos/tools/macos/src/upload_image_tool_macos.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* | ||
Compile: | ||
macos: | ||
g++ -o upload_image_tool_macos upload_image_tool_macos.cpp | ||
g++ -std=c++11 -o upload_image_tool_macos upload_image_tool_macos.cpp | ||
*/ | ||
|
||
#include <iostream> | ||
#include <sstream> | ||
#include <vector> | ||
#include <cstring> | ||
#include <cstdlib> | ||
#include <string> | ||
#include <cstdio> | ||
#include <sys/stat.h> | ||
#include <fstream> | ||
#include <unistd.h> | ||
|
||
//#include <windows.h> | ||
|
||
#include <thread> | ||
//#include <mutex> | ||
|
||
#include <time.h> | ||
#include <errno.h> | ||
|
||
using namespace std; | ||
|
||
//mutex mu; | ||
int check_image_upload = 0; | ||
|
||
int msleep(long msec) { | ||
struct timespec ts; | ||
int res; | ||
|
||
if (msec < 0) { | ||
errno = EINVAL; | ||
return -1; | ||
} | ||
|
||
ts.tv_sec = msec / 1000; | ||
ts.tv_nsec = (msec % 1000) * 1000000; | ||
|
||
do { | ||
res = nanosleep(&ts, &ts); | ||
} while (res && errno == EINTR); | ||
|
||
return res; | ||
} | ||
|
||
void image_tool_thread(char* t1_com) { | ||
stringstream t1_cmdss; | ||
string t1_cmd; | ||
|
||
t1_cmdss.clear(); | ||
t1_cmdss << "./tools/macos/image_tool/amebad_image_tool " << t1_com; | ||
getline(t1_cmdss, t1_cmd); | ||
cout << t1_cmd << endl; | ||
system(t1_cmd.c_str()); | ||
|
||
// mu.lock(); | ||
check_image_upload = 100; | ||
// mu.unlock(); | ||
} | ||
|
||
void image_tool_progress() { | ||
cout << "Uploading." << flush; | ||
while (1) { | ||
msleep(500); | ||
// mu.lock(); | ||
if (check_image_upload != 0) { | ||
break; | ||
} else { | ||
cout << "." << flush; | ||
} | ||
// mu.unlock(); | ||
} | ||
cout << " Upload Image done. " << endl; | ||
} | ||
|
||
int main(int argc, char *argv[]) { | ||
string cmd; | ||
|
||
chdir(argv[1]); | ||
|
||
cmd = "Please enter the upload mode (wait 5s)"; | ||
cout << cmd << endl; | ||
for (int i = 5; i > 0; i--) { | ||
sleep(1); | ||
cmd = to_string(i); | ||
cout << " 0" << cmd << endl; | ||
} | ||
|
||
thread t2(image_tool_progress); | ||
thread t1(image_tool_thread, argv[2]); | ||
|
||
// t2.detach(); | ||
// t1.detach(); | ||
t2.join(); | ||
t1.join(); | ||
|
||
return 0; | ||
} |
81 changes: 81 additions & 0 deletions
81
Arduino_package/ameba_d_tools_windows/tools/windows/src/upload_image_tool_windows.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
Compile: | ||
windows: | ||
mingw32-g++.exe -o upload_image_tool_windows.exe upload_image_tool_windows.cpp -static | ||
i686-w64-mingw32-g++.exe -o upload_image_tool_windows.exe upload_image_tool_windows.cpp -static | ||
*/ | ||
|
||
#include <iostream> | ||
#include <sstream> | ||
#include <vector> | ||
#include <cstring> | ||
#include <cstdlib> | ||
#include <string> | ||
#include <cstdio> | ||
#include <sys/stat.h> | ||
#include <fstream> | ||
#include <unistd.h> | ||
|
||
#include <windows.h> | ||
|
||
#include <thread> | ||
//#include <mutex> | ||
|
||
using namespace std; | ||
|
||
//mutex mu; | ||
int check_image_upload = 0; | ||
|
||
void image_tool_thread(char* t1_com) { | ||
stringstream t1_cmdss; | ||
string t1_cmd; | ||
t1_cmdss.clear(); | ||
t1_cmdss << ".\\tools\\windows\\image_tool\\amebad_image_tool.exe " << t1_com; | ||
getline(t1_cmdss, t1_cmd); | ||
system(t1_cmd.c_str()); | ||
// mu.lock(); | ||
check_image_upload = 100; | ||
// mu.unlock(); | ||
} | ||
|
||
void image_tool_progress() { | ||
cout << "Uploading." << flush; | ||
while (1) { | ||
Sleep(500); | ||
// mu.lock(); | ||
if (check_image_upload != 0) { | ||
break; | ||
} else { | ||
cout << "." << flush; | ||
} | ||
// mu.unlock(); | ||
} | ||
cout << " Upload Image done. " << endl; | ||
} | ||
|
||
|
||
int main(int argc, char *argv[]) { | ||
string cmd; | ||
chdir(argv[1]); | ||
|
||
cmd = "Please enter the upload mode (wait 5s)"; | ||
cout << cmd << endl; | ||
for (int i = 5; i > 0; i--) | ||
{ | ||
Sleep(1000); | ||
cmd = to_string(i); | ||
cout << " 0" << cmd << endl; | ||
} | ||
|
||
thread t2(image_tool_progress); | ||
thread t1(image_tool_thread, argv[2]); | ||
|
||
// t2.detach(); | ||
// t1.detach(); | ||
t2.join(); | ||
t1.join(); | ||
|
||
return 0; | ||
} |