diff options
author | Marek Szyprowski <m.szyprowski@samsung.com> | 2024-04-11 11:11:56 +0200 |
---|---|---|
committer | Seung-Woo Kim <sw0312.kim@samsung.com> | 2024-05-10 10:12:21 +0900 |
commit | f3dac83ce7dc05f5c53b01c49bcb8d54b6ccaa4b (patch) | |
tree | bea5703ed0901b429790622bc19a473ae6560682 | |
parent | d9e9c52b5cfb3117a6de56fdc7b9deaacb311660 (diff) | |
download | u-boot-f3dac83ce7dc05f5c53b01c49bcb8d54b6ccaa4b.tar.gz u-boot-f3dac83ce7dc05f5c53b01c49bcb8d54b6ccaa4b.tar.bz2 u-boot-f3dac83ce7dc05f5c53b01c49bcb8d54b6ccaa4b.zip |
tizen: bootscript: rpi4: update boot scripts
Update RPi4 boot script to match the one developed recently for
LicheePi4A/VF2. This improves the following things:
- switch to generic devtype/devnum envs like for typical distro_boot case
- correctly load script and kernel from boot_b
- root= kernel parameter is correctly set for partitions up to 19th
- reordered some operations and added more comments
- tested A/B booting
- tested booting from legacy MBR based layout
- tested USB booting
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Change-Id: If038c93db7fc7f8a6f009e5dd43ae74286a6edb2
-rw-r--r-- | include/samsung/tizen_rpi.h | 52 | ||||
-rw-r--r-- | tizen/bootscript/tizen-boot-rpi4.scr | 168 |
2 files changed, 122 insertions, 98 deletions
diff --git a/include/samsung/tizen_rpi.h b/include/samsung/tizen_rpi.h index 4f0b139f8d..d9c582ebc5 100644 --- a/include/samsung/tizen_rpi.h +++ b/include/samsung/tizen_rpi.h @@ -54,31 +54,27 @@ "name=reserved2,size=-,uuid=${uuid_gpt_reserved2},type=linux;" \ "" -#define SET_TO_PARTITION_A \ - "if test -e mmc ${mmcbootdev}:${mmcinformpart} ${slotfile}; " \ - "then ;" \ - "load mmc ${mmcbootdev}:${mmcinformpart} ${slot_addr} /${slotfile} 2; " \ - "fi; " \ - "mw.b ${slot_addr} 61; " \ - "ext4write mmc ${mmcbootdev}:${mmcinformpart} ${slot_addr} /${slotfile} 2; " - -#define SET_TO_PARTITION_B \ - "if test -e mmc ${mmcbootdev}:${mmcinformpart} ${slotfile}; " \ - "then ;" \ - "load mmc ${mmcbootdev}:${mmcinformpart} ${slot_addr} /${slotfile} 2; " \ - "fi; " \ - "mw.b ${slot_addr} 62; " \ - "ext4write mmc ${mmcbootdev}:${mmcinformpart} ${slot_addr} /${slotfile} 2; " - #ifdef CONFIG_TARGET_RPI_4_32B #define TIZEN_VC_MEM "vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000 swiotlb=8192 " #else #define TIZEN_VC_MEM "vc_mem.mem_base=0x3dc00000 vc_mem.mem_size=0x3f000000 " #endif +#define SET_INFORM_PART \ + "part number ${devtype} ${devnum} ${informname} informpart; " + +#define SET_TO_PARTITION_X(val) \ + SET_INFORM_PART \ + "if test -e ${devtype} ${devnum}:${informpart} ${slotfile}; then; " \ + "load ${devtype} ${devnum}:${informpart} ${slot_addr} /${slotfile} 2; " \ + "fi; " \ + "mw.b ${slot_addr} " val "; " \ + "ext4write ${devtype} ${devnum}:${informpart} ${slot_addr} /${slotfile} 2;" \ + #define CLEAR_REBOOT_PARAM \ - "mw.l ${rebootparam_addr} ${normal_val} ; " \ - "ext4write mmc ${mmcbootdev}:${mmcinformpart} ${rebootparam_addr} /${rebootparamfile} 8; " + SET_INFORM_PART \ + "mw.l ${rebootparam_addr} ${normal_val} ; " \ + "ext4write ${devtype} ${devnum}:${informpart} ${rebootparam_addr} /${rebootparamfile} 8; " /* SD/MMC configuration */ @@ -100,11 +96,7 @@ #define TIZEN_ENV_SETTING \ "kernel=" KERNEL_NAME "\0" \ "dfu_alt_info=" DFU_ALT_SYSTEM "\0" \ - "mmcbootdev=0\0" \ - "mmcbootpart=1\0" \ - "mmcrootdev=0\0" \ - "mmcrootpart=2\0" \ - "mmcinformpart=9\0" \ + "informpart=9\0" \ "rebootparamfile=reboot-param.bin\0" \ "slotfile=partition-ab.info\0" \ "slot_addr=0x02200000\0" \ @@ -114,24 +106,20 @@ "nodef_val=6665646e\0" \ "normal_val=6d726f6e\0" \ "download_val=6c6e7764\0" \ - "ramdiskpart=7\0" \ - "part=7\0" \ - "bootmode=ramdisk\0" \ - "bootdev=mmc\0" \ "tfm=setenv bootmode download; run bootcmd\0" \ - "tizen_bootarg=" \ + "tizen_bootarg=cgroup_enable=memory " \ TIZEN_VC_MEM \ - "8250.nr_uarts=1 dma.dmachans=0x7f35 bcm2709.serial=0xed6687d3 " \ + "8250.nr_uarts=1 dma.dmachans=0x7f35 bcm2709.serial=0xed6687d3 " \ "snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1 " \ "bcm2709.uart_clock=48000000 dwc_otg.lpm_enable=0\0" \ "opts=loglevel=4\0" \ "dfu_usb_con=0\0" \ "dfu_interface=mmc\0" \ "dfu_device=" __stringify(CONFIG_MMC_DEFAULT_DEV) "\0" \ - "set_to_part_a=" SET_TO_PARTITION_A "\0" \ - "set_to_part_b=" SET_TO_PARTITION_B "\0" \ + "set_to_part_a=" SET_TO_PARTITION_X("0x61") "\0" \ + "set_to_part_b=" SET_TO_PARTITION_X("0x62") "\0" \ "gpt_parts=" GPT_PARTS_DEFAULT "\0" \ - "update_gpt_part=gpt write mmc ${mmcbootdev} ${gpt_parts}\0" \ + "update_gpt_part=gpt write ${devtype} ${devnum} ${gpt_parts}\0" \ "reboot_param_clear=" CLEAR_REBOOT_PARAM "\0" \ "" diff --git a/tizen/bootscript/tizen-boot-rpi4.scr b/tizen/bootscript/tizen-boot-rpi4.scr index fd4b62f23a..b797ec3321 100644 --- a/tizen/bootscript/tizen-boot-rpi4.scr +++ b/tizen/bootscript/tizen-boot-rpi4.scr @@ -1,47 +1,67 @@ # 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 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" 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..."; @@ -51,7 +71,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 @@ -62,11 +81,59 @@ 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 +fi + +# 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 - setenv ramdiskpart ${partition_fallback} + 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 "${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 fi # setting console device if noting is set @@ -85,52 +152,21 @@ if test -z "${console}"; then; fi echo "console: ${console}" -# DT image by model -setenv boot_prefixes \"/\" - -# Find the ramdisk offset and block count -part start $bootdev $mmcrootdev $ramdiskpart ramdisk_start -part size $bootdev $mmcrootdev $ramdiskpart ramdisk_size +setenv bootargs \"${tizen_bootarg} ${rootargs} bootmode=${bootmode} partition_ab=${partition_ab} ${console} ${opts} ${ip_opt}\" -# 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 - -# boot from ram0 if there is sbin or it is initramfs -if test -e $bootdev $mmcrootdev:$ramdiskpart sbin/init; then; - setenv rootdev ram0 - echo "Loading Ramdisk from partition ${ramdiskpart}"; - $bootdev read $ramdisk_addr_r $ramdisk_start $ramdisk_size; -else - # Check for gzip (initramfs) magic - $bootdev read $ramdisk_addr_r $ramdisk_start 1; - if itest.w *$ramdisk_addr_r == 0x8b1f; then; - setenv rootdev ram0 - echo "Loading initramfs from partition ${ramdiskpart}"; - $bootdev read $ramdisk_addr_r $ramdisk_start $ramdisk_size; - else - if test "${bootdev}" = "mmc"; then; - setenv rootdev mmcblk${mmcrootdev}p${mmcrootpart} - fi - if test "${bootdev}" = "usb"; then; - setenv rootdev sda${mmcrootpart} - fi - setenv bootmode normal - fi -fi - -# To use cmdline for using serial console. /* Normal mode */ -setenv bootargs \"${tizen_bootarg} cgroup_enable=memory root=/dev/${rootdev} rw bootmode=${bootmode} partition_ab=${partition_ab} rootwait ${console} ${opts} ${ip_opt}\" +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"; # 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 |