9d2b7c46a84542a69a3bcdcabeb61853e7223cb6
[openwrt/openwrt.git] / target / linux / mxs / image / gen_sdcard_vfat_ext4.sh
1 #!/bin/sh
2 #
3 # Copyright (C) 2015 OpenWrt.org
4 #
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
7 #
8
9 set -x
10 [ $# -eq 6 ] || {
11 echo "SYNTAX: $0 <file> <u-boot.sb image> <bootfs image> <rootfs image> <bootfs size> <rootfs size>"
12 exit 1
13 }
14
15 OUTPUT="$1"
16 UBOOT="$2"
17 BOOTFS="$3"
18 ROOTFS="$4"
19 BOOTFSSIZE="$5"
20 ROOTFSSIZE="$6"
21
22 head=4
23 sect=63
24
25 # Set the u-boot storage to 2M
26 set $(ptgen -o $OUTPUT -h $head -s $sect -l 1024 -t 53 -p 2M -t c -p ${BOOTFSSIZE}M -t 83 -p ${ROOTFSSIZE}M)
27
28 UBOOTOFFSET="$(($1 / 512))"
29 UBOOTSIZE="$(($2 / 512))"
30 BOOTOFFSET="$(($3 / 512))"
31 BOOTSIZE="$(($4 / 512))"
32 ROOTFSOFFSET="$(($5 / 512))"
33 ROOTFSSIZE="$(($6 / 512))"
34
35 dd bs=512 if="$BOOTFS" of="$OUTPUT" seek="$BOOTOFFSET" conv=notrunc
36 dd bs=512 if="$ROOTFS" of="$OUTPUT" seek="$ROOTFSOFFSET" conv=notrunc
37 sdimage -d "$OUTPUT" -f "$UBOOT"