Skip to content

Commit 1295880

Browse files
committed
2 parents 1344fe0 + acaf6e6 commit 1295880

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

adafruit_platformdetect/board.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
2121
"""
2222

23+
import glob
2324
import os
2425
import re
2526

@@ -333,20 +334,23 @@ def _beaglebone_id(self) -> Optional[str]:
333334
if "beaglev-starlight" in board_value:
334335
return boards.BEAGLEV_STARLIGHT
335336

337+
# find device alias at i2c address 0x50 (0-00500, 0-00501, etc)
338+
nvmem_devices = glob.glob('/sys/bus/nvmem/devices/0-0050*')
339+
# do not expect there to be anything but one eeprom
340+
if len(nvmem_devices) != 1:
341+
return None
342+
343+
eeprom_dir = nvmem_devices[0]
336344
try:
337-
with open("/sys/bus/nvmem/devices/0-00500/nvmem", "rb") as eeprom:
345+
with open(f"{eeprom_dir}/nvmem", "rb") as eeprom:
338346
eeprom_bytes = eeprom.read(16)
339347
except FileNotFoundError:
340348
try:
341-
with open("/sys/bus/nvmem/devices/0-00501/nvmem", "rb") as eeprom:
349+
# Special Case for AI64
350+
with open("/sys/bus/nvmem/devices/2-00500/nvmem", "rb") as eeprom:
342351
eeprom_bytes = eeprom.read(16)
343352
except FileNotFoundError:
344-
try:
345-
# Special Case for AI64
346-
with open("/sys/bus/nvmem/devices/2-00500/nvmem", "rb") as eeprom:
347-
eeprom_bytes = eeprom.read(16)
348-
except FileNotFoundError:
349-
return None
353+
return None
350354

351355
if eeprom_bytes[:4] != b"\xaaU3\xee":
352356
return None

0 commit comments

Comments
 (0)