It's Holiday Sale Weekend at Adafruit - use the code ADATY to get 15% off items storewide! Some restrictions apply.
0

Beagle bone: Unable to export UART channel.
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Beagle bone: Unable to export UART channel.

by IMME on Thu Jul 27, 2017 7:12 pm

Hi, using the python IO libraries with the Beagle Bone Debian 4.4 I'm getting an error that I did not get with 3.8.

For this line: UART.setup("UART1")
I'm getting the following error: RuntimeError: Unable to export UART channel.
This is my version: Linux beaglebone 4.4.9-ti-r25 #1 SMP Thu May 5 23:08:13 UTC 2016 armv7l GNU/Linux

The devices are there:
root@beaglebone:~# ls -l /dev/ttyO*
lrwxrwxrwx 1 root root 5 Jul 27 22:55 /dev/ttyO0 -> ttyS0
lrwxrwxrwx 1 root root 5 Jul 27 22:55 /dev/ttyO1 -> ttyS1
lrwxrwxrwx 1 root root 5 Jul 27 22:55 /dev/ttyO2 -> ttyS2

I've added this to /etc/default/capemgr:
CAPE=BB-UART1,BB-UART2
ttyO1 and O2 were always there, when I added this line other ttyO's disapeared!

Does anyone know what I can do to get the UART working in Python?

Thanks

IMME
 
Posts: 11
Joined: Thu Jul 27, 2017 7:01 pm

Re: Beagle bone: Unable to export UART channel.

by drewfustini on Thu Jul 27, 2017 7:28 pm

I'd like to know more about the system software on your beaglebone. Please paste the output of these commands:

uname -a

cat /etc/dogtag

cat /etc/debian_version

cat /sys/devices/platform/bone_capemgr/slots

cat /proc/cmdline

cat /boot/uEnv.txt

drewfustini
 
Posts: 944
Joined: Sat Dec 26, 2015 1:19 pm

Re: Beagle bone: Unable to export UART channel.

by IMME on Fri Jul 28, 2017 2:58 am

drewfustini wrote:I'd like to know more about the system software on your beaglebone. Please paste the output of these commands:

uname -a

cat /etc/dogtag

cat /etc/debian_version

cat /sys/devices/platform/bone_capemgr/slots

cat /proc/cmdline

cat /boot/uEnv.txt



Here you go, thanks

root@beaglebone:~# cat /etc/dogtag
BeagleBoard.org Debian Image 2016-05-13
root@beaglebone:~# cat /etc/debian_version
8.4
root@beaglebone:~# cat /sys/devices/platform/bone_capemgr/slots
0: PF---- -1
1: PF---- -1
2: PF---- -1
3: PF---- -1
4: P-O-L- 0 Override Board Name,00A0,Override Manuf,BB-UART1
5: P-O-L- 1 Override Board Name,00A0,Override Manuf,BB-UART2
root@beaglebone:~# cat /proc/cmdline
console=ttyO0,115200n8 root=UUID=11228b9c-9ccf-42cd-b2ef-939e616db5e6 ro rootfstype=ext4 rootwait coherent_pool=1M quiet cape_universal=enable
root@beaglebone:~# cat /boot/uEnv.txt
#Docs: http://elinux.org/Beagleboard:U-boot_pa ... layout_2.0

uname_r=4.4.9-ti-r25
##uuid=
#dtb=

##BeagleBone Black/Green dtb's for v4.1.x (BeagleBone White just works..)

##BeagleBone Black: HDMI (Audio/Video) disabled:
#dtb=am335x-boneblack-emmc-overlay.dtb

##BeagleBone Black: eMMC disabled:
#dtb=am335x-boneblack-hdmi-overlay.dtb

##BeagleBone Black: HDMI Audio/eMMC disabled:
#dtb=am335x-boneblack-nhdmi-overlay.dtb

##BeagleBone Black: HDMI (Audio/Video)/eMMC disabled:
#dtb=am335x-boneblack-overlay.dtb

##BeagleBone Black: wl1835
#dtb=am335x-boneblack-wl1835mod.dtb

##BeagleBone Green: eMMC disabled
#dtb=am335x-bonegreen-overlay.dtb

cmdline=coherent_pool=1M quiet cape_universal=enable

#In the event of edid real failures, uncomment this next line:
#cmdline=coherent_pool=1M quiet cape_universal=enable video=HDMI-A-1:1024x768@60e

##Example v3.8.x
#cape_disable=capemgr.disable_partno=
#cape_enable=capemgr.enable_partno=

##Example v4.1.x
#cape_disable=bone_capemgr.disable_partno=
#cape_enable=bone_capemgr.enable_partno=

##enable Generic eMMC Flasher:
#cmdline=init=/opt/scripts/tools/eMMC/init-eMMC-flasher-v3.sh

uuid=11228b9c-9ccf-42cd-b2ef-939e616db5e6
root@beaglebone:~#

IMME
 
Posts: 11
Joined: Thu Jul 27, 2017 7:01 pm

Re: Beagle bone: Unable to export UART channel.

by drewfustini on Fri Jul 28, 2017 3:43 am

Instead of loading those UART capes, please try entering these commands and then run your script that uses UART:

config-pin P9_21 uart
config-pin P9_22 uart
config-pin P9_24 uart
config-pin P9_26 uart


To ensure config-pin can control all the pins, please add this to /boot/uEnv.txt so that the cape-universala overlay is loaded at boot:

cape_enable=bone_capemgr.enable_partno=cape-universala

The slots file show contain this after reboot:
debian@beaglebone:~$ cat /sys/devices/platform/bone_capemgr/slots
0: PF---- -1
1: PF---- -1
2: PF---- -1
3: PF---- -1
4: P-O-L- 0 Override Board Name,00A0,Override Manuf,cape-universala


I am able to run this test program:
Code: Select all | TOGGLE FULL SIZE
import Adafruit_BBIO.UART as UART
import serial

UART.setup("UART1")

ser = serial.Serial(port = "/dev/ttyO1", baudrate=9600)
ser.close()
ser.open()
if ser.isOpen():
  print "Serial is open!"
  ser.write("Hello World!")
  ser.close()

UART.cleanup()


Here is the output:
debian@beaglebone:~$ sudo python uart.py
Serial is open!

drewfustini
 
Posts: 944
Joined: Sat Dec 26, 2015 1:19 pm

Re: Beagle bone: Unable to export UART channel.

by IMME on Fri Jul 28, 2017 5:47 pm

drewfustini wrote:Instead of loading those UART capes, please try entering these commands and then run your script that uses UART:

config-pin P9_21 uart
config-pin P9_22 uart
config-pin P9_24 uart
config-pin P9_26 uart


To ensure config-pin can control all the pins, please add this to /boot/uEnv.txt so that the cape-universala overlay is loaded at boot:

cape_enable=bone_capemgr.enable_partno=cape-universala

The slots file show contain this after reboot:
debian@beaglebone:~$ cat /sys/devices/platform/bone_capemgr/slots
0: PF---- -1
1: PF---- -1
2: PF---- -1
3: PF---- -1
4: P-O-L- 0 Override Board Name,00A0,Override Manuf,cape-universala


I am able to run this test program:
Code: Select all | TOGGLE FULL SIZE
import Adafruit_BBIO.UART as UART
import serial

UART.setup("UART1")

ser = serial.Serial(port = "/dev/ttyO1", baudrate=9600)
ser.close()
ser.open()
if ser.isOpen():
  print "Serial is open!"
  ser.write("Hello World!")
  ser.close()

UART.cleanup()


Here is the output:
debian@beaglebone:~$ sudo python uart.py
Serial is open!
drewfustini wrote:Instead of loading those UART capes, please try entering these commands and then run your script that uses UART:

config-pin P9_21 uart
config-pin P9_22 uart
config-pin P9_24 uart
config-pin P9_26 uart


To ensure config-pin can control all the pins, please add this to /boot/uEnv.txt so that the cape-universala overlay is loaded at boot:

cape_enable=bone_capemgr.enable_partno=cape-universala

The slots file show contain this after reboot:
debian@beaglebone:~$ cat /sys/devices/platform/bone_capemgr/slots
0: PF---- -1
1: PF---- -1
2: PF---- -1
3: PF---- -1
4: P-O-L- 0 Override Board Name,00A0,Override Manuf,cape-universala


I am able to run this test program:
Code: Select all | TOGGLE FULL SIZE
import Adafruit_BBIO.UART as UART
import serial

UART.setup("UART1")

ser = serial.Serial(port = "/dev/ttyO1", baudrate=9600)
ser.close()
ser.open()
if ser.isOpen():
  print "Serial is open!"
  ser.write("Hello World!")
  ser.close()

UART.cleanup()


Here is the output:
debian@beaglebone:~$ sudo python uart.py
Serial is open!


Hi Thanks for you help however I still get the error.
You can see the result below, "send_back_vpn_ip.py" is my python code that tries to open the UART:

Any ideas please?

Thanks

Here is the code:


import Adafruit_BBIO.UART as UART
import serial
import netifaces as ni
import os
import time

os.system("ser2net &")
time.sleep(5) # delays for 5 seconds
os.system("wvdial 3gconnect &")

UART.setup("UART1")
ser = serial.Serial(port = "/dev/ttyO1", baudrate=115200)
ser.close()
ser.open()

while True:
try:
line = ser.readline()

if( line == "vpn_ip\n" ):
iflist=ni.interfaces()
if any("ppp1" in s for s in iflist):
ip = ni.ifaddresses('ppp1')[2][0]['addr']
str_back = ip + "\n"

else:
str_back = "ERROR\n"

if ser.isOpen():
ser.write(str_back)

if( line == "ready\n" ):
ser.write("OK\n")
except:
continue

ser.close()

# Eventually, you'll want to clean up, but leave this commented for now,
# as it doesn't work yet
#UART.cleanup()


Here is the result:

root@beaglebone:~#
root@beaglebone:~# ls -l /dev/ttyO*
lrwxrwxrwx 1 root root 5 Jul 28 21:34 /dev/ttyO0 -> ttyS0
lrwxrwxrwx 1 root root 5 Jul 28 21:34 /dev/ttyO1 -> ttyS1
lrwxrwxrwx 1 root root 5 Jul 28 21:34 /dev/ttyO2 -> ttyS2
lrwxrwxrwx 1 root root 5 Jul 28 21:34 /dev/ttyO4 -> ttyS4
lrwxrwxrwx 1 root root 5 Jul 28 21:34 /dev/ttyO5 -> ttyS5
root@beaglebone:~# config-pin P9_24 uart
root@beaglebone:~# config-pin P9_26 uart
root@beaglebone:~# cat /sys/devices/platform/bone_capemgr/slots
0: PF---- -1
1: PF---- -1
2: PF---- -1
3: PF---- -1
4: P-O-L- 0 Override Board Name,00A0,Override Manuf,cape-universala
root@beaglebone:~# sudo python /etc/ppp/ip-up.d/send_back_vpn_ip.py
Traceback (most recent call last):
File "/etc/ppp/ip-up.d/send_back_vpn_ip.py", line 14, in <module>
UART.setup("UART1")
RuntimeError: Unable to export UART channel.
--> WvDial: Internet dialer version 1.61
root@beaglebone:~# --> Initializing modem.
--> Sending: ATZ
ATZ
OK
--> Sending: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
OK
--> Sending: at+cgdcont=1,"ip","open.internet"
at+cgdcont=1,"ip","open.internet"
OK
--> Modem initialized.
--> Sending: ATDT*99#
--> Waiting for carrier.
ATDT*99#
CONNECT
--> Carrier detected. Starting PPP immediately.
--> Starting pppd at Fri Jul 28 21:37:09 2017
--> Pid of pppd: 1623
--> Using interface ppp0
--> pppd: 8I▒
--> pppd: 8I▒
--> pppd: 8I▒
--> local IP address 100.81.69.202
--> pppd: 8I▒
--> remote IP address 100.81.69.202
--> pppd: 8I▒
--> primary DNS address 83.136.46.138
--> pppd: 8I▒
--> secondary DNS address 62.40.32.33
--> pppd: 8I▒

IMME
 
Posts: 11
Joined: Thu Jul 27, 2017 7:01 pm

Re: Beagle bone: Unable to export UART channel.

by drewfustini on Fri Jul 28, 2017 11:19 pm

I'd like to understand better what is happening while your program is running. Please run strace to generate a lot of system calls:

sudo strace -f -o strace.log python send_back_vpn_ip.py

Then please paste the log file into a gist or attach it as a file to your post here.

drewfustini
 
Posts: 944
Joined: Sat Dec 26, 2015 1:19 pm

Re: Beagle bone: Unable to export UART channel.

by IMME on Sat Jul 29, 2017 9:27 am

strace.zip
strace log
(95.61 KiB) Downloaded 41 times
drewfustini wrote:I'd like to understand better what is happening while your program is running. Please run strace to generate a lot of system calls:

sudo strace -f -o strace.log python send_back_vpn_ip.py

Then please paste the log file into a gist or attach it as a file to your post here.


Thanks so much.

Here you go.

Ian

IMME
 
Posts: 11
Joined: Thu Jul 27, 2017 7:01 pm

Re: Beagle bone: Unable to export UART channel.

by IMME on Tue Aug 01, 2017 7:33 am

drewfustini wrote:I'd like to understand better what is happening while your program is running. Please run strace to generate a lot of system calls:

sudo strace -f -o strace.log python send_back_vpn_ip.py

Then please paste the log file into a gist or attach it as a file to your post here.


Hi, did you manage to have a look at my issue?

thanks Ian

IMME
 
Posts: 11
Joined: Thu Jul 27, 2017 7:01 pm

Re: Beagle bone: Unable to export UART channel.

by drewfustini on Tue Aug 01, 2017 5:42 pm

Hi, I've reviewed the strace log and the network related activity is making it difficult to determine what system calls are relevant to the UART serial port.

Could you please run strace with this simple test program?
Code: Select all | TOGGLE FULL SIZE
import Adafruit_BBIO.UART as UART
import serial

UART.setup("UART1")

ser = serial.Serial(port = "/dev/ttyO1", baudrate=9600)
ser.close()
ser.open()
if ser.isOpen():
  print "Serial is open!"
  ser.write("Hello World!")
  ser.close()

UART.cleanup()

drewfustini
 
Posts: 944
Joined: Sat Dec 26, 2015 1:19 pm

Re: Beagle bone: Unable to export UART channel.

by IMME on Tue Aug 01, 2017 6:21 pm

drewfustini wrote:Hi, I've reviewed the strace log and the network related activity is making it difficult to determine what system calls are relevant to the UART serial port.

Could you please run strace with this simple test program?
Code: Select all | TOGGLE FULL SIZE
import Adafruit_BBIO.UART as UART
import serial

UART.setup("UART1")

ser = serial.Serial(port = "/dev/ttyO1", baudrate=9600)
ser.close()
ser.open()
if ser.isOpen():
  print "Serial is open!"
  ser.write("Hello World!")
  ser.close()

UART.cleanup()


Hi Here you go.

Thanks Ian
Attachments
strace.log
(275.39 KiB) Downloaded 74 times

IMME
 
Posts: 11
Joined: Thu Jul 27, 2017 7:01 pm

Re: Beagle bone: Unable to export UART channel.

by IMME on Thu Aug 03, 2017 3:38 am

drewfustini wrote:Hi, I've reviewed the strace log and the network related activity is making it difficult to determine what system calls are relevant to the UART serial port.

Could you please run strace with this simple test program?
Code: Select all | TOGGLE FULL SIZE
import Adafruit_BBIO.UART as UART
import serial

UART.setup("UART1")

ser = serial.Serial(port = "/dev/ttyO1", baudrate=9600)
ser.close()
ser.open()
if ser.isOpen():
  print "Serial is open!"
  ser.write("Hello World!")
  ser.close()

UART.cleanup()


Hi Sorry for hassling you but did you manage to find anything?
Thanks,

Ian

IMME
 
Posts: 11
Joined: Thu Jul 27, 2017 7:01 pm

Re: Beagle bone: Unable to export UART channel.

by drewfustini on Thu Aug 03, 2017 3:43 am

Looking in the strace output I noticed:
14949 openat(AT_FDCWD, "/sys/devices", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 3
14949 getdents64(3, /* 10 entries */, 32768) = 304
14949 getdents64(3, /* 0 entries */, 32768) = 0
14949 close(3) = 0
14949 open("/slots", O_RDWR|O_LARGEFILE) = -1 ENOENT (No such file or directory)


It appears to fail to open the slots file. It also seems like the path is incorrect which is odd to mean.

Please run this command and paste the output:
find /usr/local/lib/ |grep Adafruit_BBIO


Also, please try installing Adafruit_BBIO from the GitHub repo and run the test script again:
https://github.com/adafruit/adafruit-beaglebone-io-python

drewfustini
 
Posts: 944
Joined: Sat Dec 26, 2015 1:19 pm

Re: Beagle bone: Unable to export UART channel.

by IMME on Thu Aug 03, 2017 5:13 am

drewfustini wrote:Looking in the strace output I noticed:
14949 openat(AT_FDCWD, "/sys/devices", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 3
14949 getdents64(3, /* 10 entries */, 32768) = 304
14949 getdents64(3, /* 0 entries */, 32768) = 0
14949 close(3) = 0
14949 open("/slots", O_RDWR|O_LARGEFILE) = -1 ENOENT (No such file or directory)


It appears to fail to open the slots file. It also seems like the path is incorrect which is odd to mean.

Please run this command and paste the output:
find /usr/local/lib/ |grep Adafruit_BBIO


Also, please try installing Adafruit_BBIO from the GitHub repo and run the test script again:
https://github.com/adafruit/adafruit-beaglebone-io-python


Thanks for that, this is what we get:
find /usr/local/lib/ |grep Adafruit_BBIO
/usr/local/lib/python2.7/dist-packages/Adafruit_BBIO-0.0.30-py2.7-linux-armv7l.egg

I've downloaded from GIT but I'm not sure how to re-install a python driver?
How should I go about this?

Thanks

Ian

IMME
 
Posts: 11
Joined: Thu Jul 27, 2017 7:01 pm

Re: Beagle bone: Unable to export UART channel.

by drewfustini on Thu Aug 03, 2017 5:33 am

Ah, ok, that is an old version of Adafruit_BBIO that doesn't support 4.x kernels.

Here is how to install from GitHub:


sudo apt-get update

sudo apt-get install build-essential python-dev python-pip -y

git clone git://github.com/adafruit/adafruit-beag ... python.git

cd adafruit-beaglebone-io-python

sudo python setup.py install

cd ..

sudo rm -rf adafruit-beaglebone-io-python

drewfustini
 
Posts: 944
Joined: Sat Dec 26, 2015 1:19 pm

Re: Beagle bone: Unable to export UART channel.

by IMME on Thu Aug 03, 2017 6:07 am

drewfustini wrote:Ah, ok, that is an old version of Adafruit_BBIO that doesn't support 4.x kernels.

Here is how to install from GitHub:


sudo apt-get update

sudo apt-get install build-essential python-dev python-pip -y

git clone git://github.com/adafruit/adafruit-beag ... python.git

cd adafruit-beaglebone-io-python

sudo python setup.py install

cd ..

sudo rm -rf adafruit-beaglebone-io-python


OK some progress, it is no longer erroring out, however there is nothing from the UART.
We get the error: slot #5 Failed verification


Any ideas? Thanks

IMME
 
Posts: 11
Joined: Thu Jul 27, 2017 7:01 pm

Please be positive and constructive with your questions and comments.