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

Find EEPROM device more reliably on BeagleBones #372

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions adafruit_platformdetect/board.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries

Check failure on line 1 in adafruit_platformdetect/board.py

View workflow job for this annotation

GitHub Actions / test

reformatted
#
# SPDX-License-Identifier: MIT

Expand All @@ -20,6 +20,7 @@

"""

import glob
import os
import re

Expand Down Expand Up @@ -321,20 +322,23 @@
if "beaglev-starlight" in board_value:
return boards.BEAGLEV_STARLIGHT

# find device alias at i2c address 0x50 (0-00500, 0-00501, etc)
nvmem_devices = glob.glob('/sys/bus/nvmem/devices/0-0050*')
# do not expect there to be anything but one eeprom
if len(nvmem_devices) != 1:
return None

eeprom_dir = nvmem_devices[0]
try:
with open("/sys/bus/nvmem/devices/0-00500/nvmem", "rb") as eeprom:
with open(f"{eeprom_dir}/nvmem", "rb") as eeprom:
eeprom_bytes = eeprom.read(16)
except FileNotFoundError:
try:
with open("/sys/bus/nvmem/devices/0-00501/nvmem", "rb") as eeprom:
# Special Case for AI64
with open("/sys/bus/nvmem/devices/2-00500/nvmem", "rb") as eeprom:
eeprom_bytes = eeprom.read(16)
except FileNotFoundError:
try:
# Special Case for AI64
with open("/sys/bus/nvmem/devices/2-00500/nvmem", "rb") as eeprom:
eeprom_bytes = eeprom.read(16)
except FileNotFoundError:
return None
return None

if eeprom_bytes[:4] != b"\xaaU3\xee":
return None
Expand Down
Loading