ramips: rt305x: add support for the ZyXEL NBG-419N board
[openwrt.git] / target / linux / rdc / image / mkimg_bifferboard.py
1 #!/usr/bin/env python
2
3 """
4 Create firmware for 4/8MB Bifferboards, suitable for uploading using
5 either bb_upload8.py or bb_eth_upload8.py
6 """
7
8 import struct, sys
9
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
23
24 if __name__ == "__main__":
25
26 if len(sys.argv) != 4:
27 print "usage: mkimg_bifferboard.py <kernel> <rootfs> <output file>"
28 sys.exit(-1)
29
30 bzimage = sys.argv[1]
31 rootfs = sys.argv[2]
32 target = sys.argv[3]
33
34 # Kernel first
35 fw = file(bzimage).read()
36 if len(fw) > (kernel_extent - config_extent):
37 raise IOError("Kernel too large")
38
39 # Pad up to end of kernel partition
40 while len(fw) < (kernel_extent - config_extent):
41 fw += "\xff"
42
43 fw += file(rootfs).read()
44
45 # Check length of total
46 if len(fw) > (flash_size - 0x10000 - config_extent):
47 raise IOError("Rootfs too large")
48
49 file(target,"wb").write(fw)
50 print "Firmware written to '%s'" % target
This page took 0.043067 seconds and 5 git commands to generate.