Skip to content
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

Allow boot from USB and NVMe on ODROID-M1 #3852

Merged
merged 1 commit into from
Feb 3, 2025

Conversation

rpardini
Copy link
Contributor

@rpardini rpardini commented Jan 31, 2025

In similar vein to @viraniac's #3784, but for the ODROID-M1.

I've adapted Armbian's mainline u-boot (which is a decent way to get rid of Petitboot) with support for setexpr and fileenv and squashfs: see armbian/build#7769. With those we can now boot HAOS using mainline u-boot in SPI, and thus run HAOS completely from NVMe, drastically enhancing performance and reliability.

Summary by CodeRabbit

  • Improvements
    • Enhanced boot script flexibility by introducing dynamic device type handling
    • Updated boot configuration to support more versatile storage device loading
    • Improved script adaptability for different hardware configurations

Use devtype instead of hardcoding device type to mmc in U-Boot script

Signed-off-by: Ricardo Pardini <[email protected]>
Copy link

@home-assistant home-assistant bot left a comment

Choose a reason for hiding this comment

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

Hi @rpardini

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@home-assistant home-assistant bot marked this pull request as draft January 31, 2025 19:18
@home-assistant
Copy link

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@rpardini rpardini marked this pull request as ready for review January 31, 2025 19:19
Copy link

coderabbitai bot commented Jan 31, 2025

📝 Walkthrough

Walkthrough

The pull request modifies the uboot-boot.ush script for the Hardkernel Odroid-M1 board, replacing hardcoded mmc commands with a more flexible ${devtype} variable. This change allows the boot script to dynamically adapt to different storage device types, making it more versatile across various hardware configurations. The modifications impact device type detection, partition reading, and file loading operations during the boot process.

Changes

File Change Summary
buildroot-external/board/hardkernel/odroid-m1/uboot-boot.ush Replaced hardcoded mmc commands with ${devtype} variable for more dynamic device type handling

Sequence Diagram

sequenceDiagram
    participant U as U-Boot
    participant S as Boot Script
    participant D as Device Storage

    U->>S: Execute boot script
    S->>S: Determine device type
    S->>D: Read partition info using ${devtype}
    S->>D: Load configuration files
    S->>D: Load kernel and device trees
    S->>U: Boot system
Loading

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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. (Beta)
  • @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 or @coderabbitai title 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.

Copy link

@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 (2)
buildroot-external/board/hardkernel/odroid-m1/uboot-boot.ush (2)

67-77: LGTM! Consider documenting storage type detection.

The kernel loading implementation correctly supports different storage types while maintaining the A/B slot system. However, it would be helpful to document how U-Boot detects and sets the ${devtype} variable.

Consider adding a comment explaining how the storage type is detected and how ${devtype} gets its value (e.g., 'mmc', 'usb', 'nvme').


Line range hint 1-77: Excellent implementation of multi-storage boot support!

The changes consistently implement device-agnostic boot support throughout the script, enabling USB and NVMe boot while maintaining all existing functionality. The implementation is clean and follows a systematic approach to replace storage-specific commands with flexible alternatives.

This implementation provides a good foundation for adding support for other storage types in the future, as it abstracts the storage-specific commands behind the ${devtype} variable.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f56130a and 1d3d63a.

📒 Files selected for processing (1)
  • buildroot-external/board/hardkernel/odroid-m1/uboot-boot.ush (3 hunks)
🔇 Additional comments (3)
buildroot-external/board/hardkernel/odroid-m1/uboot-boot.ush (3)

1-12: LGTM! Device-agnostic boot state management.

The replacement of hardcoded 'mmc' commands with '${devtype}' successfully makes the boot state management work across different storage types (MMC, USB, NVMe).


38-56: LGTM! Robust device tree handling across storage types.

The device tree and overlay handling has been correctly adapted to work with different storage types while maintaining proper error handling.

Verify that the overlays path remains consistent across storage types:

✅ Verification successful

Overlay path structure verified and consistent

The "overlays/" directory path is consistently used across all board configurations, and the implementation correctly follows the established pattern while supporting flexible storage types.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if overlay paths are consistently defined
# Look for overlay path definitions or mount points

rg -A 3 "overlays.*dtbo|overlay.*path"

Length of output: 4257


29-33: Verify config loading across storage types.

The changes correctly implement device-agnostic config loading. However, we should verify the behavior across different storage types.

✅ Verification successful

Implementation follows established device-agnostic pattern

The changes align with the device-agnostic approach used in other modern board configurations (green, m1s, vim3). This pattern has been proven to work across different storage types.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if haos-config.txt loading is tested for different storage types
# Look for test cases or documentation covering USB/NVMe config loading

# Search for test files
fd -t f -e sh -e py -e txt "test.*odroid.*m1" --exec rg -l "haos-config"

# Search for documentation
fd -t f -e md -e rst "odroid.*m1|readme|doc" --exec rg -l "haos-config.*usb|haos-config.*nvme"

Length of output: 169


Script:

#!/bin/bash
# Search for U-Boot test framework and boot scripts
fd -t f "uboot-boot.ush" --exec rg -l "haos-config"

# Look for similar patterns in other board configs
rg -p "fatload.*haos-config" buildroot-external/board/

# Check for general boot documentation
fd -t f -e md -e rst . --exec rg -l "boot.*configuration|haos.*config"

Length of output: 1706

@rpardini
Copy link
Contributor Author

This rabbit's not too knowledgeable; devtype and devnum are u-boot's standard variables.

Copy link
Member

@sairon sairon left a comment

Choose a reason for hiding this comment

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

Looks good, thanks! Once we have a way to run HAOS from NVMe only, the docs should be updated too, but I see there are more things out of date, so let's not bother with it here.

@sairon
Copy link
Member

sairon commented Feb 3, 2025

This rabbit's not too knowledgeable; devtype and devnum are u-boot's standard variables.

Better said, those are "standard boot" variables, as "standard boot" is the name of the feature that provides them. It fairly new (since ~2022) as a built-in thing in U-Boot, maybe Coderabbit will pick it at some point in the future :)

@sairon sairon merged commit c63f9ec into home-assistant:dev Feb 3, 2025
2 checks passed
@sairon sairon added board/odroid Hardkernel's ODROID Boards u-boot U-Boot related issue labels Feb 3, 2025
@rpardini
Copy link
Contributor Author

rpardini commented Feb 4, 2025

Nice. I'm working with a colleague on the Armbian uboot to get it tested and merged there (it's just setexpr and squashfs support, and a small patch to add fileenv, but otherwise is just mainline 2025.01 uboot) and then I'll come back for docs and updating the HAOS-shipped uboot the same way. Unsure if we want to go all in into supporting writing uboot to SPI as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
board/odroid Hardkernel's ODROID Boards cla-signed u-boot U-Boot related issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants