[tools] tools/firmware-utils/ptgen option to use MB rounding
[openwrt/svn-archive/archive.git] / target / linux / brcm2708 / image / gen_rpi_sdcard_img.sh
1 #!/usr/bin/env bash
2
3 set -x
4 [ $# == 5 ] || {
5 echo "SYNTAX: $0 <file> <bootfs image> <rootfs image> <bootfs size> <rootfs size>"
6 exit 1
7 }
8
9 OUTPUT="$1"
10 BOOTFS="$2"
11 ROOTFS="$3"
12 BOOTFSSIZE="$4"
13 ROOTFSSIZE="$5"
14
15 head=4
16 sect=63
17
18 set `ptgen -o $OUTPUT -h $head -s $sect -l 4096 -t c -p ${BOOTFSSIZE}M -t 83 -p ${ROOTFSSIZE}M`
19
20 BOOTOFFSET="$(($1 / 512))"
21 BOOTSIZE="$(($2 / 512))"
22 ROOTFSOFFSET="$(($3 / 512))"
23 ROOTFSSIZE="$(($4 / 512))"
24
25 dd bs=512 if="$BOOTFS" of="$OUTPUT" seek="$BOOTOFFSET" conv=notrunc
26 dd bs=512 if="$ROOTFS" of="$OUTPUT" seek="$ROOTFSOFFSET" conv=notrunc
27
28
29