7 #define SIZE_HASH_BUFFER 4096
11 uint8_t pBuf[SIZE_HASH_BUFFER];
13 //unsigned short m_crc16ccitt;
17 printf("\n\rThis utility is used to prefix a header to the patch code!\n\r");
18 printf("For loading into the bootcode and the integrity crc header!\n\r");
19 printf(" - patch_hdr [patch binary] [load address]\n\r");
20 printf("\n\r e.g. patch_hdr patch.bin 0x8e0000\n\r");
24 #define _ROMP_SIZE_ 64
26 int main(int argc, char* argv[] )
31 struct rom_patch_st patch_item;
32 uint8_t *pBufPtr = NULL;
33 uint32_t ran_patch_size = 0;
36 uint8_t name_of_patch[32];
39 _patch_init(&patch_item);
43 _patch_oepn(pBuf, argv[1]);
51 printf("%s %s %s\n\r", argv[0], argv[1], argv[2]);
55 /***************************************************************/
56 // allocate the buffer space for func address
57 if( !(patch_item.fun = (uint8_t *)malloc(SIZE_HASH_BUFFER)) )
60 // check the function address of the patch code
62 if( db_ascii_to_hex((ld_addr+2), &(patch_item.ld_addr))!=0 )
65 // check the function address of the patch code
67 if( db_ascii_to_hex((fun_addr+2), &(patch_item.fun_addr))!=0 )
70 /***************************************************************/
72 if( gen_patch_item(&patch_item, argv[1])!=TRUE )
75 printf(" - prefix to the patch binary -\n\r");
76 _patch_dump(&patch_item);
78 sprintf(name_of_patch, "h_%s", argv[1]);
80 printf("%s is to be outputed\n\r", name_of_patch);
82 _patch_append(pBuf, &patch_item);
84 out = fopen(name_of_patch, "wb");
86 // ( struct size -4 ) + patch_code size + 4-%4( make it alignment )
87 printf(" write %d bytes to h_%s as an output file", (sizeof(struct rom_patch_st)-4)+patch_item.len+(4-(patch_item.len%4)), argv[1]);
88 fwrite((uint8_t *)pBuf, sizeof(uint8_t), (sizeof(struct rom_patch_st)-4)+patch_item.len+(4-(patch_item.len%4)), out);