Skip to content

Conversation

@rpardini
Copy link
Member

@rpardini rpardini commented Jan 8, 2026

u-boot: allow custom LOGLEVEL with UBOOT_LOGLEVEL (default to 6)

  • 🌱 u-boot: better CONFIG_LOG/LOGLEVEL/LOG_MAX_LEVEL (=6)
  • 🌿 u-boot: allow custom LOGLEVEL with UBOOT_LOGLEVEL (default to 6)

Summary by CodeRabbit

  • Improvements
    • U-Boot bootloader compilation now features configurable logging levels through a new variable, replacing previously hard-coded values. This enhancement allows users to customize boot-time diagnostic output according to specific requirements, enabling better control during system initialization and improving troubleshooting capabilities for various deployment scenarios.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 8, 2026

📝 Walkthrough

Walkthrough

Refactors U-Boot log level configuration to use a configurable uboot_loglevel variable (defaulting to 6) instead of hard-coded constants, enabling centralized control of CONFIG_LOG, CONFIG_LOGLEVEL, CONFIG_LOG_MAX_LEVEL, and related settings.

Changes

Cohort / File(s) Summary
U-Boot Log Level Configuration
lib/functions/compilation/uboot.sh
Introduces uboot_loglevel variable and replaces hard-coded log level values (6) with the variable for CONFIG_LOG, CONFIG_LOGLEVEL, CONFIG_LOG_MAX_LEVEL, CONFIG_LOG_DEFAULT_LEVEL, CONFIG_SPL_LOG_MAX_LEVEL, and CONFIG_TPL_LOG_MAX_LEVEL. Updates user-visible messaging to reference the variable. Maintains backward compatibility for legacy paths and existing LOCALVERSION_AUTO disable behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested reviewers

  • paolosabatino
  • igorpecovnik
  • amazingfate

Poem

🐰 A rabbit hops through U-Boot's den,
Where log levels now bend to our pen,
No more hardcoded six—now a variable so keen,
Configurability reigns supreme, a cleaner scene! 📋

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: introducing a custom UBOOT_LOGLEVEL variable with a default value of 6, which aligns with the modifications made to lib/functions/compilation/uboot.sh.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added 02 Milestone: First quarter release size/small PR with less then 50 lines Needs review Seeking for review Framework Framework components labels Jan 8, 2026
@rpardini rpardini marked this pull request as ready for review January 8, 2026 13:52
@rpardini rpardini requested a review from a team as a code owner January 8, 2026 13:52
@rpardini
Copy link
Member Author

rpardini commented Jan 8, 2026

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 8, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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)
lib/functions/compilation/uboot.sh (1)

116-117: LGTM! Clean implementation of configurable log level.

The use of parameter expansion with a sensible default (6/info) allows flexibility while maintaining good defaults. The variable is appropriately scoped to the function.

Optional: Add input validation for robustness

Consider validating that UBOOT_LOGLEVEL is within the valid range (0-9) to catch configuration errors early:

 declare uboot_loglevel="${UBOOT_LOGLEVEL:-"6"}" # default to info
+
+# Validate log level is in valid range (0-9)
+if [[ ! "${uboot_loglevel}" =~ ^[0-9]$ ]]; then
+	display_alert "Invalid UBOOT_LOGLEVEL value" "must be 0-9, got '${uboot_loglevel}', using default 6" "wrn"
+	uboot_loglevel="6"
+fi

This is optional since invalid values would likely be caught by U-Boot's build system, but early validation provides clearer feedback.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 063c641 and ff8b7ed.

📒 Files selected for processing (1)
  • lib/functions/compilation/uboot.sh
🧰 Additional context used
🧠 Learnings (14)
📓 Common learnings
Learnt from: EvilOlaf
Repo: armbian/build PR: 0
File: :0-0
Timestamp: 2025-12-19T13:56:45.124Z
Learning: When reviewing kernel or u-boot version bump PRs in the Armbian build system, check if patches existed in previous kernel version directories (e.g., sunxi-6.12, sunxi-6.13) before describing them as new features. If a patch and the majority of its contents existed previously with no major functionality changes, focus the review on the actual changes: the version bump itself and patch compatibility adjustments. Don't describe existing patches being ported/maintained across versions as new features or drivers—this is misleading. The patches are existing code being re-aligned to work with the new upstream version.
Learnt from: EvilOlaf
Repo: armbian/build PR: 8428
File: config/boards/lckfb-taishanpi.csc:5-9
Timestamp: 2025-07-25T03:51:50.830Z
Learning: When reviewing PRs in the Armbian build system, U-Boot defconfig files and patches may be added as part of the PR changes but might not be visible in the current repository clone state during review. It's important to check the actual PR file changes directly via GitHub or the PR API to get the complete picture of what files are being added or modified.
Learnt from: EvilOlaf
Repo: armbian/build PR: 8428
File: config/boards/lckfb-taishanpi.csc:5-9
Timestamp: 2025-07-25T03:51:50.830Z
Learning: When reviewing PRs in the Armbian build system, U-Boot defconfig files and patches may be added as part of the PR changes but might not be visible in the current repository clone state during review. It's important to check the actual PR file changes directly via GitHub API (https://api.github.com/repos/armbian/build/pulls/{pr_number}/files) to get the complete picture of what files are being added or modified, especially for U-Boot patches that will be applied during the build process.
Learnt from: rpardini
Repo: armbian/build PR: 9159
File: patch/u-boot/u-boot-genio/0026-dts-configs-add-Grinn-GenioSBC-510.patch:161-161
Timestamp: 2026-01-03T20:46:29.189Z
Learning: For the Armbian genio family (config/sources/families/genio.conf and patch/u-boot/u-boot-genio/), when reviewing PRs that include vendor U-Boot patches from Collabora, avoid flagging potential issues in board configurations that are out of scope for the PR's primary focus (e.g., don't flag Genio 510/700 board issues when the PR is focused on radxa-nio-12l/Genio 1200). The maintainer prioritizes keeping vendor patches close to upstream for easier re-copying and maintenance, even if secondary board configs have potential mismatches.
<!-- </add_learning>
📚 Learning: 2025-12-19T13:56:45.124Z
Learnt from: EvilOlaf
Repo: armbian/build PR: 0
File: :0-0
Timestamp: 2025-12-19T13:56:45.124Z
Learning: When reviewing kernel or u-boot version bump PRs in the Armbian build system, check if patches existed in previous kernel version directories (e.g., sunxi-6.12, sunxi-6.13) before describing them as new features. If a patch and the majority of its contents existed previously with no major functionality changes, focus the review on the actual changes: the version bump itself and patch compatibility adjustments. Don't describe existing patches being ported/maintained across versions as new features or drivers—this is misleading. The patches are existing code being re-aligned to work with the new upstream version.

Applied to files:

  • lib/functions/compilation/uboot.sh
📚 Learning: 2025-03-31T22:20:41.849Z
Learnt from: rpardini
Repo: armbian/build PR: 8044
File: patch/u-boot/v2025.04/cmd-fileenv-read-string-from-file-into-env.patch:73-75
Timestamp: 2025-03-31T22:20:41.849Z
Learning: When porting patches between U-Boot versions (like from 2025.01 to 2025.04), rpardini prefers to maintain patches as-is rather than introducing refactoring changes, even when potential improvements are identified. This approach prioritizes consistency and reduces the risk of introducing new issues.

Applied to files:

  • lib/functions/compilation/uboot.sh
📚 Learning: 2025-12-13T11:39:08.046Z
Learnt from: pyavitz
Repo: armbian/build PR: 9058
File: patch/u-boot/legacy/u-boot-spacemit-k1/003-SpacemiT-K1X-Fixups.patch:28-67
Timestamp: 2025-12-13T11:39:08.046Z
Learning: In the Armbian build system for SpacemiT U-Boot patches (patch/u-boot/legacy/u-boot-spacemit-k1/), alignment with mainline U-Boot behavior is prioritized. For example, in boot mode handling, leaving devnum unchanged in the default case (when devtype is cleared) follows mainline conventions rather than explicitly clearing it to handle edge cases.

Applied to files:

  • lib/functions/compilation/uboot.sh
📚 Learning: 2025-12-13T11:45:02.422Z
Learnt from: pyavitz
Repo: armbian/build PR: 9058
File: patch/u-boot/legacy/u-boot-spacemit-k1/003-SpacemiT-K1X-Fixups.patch:17-25
Timestamp: 2025-12-13T11:45:02.422Z
Learning: In the SpacemiT U-Boot patches for Armbian (patch/u-boot/legacy/u-boot-spacemit-k1/), the environment variable `devnum` is set to the device name string (e.g., "mmc", "nvme") rather than a numeric index, and `distro_bootpart` holds the partition number. This implementation aligns with mainline U-Boot conventions for the SpacemiT platform and has been verified to work correctly by the maintainer.

Applied to files:

  • lib/functions/compilation/uboot.sh
📚 Learning: 2025-11-20T18:20:11.985Z
Learnt from: EvilOlaf
Repo: armbian/build PR: 8968
File: patch/u-boot/u-boot-sunxi/arm64-dts-sun50i-h6-orangepi.dtsi-Rollback-r_rsb-to-r_i2c.patch:36-36
Timestamp: 2025-11-20T18:20:11.985Z
Learning: The rewrite-patches tool (REWRITE_PATCHES=yes) in the Armbian build system can inadvertently introduce semantic changes when the u-boot/kernel git base revision differs from expected state. The tool applies patches, commits them, and re-exports them using git format-patch, which can cause the re-exported patch to reflect the base revision's state rather than preserving the original patch intent. This is particularly problematic for device tree changes like interrupt specifications. The tool currently lacks validation mechanisms to detect such semantic drift, and affected patches must be manually corrected after rewriting.

Applied to files:

  • lib/functions/compilation/uboot.sh
📚 Learning: 2025-07-13T14:00:39.402Z
Learnt from: djurny
Repo: armbian/build PR: 8315
File: config/bootscripts/boot-generic.cmd.template:62-62
Timestamp: 2025-07-13T14:00:39.402Z
Learning: In U-Boot bootscripts, the verbosity check pattern `test "${verbosity}" = "" || itest ${verbosity} -gt 0 && echo "${l_message}"` correctly implements quiet behavior when verbosity is unset or "0", and verbose behavior when verbosity > 0, due to proper operator precedence where || has lower precedence than &&.

Applied to files:

  • lib/functions/compilation/uboot.sh
📚 Learning: 2025-03-31T22:20:48.475Z
Learnt from: rpardini
Repo: armbian/build PR: 8044
File: patch/u-boot/v2025.04/cmd-fileenv-read-string-from-file-into-env.patch:76-86
Timestamp: 2025-03-31T22:20:48.475Z
Learning: For the Armbian build project, maintaining consistency with existing patches across U-Boot versions (such as between 2025.01 and 2025.04) is prioritized over refactoring individual patches for code improvements.

Applied to files:

  • lib/functions/compilation/uboot.sh
📚 Learning: 2025-05-18T00:59:02.274Z
Learnt from: djurny
Repo: armbian/build PR: 8203
File: config/bootscripts/boot-sunxi.cmd:34-38
Timestamp: 2025-05-18T00:59:02.274Z
Learning: In U-Boot shell environments, `itest` silently handles non-numeric values without producing errors, unlike in bash or other standard shells. Additionally, U-Boot doesn't support stderr redirection with syntax like `2>/dev/null`. The standard pattern for verbosity checking in U-Boot is `if test "${verbosity}" != "" ; then if itest ${verbosity} -gt 0 ; then...`, which correctly handles both numeric and non-numeric values.

Applied to files:

  • lib/functions/compilation/uboot.sh
📚 Learning: 2025-06-12T21:03:39.686Z
Learnt from: djurny
Repo: armbian/build PR: 8287
File: config/bootscripts/boot-sunxi.cmd:148-161
Timestamp: 2025-06-12T21:03:39.686Z
Learning: In Armbian U-Boot bootscripts, the `${cpu}` environment variable is always pre-set by U-Boot (or defaults to a valid value), so additional guards against it being unset are unnecessary.

Applied to files:

  • lib/functions/compilation/uboot.sh
📚 Learning: 2025-09-12T19:28:38.491Z
Learnt from: Grippy98
Repo: armbian/build PR: 8622
File: config/sources/families/k3.conf:66-66
Timestamp: 2025-09-12T19:28:38.491Z
Learning: In the Armbian k3 family build system (config/sources/families/k3.conf), builds do not fail when TIBOOT3_BOOTCONFIG is unset, even though tiboot3.bin is still listed in UBOOT_TARGET_MAP. The gating mechanism in pre_config_uboot_target__build_first_stage function works as intended to conditionally build/copy tiboot3.bin only when TIBOOT3_BOOTCONFIG is defined.

Applied to files:

  • lib/functions/compilation/uboot.sh
📚 Learning: 2025-09-13T19:51:14.713Z
Learnt from: pyavitz
Repo: armbian/build PR: 8631
File: config/boards/khadas-vim4.conf:42-42
Timestamp: 2025-09-13T19:51:14.713Z
Learning: In the Armbian build system, run_host_command_logged can properly handle shell redirection operators like >> when passed as arguments, contrary to typical command wrapper behavior. The function has been tested to work correctly with redirection for appending to files like armbianEnv.txt.

Applied to files:

  • lib/functions/compilation/uboot.sh
📚 Learning: 2025-09-13T19:51:14.713Z
Learnt from: pyavitz
Repo: armbian/build PR: 8631
File: config/boards/khadas-vim4.conf:42-42
Timestamp: 2025-09-13T19:51:14.713Z
Learning: In the Armbian build system, run_host_command_logged properly handles shell redirection operators like ">>" when passed as string arguments. This pattern is used consistently throughout the codebase, such as in lib/functions/rootfs/distro-agnostic.sh where it's used to append to armbianEnv.txt files. The function has been tested and confirmed to work correctly with this syntax.

Applied to files:

  • lib/functions/compilation/uboot.sh
📚 Learning: 2025-12-18T23:40:41.627Z
Learnt from: rpardini
Repo: armbian/build PR: 9101
File: lib/functions/image/compress-checksum.sh:44-48
Timestamp: 2025-12-18T23:40:41.627Z
Learning: In the Armbian build framework, scripts run with set -e, so a non-zero exit status will abort the script. During reviews, assume failures will stop execution unless explicitly handled. Verify that commands that must fail are checked, errors are propagated, and any critical steps have proper error handling (e.g., using pipefail where appropriate, checking exit codes, and not masking failures).

Applied to files:

  • lib/functions/compilation/uboot.sh
🧬 Code graph analysis (1)
lib/functions/compilation/uboot.sh (2)
lib/functions/logging/display-alert.sh (1)
  • display_alert (10-227)
lib/functions/logging/runners.sh (1)
  • run_host_command_logged (204-206)
🔇 Additional comments (2)
lib/functions/compilation/uboot.sh (2)

144-147: Excellent! Proper use of scripts/config with the new variable.

The implementation correctly:

  • Updates user-facing messaging to reflect the actual log level being used
  • Enables CONFIG_LOG before setting log level values
  • Applies the configurable log level to both CONFIG_LOGLEVEL and CONFIG_LOG_MAX_LEVEL
  • Uses run_host_command_logged for proper logging and error handling

165-172: Consistent application of configurable log level in debug mode.

The use of uboot_loglevel across all log-related configurations (main, SPL, and TPL) ensures consistent logging verbosity throughout all boot stages. This maintains the flexibility introduced by the UBOOT_LOGLEVEL environment variable even when UBOOT_DEBUGGING=yes.

Copy link
Contributor

@iav iav left a comment

Choose a reason for hiding this comment

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

It works.

@github-actions github-actions bot added the Ready to merge Reviewed, tested and ready for merge label Jan 8, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

✅ This PR has been reviewed and approved — all set for merge!

@github-actions github-actions bot removed the Needs review Seeking for review label Jan 8, 2026
@igorpecovnik igorpecovnik merged commit 6e7d279 into armbian:main Jan 8, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

02 Milestone: First quarter release Framework Framework components Ready to merge Reviewed, tested and ready for merge size/small PR with less then 50 lines

Development

Successfully merging this pull request may close these issues.

3 participants