BeagleBone Green + Adafruit_Blinka Python Library Permissions (Debian 12.2 Bookworm)

I’m trying to use the Adafruit_Blinka Python library in order to get readings from one of Adafruit’s IMU products. My goal with this post is to understand if sudo is required in order to simply read from the IMU; ideally I can run a python script without sudo to get readings. The IMU itself isn’t relevant here, but rather using the Adafruit_Blinka library.

I found this github issue on using the Adafruit libraries to properly detect a BeagleBone Black on 5.10 kernel: BeagleBone Black is not detected properly on kernel 5.10 and later · Issue #218 · adafruit/Adafruit_Python_PlatformDetect · GitHub

@RobertCNelson even weighed in and it looked like this particular issue was solved for Debian Buster images. However, I have a BeagleBone Green with the Debian 12.2 Bookworm image.

I was eventually able to run python -c "import board" successfully (no sudo) but it took some digging. I had to make a modification in order to run import board without a PermissionError to read the nvmem file. I found this comment here

However, I didn’t seem to have a /etc/udev/rules.d/80-eeprom-noroot.rules file so I made one as detailed here: Beagle Bone Black: no such file or directory: 0-00500/nvmem, permission denied 0-00500/nvmem · Issue #886 · adafruit/Adafruit_Blinka · GitHub

I guess I’m troubled by having to do this just to run all this without sudo. I have a solution now, but it felt icky. Should I not have to make this change? Perhaps this deserves a new PR to the Adafruit_Python_PlatformDetect library? Or should I just suck it up and find a way to live with sudo in this case?

Thanks.

I just looked at their site, very impressive sensor, have not worked with that one. It is i2c. It says the sensor has absracted out the math using an arm core. That would imply to me it is sending out positional data that can be implemented as is. You might have to do some homework on this and find out how its framing up the data and just write your own code in c++ then convert it into a python module.

page 102 has the i2c info

$groups

If your board has an i2c group add it to your user.

You can also set the permissions to test it.

$sudo chmod 666 /dev/i2c-1

FYI, 666 is testing only, change it back after testing.

If that works, you can create udev rule for it.

If that works, you can create udev rule for it.

Yes, and that’s what I’ve done. The adafruit platformdetect library needed to read /sys/bus/nvmem/devices/0-00501/nvmem, and the udev rule I made changed the owner group to gpio with the default user is a part of. That worked in order to get past the permission issue. But now I seem to have a new problem where the nvmem device “address”—for lack of a better term—has changed to 0-00502. I have no idea why this has happened, and haven’t changed the underlying kernel nor any u-boot configuration or settings.

debian@BeagleBone:~$ tree /sys/bus/nvmem/devices/
/sys/bus/nvmem/devices/
|-- 0-00502 -> ../../../devices/platform/ocp/44c00000.interconnect/44c00000.interconnect:segment@200000/44e0b000.target-module/44e0b000.i2c/i2c-0/0-0050/0-00502

As a result, my board cannot be detected as a BBG by the library like I would expect. I can read the EEPROM just fine:

debian@BeagleBone:~$ sudo cat /sys/bus/nvmem/devices/0-00502/nvmem | xxd | head -n 2
00000000: aa55 33ee 4133 3335 424e 4c54 4242 4731  .U3.A335BNLTBBG1
00000010: 4242 4731 3233 3235 3033 3034 ffff ffff  BBG123250304....

beagle-version:

eeprom:[A335BNLTBBG1BBG123250304]
model:[TI_AM335x_BeagleBone_Green]
dogtag:[BeagleBoard.org Debian Bookworm IoT Image 2023-10-07]
bootloader:[microSD-(push-button)]:[/dev/mmcblk0]:[U-Boot SPL 2022.04-00038-gbaca7b469d (Nov 06 2024 - 17:14:19 -0700)]:[location: dd MBR]
UBOOT: Booted Device-Tree:[am335x-boneblack-uboot-univ.dts]
UBOOT: Loaded Overlay:[BB-ADC-00A0.kernel]
UBOOT: Loaded Overlay:[BB-I2C2-RTC-DS3231]
UBOOT: Loaded Overlay:[BB-SPIDEV0-00A0.kernel]
UBOOT: Loaded Overlay:[BB-UART1-00A0.kernel]
UBOOT: Loaded Overlay:[M-BB-BBG-00A0.kernel]
kernel:[5.10.168-ti-r77]
/boot/uEnv.txt Settings:
uboot_overlay_options:[enable_uboot_overlays=1]
uboot_overlay_options:[uboot_overlay_addr4=BB-I2C2-RTC-DS3231.dtbo]
uboot_overlay_options:[uboot_overlay_addr5=BB-UART1-00A0.dtbo]
uboot_overlay_options:[uboot_overlay_addr6=BB-SPIDEV0-00A0.dtbo]
uboot_overlay_options:[disable_uboot_overlay_emmc=1]
uboot_overlay_options:[disable_uboot_overlay_video=1]
uboot_overlay_options:[disable_uboot_overlay_audio=1]
uboot_overlay_options:[disable_uboot_overlay_wireless=1]
uboot_overlay_options:[enable_uboot_cape_universal=1]
pkg check: to individually upgrade run: [sudo apt install --only-upgrade <pkg>]
WARNING:pkg:[bb-cape-overlays]:[NOT_INSTALLED]
pkg:[bb-customizations]:[1.20240119.0-0~bookworm+20240119]
pkg:[bb-usb-gadgets]:[1.20231003.1-0~bookworm+20231003]
pkg:[bb-wl18xx-firmware]:[1.20230414.0-0~bookworm+20230414]
pkg:[kmod]:[30+20221128-1]
WARNING:pkg:[librobotcontrol]:[NOT_INSTALLED]
pkg:[firmware-ti-connectivity]:[20230210-5]
groups:[debian : debian adm kmem dialout cdrom floppy audio dip video plugdev users systemd-journal input render netdev i2c bluetooth gpio admin tisdk weston-launch cloud9ide spi]
cmdline:[console=ttyS0,115200n8 bone_capemgr.uboot_capemgr_enabled=1 root=/dev/mmcblk0p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 lpj=1990656 rng_core.default_quality=100 quiet]
dmesg | grep remote
[   13.473831] remoteproc remoteproc0: wkup_m3 is available
[   26.608058] systemd[1]: Reached target remote-fs.target - Remote File Systems.
[   53.394198] remoteproc remoteproc0: powering up wkup_m3
[   53.394236] remoteproc remoteproc0: Booting fw image am335x-pm-firmware.elf, size 217148
[   53.394534] remoteproc remoteproc0: remote processor wkup_m3 is now up
[   81.494612] remoteproc remoteproc1: 4a334000.pru is available
[   81.556819] remoteproc remoteproc2: 4a338000.pru is available
dmesg | grep pru
[   81.494612] remoteproc remoteproc1: 4a334000.pru is available
[   81.556819] remoteproc remoteproc2: 4a338000.pru is available
dmesg | grep pinctrl-single
[   12.847925] pinctrl-single 44e10800.pinmux: 142 pins, size 568
dmesg | grep gpio-of-helper
[   12.849823] gpio-of-helper ocp:cape-universal: Failed to get gpio property of 'P8_03'
[   12.849852] gpio-of-helper ocp:cape-universal: Failed to create gpio entry
[   13.729509] gpio-of-helper ocp:cape-universal: Allocated GPIO id=0 name='P8_03'
[   13.729788] gpio-of-helper ocp:cape-universal: Allocated GPIO id=1 name='P8_04'
[   13.730001] gpio-of-helper ocp:cape-universal: Allocated GPIO id=2 name='P8_05'
[   13.730200] gpio-of-helper ocp:cape-universal: Allocated GPIO id=3 name='P8_06'
[   13.730723] gpio-of-helper ocp:cape-universal: Allocated GPIO id=4 name='P8_07'
[   13.730938] gpio-of-helper ocp:cape-universal: Allocated GPIO id=5 name='P8_08'
[   13.731127] gpio-of-helper ocp:cape-universal: Allocated GPIO id=6 name='P8_09'
[   13.731337] gpio-of-helper ocp:cape-universal: Allocated GPIO id=7 name='P8_10'
[   13.731662] gpio-of-helper ocp:cape-universal: Allocated GPIO id=8 name='P8_11'
[   13.731888] gpio-of-helper ocp:cape-universal: Allocated GPIO id=9 name='P8_12'
[   13.732221] gpio-of-helper ocp:cape-universal: Allocated GPIO id=10 name='P8_13'
[   13.732436] gpio-of-helper ocp:cape-universal: Allocated GPIO id=11 name='P8_14'
[   13.732642] gpio-of-helper ocp:cape-universal: Allocated GPIO id=12 name='P8_15'
[   13.732829] gpio-of-helper ocp:cape-universal: Allocated GPIO id=13 name='P8_16'
[   13.733055] gpio-of-helper ocp:cape-universal: Allocated GPIO id=14 name='P8_17'
[   13.733264] gpio-of-helper ocp:cape-universal: Allocated GPIO id=15 name='P8_18'
[   13.733451] gpio-of-helper ocp:cape-universal: Allocated GPIO id=16 name='P8_19'
[   13.733651] gpio-of-helper ocp:cape-universal: Allocated GPIO id=17 name='P8_20'
[   13.733837] gpio-of-helper ocp:cape-universal: Allocated GPIO id=18 name='P8_21'
[   13.734052] gpio-of-helper ocp:cape-universal: Allocated GPIO id=19 name='P8_22'
[   13.734250] gpio-of-helper ocp:cape-universal: Allocated GPIO id=20 name='P8_23'
[   13.734432] gpio-of-helper ocp:cape-universal: Allocated GPIO id=21 name='P8_24'
[   13.734630] gpio-of-helper ocp:cape-universal: Allocated GPIO id=22 name='P8_25'
[   13.734840] gpio-of-helper ocp:cape-universal: Allocated GPIO id=23 name='P8_26'
[   13.735032] gpio-of-helper ocp:cape-universal: Allocated GPIO id=24 name='P8_27'
[   13.735233] gpio-of-helper ocp:cape-universal: Allocated GPIO id=25 name='P8_28'
[   13.735417] gpio-of-helper ocp:cape-universal: Allocated GPIO id=26 name='P8_29'
[   13.735746] gpio-of-helper ocp:cape-universal: Allocated GPIO id=27 name='P8_30'
[   13.735960] gpio-of-helper ocp:cape-universal: Allocated GPIO id=28 name='P8_31'
[   13.736163] gpio-of-helper ocp:cape-universal: Allocated GPIO id=29 name='P8_32'
[   13.736366] gpio-of-helper ocp:cape-universal: Allocated GPIO id=30 name='P8_33'
[   13.736555] gpio-of-helper ocp:cape-universal: Allocated GPIO id=31 name='P8_34'
[   13.736768] gpio-of-helper ocp:cape-universal: Allocated GPIO id=32 name='P8_35'
[   13.736969] gpio-of-helper ocp:cape-universal: Allocated GPIO id=33 name='P8_36'
[   13.737161] gpio-of-helper ocp:cape-universal: Allocated GPIO id=34 name='P8_37'
[   13.737380] gpio-of-helper ocp:cape-universal: Allocated GPIO id=35 name='P8_38'
[   13.737585] gpio-of-helper ocp:cape-universal: Allocated GPIO id=36 name='P8_39'
[   13.737781] gpio-of-helper ocp:cape-universal: Allocated GPIO id=37 name='P8_40'
[   13.737997] gpio-of-helper ocp:cape-universal: Allocated GPIO id=38 name='P8_41'
[   13.738199] gpio-of-helper ocp:cape-universal: Allocated GPIO id=39 name='P8_42'
[   13.738401] gpio-of-helper ocp:cape-universal: Allocated GPIO id=40 name='P8_43'
[   13.738585] gpio-of-helper ocp:cape-universal: Allocated GPIO id=41 name='P8_44'
[   13.738784] gpio-of-helper ocp:cape-universal: Allocated GPIO id=42 name='P8_45'
[   13.738994] gpio-of-helper ocp:cape-universal: Allocated GPIO id=43 name='P8_46'
[   13.739188] gpio-of-helper ocp:cape-universal: Allocated GPIO id=44 name='P9_11'
[   13.739413] gpio-of-helper ocp:cape-universal: Allocated GPIO id=45 name='P9_12'
[   13.739730] gpio-of-helper ocp:cape-universal: Allocated GPIO id=46 name='P9_13'
[   13.739955] gpio-of-helper ocp:cape-universal: Allocated GPIO id=47 name='P9_14'
[   13.740156] gpio-of-helper ocp:cape-universal: Allocated GPIO id=48 name='P9_15'
[   13.740347] gpio-of-helper ocp:cape-universal: Allocated GPIO id=49 name='P9_16'
[   13.740550] gpio-of-helper ocp:cape-universal: Allocated GPIO id=50 name='P9_17'
[   13.740757] gpio-of-helper ocp:cape-universal: Allocated GPIO id=51 name='P9_18'
[   13.740945] gpio-of-helper ocp:cape-universal: Allocated GPIO id=52 name='P9_19'
[   13.741144] gpio-of-helper ocp:cape-universal: Allocated GPIO id=53 name='P9_20'
[   13.741333] gpio-of-helper ocp:cape-universal: Allocated GPIO id=54 name='P9_21'
[   13.741541] gpio-of-helper ocp:cape-universal: Allocated GPIO id=55 name='P9_22'
[   13.741757] gpio-of-helper ocp:cape-universal: Allocated GPIO id=56 name='P9_23'
[   13.741969] gpio-of-helper ocp:cape-universal: Allocated GPIO id=57 name='P9_24'
[   13.742500] gpio-of-helper ocp:cape-universal: Allocated GPIO id=58 name='P9_25'
[   13.742740] gpio-of-helper ocp:cape-universal: Allocated GPIO id=59 name='P9_26'
[   13.742954] gpio-of-helper ocp:cape-universal: Allocated GPIO id=60 name='P9_27'
[   13.743162] gpio-of-helper ocp:cape-universal: Allocated GPIO id=61 name='P9_28'
[   13.743356] gpio-of-helper ocp:cape-universal: Allocated GPIO id=62 name='P9_29'
[   13.743677] gpio-of-helper ocp:cape-universal: Allocated GPIO id=63 name='P9_30'
[   13.743879] gpio-of-helper ocp:cape-universal: Allocated GPIO id=64 name='P9_31'
[   13.744115] gpio-of-helper ocp:cape-universal: Allocated GPIO id=65 name='P9_41'
[   13.744321] gpio-of-helper ocp:cape-universal: Allocated GPIO id=66 name='P9_91'
[   13.744555] gpio-of-helper ocp:cape-universal: Allocated GPIO id=67 name='P9_42'
[   13.744768] gpio-of-helper ocp:cape-universal: Allocated GPIO id=68 name='P9_92'
[   13.744782] gpio-of-helper ocp:cape-universal: ready
dmesg | grep wlcore
lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
END

My hacky idea is to add a symlink to the 0-00502 nvmem device. But so far it hasn’t worked. Another way to get around this issue is to edit the library code itself to also check 0-00502. But both seem unnecessary and feel like band-aids.

If that is what it takes go for it. This stuff is complex, its not even worth thinking about how to get a solution. So many hours are lost trying to make things “right”, its not good. Main thing is if it works, and works to your systems design expectations. Be sure to test it more than you normally would and hopefully the true reason for that change will become visible. You don’t want surprises after the product is delivered to the customer. At the end of the day that is what matters the most.

This is pure conjecture, it might be some enumeration protocol in the kernel, what ever is generating the 0-00502 that is changing.

1 Like