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

silabs-flasher: Support Yellow with CM5 #3851

Merged
merged 1 commit into from
Dec 3, 2024
Merged

Conversation

agners
Copy link
Member

@agners agners commented Dec 3, 2024

Support flashing the internal radio on Home Assistant Yellow with CM5.

Summary by CodeRabbit

  • New Features

    • Updated flasher script for compatibility with Home Assistant Yellow using the CM5 module.
    • Introduced a new function to simplify device checks for Home Assistant Yellow.
  • Bug Fixes

    • Enhanced error handling and logging in the flasher script.
  • Documentation

    • Updated changelog to reflect the new version (0.3.2) and changes made.

Support flashing the internal radio on Home Assistant Yellow with CM5.
Copy link
Contributor

coderabbitai bot commented Dec 3, 2024

📝 Walkthrough

Walkthrough

The pull request includes updates to the Silicon Labs Flasher add-on, specifically version 0.3.2. The CHANGELOG.md has been modified to reflect this new version, highlighting changes to the flasher script for compatibility with Home Assistant Yellow and the CM5 module. The config.yaml file has been updated to change the version number from 0.3.1 to 0.3.2. Additionally, the universal-silabs-flasher-up script has been enhanced with a new function to simplify device checks related to Home Assistant Yellow, while maintaining existing functionality.

Changes

File Change Summary
silabs_flasher/CHANGELOG.md Added new version entry ## 0.3.2 and description for flasher script compatibility with Home Assistant Yellow.
silabs_flasher/config.yaml Updated version from 0.3.1 to 0.3.2.
silabs_flasher/rootfs/etc/s6-overlay/scripts/universal-silabs-flasher-up Added function is_home_assistant_yellow for improved device checks related to Home Assistant Yellow.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Flasher Script
    participant Device

    User->>Flasher Script: Start flashing process
    Flasher Script->>Device: Check device type
    alt Device is Home Assistant Yellow
        Flasher Script->>Device: Set gpio_reset_flag to --bootloader-reset yellow
        Flasher Script->>Device: Use specific firmware for Home Assistant Yellow
    else Device is not Home Assistant Yellow
        Flasher Script->>Device: Use default firmware
    end
    Flasher Script->>Device: Flash firmware
    Device-->>Flasher Script: Confirm flashing complete
    Flasher Script-->>User: Flashing process complete
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 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
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

🧹 Outside diff range and nitpick comments (3)
silabs_flasher/rootfs/etc/s6-overlay/scripts/universal-silabs-flasher-up (3)

33-51: LGTM! Consider adding more detailed documentation.

The is_home_assistant_yellow function implementation is robust and follows good practices. However, it would be beneficial to add a comment explaining why these specific paths are checked and what they represent.

Add documentation above the paths array:

 # Check the known paths for Home Assistant Yellow
 local paths=(
+    # Primary path for standard Raspberry Pi serial port mapping
     "/sys/devices/platform/soc/fe201800.serial/tty/ttyAMA1"
+    # Alternative path for PCIe-based serial port mapping
     "/sys/devices/platform/axi/1000120000.pcie/1f0003c000.serial/tty/ttyAMA1"
 )

73-74: Consider making the firmware version configurable.

The firmware version (7.4.4.0) is currently hardcoded. This could make future updates more difficult and error-prone.

Consider one of these approaches:

  1. Move firmware versions to a configuration file
  2. Add them as add-on configuration options
  3. Define them as environment variables

Example configuration approach:

+ # At the start of the script
+ declare -A FIRMWARE_VERSIONS=(
+   ["yellow"]="7.4.4.0"
+   ["skyconnect"]="7.4.4.0"
+ )
+
  if is_home_assistant_yellow; then
-     firmware="yellow_zigbee_ncp_7.4.4.0.gbl"
+     firmware="yellow_zigbee_ncp_${FIRMWARE_VERSIONS["yellow"]}.gbl"

34-51: Consider enhancing error handling for Yellow detection.

While the implementation works correctly, it might benefit from more detailed error reporting when Yellow detection fails.

Consider adding more detailed logging:

 function is_home_assistant_yellow {
     # First, ensure the device is /dev/ttyAMA1
     if [ "${device}" != "/dev/ttyAMA1" ]; then
+        bashio::log.debug "Device ${device} is not ttyAMA1, not a Yellow device"
         return 1
     fi

     # Check the known paths for Home Assistant Yellow
     local paths=(
         "/sys/devices/platform/soc/fe201800.serial/tty/ttyAMA1"
         "/sys/devices/platform/axi/1000120000.pcie/1f0003c000.serial/tty/ttyAMA1"
     )
     for path in "${paths[@]}"; do
         if [ -d "${path}" ]; then
+            bashio::log.debug "Found Yellow device at ${path}"
             return 0
         fi
     done
+    bashio::log.debug "No Yellow device paths found"
     return 1
 }

Also applies to: 56-61

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 5d9cb42 and 5f767bd.

📒 Files selected for processing (3)
  • silabs_flasher/CHANGELOG.md (1 hunks)
  • silabs_flasher/config.yaml (1 hunks)
  • silabs_flasher/rootfs/etc/s6-overlay/scripts/universal-silabs-flasher-up (2 hunks)
✅ Files skipped from review due to trivial changes (2)
  • silabs_flasher/config.yaml
  • silabs_flasher/CHANGELOG.md
🔇 Additional comments (1)
silabs_flasher/rootfs/etc/s6-overlay/scripts/universal-silabs-flasher-up (1)

Line range hint 56-61: LGTM! Clear and well-structured logic.

The implementation properly handles the bootloader reset flag setting with appropriate logging.

@agners agners merged commit dedf6cd into master Dec 3, 2024
11 checks passed
@agners agners deleted the fix-yellow-detection-on-cm5 branch December 3, 2024 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants