/* * generate firmware control block (FCB) - required to boot iMX53 from NAND * * only works for 2k page NANDs * bad block handling of ROM bootloader is disabled * * fcb length is 4kB (2 pages) * image start at page 2 */ #include #include #include #include struct fcb_entry { uint32_t addr; uint32_t value; }; struct fcb_entry fcb_entries[] = { { 0x00, 0x00000000 }, // res. { 0x04, 0x46434220 }, // fingerprint #2 (ascii FCB) { 0x08, 0x01000000 }, // fingerprint #3 (version) { 0x68, 0x02000000 }, // primary image start page (page 2) { 0x6C, 0x02000000 }, // secondary image start page (page 2) { 0x78, 0x00000000 }, // Start page address of DBBT Search Area (0 means no bad blocks) { 0x7C, 0x00000000 }, // Bad Block Marker Offset in page data buffer { 0xAC, 0x00000000 }, // Bad Block Marker Swapping Enable { 0xB0, 0x00000000 }, // Bad Block Marker Offset to Spare Byte }; int main() { int i, ret; char *fname = "fcb.bin"; FILE *fp; uint8_t fcbimage[4 * 1024]; memset(fcbimage, 0, sizeof(fcbimage)); for(i = 0; i < (int) (sizeof(fcb_entries) / sizeof(fcb_entries[0])); i++) { if((fcb_entries[i].addr + 3) >= sizeof(fcbimage)) { printf("Invalid FCB entry (index:%d)\n", i); continue; } fcbimage[fcb_entries[i].addr + 0] = fcb_entries[i].value >> 24; fcbimage[fcb_entries[i].addr + 1] = fcb_entries[i].value >> 16; fcbimage[fcb_entries[i].addr + 2] = fcb_entries[i].value >> 8; fcbimage[fcb_entries[i].addr + 3] = fcb_entries[i].value >> 0; } if((fp = fopen(fname, "w")) == NULL) { printf("could not open %s!\n", fname); return -1; } ret = fwrite(fcbimage, 1, sizeof(fcbimage), fp); printf("wrote %d bytes.\n", ret); if(ret != sizeof(fcbimage)) printf("error - incomplete file!\n"); fclose(fp); return 0; }