declare CONV_ASCII=""
declare -i FUS_ENTRY_NUM=0
-# binary name | part number | bs
+# binary name | part number | bs | label | fs type
declare -a PART_TABLE=(
- "boot.img" 1 4M
- "rootfs.img" 2 4M
- "system-data.img" 3 4M
- "user.img" 5 4M
- "modules.img" 6 4M
- "ramdisk.img" 7 4M
- "ramdisk-recovery.img" 8 4M
- "hal.img" 10 4M
+ "boot.img" 1 4M boot vfat
+ "rootfs.img" 2 4M rootfs ext4
+ "system-data.img" 3 4M system-data ext4
+ "user.img" 5 4M user ext4
+ "modules.img" 6 4M modules ext4
+ "ramdisk.img" 7 4M ramdisk ext4
+ "ramdisk-recovery.img" 8 4M ramdisk-recovery ext4
+ "hal.img" 10 4M hal ext4
)
-declare -r -i PART_TABLE_COL=3
+declare -r -i PART_TABLE_COL=5
declare -r -i PART_TABLE_ROW=${#PART_TABLE[*]}/${PART_TABLE_COL}
# partition table support
let "USER_SZ = $SIZE_MB - $BOOT_SZ - $ROOTFS_SZ - $DATA_SZ - $MODULE_SZ - $RAMDISK_SZ - $RAMDISK_RECOVERY_SZ - $INFORM_SZ - $EXTEND_SZ - $HAL_SZ - $RESERVED2_SZ"
- local -r BOOT=boot
- local -r ROOTFS=rootfs
- local -r SYSTEMDATA=system-data
- local -r USER=user
- local -r MODULE=modules
- local -r RAMDISK=ramdisk
- local -r RAMDISK_RECOVERY=ramdisk-recovery
+ local -r BOOT=${PART_TABLE[0 * ${PART_TABLE_COL} + 3]}
+ local -r ROOTFS=${PART_TABLE[1 * ${PART_TABLE_COL} + 3]}
+ local -r SYSTEMDATA=${PART_TABLE[2 * ${PART_TABLE_COL} + 3]}
+ local -r USER=${PART_TABLE[3 * ${PART_TABLE_COL} + 3]}
+ local -r MODULE=${PART_TABLE[4 * ${PART_TABLE_COL} + 3]}
+ local -r RAMDISK=${PART_TABLE[5 * ${PART_TABLE_COL} + 3]}
+ local -r RAMDISK_RECOVERY=${PART_TABLE[6 * ${PART_TABLE_COL} + 3]}
local -r INFORM=inform
- local -r HAL=hal
+ local -r HAL=${PART_TABLE[7 * ${PART_TABLE_COL} + 3]}
local -r RESERVED2=reserved2
if [[ $USER_SZ -le 100 ]]
__EOF__
fi
- local -r PART1=/dev/`lsblk ${DISK} -o TYPE,KNAME | grep part | awk '{ print $2 }' | grep -G "[a-z]1\$"`
- mkfs.vfat -F 16 ${PART1} -n $BOOT
-
- local -r PART2=/dev/`lsblk ${DISK} -o TYPE,KNAME | grep part | awk '{ print $2 }' | grep -G "[a-z]2\$"`
- mkfs.ext4 -q ${PART2} -L $ROOTFS -F
-
- local -r PART3=/dev/`lsblk ${DISK} -o TYPE,KNAME | grep part | awk '{ print $2 }' | grep -G "[a-z]3\$"`
- mkfs.ext4 -q ${PART3} -L $SYSTEMDATA -F
-
- local -r PART5=/dev/`lsblk ${DISK} -o TYPE,KNAME | grep part | awk '{ print $2 }' | grep -G "[a-z]5\$"`
- mkfs.ext4 -q ${PART5} -L $USER -F
-
- local -r PART6=/dev/`lsblk ${DISK} -o TYPE,KNAME | grep part | awk '{ print $2 }' | grep -G "[a-z]6\$"`
- mkfs.ext4 -q ${PART6} -L $MODULE -F
-
- local -r PART7=/dev/`lsblk ${DISK} -o TYPE,KNAME | grep part | awk '{ print $2 }' | grep -G "[a-z]7\$"`
- mkfs.ext4 -q ${PART7} -L $RAMDISK -F
-
- local -r PART8=/dev/`lsblk ${DISK} -o TYPE,KNAME | grep part | awk '{ print $2 }' | grep -G "[a-z]8\$"`
- mkfs.ext4 -q ${PART8} -L $RAMDISK_RECOVERY -F
+ for ((idx=0;idx<$PART_TABLE_ROW;idx++)); do
+ local PART=/dev/`lsblk ${DISK} -o TYPE,KNAME | grep part | awk '{ print $2 }' | grep -G "[a-z]${PART_TABLE[$idx * ${PART_TABLE_COL} + 1]}\$"`
+ if [ "${PART_TABLE[$idx * ${PART_TABLE_COL} + 4]}" == "vfat" ]; then
+ mkfs.vfat -F 16 ${PART} -n ${PART_TABLE[$idx * ${PART_TABLE_COL} + 3]}
+ elif [ "${PART_TABLE[$idx * ${PART_TABLE_COL} + 4]}" == "ext4" ]; then
+ mkfs.ext4 -q ${PART} -L ${PART_TABLE[$idx * ${PART_TABLE_COL} + 3]} -F
+ else
+ echo "Skip to format for unknown filesystem type ${PART_TABLE[$idx * ${PART_TABLE_COL} + 4]} for part$idx, ${PART_TABLE[$idx * ${PART_TABLE_COL} + 3]}"
+ fi
+ done
local -r PART9=/dev/`lsblk ${DISK} -o TYPE,KNAME | grep part | awk '{ print $2 }' | grep -G "[a-z]9\$"`
mkfs.ext4 -q ${PART9} -L $INFORM -F
- local -r PART10=/dev/`lsblk ${DISK} -o TYPE,KNAME | grep part | awk '{ print $2 }' | grep -G "[a-z]10\$"`
- mkfs.ext4 -q ${PART10} -L $HAL -F
-
- local -r PART11=/dev/`lsblk ${DISK} -o TYPE,KNAME | grep part | awk '{ print $2 }' | grep -G "[a-z]11\$"`
- mkfs.ext4 -q ${PART11} -L $RESERVED2 -F
-
# create "reboot-param.bin" file in inform partition for passing reboot parameter
# It should be done only once upon partition format.
- umount ${PART9}
mkdir mnt_tmp
mount -t ext4 ${PART9} ./mnt_tmp
touch ./mnt_tmp/reboot-param.bin
sync
umount ./mnt_tmp
rmdir mnt_tmp
+
+ local -r PART11=/dev/`lsblk ${DISK} -o TYPE,KNAME | grep part | awk '{ print $2 }' | grep -G "[a-z]11\$"`
+ mkfs.ext4 -q ${PART11} -L $RESERVED2 -F
}
function show_usage () {
function print_logo () {
echo ""
- echo "Raspberry Pi downloader, version 2.0.3"
+ echo "Raspberry Pi downloader, version 2.0.4"
echo ""
}