summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateusz Moscicki <m.moscicki2@partner.samsung.com>2024-07-11 14:56:01 +0200
committerMateusz Moscicki <m.moscicki2@partner.samsung.com>2024-07-11 14:56:01 +0200
commite933c6603d53dbb02070972ba80487f33589cd9d (patch)
tree02d403e0e98220355804c246223441d4963ac873
parent29ab0db761c97229602c98e99a6dc23b4ce0e6a3 (diff)
downloadu-boot-e933c6603d53dbb02070972ba80487f33589cd9d.tar.gz
u-boot-e933c6603d53dbb02070972ba80487f33589cd9d.tar.bz2
u-boot-e933c6603d53dbb02070972ba80487f33589cd9d.zip
tizen: rpi4: Synchronization of changes from tizen branchaccepted/tizen/8.0/unified/20240715.155230
Due to the fact that in Tizen 9.0 ramdisk-recovery is initramfs (cpio.gz), the u-boot script must be able to handle this format as well, so that an OS Upgrade from 8.0 to 9.0 is possible. Change-Id: I37c2335327ebb6434bc30d3b454e7bab915ee3a4
-rw-r--r--tizen/bootscript/tizen-boot-rpi4.scr165
1 files changed, 108 insertions, 57 deletions
diff --git a/tizen/bootscript/tizen-boot-rpi4.scr b/tizen/bootscript/tizen-boot-rpi4.scr
index 8a009968c9..c9f15843fd 100644
--- a/tizen/bootscript/tizen-boot-rpi4.scr
+++ b/tizen/bootscript/tizen-boot-rpi4.scr
@@ -1,40 +1,61 @@
# U-boot script for tizen RPI4
-setenv legacy_ramdisk_part 0x7
-setenv legacy_recovery_part 0x8
-
-if test "${target}" = "mmc0"; then;
- setenv bootdev mmc
-fi
-if test "${target}" = "usb0"; then;
- setenv bootdev usb
- setenv opts "${opts} rootdelay=2"
+setenv legacy_boot_part 0x1
+setenv legacy_rootfs_part 0x2
+setenv legacy_ramdisk_part 0x7
+setenv legacy_ramdisk-recovery_part 0x8
+setenv legacy_inform_part 0x9
+
+if test -z "${devtype}"; then
+ if test "${target}" = "mmc0"; then;
+ setenv devtype mmc
+ fi
+ if test "${target}" = "usb0"; then;
+ setenv devtype usb
+ fi
fi
-# find 'inform' partition or use ${mmcinformpart} fallback
-part number $bootdev $mmcbootdev "inform" res
-if test -n "${res}"; then;
- setenv mmcinformpart ${res}
+# find 'inform' partition
+setenv informpart $legacy_inform_part
+part number $devtype $devnum "inform" informpart
+if test -z "${informpart}"; then;
+ echo No \"inform\" partition found.
+ exit
fi
-# set sane defaults
-setenv partition_name "ramdisk"
setenv partition_ab "a"
-setenv partition_fallback ${legacy_ramdisk_part}
-
-if test -e $bootdev $mmcbootdev:$mmcinformpart $slotfile; then;
- ext4load $bootdev $mmcbootdev:$mmcinformpart $slot_addr $slotfile;
+if test -e $devtype $devnum:$informpart $slotfile; then;
+ ext4load $devtype $devnum:$informpart $slot_addr $slotfile;
if itest.b *${slot_addr} == 0x62; then;
setenv partition_ab "b"
fi
fi
echo "boot from slot_${partition_ab}"
-if test -e $bootdev $mmcbootdev:$mmcinformpart $rebootparamfile; then;
- ext4load $bootdev $mmcbootdev:$mmcinformpart $rebootparam_addr $rebootparamfile;
+# find the boot partition
+setenv bootpart $legacy_boot_part
+part number $devtype $devnum "boot_${partition_ab}" bootpart
+if test -z "${bootpart}"; then;
+ echo No \"boot_${partition_ab}\" partition found.
+ exit
+fi
+
+# check if we need to let distro_boot to switch to boot_b
+if test "0x${distro_bootpart}" -ne "${bootpart}"; then
+ exit
+fi
+
+# set sane defaults
+setenv partition_name "ramdisk"
+if test -z "${bootmode}"; then;
+ setenv bootmode "normal"
+fi
+
+# check rebootparamfile
+if test -e $devtype $devnum:$informpart $rebootparamfile; then;
+ ext4load $devtype $devnum:$informpart $rebootparam_addr $rebootparamfile;
if itest.l *${rebootparam_addr} == ${upgrade_val}; then;
setenv partition_name "ramdisk-recovery"
- setenv partition_fallback ${legacy_recovery_part}
setenv bootmode "fota"
if test -e $devtype $devnum:$informpart $upgradetypefile; then;
ext4load $devtype $devnum:$informpart $upgradetype_addr $upgradetypefile;
@@ -44,11 +65,9 @@ if test -e $bootdev $mmcbootdev:$mmcinformpart $rebootparamfile; then;
fi
elif itest.l *${rebootparam_addr} == ${recovery_val}; then;
setenv partition_name "ramdisk-recovery"
- setenv partition_fallback ${legacy_recovery_part}
setenv bootmode "recovery"
elif itest.l *${rebootparam_addr} == ${download_val}; then;
setenv partition_name "ramdisk-recovery"
- setenv partition_fallback ${legacy_recovery_part}
setenv bootmode "flash"
elif itest.l *${rebootparam_addr} == ${nodef_val}; then;
echo "This reboot parameter is not supported...";
@@ -58,7 +77,6 @@ fi
# This is for jumping to flash mode on u-boot.
if test "${bootmode}" = "download"; then;
setenv partition_name "ramdisk-recovery"
- setenv partition_fallback ${legacy_recovery_part}
setenv bootmode "flash"
fi
@@ -69,59 +87,92 @@ if test "${bootmode}" = "flash"; then;
fi
# find the selected ramdisk variant partition
-part number $bootdev $mmcbootdev "${partition_name}_${partition_ab}" res
-if test -n "${res}"; then;
- setenv ramdiskpart ${res}
+if test "${bootmode}" != "rootfs"; then;
+ setenv tmp_env "setenv ramdiskpart \"\$\{legacy_${partition_name}_part\}\""
+ run tmp_env
+ setenv tmp_env
+ part number $devtype $devnum "${partition_name}_${partition_ab}" ramdiskpart
else
- setenv ramdiskpart ${partition_fallback}
+ setenv ramdiskpart
fi
-# boot from ram0 if there is sbin
-if test -e $bootdev $mmcrootdev:$ramdiskpart sbin/init; then;
- setenv rootdev ram0
+# load ramdisk
+if test -n "${ramdiskpart}"; then;
+ # Find the ramdisk offset and block count
+ part start $devtype $devnum $ramdiskpart ramdisk_start
+ part size $devtype $devnum $ramdiskpart ramdisk_size
+ # Load it
+ $devtype dev $devnum;
+ $devtype read $ramdisk_addr_r $ramdisk_start $ramdisk_size;
+ # Set to ramdisk_size with real partition size. (Need to multiply block-size 0x200)
+ setexpr ramdisk_size $ramdisk_size * 200
+fi
+
+# check loaded ramdisk
+if test -e $devtype $devnum:$ramdiskpart sbin/init; then;
+ echo "Using ramdisk from partition ${ramdiskpart}";
+ # boot from ram0 if there is sbin
+ setenv rootargs root=/dev/ram0 rw
+elif itest.w *$ramdisk_addr_r == 0x8b1f; then; # check for gzip (initramfs) magic
+ echo "Using initramfs from partition ${ramdiskpart}";
+ setenv rootargs
else
- if test "${bootdev}" = "mmc"; then;
- setenv rootdev mmcblk${mmcrootdev}p${mmcrootpart}
+ echo "Booting without initrd/initramfs";
+ setenv bootmode normal
+ setenv ramdisk_size 0
+
+ # find the rootfs partition
+ setenv rootfspart $legacy_rootfs_part
+ part number $devtype $devnum "rootfs_${partition_ab}" rootfspart
+ if test -z "${rootfspart}"; then;
+ echo No \"rootfs_${partition_ab}\" partition found.
+ exit
+ fi
+
+ # simplified hex2dec conversion for 0x1..0x13->1..19 range
+ if itest $rootfspart > 9; then;
+ setexpr rootfspart $rootfspart + 6
+ else
+ setexpr rootfspart $rootfspart + 0
fi
- if test "${bootdev}" = "usb"; then;
- setenv rootdev sda${mmcrootpart}
+ if test "${devtype}" = "mmc"; then;
+ setenv rootargs root=/dev/mmcblk${devnum}p${rootfspart} rw rootwait
+ elif test "${devtype}" = "usb"; then;
+ setenv rootargs root=/dev/sda${rootfspart} rw rootwait
fi
- setenv bootmode normal
fi
# setting console device if noting is set
if test -z "${console}"; then;
- setenv console "console=ttyS0,115200n8 earlycon=uart8250,mmio32,0xfe215040"
+ if test "$board_name" = "5 Model B"; then;
+ fdt addr $fdt_addr;
+ fdt get value uart "/axi/pcie@120000/rp1/serial@30000" status;
+ if test "$uart" = "okay"; then;
+ setenv console "console=ttyAMA0,115200n8";
+ else
+ setenv console "console=ttyAMA10,115200n8 earlycon";
+ fi
+ else
+ setenv console "console=ttyS0,115200n8 earlycon=uart8250,mmio32,0xfe215040";
+ fi
fi
echo "console: ${console}"
-# DT image by model
-setenv boot_prefixes \"/\"
-
-# To use cmdline for using serial console. /* Normal mode */
-setenv bootargs \"${tizen_bootarg} root=/dev/${rootdev} rw bootmode=${bootmode} partition_ab=${partition_ab} rootwait ${console} ${opts} ${ip_opt}\"
+setenv bootargs \"${tizen_bootarg} ${rootargs} bootmode=${bootmode} partition_ab=${partition_ab} ${console} ${opts} ${ip_opt}\"
-# Find the ramdisk offset and block count
-part start $bootdev $mmcrootdev $ramdiskpart ramdisk_start
-part size $bootdev $mmcrootdev $ramdiskpart ramdisk_size
-
-# Set to ramdisksize with real partition size. (Need to multiply block-size 0x200)
-setexpr ramdisksize $ramdisk_size * 200
-setexpr tizen_kernel_addr_r $ramdisk_addr_r + $ramdisksize
+setenv boot_prefixes \"/\"
+setexpr tizen_kernel_addr_r $ramdisk_addr_r + $ramdisk_size
echo "Searching for kernel in"; for prefix in $boot_prefixes; do
-if load $bootdev $mmcbootdev:$mmcbootpart $tizen_kernel_addr_r $prefix$kernel; then;
+echo $prefix$kernel on partition $bootpart;
+if load $devtype $devnum:$bootpart $tizen_kernel_addr_r $prefix$kernel; then;
echo ${bootmode} "boot";
- if test -e $bootdev $mmcrootdev:$ramdiskpart sbin/init; then;
- echo "Loading Ramdisk from partition ${ramdiskpart}";
- $bootdev read $ramdisk_addr_r $ramdisk_start $ramdisk_size;
- fi
# use fdt already preloaded by the firmware available at $fdt_addr
if test "$kernel" = "zImage"; then;
- bootz $tizen_kernel_addr_r $ramdisk_addr_r:$ramdisksize $fdt_addr;
+ bootz $tizen_kernel_addr_r $ramdisk_addr_r:$ramdisk_size $fdt_addr;
else
- booti $tizen_kernel_addr_r $ramdisk_addr_r:$ramdisksize $fdt_addr;
+ booti $tizen_kernel_addr_r $ramdisk_addr_r:$ramdisk_size $fdt_addr;
fi
fi
done