write to slots file as normal user?

110 views
Skip to first unread message

Drew Fustini

unread,
Aug 30, 2017, 10:58:16 PM8/30/17
to Robert Nelson, Thomas Livingstone, Beagle Board
This person noticed that Adafruit_BBIO doesn't work when not root:
https://forums.adafruit.com/viewtopic.php?f=49&t=105847#p606973

Issue seems to be:
open("/sys/devices/platform/bone_capemgr/slots", O_RDWR|O_LARGEFILE) = -1
EACCES (Permission denied)

Do we want to let normal users write to
/sys/devices/platform/bone_capemgr/slots ?

Thanks,
Drew

Peter Lawler

unread,
Aug 31, 2017, 7:56:37 AM8/31/17
to BeagleBoard, robert...@gmail.com, tdli...@gmail.com
. chmod 664 /sys/devices/platform/bone_capemgr/slots
 
 
$groupadd --system slots
$usermod --append --groups slots debian
then
$chmod 664 /sys/devices/platform/bone_capemgr/slots
$chgrp slots /sys/devices/platform/bone_capemgr/slots
(though to be honest I have no idea if this would be permanent etc. and probably not, it would be 'nice')


Robert Nelson

unread,
Aug 31, 2017, 8:19:24 AM8/31/17
to Peter Lawler, BeagleBoard, Thomas Livingstone
we could just add a udev rule too. ;)

Regards,

--
Robert Nelson
https://rcn-ee.com/

Peter Lawler

unread,
Aug 31, 2017, 8:21:39 AM8/31/17
to Robert Nelson, Thomas Livingstone, BeagleBoard
You kids these days.... :-P



Jason Kridner

unread,
Aug 31, 2017, 9:05:02 AM8/31/17
to beagl...@googlegroups.com, Robert Nelson, Thomas Livingstone
It would be a pretty big security hole, but we have plenty of those. It would at least take a targeted attack. I'm in favor. 




--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/CAG73kvVUhVSzanZtLT1S8Seb%3D8FJj7QF-8hHDpSBNZybf7hrVQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Drew Fustini

unread,
Aug 31, 2017, 10:28:57 PM8/31/17
to Beagle Board
Thanks, Peter. After running those commands, I was able to write to
slots file as user debian.

On Thu, Aug 31, 2017 at 6:56 AM, Peter Lawler <relwa...@gmail.com> wrote:
>
>
> --
> For more options, visit http://beagleboard.org/discuss
> ---
> You received this message because you are subscribed to the Google Groups
> "BeagleBoard" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to beagleboard...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/beagleboard/6871541d-a420-4cf2-9a62-fa40379df41e%40googlegroups.com.

tdlivings

unread,
Sep 1, 2017, 2:18:08 PM9/1/17
to BeagleBoard
Did not work for me.

I attached the terminal dumps.
ssh into BBBW apply commands try python and sudo python failed both times is first file.
Power down reboot and try again is second file.

Tom
TermiADCScratchfix_2.txt
TermiADCScratchfix_1.txt

Robert Nelson

unread,
Sep 1, 2017, 2:25:50 PM9/1/17
to Beagle Board, Thomas Livingstone
On Fri, Sep 1, 2017 at 1:18 PM, tdlivings <tdli...@gmail.com> wrote:
> Did not work for me.
>
> I attached the terminal dumps.
> ssh into BBBW apply commands try python and sudo python failed both times is
> first file.
> Power down reboot and try again is second file.

{RuntimeError: Unable to setup ADC system. Possible causes are:
- A cape with a conflicting pin mapping is loaded
- A device tree object is loaded that uses the same name for a
fragment: helper}

adc is already loaded..

This would show that:

sudo /opt/scripts/tools/version.sh

http://elinux.org/Beagleboard:BeagleBoneBlack_Debian#U-Boot_Disable_on-board_devices

see the adc disable..

tdlivings

unread,
Sep 1, 2017, 2:43:40 PM9/1/17
to BeagleBoard, tdli...@gmail.com
Robert 
I do not know what you mean by adc is already loaded as it is part of a python module but let's just assume I am the unknowing one.

I ran your version.sh and here is the results

Last login: Fri Sep  1 18:02:47 2017 from 192.168.0.15

debian@beaglebone:~$ sudo /opt/scripts/tools/version.sh 

[sudo] password for debian: 

git:/opt/scripts/:[8e0b1e6f135ff3c30468f49a7a952c98be97219a]

eeprom:[A335BNLTBWA51646BBWG2052]

dogtag:[BeagleBoard.org Debian Image 2017-08-24]

bootloader:[microSD-(push-button)]:[/dev/mmcblk0]:[U-Boot 2017.09-rc2-00002-g84a7f2]

bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot 2017.03-rc1-00003-ga09f2d]

kernel:[4.4.83-ti-r119]

nodejs:[v6.11.2]

uboot_overlay_options:[enable_uboot_overlays=1]

uboot_overlay_options:[uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-4-TI-00A0.dtbo]

uboot_overlay_options:[enable_uboot_cape_universal=1]

pkg:[bb-cape-overlays]:[4.4.20170728.0-0rcnee1~stretch+20170728]

pkg:[bb-wl18xx-firmware]:[1.20170821-0rcnee1~stretch+20170821]

pkg:[firmware-ti-connectivity]:[20161130-3]

debian@beaglebone:~


Tom

Robert Nelson

unread,
Sep 1, 2017, 2:52:23 PM9/1/17
to Beagle Board, Thomas Livingstone
> bootloader:[microSD-(push-button)]:[/dev/mmcblk0]:[U-Boot
> 2017.09-rc2-00002-g84a7f2]
>
> bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot
> 2017.03-rc1-00003-ga09f2d]

So, your eMMC's bootloader is getting in the way, hence your not
booting what you expect:

so kill the MLO file via:

sudo dd if=/dev/zero of=/dev/mmcblk1 count=1 seek=1 bs=128k

and it'll default to the correct bootloader found on the microSD.

tdlivings

unread,
Sep 1, 2017, 3:07:56 PM9/1/17
to BeagleBoard, tdli...@gmail.com
Robert
 Interesting as all I did was download the latest image you posted on Beagleboard.org and burn an sd card with it.
I expanded the file system and tried it out.
Seems to me if booting from an sd card the eMMC boot loader should neve be run.

I will give a try to killing the MLO file and I will see what image is actually in flash on this BBBW. 

Tom

Robert Nelson

unread,
Sep 1, 2017, 3:12:48 PM9/1/17
to Beagle Board, Thomas Livingstone
On Fri, Sep 1, 2017 at 2:07 PM, tdlivings <tdli...@gmail.com> wrote:
> Robert
> Interesting as all I did was download the latest image you posted on
> Beagleboard.org and burn an sd card with it.
> I expanded the file system and tried it out.
> Seems to me if booting from an sd card the eMMC boot loader should neve be
> run.

The am335x's bootrom defaults to eMMC first...

> I will give a try to killing the MLO file and I will see what image is
> actually in flash on this BBBW.

tdlivings

unread,
Sep 1, 2017, 3:25:09 PM9/1/17
to BeagleBoard, tdli...@gmail.com
Robert
OK deleted the file using your command and after a reboot it worked running python without sudo.
So whats in flash is upsetting the system, I will see what is in flash after dinner.

Last login: Fri Sep  1 19:16:09 2017 from 192.168.0.15

debian@beaglebone:~$ uname -a

Linux beaglebone 4.4.83-ti-r119 #1 SMP Thu Aug 17 06:39:24 UTC 2017 armv7l GNU/Linux

debian@beaglebone:~$ cat /etc/dogtag

BeagleBoard.org Debian Image 2017-08-24

debian@beaglebone:~$ python

Python 2.7.13 (default, Jan 19 2017, 14:48:08) 

[GCC 6.3.0 20170118] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> import Adafruit_BBIO.ADC as ADC

>>> ADC.setup()

>>> ADC.readraw("AIN1")

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

AttributeError: 'module' object has no attribute 'readraw'

>>> ADC.read_raw("AIN1")

3648.0

>>> quit()

debian@beaglebone:~


Tom

tdlivings

unread,
Sep 1, 2017, 8:59:33 PM9/1/17
to BeagleBoard, tdli...@gmail.com
Robert
 Turns out what was in flash was dead, would not even boot.
I may have booted from flash on this board once when I first purchased the board last fall.
So I have no idea what happened to  flash or when.
So I downloaded the latest 08/31/2017 IOT image and converted it to a flasher image and
flashed the eMMC with it.
It flashed fine and booted, which said at least the eMMC was not defective

I took a look at what was there using a cloud9 terminal as I have not run connman yet
and tried python Adafruit_BBIO ADC and it worked.
I did not execute any of the commands to create a new group and change file permissions.
It just worked out of the box.

Did you make any changes to the 08/31 image from this discussion that would have fixed the issue?

Tomorrow I can try an sd card with a fresh image without the fixed discussed earlier today and see what
happens with flash having a good image. 

Here is what I did

debian@beaglebone:/var/lib/cloud9$ uname -a
Linux beaglebone 4.4.84-ti-r120 #1 SMP Sun Aug 27 03:11:07 UTC 2017 armv7l GNU/Linux
debian@beaglebone:/var/lib/cloud9$ cat /etc/dogtag
BeagleBoard.org Debian Image 2017-08-31
debian@beaglebone:/var/lib/cloud9$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            217M     0  217M   0% /dev
tmpfs            49M  4.9M   44M  10% /run
/dev/mmcblk1p1  3.5G  1.6G  1.7G  48% /
tmpfs           244M     0  244M   0% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           244M     0  244M   0% /sys/fs/cgroup
debian@beaglebone:/var/lib/cloud9$ python
Python 2.7.13 (default, Jan 19 2017, 14:48:08)
[GCC 6.3.0 20170118] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Adafruit_BBIO.ADC as ADC
>>> ADC.setup()
>>> ADC.read_raw("AIN0")
3950.0
>>> quit()
debian@beaglebone:/var/lib/cloud9$

Tom

tdlivings

unread,
Sep 2, 2017, 2:12:31 PM9/2/17
to BeagleBoard, tdli...@gmail.com
Robert
Testing update

I made a clean 08-31-2917 sd card image and bootsd it to see if that
worked as well and it worked running python and the ADC test.
I did the test both in cloud9 and ssh into as debian user.
I made none of the fixes from this thread to the image just booted and
tried the ADC test

So 08-31-2017 image works in flash as stated in my previous post and 
from an sd card with a working 0831-2017 image in eMMC.

So I ask did you apply a fix to the 08-31-2017 image such as the udder rule
mentioned here.
Tom
Reply all
Reply to author
Forward
0 new messages