[rdc] resync kernel configuration, re-enable printk and make the kernel fit under...
[openwrt.git] / scripts / combined-image.sh
1 #!/bin/sh
2
3 BLKSZ=65536
4
5 [ -f "$1" -a -f "$2" ] || {
6 echo "Usage: $0 <kernel image> <rootfs image> [output file]"
7 exit 1
8 }
9
10 # Make sure provided images are 64k aligned.
11 kern=$(mktemp)
12 root=$(mktemp)
13 dd if="$1" of="$kern" bs=$BLKSZ conv=sync 2>/dev/null
14 dd if="$2" of="$root" bs=$BLKSZ conv=sync 2>/dev/null
15
16 # Calculate md5sum over combined kernel and rootfs image.
17 md5=$(cat "$kern" "$root" | md5sum -)
18
19 # Write image header followed by kernel and rootfs image.
20 # The header is padded to 64k, format is:
21 # CI magic word ("Combined Image")
22 # <kernel length> length of kernel encoded as zero padded 8 digit hex
23 # <rootfs length> length of rootfs encoded as zero padded 8 digit hex
24 # <md5sum> checksum of the combined kernel and rootfs image
25 ( printf "CI%08x%08x%32s" \
26 $(stat -c "%s" "$kern") $(stat -c "%s" "$root") "${md5%% *}" | \
27 dd bs=$BLKSZ conv=sync;
28 cat "$kern" "$root"
29 ) > ${3:-openwrt-combined.img} 2>/dev/null
30
31 # Clean up.
32 rm -f "$kern" "$root"
This page took 0.049976 seconds and 5 git commands to generate.