From c96b3ab8756542e29622f7055dd6538237fd7041 Mon Sep 17 00:00:00 2001 From: Junghoon Kim Date: Tue, 11 Jul 2017 11:14:26 +0900 Subject: [PATCH] scripts: odroid-xu4: add ramdisk.img flashing support In Tizen 4.0, "ramdisk.img" is added in the platform snapshots. For that reason, this patch supports "ramdisk.img" flashing so that u-boot can be jumped to initrd instead of rootfs. Change-Id: Id80d62c9b53190812d5b5dc699729459515b68a1 Signed-off-by: Junghoon Kim --- scripts/sd_fusing_xu4.sh | 70 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 61 insertions(+), 9 deletions(-) diff --git a/scripts/sd_fusing_xu4.sh b/scripts/sd_fusing_xu4.sh index d37b9f9..bc5825f 100755 --- a/scripts/sd_fusing_xu4.sh +++ b/scripts/sd_fusing_xu4.sh @@ -18,6 +18,7 @@ declare -a PART_TABLE=( "tzsw.bin.hardkernel" "" 2111 512 "params.bin" "" 6272 512 "boot.img" 1 0 512 + "ramdisk.img" 1 0 512 "rootfs.img" 2 0 4M "system-data.img" 3 0 4M "user.img" 5 0 4M @@ -116,7 +117,18 @@ function fusing_image () { local -r input_size=`du -b $fusing_img | awk '{print $1}'` print_message 2 "[Fusing $1]" - dd if=$fusing_img | pv -s $input_size | dd of=$device seek=$seek bs=$bs + + if [ "$(basename $fusing_img)" == "ramdisk.img" ]; then + umount $device + mkdir mnt_tmp + mount -t vfat $device ./mnt_tmp + cp -f $fusing_img ./mnt_tmp + umount ./mnt_tmp + rmdir mnt_tmp + echo "fusing $fusing_img is done." + else + dd if=$fusing_img | pv -s $input_size | dd of=$device seek=$seek bs=$bs + fi if [ $(basename $fusing_img) == "u-boot-mmc.bin" ];then add_fusing_entry "u-boot" $seek 2048 @@ -138,25 +150,64 @@ function fuse_image_tarball () { cd .. rm -rf $temp_dir - eval sync } -function fuse_image () { +function check_binary_format () { + local -r binary=$1 + + case "$binary" in + *.tar | *.tar.gz) + fuse_image_tarball $binary + eval sync + ;; + *) + fusing_image $binary + eval sync + ;; + esac +} +function fuse_image () { if [ "$FUSING_BINARY_NUM" == 0 ]; then return fi + # NOTE: to ensure ramdisk booting, ramdisk image should be copied after + # boot image is flashed into boot partition. + # + # This code guarantees that ramdisk image is flashed in the end of binaries. + local -i tmpval=$FUSING_BINARY_NUM-1 for ((fuse_idx = 0 ; fuse_idx < $FUSING_BINARY_NUM ; fuse_idx++)) do local filename=${FUSING_BINARY_ARRAY[fuse_idx]} + local tmpname="" case "$filename" in - *.tar | *.tar.gz) - fuse_image_tarball $filename + *.tar | *.tar.gz) + if [ $fuse_idx -lt $tmpval ]; then + local tar_contents=`tar tvf $filename | awk 'BEGIN {FS=" "} {print $6}'` + + for content in $tar_contents + do + if [ "$content" == "ramdisk.img" ]; then + tmpname=$filename + filename=${FUSING_BINARY_ARRAY[$tmpval]} + FUSING_BINARY_ARRAY[$tmpval]=$tmpname + break + fi + done + fi + check_binary_format $filename ;; - *) - fusing_image $filename + *) + if [ $fuse_idx -lt $tmpval ]; then + if [ "$filename" == "ramdisk.img" ]; then + tmpname=$filename + filename=${FUSING_BINARY_ARRAY[$tmpval]} + FUSING_BINARY_ARRAY[$tmpval]=$tmpname + fi + fi + check_binary_format $filename ;; esac done @@ -167,7 +218,7 @@ function fuse_image () { function mkpart_3 () { # NOTE: if your sfdisk version is less than 2.26.0, then you should use following sfdisk command: # sfdisk --in-order --Linux --unit M $DISK <<-__EOF__ - + # # NOTE: sfdisk 2.26 doesn't support units other than sectors and marks --unit option as deprecated. # The input data needs to contain multipliers (MiB) instead. local version=`sfdisk -v | awk '{print $4}'` @@ -316,7 +367,8 @@ function check_args () { function print_logo () { echo "" - echo "Odroid-XU3/4 downloader" + echo "[Odroid-XU3/4 downloader]" + echo "This version also supports Tizen 4.0." echo "" } -- 2.7.4