From: Marek Szyprowski Date: Fri, 1 Sep 2023 15:24:25 +0000 (+0200) Subject: tizen: rpi4: remove hardcoded partition numbers X-Git-Tag: accepted/tizen/unified/20231106.171643~16 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5d42c2d2f76b8c787ce4582da9485d8e790b107a;p=platform%2Fkernel%2Fu-boot.git tizen: rpi4: remove hardcoded partition numbers GPT partition layout already provides names for all partitions, so if possible, use them instead of the hardcoded numbers in boot script. Signed-off-by: Marek Szyprowski Change-Id: Id35838f9bb11970ab94963947f6140db836944e3 --- diff --git a/tizen/bootscript/tizen-boot-rpi4.scr b/tizen/bootscript/tizen-boot-rpi4.scr index 78dfb9e..bc34f03 100644 --- a/tizen/bootscript/tizen-boot-rpi4.scr +++ b/tizen/bootscript/tizen-boot-rpi4.scr @@ -1,5 +1,8 @@ # 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 @@ -8,55 +11,39 @@ if test "${target}" = "usb0"; then; setenv opts "${opts} rootdelay=2" fi +# find 'inform' partition or use ${mmcinformpart} fallback +part number $bootdev $mmcbootdev "inform" res +if test -n "${res}"; then; + setenv mmcinformpart ${res} +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 itest.b *${slot_addr} == 0x62; then; - setenv ramdiskpart 0xe - setenv part 14 - setenv partition_ab b - echo "boot from slot_b"; - else - setenv ramdiskpart 7 - setenv part 7 - setenv partition_ab a - echo "boot from slot_a"; + setenv partition_ab "b" fi -else - setenv ramdiskpart 7 - setenv part 7 - setenv partition_ab a - echo "boot from slot_a"; fi +echo "boot from slot_${partition_ab}" if test -e $bootdev $mmcbootdev:$mmcinformpart $rebootparamfile; then; ext4load $bootdev $mmcbootdev:$mmcinformpart $rebootparam_addr $rebootparamfile; if itest.l *${rebootparam_addr} == ${upgrade_val}; then; - if test "${partition_ab}" = "b"; then - setenv ramdiskpart 0xf - setenv part 15 - else - setenv ramdiskpart 8 - setenv part 8 - fi - setenv bootmode fota + setenv partition_name "ramdisk-recovery" + setenv partition_fallback ${legacy_recovery_part} + setenv bootmode "fota" elif itest.l *${rebootparam_addr} == ${recovery_val}; then; - if test "${partition_ab}" = "b"; then - setenv ramdiskpart 0xf - setenv part 15 - else - setenv ramdiskpart 8 - setenv part 8 - fi - setenv bootmode recovery + setenv partition_name "ramdisk-recovery" + setenv partition_fallback ${legacy_recovery_part} + setenv bootmode "recovery" elif itest.l *${rebootparam_addr} == ${download_val}; then; - if test "${partition_ab}" = "b"; then - setenv ramdiskpart 0xf - setenv part 15 - else - setenv ramdiskpart 8 - setenv part 8 - fi - setenv bootmode flash + 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..."; fi @@ -64,14 +51,9 @@ fi # This is for jumping to flash mode on u-boot. if test "${bootmode}" = "download"; then; - if test "${partition_ab}" = "b"; then - setenv ramdiskpart 0xf - setenv part 15 - else - setenv ramdiskpart 8 - setenv part 8 - fi - setenv bootmode flash + setenv partition_name "ramdisk-recovery" + setenv partition_fallback ${legacy_recovery_part} + setenv bootmode "flash" fi if test "${bootmode}" = "flash"; then; @@ -80,6 +62,14 @@ if test "${bootmode}" = "flash"; then; fi fi +# find the selected ramdisk variant partition +part number $bootdev $mmcbootdev "${partition_name}_${partition_ab}" res +if test -n "${res}"; then; + setenv ramdiskpart ${res} +else + setenv ramdiskpart ${partition_fallback} +fi + # boot from ram0 if there is sbin if test -e $bootdev $mmcrootdev:$ramdiskpart sbin/init; then; setenv rootdev ram0 @@ -117,8 +107,7 @@ echo "Searching for kernel in"; for prefix in $boot_prefixes; do if load $bootdev $mmcbootdev:$mmcbootpart $tizen_kernel_addr_r $prefix$kernel; then; echo ${bootmode} "boot"; if test -e $bootdev $mmcrootdev:$ramdiskpart sbin/init; then; - echo "Loading Ramdisk from partition"${part}; - echo "Environment value of ramdiskpart is" ${ramdiskpart}; + echo "Loading Ramdisk from partition ${ramdiskpart}"; $bootdev read $ramdisk_addr_r $ramdisk_start $ramdisk_size; fi