3 // Read the x-load.bin file and write out the x-load.bin.ift file.
4 // The signed image is the original pre-pended with the size of the image
5 // and the load address. If not entered on command line, file name is
6 // assumed to be x-load.bin in current directory and load address is
17 main(int argc, char *argv[])
20 char ifname[FILENAME_MAX], ofname[FILENAME_MAX], ch;
22 unsigned long loadaddr, len;
26 // Default to x-load.bin and 0x40200800.
27 strcpy(ifname, "x-load.bin");
28 loadaddr = 0x40200800;
30 if ((argc == 2) || (argc == 3))
31 strcpy(ifname, argv[1]);
34 loadaddr = strtol(argv[2], NULL, 16);
36 // Form the output file name.
37 strcpy(ofname, ifname);
38 strcat(ofname, ".ift");
40 // Open the input file.
41 ifile = fopen(ifname, "rb");
43 printf("Cannot open %s\n", ifname);
51 // Open the output file and write it.
52 ofile = fopen(ofname, "wb");
54 printf("Cannot open %s\n", ofname);
59 // Pad 1 sector of zeroes.
61 //for (i=0; i<0x200; i++)
62 // fwrite(&ch, 1, 1, ofile);
64 fwrite(&len, 1, 4, ofile);
65 fwrite(&loadaddr, 1, 4, ofile);
66 for (i=0; i<len; i++) {
67 fread(&ch, 1, 1, ifile);
68 fwrite(&ch, 1, 1, ofile);