Skip to content

sunxi/mvebu: U-Boot calc load addresses, bootscript enhancements #8203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 20 commits into from

Conversation

djurny
Copy link
Contributor

@djurny djurny commented May 16, 2025

Description

GitHub issue reference:

Jira reference number AR-2680

Fix Helios4 wake-on-lan service.

Documentation summary for feature / change

  1. mvebu:
    1. Cosmetic changes, reformatting, regrouping
    2. Adding commonly used U-Boot environment variables
    3. Add "functions" to inform, warn operators and to show critical errors to operators
    4. Add more error checking on load, fdt apply and other operations
    5. Small refactoring of fixup script loading
    6. helios4:
      1. Fixed wake-on-lan systemd service unit
  2. sunxi:
    1. Cosmetic changes, reformatting, regrouping
    2. Adding commonly used U-Boot environment variables
    3. Add "functions" to inform, warn operators and to show critical errors to operators
    4. Add more error checking on load, fdt apply and other operations
    5. Small refactoring of fixup script loading
    6. Add load address calculation to avoid overlap issues
    7. Avoid U-Boot load address calculation falsely trips overlap error due to OBOE

How Has This Been Tested?

  • mvebu: OK
U-Boot SPL 2019.04-armbian-2019.04-S3c99-Pcd6a-H9530-V0854-Bb703-R448a (May 10 2025 - 09:39:24 +0000)
High speed PHY - Version: 2.0
Detected Device ID 6828
board SerDes lanes topology details:
 | Lane #  | Speed |  Type       |
 --------------------------------
 |   0    |  6   |  SATA0       |
 |   1    |  5   |  USB3 HOST0  |
 |   2    |  6   |  SATA1       |
 |   3    |  6   |  SATA3       |
 |   4    |  6   |  SATA2       |
 |   5    |  5   |  USB3 HOST1  |
 --------------------------------
High speed PHY - Ended Successfully
mv_ddr: mv_ddr-armada-18.09.2 
DDR3 Training Sequence - Switching XBAR Window to FastPath Window
DDR Training Sequence - Start scrubbing
DDR3 Training Sequence - End scrubbing
mv_ddr: completed successfully
Trying to boot from MMC1


U-Boot 2019.04-armbian-2019.04-S3c99-Pcd6a-H9530-V0854-Bb703-R448a (May 10 2025 - 09:39:24 +0000)

SoC:   MV88F6828-A0 at 1600 MHz
DRAM:  2 GiB (800 MHz, 32-bit, ECC enabled)
MMC:   mv_sdh: 0
Loading Environment from EXT4... ** File not found /boot/boot.env **

** Unable to read "/boot/boot.env" from mmc0:1 **
Model: Helios4
Board: Helios4
SCSI:  MVEBU SATA INIT
Target spinup took 0 ms.
Target spinup took 0 ms.
AHCI 0001.0000 32 slots 2 ports 6 Gbps 0x3 impl SATA mode
flags: 64bit ncq led only pmp fbss pio slum part sxs 

Net:   
Warning: ethernet@70000 (eth1) using random MAC address - 8a:97:bf:a0:3c:db
eth1: ethernet@70000
Hit any key to stop autoboot:  0 
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
Found U-Boot script /boot/boot.scr
8022 bytes read in 407 ms (18.6 KiB/s)
## Executing script at 03000000
Boot script loaded from mmc
158 bytes read in 393 ms (0 Bytes/s)
Imported environment (/boot/armbianEnv.txt) from mmc to 0x00300000
28834 bytes read in 764 ms (36.1 KiB/s)
Loaded DT (/boot/dtb/armada-388-helios4.dtb) from mmc to 0x02040000
8854712 bytes read in 1936 ms (4.4 MiB/s)
Loaded kernel (/boot/zImage) from mmc to 2049000
10493433 bytes read in 2254 ms (4.4 MiB/s)
Loaded initial ramdisk (/boot/uInitrd) from mmc to 28bb000
## Loading init Ramdisk from Legacy Image at 028bb000 ...
   Image Name:   uInitrd
   Created:      2025-05-17  15:34:03 UTC
   Image Type:   ARM Linux RAMDisk Image (gzip compressed)
   Data Size:    10493369 Bytes = 10 MiB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 02040000
   Booting using the fdt blob at 0x2040000
   Loading Ramdisk to 0f5fe000, end 0ffffdb9 ... OK
   Loading Device Tree to 0f5f3000, end 0f5fdfff ... OK

Starting kernel ...

Loading, please wait...
Starting systemd-udevd version 252.36-1~deb12u1
  • sunxi:
    Built 25.08.trunk: OK

    U-Boot SPL 2024.01-armbian-2024.01-S866c-P6b16-Ha5c2-V367a-Bb703-R448a (Apr 29 2025 - 02:50:09 +0000)
    DRAM: 512 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-2024.01-S866c-P6b16-Ha5c2-V367a-Bb703-R448a (Apr 29 2025 - 02:50:09 +0000) Allwinner Technology
    
    CPU:   Allwinner H3 (SUN8I 1680)
    Model: Xunlong Orange Pi Zero
    DRAM:  512 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
    9829 bytes read in 4 ms (2.3 MiB/s)
    ## Executing script at 43100000
    U-Boot loaded from SD
    388 bytes read in 3 ms (126 KiB/s)
    Imported environment (/boot/armbianEnv.txt) from mmc to 0x45000000
    Found mainline kernel configuration
    35384 bytes read in 8 ms (4.2 MiB/s)
    Loaded DT (/boot/dtb/sun8i-h2-plus-orangepi-zero.dtb) from mmc to 0x43000000
    Working FDT set to 43000000
    Loading kernel provided DT overlay(s) from mmc to 0x45000000
    504 bytes read in 10 ms (48.8 KiB/s)
    Applied DT overlay usbhost2 (/boot/dtb/overlay/sun8i-h3-usbhost2.dtbo)
    504 bytes read in 11 ms (43.9 KiB/s)
    Applied DT overlay usbhost3 (/boot/dtb/overlay/sun8i-h3-usbhost3.dtbo)
    617 bytes read in 10 ms (59.6 KiB/s)
    Applied DT overlay tve (/boot/dtb/overlay/sun8i-h3-tve.dtbo)
    Loading user provided DT overlay(s) from mmc to 0x45000000
    835 bytes read in 4 ms (203.1 KiB/s)
    Applied user DT overlay rtc0-i2c-ds3231-rtc1-soc (/boot/overlay-user/rtc0-i2c-ds3231-rtc1-soc.dtbo)
    4185 bytes read in 11 ms (371.1 KiB/s)
    ## Executing script at 45000000
    Sourced fixup script (/boot/dtb/overlay/sun8i-h3-fixup.scr) from mmc to 0x45000000
    11015528 bytes read in 459 ms (22.9 MiB/s)
    Loaded kernel (/boot/zImage) from mmc to 4300a000
    12354794 bytes read in 515 ms (22.9 MiB/s)
    Loaded initial ramdisk (/boot/uInitrd) from mmc to 43a8c000
    Kernel image @ 0x4300a000 [ 0x000000 - 0xa81568 ]
    ## Loading init Ramdisk from Legacy Image at 43a8c000 ...
       Image Name:   uInitrd
       Image Type:   ARM Linux RAMDisk Image (gzip compressed)
       Data Size:    12354730 Bytes = 11.8 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 49437000, end 49fff4aa ... OK
       Loading Device Tree to 4942b000, end 49436fff ... OK
    Working FDT set to 4942b000
    
    Starting kernel ...
    

    Downgraded to 25.2.2 : OK

    U-Boot SPL 2024.01-armbian-2024.01-S866c-P6b16-Ha5c2-V367a-Bb703-R448a (Apr 29 2025 - 02:50:09 +0000)
    DRAM: 512 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-2024.01-S866c-P6b16-Ha5c2-V367a-Bb703-R448a (Apr 29 2025 - 02:50:09 +0000) Allwinner Technology
    
    CPU:   Allwinner H3 (SUN8I 1680)
    Model: Xunlong Orange Pi Zero
    DRAM:  512 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
    9829 bytes read in 4 ms (2.3 MiB/s)
    ## Executing script at 43100000
    U-Boot loaded from SD
    393 bytes read in 3 ms (127.9 KiB/s)
    Imported environment (/boot/armbianEnv.txt) from mmc to 0x45000000
    Found mainline kernel configuration
    35473 bytes read in 11 ms (3.1 MiB/s)
    Loaded DT (/boot/dtb/sun8i-h2-plus-orangepi-zero.dtb) from mmc to 0x43000000
    Working FDT set to 43000000
    Loading kernel provided DT overlay(s) from mmc 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 11 ms (43.9 KiB/s)
    Applied DT overlay usbhost3 (/boot/dtb/overlay/sun8i-h3-usbhost3.dtbo)
    617 bytes read in 11 ms (54.7 KiB/s)
    Applied DT overlay tve (/boot/dtb/overlay/sun8i-h3-tve.dtbo)
    374 bytes read in 10 ms (36.1 KiB/s)
    Applied DT overlay i2c0 (/boot/dtb/overlay/sun8i-h3-i2c0.dtbo)
    Loading user provided DT overlay(s) from mmc to 0x45000000
    835 bytes read in 4 ms (203.1 KiB/s)
    Applied user DT overlay rtc0-i2c-ds3231-rtc1-soc (/boot/overlay-user/rtc0-i2c-ds3231-rtc1-soc.dtbo)
    4185 bytes read in 11 ms (371.1 KiB/s)
    ## Executing script at 45000000
    Sourced fixup script (/boot/dtb/overlay/sun8i-h3-fixup.scr) from mmc to 0x45000000
    10746248 bytes read in 448 ms (22.9 MiB/s)
    Loaded kernel (/boot/zImage) from mmc to 4300a000
    11678154 bytes read in 488 ms (22.8 MiB/s)
    Loaded initial ramdisk (/boot/uInitrd) from mmc to 43a4a000
    Kernel image @ 0x4300a000 [ 0x000000 - 0xa3f988 ]
    ## Loading init Ramdisk from Legacy Image at 43a4a000 ...
       Image Name:   uInitrd
       Image Type:   ARM Linux RAMDisk Image (gzip compressed)
       Data Size:    11678090 Bytes = 11.1 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 494dc000, end 49fff18a ... OK
       Loading Device Tree to 494d0000, end 494dbfff ... OK
    Working FDT set to 494d0000
    
    Starting kernel ...
    

Checklist:

Please delete options that are not relevant.

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings

djurny added 15 commits May 12, 2025 21:58
armbian#8178
- Add switch to turn avoidance on/off
- Increment base address before alignment to resolve the oboe
- oboe observed in U-Boot v2021.04 and in particular with DT loading
- Check all load actions
- Add optional early exit with explanation in case a load fails
- Added FDT resize/trim to allow big DT and overlays and still use
  configured load addresses in case `setexpr` not available
- Moved FDT resize and next load address alignment
- Added filename information to load instructions
- Moved all "global" variable determinations to the top of the
  bootscript
- Determine the load address for kernel and initial ramdisk based
  on DT and kernel image size.
- Added FDT resize/trim to allow big DT and overlays and still use
  configured load addresses in case `setexpr` not available
- Moved FDT resize and next load address alignment
- Added filename information to load instructions
- Check all load actions
- Add optional early exit with explanation in case a load fails
- Add switch to turn avoidance on/off
- Increment base address before alignment to resolve the oboe
- oboe observed in U-Boot v2021.04 and in particular with DT loading
armbian#8178
- Add switch to turn avoidance on/off
- Increment base address before alignment to resolve the oboe
- oboe observed in U-Boot v2021.04 and in particular with DT loading
- Check all load actions
- Add optional early exit with explanation in case a load fails
- Added FDT resize/trim to allow big DT and overlays and still use
  configured load addresses in case `setexpr` not available
- Moved FDT resize and next load address alignment
- Added filename information to load instructions
- Moved all "global" variable determinations to the top of the
  bootscript
- reformatted
- added "functions" for messaging
- added load address calculation for sunxi
- added overlap avoidance for sunxi
- added more messaging towards console
- introduced some U-Boot commonly used variables
Copy link
Contributor

coderabbitai bot commented May 16, 2025

"""

Walkthrough

This pull request extensively refactors the boot-mvebu.cmd and boot-sunxi.cmd U-Boot boot scripts. The changes reorganize and expand environment variable initialization, introduce new variables for verbosity and file overrides, and implement robust error handling and messaging. Device tree (DT) and overlay loading logic is enhanced to check file existence, handle errors explicitly, and reload the original DT if overlays fail. Fixup script processing is improved with stepwise checks and messaging. Kernel and ramdisk loading now use overridable filenames and include critical error handling. The boot command's control flow is clarified, with consistent messaging and improved address alignment logic.

The Helios4 board configuration is updated to add the "ethtool" package for Wake-on-LAN (WoL) support. Correspondingly, the Helios4 WoL systemd service is modified to enable WoL on all network interfaces matching "en*" or "eth*", replacing the previous fixed single interface configuration.

Assessment against linked issues

Objective Addressed Explanation
Correct DT and kernel/ramdisk load address calculation to avoid false overlap detection in U-Boot (AR-2680)
Fix address alignment logic to use itest for hex values instead of test (AR-2680)

Possibly related PRs

Suggested labels

ready to merge

Suggested reviewers

  • igorpecovnik
  • Heisath
    """

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.

✨ Finishing Touches
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Commit Unit Tests in branch main
  • Post Copyable Unit Tests in Comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added size/small PR with less then 50 lines 05 Milestone: Second quarter release labels May 16, 2025
@github-actions github-actions bot added size/large PR with 250 lines or more Needs review Seeking for review Hardware Hardware related like kernel, U-Boot, ... and removed size/small PR with less then 50 lines labels May 16, 2025
@djurny djurny marked this pull request as ready for review May 17, 2025 15:46
@djurny djurny requested a review from igorpecovnik as a code owner May 17, 2025 15:46
@coderabbitai coderabbitai bot added the Ready to merge Reviewed, tested and ready for merge label May 17, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (2)
config/bootscripts/boot-sunxi.cmd (1)

253-259: fdt_totalsize fallback can underestimate after overlays are applied

The manual size calculation re-uses the original ${fdtfilesize} captured before overlays & fixups, so the resulting total may be too small and cause kernel overwrite when large overlays are applied.

Consider:

-        setexpr fdt_totalsize ${fdtfilesize} / 0x1000
+        /* Use current header size, not original file size */
+        fdt header get tmp_totalsize totalsize || true
+        if test "${tmp_totalsize}" != "" ; then
+            setexpr fdtfilesize ${tmp_totalsize}
+        fi
+        setexpr fdt_totalsize ${fdtfilesize} / 0x1000
config/bootscripts/boot-mvebu.cmd (1)

102-123: Run-time test coverage is fragile – consider adding CI unit-tests for script logic

Both bugs above slipped through because boot scripts are executed only on hardware.
A minimal CI step that runs mkimage -T script followed by a grep of expected log strings (e.g. “Applied DT overlay …”) would have caught them early.

Also applies to: 130-151

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 000c787 and 888c995.

📒 Files selected for processing (2)
  • config/bootscripts/boot-mvebu.cmd (3 hunks)
  • config/bootscripts/boot-sunxi.cmd (2 hunks)
🔇 Additional comments (3)
config/bootscripts/boot-sunxi.cmd (2)

119-134: Empty ‘then’ branch hampers readability, makes flow harder to follow

The outer if test -e … ; then block has no body, pushing all useful work into the nested else … chain.
A no-op branch is legal but confusing, especially in a 9-level cascade. Consider flipping the condition or collapsing the logic to make intent clearer and maintenance easier.

[ suggest_optional_refactor ]


158-178:

❌ Incorrect review comment

overlay_prefix may be undefined – produces “//…dtbo” paths

Both overlay loops rely on ${overlay_prefix} but the variable is never set in this script.
If absent in the imported environment the generated filename becomes "/overlay/-foo.dtbo" which will never exist, silently causing warnings.

Recommendation:

  1. Provide a sane default early in the script, e.g.
    setenv overlay_prefix "${overlay_prefix:=sunxi}".
  2. Or guard each usage with if test "${overlay_prefix}" != "" ; then ….

Also applies to: 186-206


I’ll search the repo for any definitions or usage of overlay_prefix to confirm whether it’s ever initialized.


🏁 Script executed:

#!/bin/bash
# Search for overlay_prefix across the entire repository
rg overlay_prefix -n

# Narrow down to occurrences in the boot-sunxi script
rg overlay_prefix -n config/bootscripts/boot-sunxi.cmd

Length of output: 8010


I’ll check whether boot-sunxi.cmd loads armbianEnv.txt or otherwise initializes overlay_prefix:


🏁 Script executed:

#!/bin/bash
# Look for environment import or armbianEnv in boot-sunxi script
rg "env import" -n config/bootscripts/boot-sunxi.cmd
rg "armbianEnv" -n config/bootscripts/boot-sunxi.cmd

Length of output: 262


overlay_prefix is initialized via armbianEnv.txt import – no changes needed

The script sets

setenv envfile 'armbianEnv.txt'if load ${devtype} ${devnum}:${distro_bootpart} ${load_addr} ${prefix}${envfile}; then  
    env import -t ${load_addr} ${filesize}fi

early on, which populates ${overlay_prefix} (it’s written into armbianEnv.txt by the build). The loops at lines 158–178 and 186–206 run after that import, so ${overlay_prefix} will always be defined.

As other board scripts make the same assumption, no default or extra guard is required here.

Likely an incorrect or invalid review comment.

config/bootscripts/boot-mvebu.cmd (1)

49-55: Self-test for setexpr clobbers variable namespace

Using the variable name setexpr shadows the command itself in subsequent calls on some U-Boot versions that support env setexpr.
Safer to store the flag in a differently named variable, e.g. has_setexpr.

[ suggest_nitpick ]

@djurny
Copy link
Contributor Author

djurny commented May 17, 2025

Wow looks like I stared myself blind and got a reality check by some AI 🤭

@djurny djurny marked this pull request as draft May 17, 2025 16:42
sunxi:
- sync up with mvebu
- add earlycon option
- improve on messages

mvebu:
- sync up with sunxi
- fix loading proper ${overlay}
- fix loading proper ${user_overlay}
- improve on messages
@github-actions github-actions bot removed the Ready to merge Reviewed, tested and ready for merge label May 17, 2025
@djurny djurny marked this pull request as ready for review May 17, 2025 23:56
@coderabbitai coderabbitai bot added the Ready to merge Reviewed, tested and ready for merge label May 17, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
config/bootscripts/boot-sunxi.cmd (1)

114-117: Valid implementation of string substitution in U-Boot.

The setexpr sub command is correctly used for string operations to remove the vendor prefix from the fdtfile variable, as documented in U-Boot's setexpr command documentation when CONFIG_REGEX=y is enabled.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 888c995 and d1b19ea.

📒 Files selected for processing (2)
  • config/bootscripts/boot-mvebu.cmd (3 hunks)
  • config/bootscripts/boot-sunxi.cmd (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • config/bootscripts/boot-mvebu.cmd
🧰 Additional context used
🧠 Learnings (1)
config/bootscripts/boot-sunxi.cmd (1)
Learnt from: djurny
PR: armbian/build#8203
File: config/bootscripts/boot-sunxi.cmd:111-114
Timestamp: 2025-05-17T23:08:31.722Z
Learning: In U-Boot scripts, the `setexpr sub` command is valid for string operations when CONFIG_REGEX=y is enabled. This allows for pattern substitution in strings, as documented in https://docs.u-boot.org/en/latest/usage/cmd/setexpr.html. The syntax is `setexpr <variable> sub <pattern> <replacement> <string>`.
🔇 Additional comments (13)
config/bootscripts/boot-sunxi.cmd (13)

6-25: Well-structured environment initialization with comprehensive defaults.

The environment initialization block is well organized with logical grouping of variables. The addition of variables for alignment control, error handling, and verbosity will improve script robustness and debugging capabilities.


34-39: Good implementation of helper functions for consistent messaging and error handling.

The helper functions for alignment and message handling create a consistent approach to user feedback throughout the script. The critical_error function with conditional exit is particularly valuable for preventing boot continuation after fatal errors.


40-53: Robust handling of mandatory and optional environment variables.

The script now properly enforces required variables (fdtfile) with clear error messages, while providing sensible defaults for optional variables. This prevents silent failures later in the boot process.


61-76: Well-implemented environment file loading with proper error handling.

The environment file loading sequence now has comprehensive checks for file existence, load success, and import success, with appropriate success and failure messaging based on verbosity settings.


109-137: Comprehensive device tree file path resolution with fallbacks.

The script now intelligently attempts multiple possible device tree file locations, handling vendor prefixes and falling back to defaults if needed. This improves compatibility across different system configurations.


142-150: Improved device tree loading with clear error messaging.

The device tree loading now has proper error handling with informative success messages and critical error exits on failure, improving reliability and troubleshooting.


156-182: Robust kernel overlay loading with individual success/failure reporting.

The overlay loading process now properly checks for file existence, loads each overlay individually, and reports success or failure for each overlay. This provides clear feedback about which overlays were successfully applied.


184-210: Well-implemented user overlay support with detailed error reporting.

The user overlay handling mirrors the kernel overlay implementation with consistent checks and messaging, making the user experience more predictable and debugging easier.


212-245: Robust error recovery for overlay failures.

If any overlay fails to apply, the script now properly reloads the original device tree and continues. The fixup script handling also has proper error checking and reporting.


247-263: Well-implemented device tree size calculation.

The script now properly resizes the device tree after overlays and calculates or approximates the total size including the extra size. This is important for determining the next load address.


265-290: Improved load address calculation to prevent memory overlaps.

The memory address calculation for kernel and ramdisk loading now properly avoids overlaps by calculating each address based on the previous load's size and applying alignment. This is essential for preventing boot failures due to memory corruption.


291-294: Added error handling for boot command.

The script now reports a critical error if the boot command fails, rather than silently continuing or failing without explanation.


294-300: Sequential loading in legacy boot path.

The legacy boot path now explicitly loads ramdisk and kernel before device tree script, which provides a more predictable loading sequence.

Removed duplicate block for earlycon enabling
@github-actions github-actions bot removed the Ready to merge Reviewed, tested and ready for merge label May 18, 2025
@coderabbitai coderabbitai bot added the Ready to merge Reviewed, tested and ready for merge label May 18, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
config/bootscripts/boot-sunxi.cmd (1)

158-177: Set a default for overlay_prefix to prevent malformed file paths

When overlay_prefix is unset the generated path becomes
${fdtdir}/overlay/-${overlay}.dtbo, guaranteeing a ❌ “file not found” and noisy warnings.
Defaulting the variable to the vendor (or a safe fallback like sunxi) keeps the behaviour intact for existing users while eliminating spurious errors.

+# fall back to vendor name when overlay_prefix not supplied
+if test "${overlay_prefix}" = ""; then
+        setenv overlay_prefix "${vendor}"
+fi
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d1b19ea and c3f3362.

📒 Files selected for processing (1)
  • config/bootscripts/boot-sunxi.cmd (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
config/bootscripts/boot-sunxi.cmd (1)
Learnt from: djurny
PR: armbian/build#8203
File: config/bootscripts/boot-sunxi.cmd:111-114
Timestamp: 2025-05-17T23:08:31.722Z
Learning: In U-Boot scripts, the `setexpr sub` command is valid for string operations when CONFIG_REGEX=y is enabled. This allows for pattern substitution in strings, as documented in https://docs.u-boot.org/en/latest/usage/cmd/setexpr.html. The syntax is `setexpr <variable> sub <pattern> <replacement> <string>`.
🔇 Additional comments (1)
config/bootscripts/boot-sunxi.cmd (1)

88-90: Early-console is now appended only once – good catch!
The previous double-injection has been removed; bootargs stay clean.

- add ethtool
- enable wol on all found ethernet interfaces
- support commonly used network device naming schemes
@djurny djurny requested review from Heisath and a team as code owners May 19, 2025 13:59
@github-actions github-actions bot added Ready to merge Reviewed, tested and ready for merge BSP Board Support Packages and removed Ready to merge Reviewed, tested and ready for merge labels May 19, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/bsp/mvebu/helios4/helios4-wol.service (1)

2-2: Description should be updated to match implementation.

The unit Description still references only "eth0" but the implementation now handles multiple network interfaces.

-Description=Enable Wake-on-LAN for Helios4 eth0
+Description=Enable Wake-on-LAN for Helios4 network interfaces
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c3f3362 and 32ef1bf.

📒 Files selected for processing (2)
  • config/boards/helios4.conf (1 hunks)
  • packages/bsp/mvebu/helios4/helios4-wol.service (1 hunks)
🔇 Additional comments (2)
config/boards/helios4.conf (1)

16-16: LGTM! Package addition is well-documented.

The addition of the ethtool package is well-documented with a clear comment explaining its purpose for the WoL service.

packages/bsp/mvebu/helios4/helios4-wol.service (1)

7-7: Improved implementation to handle multiple network interfaces.

The updated script now properly handles all network interfaces matching "en*" or "eth*" patterns rather than just eth0, making the service more flexible. Good use of parameter expansion with :? for error checking.

@github-actions github-actions bot removed the Ready to merge Reviewed, tested and ready for merge label May 19, 2025
@djurny djurny marked this pull request as draft May 25, 2025 20:24
@djurny
Copy link
Contributor Author

djurny commented May 25, 2025

Prepare to close, add lessons learned from rockchip boot script, then split into per arch pull requests.

@djurny djurny closed this May 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
05 Milestone: Second quarter release BSP Board Support Packages Hardware Hardware related like kernel, U-Boot, ... Needs review Seeking for review size/large PR with 250 lines or more
Development

Successfully merging this pull request may close these issues.

1 participant