Fix chip detection failure on Alpine Linux and other non-standard distros#414
Merged
makermelissa merged 1 commit intoadafruit:mainfrom Apr 22, 2026
Merged
Conversation
Three fixes in chip.py: 1. Add early device-tree check for Broadcom BCM chips. Previously, BCM detection relied solely on /proc/cpuinfo Hardware field, which is absent on aarch64 Alpine Linux (and potentially other distros). The new check matches 'brcm,bcm2' in /proc/device-tree/compatible, which is present on all Raspberry Pi boards regardless of distro. 2. Guard against NoneType crash when compatible is None. If both /proc/cpuinfo Hardware and /proc/device-tree/compatible are unavailable, compatible.split() would raise AttributeError, which gets silently swallowed by __getattr__ and surfaces as a confusing bare AttributeError. 3. Include attribute name in __getattr__ AttributeError for better debugging. Fixes adafruit#342
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Alpine Linux (aarch64),
detector.chip.idraises a bareAttributeErroron Raspberry Pi boards (#342). This happens because:/proc/cpuinfoon Alpine aarch64 doesn't include aHardwarefield_linux_id()hardwareandcompatibleareNone,compatible.split(',')crashes withAttributeError, which gets silently swallowed by__getattr__and surfaces as a confusing bareAttributeError()Fix
Three changes in
chip.py:Add early device-tree check for BCM chips — matches
brcm,bcm2in/proc/device-tree/compatible, which is present on all Raspberry Pi boards regardless of distro. This is consistent with how other chip families (TI, Allwinner, Rockchip, etc.) are already detected via device-tree.Guard against NoneType crash — if
compatibleisNone, use an empty list instead of crashing on.split().Improve
__getattr__error message — include the attribute name ("id") so the error is actually debuggable.Fixes #342