| target/linux/rdc/image/mkimg_bifferboard.py |
| 1 | 1 | #!/usr/bin/env python |
| 2 | 2 | |
| 3 | 3 | """ |
| 4 | | Create firmware for 8MB Bifferboards |
| 5 | | Firmware does not include the config blocks |
| 6 | | Firmware starts just after config |
| 4 | Create firmware for 4/8MB Bifferboards, suitable for uploading using |
| 5 | either bb_upload8.py or bb_eth_upload8.py |
| 7 | 6 | """ |
| 8 | 7 | |
| 9 | 8 | import struct, sys |
| 10 | 9 | |
| 11 | | kernel_extent = 0x200000 |
| 12 | | config = 0x6000 |
| 10 | # Increase the kmax value if the script gives errors about the kernel being |
| 11 | # too large. You need to set the Biffboot kmax value to the same value you |
| 12 | # use here. |
| 13 | kmax = 0x10 |
| 14 | |
| 15 | # No need to change this for 4MB devices, it's only used to tell you if |
| 16 | # the firmware is too large! |
| 17 | flash_size = 0x800000 |
| 18 | |
| 19 | # This is always the same, for 1MB, 4MB and 8MB devices |
| 20 | config_extent = 0x6000 |
| 21 | |
| 22 | kernel_extent = kmax * 0x10000 |
| 13 | 23 | |
| 14 | 24 | if __name__ == "__main__": |
| 15 | 25 | |
| 16 | 26 | if len(sys.argv) != 4: |
| 17 | | print "usage: mkimg_bifferboard.py <kernel> <64k JFFS> <output file>" |
| 18 | | sys.exit(0) |
| 27 | print "usage: mkimg_bifferboard.py <kernel> <rootfs> <output file>" |
| 28 | sys.exit(-1) |
| 19 | 29 | |
| 20 | 30 | bzimage = sys.argv[1] |
| 21 | 31 | rootfs = sys.argv[2] |
| ... | ... | |
| 23 | 33 | |
| 24 | 34 | # Kernel first |
| 25 | 35 | fw = file(bzimage).read() |
| 26 | | if len(fw) > (kernel_extent - config): |
| 36 | if len(fw) > (kernel_extent - config_extent): |
| 27 | 37 | raise IOError("Kernel too large") |
| 28 | 38 | |
| 29 | | # Pad up to 0x200000 |
| 30 | | while len(fw) < (kernel_extent - config): |
| 39 | # Pad up to end of kernel partition |
| 40 | while len(fw) < (kernel_extent - config_extent): |
| 31 | 41 | fw += "\xff" |
| 32 | 42 | |
| 33 | 43 | fw += file(rootfs).read() |
| 34 | 44 | |
| 35 | 45 | # Check length of total |
| 36 | | if len(fw) > (0x800000 - 0x10000 - 0x6000): |
| 46 | if len(fw) > (flash_size - 0x10000 - config_extent): |
| 37 | 47 | raise IOError("Rootfs too large") |
| 38 | 48 | |
| 39 | 49 | file(target,"wb").write(fw) |