|
@@ -20,12 +20,17 @@ typedef struct {
|
|
|
uint32_t blen;
|
|
uint32_t blen;
|
|
|
uint32_t dlen;
|
|
uint32_t dlen;
|
|
|
}data_t;
|
|
}data_t;
|
|
|
-typedef struct {
|
|
|
|
|
- uint8_t magic[14];
|
|
|
|
|
- uint16_t size;
|
|
|
|
|
- uint32_t partition;
|
|
|
|
|
- uint32_t version;
|
|
|
|
|
|
|
+typedef union {
|
|
|
|
|
+ struct {
|
|
|
|
|
+ uint8_t magic[14];
|
|
|
|
|
+ uint16_t size;
|
|
|
|
|
+ uint32_t partition;
|
|
|
|
|
+ uint32_t version;
|
|
|
|
|
+ }hdr;
|
|
|
|
|
+ uint8_t padd[128];
|
|
|
}fw_hdr_t;
|
|
}fw_hdr_t;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
typedef struct {
|
|
typedef struct {
|
|
|
uint32_t operation_flag; // 0
|
|
uint32_t operation_flag; // 0
|
|
|
uint32_t partition; // 1
|
|
uint32_t partition; // 1
|
|
@@ -216,10 +221,11 @@ static int get_info(char *buf, fw_hdr_t *hdr, fw_info_t *inf, fw_image_t *img)
|
|
|
uint32_t rom_addr = get_int(buf, "PROGRAME_APP1");
|
|
uint32_t rom_addr = get_int(buf, "PROGRAME_APP1");
|
|
|
|
|
|
|
|
//fill hdr
|
|
//fill hdr
|
|
|
- get_magic(buf, "MODBUS_HEAD", hdr->magic);
|
|
|
|
|
- hdr->size = 0;
|
|
|
|
|
- hdr->version = version;
|
|
|
|
|
- hdr->partition = partition;
|
|
|
|
|
|
|
+ memset(hdr, 0xff, sizeof(fw_hdr_t));
|
|
|
|
|
+ get_magic(buf, "MODBUS_HEAD", hdr->hdr.magic);
|
|
|
|
|
+ hdr->hdr.size = 0;
|
|
|
|
|
+ hdr->hdr.version = version;
|
|
|
|
|
+ hdr->hdr.partition = partition;
|
|
|
|
|
|
|
|
//fill inf
|
|
//fill inf
|
|
|
inf->operation_flag = 0; // 0
|
|
inf->operation_flag = 0; // 0
|
|
@@ -299,7 +305,7 @@ static int file_read(const TCHAR* path, data_t *data)
|
|
|
|
|
|
|
|
r = ReadFile(hFile, data->data, data->dlen, &rlen, NULL);
|
|
r = ReadFile(hFile, data->data, data->dlen, &rlen, NULL);
|
|
|
if (r==FALSE) {
|
|
if (r==FALSE) {
|
|
|
- printf("ReadFile fw failed\n");
|
|
|
|
|
|
|
+ _tprintf(_T("%s read failed\n"), path);
|
|
|
goto quit;
|
|
goto quit;
|
|
|
}
|
|
}
|
|
|
r = 0;
|
|
r = 0;
|
|
@@ -376,9 +382,9 @@ int main(char argc, char *argv[])
|
|
|
if (r) {
|
|
if (r) {
|
|
|
goto fail;
|
|
goto fail;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
get_info(fcfg.data, &fwHdr, &fwInfo, &fwImg);
|
|
get_info(fcfg.data, &fwHdr, &fwInfo, &fwImg);
|
|
|
- get_ver(version, fwHdr.version);
|
|
|
|
|
|
|
+ get_ver(version, fwHdr.hdr.version);
|
|
|
|
|
|
|
|
path1 = argv[1];
|
|
path1 = argv[1];
|
|
|
if (make_single_bin) {
|
|
if (make_single_bin) {
|