|
@@ -222,6 +222,7 @@ static int get_info(char *buf, fw_hdr_t *hdr, fw_info_t *inf, fw_image_t *img)
|
|
|
uint32_t version = get_version(buf, "VERSION");
|
|
uint32_t version = get_version(buf, "VERSION");
|
|
|
uint32_t partition = get_int(buf, "PARTITION");
|
|
uint32_t partition = get_int(buf, "PARTITION");
|
|
|
uint32_t rom_addr = get_int(buf, "PROGRAME_APP1");
|
|
uint32_t rom_addr = get_int(buf, "PROGRAME_APP1");
|
|
|
|
|
+ uint32_t use_one_app = get_int(buf, "USE_ONE_APP");
|
|
|
|
|
|
|
|
//fill hdr
|
|
//fill hdr
|
|
|
memset(hdr, 0xff, sizeof(fw_hdr_t));
|
|
memset(hdr, 0xff, sizeof(fw_hdr_t));
|
|
@@ -241,9 +242,18 @@ static int get_info(char *buf, fw_hdr_t *hdr, fw_info_t *inf, fw_image_t *img)
|
|
|
inf->app1_version = version; // V1.0.0.0 (1<<24 | 0 << 16 | 0 << 8 | 0)
|
|
inf->app1_version = version; // V1.0.0.0 (1<<24 | 0 << 16 | 0 << 8 | 0)
|
|
|
inf->app1_rom_addr = rom_addr; // PROGRAME_APP1 0x08005400
|
|
inf->app1_rom_addr = rom_addr; // PROGRAME_APP1 0x08005400
|
|
|
inf->app1_partition = 1; // 1
|
|
inf->app1_partition = 1; // 1
|
|
|
- inf->app2_version = version; // V1.0.0.0 (1<<24 | 0 << 16 | 0 << 8 | 0)
|
|
|
|
|
- inf->app2_rom_addr = get_int(buf, "PROGRAME_APP2"); // PROGRAME_APP2 0x0800A400
|
|
|
|
|
- inf->app2_partition = 2; // 1
|
|
|
|
|
|
|
+ if(use_one_app)
|
|
|
|
|
+ {
|
|
|
|
|
+ inf->app2_version = 0xFFFFFFFF; // V1.0.0.0 (1<<24 | 0 << 16 | 0 << 8 | 0)
|
|
|
|
|
+ inf->app2_rom_addr = 0xFFFFFFFF; // PROGRAME_APP2 0x0800A400
|
|
|
|
|
+ inf->app2_partition = 0xFFFFFFFF; // 1
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ inf->app2_version = version; // V1.0.0.0 (1<<24 | 0 << 16 | 0 << 8 | 0)
|
|
|
|
|
+ inf->app2_rom_addr = get_int(buf, "PROGRAME_APP2"); // PROGRAME_APP2 0x0800A400
|
|
|
|
|
+ inf->app2_partition = 2; // 1
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
//fill img
|
|
//fill img
|
|
|
img->boot.blen = get_int(buf, "BOOT_LOADER_SIZE");
|
|
img->boot.blen = get_int(buf, "BOOT_LOADER_SIZE");
|
|
@@ -254,9 +264,16 @@ static int get_info(char *buf, fw_hdr_t *hdr, fw_info_t *inf, fw_image_t *img)
|
|
|
|
|
|
|
|
img->app1.blen = get_int(buf, "PROGRAME_APP1_SIZE");
|
|
img->app1.blen = get_int(buf, "PROGRAME_APP1_SIZE");
|
|
|
img->app1.data = my_malloc(img->app1.blen);
|
|
img->app1.data = my_malloc(img->app1.blen);
|
|
|
-
|
|
|
|
|
- img->app2.blen = get_int(buf, "PROGRAME_APP2_SIZE");
|
|
|
|
|
- img->app2.data = my_malloc(img->app2.blen);
|
|
|
|
|
|
|
+ if (use_one_app)
|
|
|
|
|
+ {
|
|
|
|
|
+ img->app2.blen = 0;
|
|
|
|
|
+ img->app2.data == NULL;
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ img->app2.blen = get_int(buf, "PROGRAME_APP2_SIZE");
|
|
|
|
|
+ img->app2.data = my_malloc(img->app2.blen);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
@@ -349,7 +366,7 @@ static int get_ver(char *ver, uint32_t v)
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
//////////////////////////////////////////
|
|
//////////////////////////////////////////
|
|
|
-static TCHAR* cfgPath = (TCHAR*)__TEXT("./cfg.h");
|
|
|
|
|
|
|
+//static TCHAR* cfgPath = (TCHAR*)__TEXT("./cfg.h");
|
|
|
|
|
|
|
|
int main(char argc, char *argv[])
|
|
int main(char argc, char *argv[])
|
|
|
{
|
|
{
|
|
@@ -365,18 +382,25 @@ int main(char argc, char *argv[])
|
|
|
TCHAR* xpath1=NULL, * xpath2 = NULL,* xpath3 = NULL;
|
|
TCHAR* xpath1=NULL, * xpath2 = NULL,* xpath3 = NULL;
|
|
|
int make_single_bin = 0;
|
|
int make_single_bin = 0;
|
|
|
char version[32],md5[32];
|
|
char version[32],md5[32];
|
|
|
-
|
|
|
|
|
- if (argc==2) {
|
|
|
|
|
- printf("make a upgrade file\n");
|
|
|
|
|
- }
|
|
|
|
|
- else if(argc == 3){
|
|
|
|
|
- printf("make a single bin\n");
|
|
|
|
|
- make_single_bin = 1;
|
|
|
|
|
- }
|
|
|
|
|
- else {
|
|
|
|
|
- printf("usage: mb app.bin or mb boot.bin app.bin\n");
|
|
|
|
|
|
|
+ TCHAR* cfgPath;
|
|
|
|
|
+
|
|
|
|
|
+ //if (argc==2) {
|
|
|
|
|
+ // printf("make a upgrade file\n");
|
|
|
|
|
+ //}
|
|
|
|
|
+ //else if(argc == 3){
|
|
|
|
|
+ // printf("make a single bin\n");
|
|
|
|
|
+ // make_single_bin = 1;
|
|
|
|
|
+ //}
|
|
|
|
|
+ //else {
|
|
|
|
|
+ // printf("usage: mb app.bin or mb boot.bin app.bin\n");
|
|
|
|
|
+ // return -1;
|
|
|
|
|
+ //}
|
|
|
|
|
+ if (argc != 4)
|
|
|
|
|
+ {
|
|
|
|
|
+ printf("usage: mb cfg.h app.bin or mb boot.bin app.bin\n");
|
|
|
return -1;
|
|
return -1;
|
|
|
}
|
|
}
|
|
|
|
|
+ cfgPath = char_to_tchar(argv[1]);
|
|
|
r = file_read(cfgPath, &fcfg);
|
|
r = file_read(cfgPath, &fcfg);
|
|
|
if (r) {
|
|
if (r) {
|
|
|
goto fail;
|
|
goto fail;
|
|
@@ -385,16 +409,16 @@ int main(char argc, char *argv[])
|
|
|
get_info(fcfg.data, &fwHdr, &fwInfo, &fwImg);
|
|
get_info(fcfg.data, &fwHdr, &fwInfo, &fwImg);
|
|
|
get_ver(version, fwHdr.hdr.version);
|
|
get_ver(version, fwHdr.hdr.version);
|
|
|
|
|
|
|
|
- path1 = argv[1];
|
|
|
|
|
- if (make_single_bin) {
|
|
|
|
|
|
|
+ path1 = argv[2];
|
|
|
|
|
+ //if (make_single_bin) {
|
|
|
|
|
|
|
|
- xpath1 = char_to_tchar(path1);
|
|
|
|
|
- flen = file_read(xpath1, &fwImg.boot);
|
|
|
|
|
- if (flen < 0) {
|
|
|
|
|
|
|
+ xpath1 = char_to_tchar(path1);
|
|
|
|
|
+ flen = file_read(xpath1, &fwImg.boot);
|
|
|
|
|
+ if (flen < 0) {
|
|
|
goto fail;
|
|
goto fail;
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- path2 = argv[2];
|
|
|
|
|
|
|
+ path2 = argv[3];
|
|
|
xpath2 = char_to_tchar(path2);
|
|
xpath2 = char_to_tchar(path2);
|
|
|
flen = file_read(xpath2, &fwImg.app1);
|
|
flen = file_read(xpath2, &fwImg.app1);
|
|
|
if (flen < 0) {
|
|
if (flen < 0) {
|
|
@@ -449,17 +473,18 @@ int main(char argc, char *argv[])
|
|
|
WriteFile(hFile, fwImg.boot.data, fwImg.boot.blen, NULL, NULL);
|
|
WriteFile(hFile, fwImg.boot.data, fwImg.boot.blen, NULL, NULL);
|
|
|
WriteFile(hFile, fwImg.info.data, fwImg.info.blen, NULL, NULL);
|
|
WriteFile(hFile, fwImg.info.data, fwImg.info.blen, NULL, NULL);
|
|
|
WriteFile(hFile, fwImg.app1.data, fwImg.app1.blen, NULL, NULL);
|
|
WriteFile(hFile, fwImg.app1.data, fwImg.app1.blen, NULL, NULL);
|
|
|
- WriteFile(hFile, fwImg.app1.data, fwImg.app1.blen, NULL, NULL);
|
|
|
|
|
- }
|
|
|
|
|
- else {
|
|
|
|
|
- xpath1 = char_to_tchar(path1);
|
|
|
|
|
|
|
+ if(fwImg.app2.data != NULL)
|
|
|
|
|
+ WriteFile(hFile, fwImg.app1.data, fwImg.app1.blen, NULL, NULL);
|
|
|
|
|
+ //}
|
|
|
|
|
+ //else {
|
|
|
|
|
+ xpath1 = char_to_tchar(path2);
|
|
|
flen = file_read(xpath1, &fupg);
|
|
flen = file_read(xpath1, &fupg);
|
|
|
if (flen < 0) {
|
|
if (flen < 0) {
|
|
|
goto fail;
|
|
goto fail;
|
|
|
}
|
|
}
|
|
|
get_time(xpath1, time1, sizeof(time1));
|
|
get_time(xpath1, time1, sizeof(time1));
|
|
|
|
|
|
|
|
- strcpy(imgPath, path1);
|
|
|
|
|
|
|
+ strcpy(imgPath, path2);
|
|
|
dot = strrchr(imgPath, '\\');
|
|
dot = strrchr(imgPath, '\\');
|
|
|
if (dot) {
|
|
if (dot) {
|
|
|
dot[1] = 0;
|
|
dot[1] = 0;
|
|
@@ -496,7 +521,7 @@ int main(char argc, char *argv[])
|
|
|
//WriteFile(hFile, &md5, sizeof(md5), NULL, NULL);
|
|
//WriteFile(hFile, &md5, sizeof(md5), NULL, NULL);
|
|
|
|
|
|
|
|
print_md5("md5: ", md5);
|
|
print_md5("md5: ", md5);
|
|
|
- }
|
|
|
|
|
|
|
+// }
|
|
|
|
|
|
|
|
fail:
|
|
fail:
|
|
|
if(hFile) CloseHandle(hFile);
|
|
if(hFile) CloseHandle(hFile);
|