accessing pin p8_14

93 views
Skip to first unread message

Mark Copper

unread,
Apr 9, 2020, 3:58:51 PM4/9/20
to BeagleBoard
I have code that wants to write a Boolean value to this file on the Beaglebone:
   /sys/class/gpio/gpio26/value
but there is no directory "gpio26" on this Beaglebone. 

This code appears to have functioned in 2011 or so until some time 2013 and accessed P8 pin 14.

What changed?

Thank you.

----

uname -a: Linux beaglebone 4.19.94-ti-r42 #1buster SMP PREEMPT Tue Mar 31 19:38:29 UTC 2020 armv7l GNU/Linux

Robert Nelson

unread,
Apr 9, 2020, 4:11:34 PM4/9/20
to Beagle Board, mlco...@gmail.com
On Thu, Apr 9, 2020 at 2:59 PM Mark Copper <mlco...@gmail.com> wrote:
>
> I have code that wants to write a Boolean value to this file on the Beaglebone:
> /sys/class/gpio/gpio26/value
> but there is no directory "gpio26" on this Beaglebone.
>
> This code appears to have functioned in 2011 or so until some time 2013 and accessed P8 pin 14.
>
> What changed?

Run:

sudo /opt/scripts/tools/version.sh

So we can see what failed..

Regards,

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

jonnymo

unread,
Apr 9, 2020, 4:23:34 PM4/9/20
to Beagle Board, mlco...@gmail.com
Was the following already run or is the expectation that this is already enabled via an overlay or something?

  echo 26 > /sys/class/gpio/export

Cheers,

Jon

--
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/CAOCHtYjnfhcPbvM%2Bwg-kHGiALxB8mo3mugTujS-zunZRDqnoAQ%40mail.gmail.com.

Mark Copper

unread,
Apr 9, 2020, 4:59:17 PM4/9/20
to BeagleBoard
I'm uneasy about this. I don't know device tree basics. But thanks for responding. I am attaching the output of version.sh
opt_scripts_tools_version

Robert Nelson

unread,
Apr 9, 2020, 5:10:02 PM4/9/20
to Beagle Board, mlco...@gmail.com
On Thu, Apr 9, 2020 at 3:59 PM Mark Copper <mlco...@gmail.com> wrote:
>
> I'm uneasy about this. I don't know device tree basics. But thanks for responding. I am attaching the output of version.sh

Thanks for the report.. Sadly that didn't detect anything 'wrong'..

eeprom:[A335BNLTAIA05016BBBI4952]
model:[TI_AM335x_BeagleBone_Black]
dogtag:[BeagleBoard.org Debian Buster IoT Image 2020-04-06]
bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot
2019.04-00002-g07d5700e21]:[location: dd MBR]
UBOOT: Booted Device-Tree:[am335x-boneblack-uboot-univ.dts]
UBOOT: Loaded Overlay:[AM335X-PRU-RPROC-4-19-TI-00A0]
UBOOT: Loaded Overlay:[BB-ADC-00A0]
UBOOT: Loaded Overlay:[BB-BONE-eMMC1-01-00A0]
kernel:[4.19.94-ti-r42]

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

So what i'd expect to see would be:

debian@bbb-pwr03-ser11:/sys/class/gpio$ ls
export gpio117 gpio26 gpio37 gpio5 gpio68 gpio77 gpio9
gpio10 gpio12 gpio27 gpio38 gpio50 gpio69 gpio78 gpiochip0
gpio11 gpio13 gpio3 gpio39 gpio51 gpio7 gpio79 gpiochip32
gpio110 gpio14 gpio30 gpio4 gpio60 gpio70 gpio8 gpiochip64
gpio111 gpio15 gpio31 gpio44 gpio61 gpio71 gpio80 gpiochip96
gpio112 gpio19 gpio32 gpio45 gpio62 gpio72 gpio81 unexport
gpio113 gpio2 gpio33 gpio46 gpio63 gpio73 gpio86
gpio114 gpio20 gpio34 gpio47 gpio65 gpio74 gpio87
gpio115 gpio22 gpio35 gpio48 gpio66 gpio75 gpio88
gpio116 gpio23 gpio36 gpio49 gpio67 gpio76 gpio89
debian@bbb-pwr03-ser11:/sys/class/gpio$

Do any gpio directories show up?

Robert Nelson

unread,
Apr 9, 2020, 5:18:08 PM4/9/20
to Beagle Board, mlco...@gmail.com
On Thu, Apr 9, 2020 at 4:09 PM Robert Nelson <robert...@gmail.com> wrote:
>
> On Thu, Apr 9, 2020 at 3:59 PM Mark Copper <mlco...@gmail.com> wrote:
> >
> > I'm uneasy about this. I don't know device tree basics. But thanks for responding. I am attaching the output of version.sh
>
> Thanks for the report.. Sadly that didn't detect anything 'wrong'..
>
> eeprom:[A335BNLTAIA05016BBBI4952]

Side note, "AIA0" decodes to the "Arrow BeagleBone Black Industrial",
my version of that board is an hour away.. Unfortunately, due to world
event's i'm working from home, so till things change. i can't locally
debug..

Mark Copper

unread,
Apr 9, 2020, 5:41:29 PM4/9/20
to BeagleBoard


So what i'd expect to see would be:

debian@bbb-pwr03-ser11:/sys/class/gpio$ ls
export   gpio117  gpio26  gpio37  gpio5   gpio68  gpio77  gpio9
gpio10   gpio12   gpio27  gpio38  gpio50  gpio69  gpio78  gpiochip0
gpio11   gpio13   gpio3   gpio39  gpio51  gpio7   gpio79  gpiochip32
gpio110  gpio14   gpio30  gpio4   gpio60  gpio70  gpio8   gpiochip64
gpio111  gpio15   gpio31  gpio44  gpio61  gpio71  gpio80  gpiochip96
gpio112  gpio19   gpio32  gpio45  gpio62  gpio72  gpio81  unexport
gpio113  gpio2    gpio33  gpio46  gpio63  gpio73  gpio86
gpio114  gpio20   gpio34  gpio47  gpio65  gpio74  gpio87
gpio115  gpio22   gpio35  gpio48  gpio66  gpio75  gpio88
gpio116  gpio23   gpio36  gpio49  gpio67  gpio76  gpio89
debian@bbb-pwr03-ser11:/sys/class/gpio$

Do any gpio directories show up?

 
Yes, but 5 fewer, gpio26 included:

 debian@beaglebone:~$ ls /sys/class/gpio/
export   gpio112  gpio117  gpio19  gpio27  gpio33  gpio45  gpio5   gpio62  gpio68  gpio72  gpio77  gpio81  gpio9       unexport
gpio10   gpio113  gpio12   gpio2   gpio3   gpio35  gpio46  gpio50  gpio63  gpio69  gpio73  gpio78  gpio86  gpiochip0
gpio11   gpio114  gpio13   gpio20  gpio30  gpio36  gpio47  gpio51  gpio65  gpio7   gpio74  gpio79  gpio87  gpiochip32
gpio110  gpio115  gpio14   gpio22  gpio31  gpio37  gpio48  gpio60  gpio66  gpio70  gpio75  gpio8   gpio88  gpiochip64
gpio111  gpio116  gpio15   gpio23  gpio32  gpio4   gpio49  gpio61  gpio67  gpio71  gpio76  gpio80  gpio89  gpiochip96

There is much for me to study here at home. :) 


Robert Nelson

unread,
Apr 9, 2020, 5:56:57 PM4/9/20
to Beagle Board, mlco...@gmail.com
> Yes, but 5 fewer, gpio26 included:
>
> debian@beaglebone:~$ ls /sys/class/gpio/
> export gpio112 gpio117 gpio19 gpio27 gpio33 gpio45 gpio5 gpio62 gpio68 gpio72 gpio77 gpio81 gpio9 unexport
> gpio10 gpio113 gpio12 gpio2 gpio3 gpio35 gpio46 gpio50 gpio63 gpio69 gpio73 gpio78 gpio86 gpiochip0
> gpio11 gpio114 gpio13 gpio20 gpio30 gpio36 gpio47 gpio51 gpio65 gpio7 gpio74 gpio79 gpio87 gpiochip32
> gpio110 gpio115 gpio14 gpio22 gpio31 gpio37 gpio48 gpio60 gpio66 gpio70 gpio75 gpio8 gpio88 gpiochip64
> gpio111 gpio116 gpio15 gpio23 gpio32 gpio4 gpio49 gpio61 gpio67 gpio71 gpio76 gpio80 gpio89 gpiochip96
>
> There is much for me to study here at home. :)

That makes it even more confusing.. i was expecting '2' gpio nodes as
that is usually the issue, but most of them show up..???...

Do you happen to have a usb-serial adapter to plug into j1?

https://elinux.org/Beagleboard:BeagleBone_Black_Serial

I'd like to see what u-boot does on startup..

I'm most interested in this section:

***********************************************
U-Boot 2019.04-00002-g07d5700e21 (Mar 06 2020 - 11:24:55 -0600),
Build: jenkins-github_Bootloader-Builder-137

CPU : AM335X-GP rev 2.1
I2C: ready
DRAM: 512 MiB
No match for driver 'omap_hsmmc'
No match for driver 'omap_hsmmc'
Some drivers were not found
Reset Source: Global warm SW reset has occurred.
Reset Source: Power-on reset has occurred.
RTC 32KCLK Source: External.
MMC: OMAP SD/MMC: 0, OMAP SD/MMC: 1
Loading Environment from EXT4... ** File not found /boot/uboot.env **

** Unable to read "/boot/uboot.env" from mmc0:1 **
Board: BeagleBone Black
<ethaddr> not set. Validating first E-fuse MAC
BeagleBone Black:
Model: SeeedStudio BeagleBone Green:
BeagleBone: cape eeprom: i2c_probe: 0x54:
BeagleBone: cape eeprom: i2c_probe: 0x55:
BeagleBone: cape eeprom: i2c_probe: 0x56:
BeagleBone: found invalid cape eeprom: i2c_probe: 0x57:
Net: eth0: MII MODE
cpsw, usb_ether
Press SPACE to abort autoboot in 0 seconds
board_name=[BBG1] ...
switch to partitions #0, OK
mmc0 is current device
SD/MMC found on device 0
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
gpio: pin 56 (gpio 56) value is 0
gpio: pin 55 (gpio 55) value is 0
gpio: pin 54 (gpio 54) value is 0
gpio: pin 53 (gpio 53) value is 1
switch to partitions #0, OK
mmc0 is current device
gpio: pin 54 (gpio 54) value is 1
Checking for: /uEnv.txt ...
Checking for: /boot.scr ...
Checking for: /boot/boot.scr ...
Checking for: /boot/uEnv.txt ...
gpio: pin 55 (gpio 55) value is 1
2055 bytes read in 40 ms (49.8 KiB/s)
Loaded environment from /boot/uEnv.txt
Checking if uname_r is set in /boot/uEnv.txt...
gpio: pin 56 (gpio 56) value is 1
Running uname_boot ...
loading /boot/vmlinuz-4.14.108-ti-r131 ...
9654768 bytes read in 648 ms (14.2 MiB/s)
debug: [enable_uboot_overlays=1] ...
debug: [enable_uboot_cape_universal=1] ...
debug: [uboot_base_dtb_univ=am335x-boneblack-uboot-univ.dtb] ...
uboot_overlays: [uboot_base_dtb=am335x-boneblack-uboot-univ.dtb] ...
uboot_overlays: Switching too: dtb=am335x-boneblack-uboot-univ.dtb ...
loading /boot/dtbs/4.14.108-ti-r131/am335x-boneblack-uboot-univ.dtb ...
162971 bytes read in 118 ms (1.3 MiB/s)
uboot_overlays: [fdt_buffer=0x60000] ...
uboot_overlays: loading /lib/firmware/M-BB-BBG-00A0.dtbo ...
423 bytes read in 404 ms (1000 Bytes/s)
uboot_overlays: loading /lib/firmware/BB-ADC-00A0.dtbo ...
867 bytes read in 487 ms (1000 Bytes/s)
uboot_overlays: uboot loading of
[/lib/firmware/BB-BONE-eMMC1-01-00A0.dtbo] disabled by /boot/uEnv.txt
[disable_uboot_overlay_emmc=1]...
uboot_overlays: loading /lib/firmware/AM335X-PRU-RPROC-4-14-TI-00A0.dtbo ...
3811 bytes read in 105 ms (35.2 KiB/s)
loading /boot/initrd.img-4.14.108-ti-r131 ...
3299068 bytes read in 244 ms (12.9 MiB/s)
debug: [console=ttyO0,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] ...
debug: [bootz 0x82000000 0x88080000:3256fc 88000000] ...
## Flattened Device Tree blob at 88000000
Booting using the fdt blob at 0x88000000
Loading Ramdisk to 8fcda000, end 8ffff6fc ... OK
Loading Device Tree to 8fc4f000, end 8fcd9fff ... OK

Starting kernel ...

[ 0.000000] Booting Linux on physical CPU 0x0

***********************************************

Mark Copper

unread,
Apr 9, 2020, 6:17:35 PM4/9/20
to BeagleBoard


On Thursday, April 9, 2020 at 4:56:57 PM UTC-5, RobertCNelson wrote:
> Yes, but 5 fewer, gpio26 included:
>
>  debian@beaglebone:~$ ls /sys/class/gpio/
> export   gpio112  gpio117  gpio19  gpio27  gpio33  gpio45  gpio5   gpio62  gpio68  gpio72  gpio77  gpio81  gpio9       unexport
> gpio10   gpio113  gpio12   gpio2   gpio3   gpio35  gpio46  gpio50  gpio63  gpio69  gpio73  gpio78  gpio86  gpiochip0
> gpio11   gpio114  gpio13   gpio20  gpio30  gpio36  gpio47  gpio51  gpio65  gpio7   gpio74  gpio79  gpio87  gpiochip32
> gpio110  gpio115  gpio14   gpio22  gpio31  gpio37  gpio48  gpio60  gpio66  gpio70  gpio75  gpio8   gpio88  gpiochip64
> gpio111  gpio116  gpio15   gpio23  gpio32  gpio4   gpio49  gpio61  gpio67  gpio71  gpio76  gpio80  gpio89  gpiochip96
>
> There is much for me to study here at home. :)

That makes it even more confusing.. i was expecting '2' gpio nodes as
that is usually the issue, but most of them show up..???...

Do you happen to have a usb-serial adapter to plug into j1?

https://elinux.org/Beagleboard:BeagleBone_Black_Serial

I'd like to see what u-boot does on startup..


Yes, I do. Yes, I'll run it. Only I have it at our warehouse. I've been lazy to go get it but now I will. (after a hamburger). 

Thank you. 

Mark Copper

unread,
Apr 13, 2020, 12:38:57 PM4/13/20
to BeagleBoard
Argh! I must confess that shot myself in the foot.

Starting with a clean reboot, GPIO devices are all existent as they should be:

debian@beaglebone:~/stepper/beaglebone$ ls /sys/class/gpio/
export   gpio112  gpio117  gpio19  gpio26  gpio32  gpio37  gpio45  gpio5   gpio62  gpio68  gpio72  gpio77  gpio81  gpio9       unexport
gpio10   gpio113  gpio12   gpio2   gpio27  gpio33  gpio38  gpio46  gpio50  gpio63  gpio69  gpio73  gpio78  gpio86  gpiochip0
gpio11   gpio114  gpio13   gpio20  gpio3   gpio34  gpio39  gpio47  gpio51  gpio65  gpio7   gpio74  gpio79  gpio87  gpiochip32
gpio110  gpio115  gpio14   gpio22  gpio30  gpio35  gpio4   gpio48  gpio60  gpio66  gpio70  gpio75  gpio8   gpio88  gpiochip64
gpio111  gpio116  gpio15   gpio23  gpio31  gpio36  gpio44  gpio49  gpio61  gpio67  gpio71  gpio76  gpio80  gpio89  gpiochip96

Then I ran this snippet of code:

#define SYSFS_GPIO_DIR "/sys/class/gpio"
#define MAX_BUF 64

int gpio_export(unsigned int gpio)
{
        int fd, len;
        char buf[MAX_BUF];

        fd = open(SYSFS_GPIO_DIR "/export", O_WRONLY);
        if (fd < 0) {
                perror("gpio/export");
                return fd;
        }

        len = snprintf(buf, sizeof(buf), "%d", gpio);
        write(fd, buf, len);
        close(fd);

        return 0;
}

int main(int argc, char *argv[]){

        gpio_export(26);

        return 0;
}

and *poof* gpio26 disappears:

debian@beaglebone:~/stepper/beaglebone$ ls /sys/class/gpio/
export   gpio112  gpio117  gpio19  gpio27  gpio33  gpio38  gpio46  gpio50  gpio63  gpio69  gpio73  gpio78  gpio86  gpiochip0
gpio10   gpio113  gpio12   gpio2   gpio3   gpio34  gpio39  gpio47  gpio51  gpio65  gpio7   gpio74  gpio79  gpio87  gpiochip32
gpio11   gpio114  gpio13   gpio20  gpio30  gpio35  gpio4   gpio48  gpio60  gpio66  gpio70  gpio75  gpio8   gpio88  gpiochip64
gpio110  gpio115  gpio14   gpio22  gpio31  gpio36  gpio44  gpio49  gpio61  gpio67  gpio71  gpio76  gpio80  gpio89  gpiochip96
gpio111  gpio116  gpio15   gpio23  gpio32  gpio37  gpio45  gpio5   gpio62  gpio68  gpio72  gpio77  gpio81  gpio9   unexport

Sorry for the distraction.
Reply all
Reply to author
Forward
0 new messages