tizen: bootscript: Adapt the script to work u-boot boot device/partition detection
authorŁukasz Stelmach <l.stelmach@samsung.com>
Wed, 2 Aug 2023 07:49:35 +0000 (09:49 +0200)
committerJaehoon Chung <jh80.chung@samsung.com>
Tue, 17 Oct 2023 11:02:45 +0000 (20:02 +0900)
Make the bootscript work properly when called by the upstream
distro_bootcmd script.

Change-Id: Iad38fdfdb7a6d10cd27924458fa9d23911a607db
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
tizen/bootscript/tizen-boot-vf2.scr

index 11a5a79..f5c3074 100644 (file)
@@ -1,13 +1,18 @@
 # U-boot script for tizen VF2 and QEMU
 
-if test "${target}" = "virtio0"; then;
-       setenv devtype virtio
-fi
-if test "${target}" = "mmc0" -o "${target}" = "mmc1"; then;
-       setenv devtype mmc
+if test -z "${devtype}"; then
+       setenv devtype "${bootdevtype}"
+       if test "${target}" = "virtio0"; then;
+               setenv devtype virtio
+       fi
+       if test "${target}" = "mmc0" -o "${target}" = "mmc1"; then;
+               setenv devtype mmc
+       fi
+       if test "${target}" = "usb0"; then;
+               setenv devtype usb
+       fi
 fi
-if test "${target}" = "usb0"; then;
-       setenv devtype usb
+if test "${devtype}" = "usb"; then;
        setenv opts "${opts} rootdelay=2"
 fi
 
@@ -84,11 +89,11 @@ if test "${bootmode}" = "flash"; then;
 fi
 
 # boot from ramdisk if there is sbin
-if test -e $devtype $bootdevnum:$ramdiskpart sbin/init; then;
+if test -e $devtype $devnum:$ramdiskpart sbin/init; then;
        setenv rootdev ram0
 else
        if test "${devtype}" = "mmc"; then;
-               setenv rootdev mmcblk${bootdevnum}p${rootpart}
+               setenv rootdev mmcblk${devnum}p${rootpart}
        fi
        if test "${devtype}" = "usb"; then;
                setenv rootdev sda${rootpart}
@@ -112,8 +117,8 @@ setenv boot_prefixes \"/\"
 setenv bootargs \"${tizen_bootarg} root=/dev/${rootdev} rw bootmode=${bootmode} partition_ab=${partition_ab} rootwait ${console} ${opts} ${ip_opt} stmmaceth=chain_mode:1\"
 
 # Find the ramdisk offset and block count
-part start $devtype $bootdevnum $ramdiskpart ramdisk_start
-part size $devtype $bootdevnum $ramdiskpart ramdisk_size
+part start $devtype $devnum $ramdiskpart ramdisk_start
+part size $devtype $devnum $ramdiskpart ramdisk_size
 
 # Set to ramdisksize with real partition size. (Need to multiply block-size 0x200)
 setexpr ramdisksize $ramdisk_size * 200
@@ -123,13 +128,21 @@ echo "Searching for kernel in"; for prefix in $boot_prefixes; do
 if load $devtype $devnum:$distro_bootpart $tizen_kernel_addr_r $prefix$kernel; then;
        echo ${bootmode} "boot";
 
-       if test -e $devtype $bootdevnum:$ramdiskpart sbin/init; then;
-               echo "Loading Ramdisk from partition"${part};
+       if test -e $devtype $devnum:$ramdiskpart sbin/init; then;
+               echo "Loading Ramdisk from partition" ${part};
                echo "Environment value of ramdiskpart is" ${ramdiskpart};
+               $devtype dev $devnum
                $devtype read $ramdisk_addr_r $ramdisk_start $ramdisk_size;
        fi
 
-       load $devtype $bootdevnum:$distro_bootpart $fdt_addr_r $fdtfile
+       if test "${board_name}" = "qemu-riscv"; then
+               # If running in QEMU use the DeviceTree provided by
+               # the emulator. It is the most accurate description of
+               # the platform.
+               fdt move $fdt_addr $fdt_addr_r
+       else
+               load $devtype $devnum:$distro_bootpart $fdt_addr_r $prefix$fdtfile
+       fi
        booti $tizen_kernel_addr_r $ramdisk_addr_r:$ramdisksize $fdt_addr_r;
 fi
 done