040c46274e4609d2945a15d92615ff89d98a74d8
[openwrt/openwrt.git] / target / linux / rdc / image / mkimg_bifferboard.py
1 #!/usr/bin/env python
2
3 """
4 Create firmware for 8MB Bifferboards
5 Firmware does not include the config blocks
6 Firmware starts just after config
7 """
8
9 import struct, sys
10
11 kernel_extent = 0x200000
12 config = 0x6000
13
14 if __name__ == "__main__":
15
16 if len(sys.argv) != 4:
17 print "usage: mkimg_bifferboard.py <kernel> <64k JFFS> <output file>"
18 sys.exit(0)
19
20 bzimage = sys.argv[1]
21 rootfs = sys.argv[2]
22 target = sys.argv[3]
23
24 # Kernel first
25 fw = file(bzimage).read()
26 if len(fw) > (kernel_extent - config):
27 raise IOError("Kernel too large")
28
29 # Pad up to 0x200000
30 while len(fw) < (kernel_extent - config):
31 fw += "\xff"
32
33 fw += file(rootfs).read()
34
35 # Check length of total
36 if len(fw) > (0x800000 - 0x10000 - 0x6000):
37 raise IOError("Rootfs too large")
38
39 file(target,"wb").write(fw)
40 print "Firmware written to '%s'" % target