Jump to content

[Armbian build PR] - sunxi: bootscript load address calculation a.o.


Recommended Posts

Posted

Description

Attempt to work towards one U-Boot bootscript for (at least) mvebu, sunxi and rockchip64. This adds:

  • (Aligned) load address calculations This will remove the need to update any kernel_load_addr_r or ramdisk_addr_r in case kernel image increases. Calculation is based on either
    • Flat kernel image image_size + text_offset as specified in the vmlinux(/Image) header info
    • Compressed kernel image filesize (vmlinuz/zImage)
  • Clear warnings to user in case files are not found, not able to load or application failed.
  • Merge of armbianEnv.txt kernel options was attempted for sunxi, mvebu and rockchip64.
  • DT folder determination based on sunxi approach.
  • DT file determination based on sunxi approach.
  • Compat with /boot/dtb/fdtfile.dtb and /boot/dtb/vendor/fdtfile.dtb.
  • Simplified some constructs by assuming U-Boot has successfully sourced us with a set of pre-set variables, like ${prefix} ${devtype} etc.
  • Actively set the ${kernel_comp_*} parameters based on calculations of load addresses.
  • Ability to select different kernel/initrd by setting kver in armbianEnv.txt

Also:

  • Any warning or error includes a 10 second delay to make sure the user is able to see and read them.
  • Any "informative" message added by the bootscript can be silenced by setting verbosity to 0
  • Attempted to make the bootscript 'reentrant' in away: all variables required for proper (re)execution are set, which should allow for the entire bootscript to be re-run on a next boot_target.
  • All variables used in for-loops are actively cleared from the environment to ensure for loops work as expected.
  • Any pre-set variable that might be used in next boot_target will be reset whenever necessary.

Documentation summary for feature / change

  • [ ] short description (copy / paste of PR title)
  • [x] summary (description relevant for end users) Load address calculation can be disabled by adding load_addr_calc=off to armbianEnv.txt Load address calculation OBOE avoidance can be disabled by adding align_overlap_oboe_avoidance=off to armbianEnv.txt User can set custom fdtdir and fdtfile in armbianEnv.txt, but make sure to only specify DT filename in fdtfile. fdtdir will be used to both load DT, DT overlays and fixup scripts
  • [ ] example of usage (how to see this in function)

How Has This Been Tested?

  • [x] Orangepi Zero (first gen):
    [12:39:52] U-Boot SPL 2024.01-armbian-2024.01-S866c-P6b16-Ha5c2-V367a-Bb703-R448a (Apr 29 2025 - 02:50:09 +0000)
    [12:39:52] DRAM: 512 MiB
    [12:39:52] Trying to boot from MMC1
    [12:39:53] ns16550_serial serial@1c28000: pinctrl_select_state_full: uclass_get_device_by_phandle_id: err=-19
    
    
    [12:39:53] U-Boot 2024.01-armbian-2024.01-S866c-P6b16-Ha5c2-V367a-Bb703-R448a (Apr 29 2025 - 02:50:09 +0000) Allwinner Technology
    
    [12:39:53] CPU:   Allwinner H3 (SUN8I 1680)
    [12:39:53] Model: Xunlong Orange Pi Zero
    [12:39:53] DRAM:  512 MiB
    [12:39:53] Core:  70 devices, 19 uclasses, devicetree: separate
    [12:39:53] WDT:   Not starting watchdog@1c20ca0
    [12:39:53] MMC:   mmc@1c0f000: 0, mmc@1c10000: 1
    [12:39:53] Loading Environment from FAT... Unable to use mmc 0:1...
    [12:39:53] In:    serial,usbkbd
    [12:39:53] Out:   serial
    [12:39:53] Err:   serial
    [12:39:53] Starting SCP...
    [12:39:53] Net:   SCP/INF: Crust v0.6.10000
    [12:39:53] eth0: ethernet@1c30000
    [12:39:53] starting USB...
    [12:39:53] Bus usb@1c1a000: sun4i_usb_phy phy@1c19400: External vbus detected, not enabling our own vbus
    [12:39:53] USB EHCI 1.00
    [12:39:53] Bus usb@1c1a400: USB OHCI 1.0
    [12:39:53] Bus usb@1c1b000: USB EHCI 1.00
    [12:39:53] Bus usb@1c1b400: USB OHCI 1.0
    [12:39:53] Bus usb@1c1c000: USB EHCI 1.00
    [12:39:53] Bus usb@1c1c400: USB OHCI 1.0
    [12:39:53] scanning bus usb@1c1a000 for devices... 1 USB Device(s) found
    [12:39:54] scanning bus usb@1c1a400 for devices... 1 USB Device(s) found
    [12:39:55] scanning bus usb@1c1b000 for devices... 1 USB Device(s) found
    [12:39:56] scanning bus usb@1c1b400 for devices... 1 USB Device(s) found
    [12:39:57] scanning bus usb@1c1c000 for devices... 1 USB Device(s) found
    [12:39:59] scanning bus usb@1c1c400 for devices... 1 USB Device(s) found
    [12:40:00]        scanning usb for storage devices... 0 Storage Device(s) found
    [12:40:00] Autoboot in 1 seconds, press <Space> to stop
    [12:40:01] switch to partitions #0, OK
    [12:40:01] mmc0 is current device
    [12:40:01] Scanning mmc 0:1...
    [12:40:01] Found U-Boot script /boot/boot.scr
    [12:40:01] 18117 bytes read in 4 ms (4.3 MiB/s)
    [12:40:01] ## Executing script at 43100000
    [12:40:01] Boot script loaded from mmc 0:1.
    [12:40:01] 687 bytes read in 3 ms (223.6 KiB/s)
    [12:40:01] Loaded/imported environment /boot/armbianEnv.txt to/from 0x45000000.
    [12:40:01] Found mainline kernel configuration.
    [12:40:01] 35473 bytes read in 11 ms (3.1 MiB/s)
    [12:40:01] Loaded DT /boot/dtb/sun8i-h2-plus-orangepi-zero.dtb to 0x43000000.
    [12:40:01] Working FDT set to 43000000
    [12:40:01] Loading kernel provided DT overlay(s) from /boot/dtb/overlay to 0x45000000 ..
    [12:40:01] 504 bytes read in 10 ms (48.8 KiB/s)
    [12:40:01] Applied DT overlay usbhost2 (/boot/dtb/overlay/sun8i-h3-usbhost2.dtbo).
    [12:40:01] 504 bytes read in 10 ms (48.8 KiB/s)
    [12:40:01] Applied DT overlay usbhost3 (/boot/dtb/overlay/sun8i-h3-usbhost3.dtbo).
    [12:40:01] 617 bytes read in 10 ms (59.6 KiB/s)
    [12:40:01] Applied DT overlay tve (/boot/dtb/overlay/sun8i-h3-tve.dtbo).
    [12:40:01] 374 bytes read in 9 ms (40 KiB/s)
    [12:40:01] Applied DT overlay i2c0 (/boot/dtb/overlay/sun8i-h3-i2c0.dtbo).
    [12:40:01] Loading user provided DT overlay(s) from /boot/overlay-user to 0x45000000 ..
    [12:40:01] 835 bytes read in 3 ms (271.5 KiB/s)
    [12:40:01] Applied user DT overlay rtc0-i2c-ds3231-rtc1-soc (/boot/overlay-user/rtc0-i2c-ds3231-rtc1-soc.dtbo).
    [12:40:01] 4185 bytes read in 10 ms (408.2 KiB/s)
    [12:40:01] ## Executing script at 45000000
    [12:40:01] Loaded/sourced fixup script /boot/dtb/overlay/sun8i-h3-fixup.scr to/at 0x45000000.
    [12:40:02] 10554192 bytes read in 441 ms (22.8 MiB/s)
    [12:40:02] Loaded compressed kernel image /boot/zImage to 4300a000.
    [12:40:02] Using compressed kernel image filesize 0xa10b50 bytes to calculate initial ramdisk load address.
    [12:40:02] 11621101 bytes read in 484 ms (22.9 MiB/s)
    [12:40:02] Loaded initial ramdisk /boot/uInitrd to 43a1b000.
    [12:40:02] Unknown command 'kaslrseed' - try 'help'
    [12:40:02] Not able to prepare for KASLR.
    [12:40:02] Kernel commandline arguments:
    [12:40:02]   root=/dev/nfs
    [12:40:02]   rootfstype=nfs
    [12:40:02]   rootwait
    [12:40:02]   splash=verbose
    [12:40:02]   earlycon
    [12:40:02]   console=ttyS0,115200
    [12:40:02]   consoleblank=0
    [12:40:02]   loglevel=8
    [12:40:02]   ubootpart=81f6566a-01
    [12:40:02]   usb-storage.quirks=0x2537:0x1066:u,0x2537:0x1068:u,0x174c:0x55aa:u
    [12:40:02]   dwc_otg.fiq_enable=0
    [12:40:02]   net.ifnames=0
    [12:40:02]   ipv6.disable=1
    [12:40:02]   rw
    [12:40:02]   nfsroot=192.168.2.34:/export/rootfs/blippi
    [12:40:02]   ip=dhcp
    [12:40:02]   nfsrootdebug
    [12:40:02]   nfs.enable_ino64=0
    [12:40:02]   cgroup_enable=cpuset
    [12:40:02]   cgroup_memory=1
    [12:40:02]   cgroup_enable=memory
    [12:40:02] Kernel image @ 0x4300a000 [ 0x000000 - 0xa10b50 ]
    [12:40:02] ## Loading init Ramdisk from Legacy Image at 43a1b000 ...
    [12:40:02]    Image Name:   uInitrd
    [12:40:02]    Image Type:   ARM Linux RAMDisk Image (gzip compressed)
    [12:40:02]    Data Size:    11621037 Bytes = 11.1 MiB
    [12:40:02]    Load Address: 00000000
    [12:40:02]    Entry Point:  00000000
    [12:40:02]    Verifying Checksum ... OK
    [12:40:02] ## Flattened Device Tree blob at 43000000
    [12:40:02]    Booting using the fdt blob at 0x43000000
    [12:40:02] Working FDT set to 43000000
    [12:40:02]    Loading Ramdisk to 494ea000, end 49fff2ad ... OK
    [12:40:02]    Loading Device Tree to 494de000, end 494e9fff ... OK
    [12:40:02] Working FDT set to 494de000
    
    [12:40:02] Starting kernel ...
    
    [12:40:03] [    0.000000] Booting Linux on physical CPU 0x0
    
  • [x] Orangepi zero (first gen): OK
    U-Boot SPL 2024.01-armbian (Feb 23 2024 - 10:47:39 +0000)
    DRAM: 256 MiB
    Trying to boot from MMC1
    ns16550_serial serial@1c28000: pinctrl_select_state_full: uclass_get_device_by_phandle_id: err=-19
    
    
    U-Boot 2024.01-armbian (Feb 23 2024 - 10:47:39 +0000) Allwinner Technology
    
    CPU:   Allwinner H3 (SUN8I 1680)
    Model: Xunlong Orange Pi Zero
    DRAM:  256 MiB
    Core:  70 devices, 19 uclasses, devicetree: separate
    WDT:   Not starting watchdog@1c20ca0
    MMC:   mmc@1c0f000: 0, mmc@1c10000: 1
    Loading Environment from FAT... Unable to use mmc 0:1...
    In:    serial,usbkbd
    Out:   serial
    Err:   serial
    Starting SCP...
    Net:   SCP/INF: Crust v0.6.10000
    eth0: ethernet@1c30000
    starting USB...
    Bus usb@1c1a000: sun4i_usb_phy phy@1c19400: External vbus detected, not enabling our own vbus
    USB EHCI 1.00
    Bus usb@1c1a400: USB OHCI 1.0
    Bus usb@1c1b000: USB EHCI 1.00
    Bus usb@1c1b400: USB OHCI 1.0
    Bus usb@1c1c000: USB EHCI 1.00
    Bus usb@1c1c400: USB OHCI 1.0
    scanning bus usb@1c1a000 for devices... 1 USB Device(s) found
    scanning bus usb@1c1a400 for devices... 1 USB Device(s) found
    scanning bus usb@1c1b000 for devices... 1 USB Device(s) found
    scanning bus usb@1c1b400 for devices... 1 USB Device(s) found
    scanning bus usb@1c1c000 for devices... 1 USB Device(s) found
    scanning bus usb@1c1c400 for devices... 1 USB Device(s) found
           scanning usb for storage devices... 0 Storage Device(s) found
    Autoboot in 1 seconds, press <Space> to stop
    switch to partitions #0, OK
    mmc0 is current device
    Scanning mmc 0:1...
    Found U-Boot script /boot/boot.scr
    18202 bytes read in 5 ms (3.5 MiB/s)
    ## Executing script at 43100000
    Boot script loaded from mmc 0:1.
    265 bytes read in 4 ms (64.5 KiB/s)
    Loaded/imported environment /boot/armbianEnv.txt to/from 0x45000000.
    Found mainline kernel configuration.
    35473 bytes read in 9 ms (3.8 MiB/s)
    Loaded DT /boot/dtb/sun8i-h2-plus-orangepi-zero.dtb to 0x43000000.
    Working FDT set to 43000000
    Loading kernel provided DT overlay(s) from /boot/dtb/overlay to 0x45000000 ..
    504 bytes read in 11 ms (43.9 KiB/s)
    Applied DT overlay usbhost2 (/boot/dtb/overlay/sun8i-h3-usbhost2.dtbo).
    504 bytes read in 12 ms (41 KiB/s)
    Applied DT overlay usbhost3 (/boot/dtb/overlay/sun8i-h3-usbhost3.dtbo).
    4185 bytes read in 11 ms (371.1 KiB/s)
    ## Executing script at 45000000
    Loaded/sourced fixup script /boot/dtb/overlay/sun8i-h3-fixup.scr to/at 0x45000000.
    10554192 bytes read in 442 ms (22.8 MiB/s)
    Loaded compressed kernel image /boot/zImage to 4300a000.
    Using compressed kernel image filesize 0xa10b50 bytes to calculate initial ramdisk load address.
    11867098 bytes read in 497 ms (22.8 MiB/s)
    Loaded initial ramdisk /boot/uInitrd to 43a1b000.
    Unknown command 'kaslrseed' - try 'help'
    Not able to prepare for KASLR.
    Kernel commandline arguments:
      root=PARTUUID=1c01f668-02
      rootfstype=f2fs
      rootwait
      splash=verbose
      console=ttyS0,115200
      consoleblank=0
      loglevel=8
      ubootpart=1c01f668-01
      usb-storage.quirks=0x2537:0x1066:u,0x2537:0x1068:u,0x174c:0x55aa:u
      net.ifnames=0
      ipv6.disable=1
      cgroup_enable=cpuset
      cgroup_memory=1
      cgroup_enable=memory
    Kernel image @ 0x4300a000 [ 0x000000 - 0xa10b50 ]
    ## Loading init Ramdisk from Legacy Image at 43a1b000 ...
       Image Name:   uInitrd
       Image Type:   ARM Linux RAMDisk Image (gzip compressed)
       Data Size:    11867034 Bytes = 11.3 MiB
       Load Address: 00000000
       Entry Point:  00000000
       Verifying Checksum ... OK
    ## Flattened Device Tree blob at 43000000
       Booting using the fdt blob at 0x43000000
    Working FDT set to 43000000
       Loading Ramdisk to 494ae000, end 49fff39a ... OK
       Loading Device Tree to 494a2000, end 494adfff ... OK
    Working FDT set to 494a2000
    
    Starting kernel ...
    

Checklist:

  • [ ] My code follows the style guidelines of this project
  • [x] I have performed a self-review of my own code
  • [x] I have commented my code, particularly in hard-to-understand areas
  • [ ] My changes generate no new warnings New warnings introduced:
    • Environment load failed
    • Environment import failed
    • DT load/application failed
    • DT (user) overlay load/application failed
    • Initial ramdisk load failed
    • Kernel image load failed
    • Boot failed
  • [x] Any dependent changes have been merged and published in downstream modules Prequisite U-Boot setexpr command already merged via https://github.com/armbian/build/pull/8260.

View the full article

×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines