Adafruit Industries, Essential service and business: NYC – Executive Order 202.6 - Read more. Accepting essential orders - here's how.
0

Adafruit_BBIO problems
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: Adafruit_BBIO problems

by silver2row on Sun Sep 30, 2018 7:25 pm

Hello,

To get help on this matter, if you are willing, you will have to divulge all the info. you have currently in your possession. Things have changed, i.e. this is a fact. I think that someone else w/ much more info. can help you. I thought trying my last idea could return a result that differed from what you are describing.

Seth

P.S. Although it seems very difficult, I say it is easier but memory must serve us well on the newer images w/ config-pin, e.g. esp. if it is not pre-configured to run on boot. Did you ever try: sudo config-pin P9.19 uart or sudo config-pin P9.20 uart? There should have been a couple of errors.

silver2row
 
Posts: 177
Joined: Sat Jan 30, 2016 3:42 pm

Re: Adafruit_BBIO problems

by denys on Sun Sep 30, 2018 11:16 pm

Ah.
The previous post of mine, with the code not working again, it had to be run sudo.
Working as before now.

As for divulging all the info Seth, I thought I had.

The reality is my questions have not really been answered. My original post was asking why the code no longer worked. And the instructions to update to the latest kernel only made it worse.
I'm going to make a new SD card with the oldest kernel, then it will all work again.
Thanks for the help just the same :)

denys
 
Posts: 50
Joined: Fri Aug 10, 2018 1:08 am

Re: Adafruit_BBIO problems

by drewfustini on Tue Oct 02, 2018 12:06 am

denys wrote:Hi again Seth.
I have another BBB and it is running Angstrom. My son got it going with his updated code on the old kernel.
I could not as apt-get did not work, but he showed me the opkg installing.
It does look like my main problem started with updating to the latest kernel.

Adafruit_BBIO no longer supports Angstrom. I would recommend that you use the latest BeagleBoard.org Debian image.

denys wrote:Still, the other BBB is running the latest kernel, and all is running except the PWM.
EDIT:
The newest kernel BBB now will not restart the code after running until the ssh connection was lost when my mac went to sleep.
This is what comes up now...
Code: Select all | TOGGLE FULL SIZE
debian@beaglebone:~$ python -u OMCB_IO_9A_works.py
Traceback (most recent call last):
  File "OMCB_IO_9A_works.py", line 9, in <module>
    ADC.setup()
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
debian@beaglebone:~$


Whatever has been done in the new kernel sure makes the BBB a lot harder to use!

It is very import to run this command and paste the output in the reply:
sudo /opt/scripts/tools/version.sh

This script will output the versions of software running on your BeagleBone including the version of the u-boot bootloader. Older versions of u-boot booloader on the eMMC can cause issues with ability to use peripherals like PWM and ADC.

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

Re: Adafruit_BBIO problems

by denys on Tue Oct 02, 2018 1:42 am

Hi again Drew.
Here is the result...
Code: Select all | TOGGLE FULL SIZE
debian@beaglebone:~$ sudo /opt/scripts/tools/version.sh
[sudo] password for debian:
git:/opt/scripts/:[31292bce1d4b35b497cc7a013d6d57e7e1f4f5c4]
eeprom:[A335BNLT00C01618BBBK19BD]
model:[TI_AM335x_BeagleBone_Black]
dogtag:[BeagleBoard.org Debian Image 2018-06-17]
bootloader:[microSD-(push-button)]:[/dev/mmcblk0]:[U-Boot 2018.03-00002-gac9cce7c6a]:[location: dd MBR]
bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot 2016.01-00001-g4eb802e]:[location: dd MBR]
kernel:[4.14.49-ti-r54]
nodejs:[v6.14.3]
uboot_overlay_options:[enable_uboot_overlays=1]
uboot_overlay_options:[uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-14-TI-00A0.dtbo]
uboot_overlay_options:[enable_uboot_cape_universal=1]
pkg check: to individually upgrade run: [sudo apt install --only-upgrade <pkg>]
pkg:[bb-cape-overlays]:[4.4.20180928.0-0rcnee0~stretch+20180928]
pkg:[bb-wl18xx-firmware]:[1.20180517-0rcnee0~stretch+20180517]
pkg:[kmod]:[23-2rcnee1~stretch+20171005]
pkg:[roboticscape]:[0.4.4-git20180608.0-0rcnee0~stretch+20180609]
pkg:[firmware-ti-connectivity]:[20170823-1rcnee1~stretch+20180328]
groups:[debian : debian adm kmem dialout cdrom floppy audio dip video plugdev users systemd-journal i2c bluetooth netdev cloud9ide gpio pwm eqep admin spi tisdk weston-launch xenomai]
cmdline:[console=ttyO0,115200n8 root=/dev/mmcblk0p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 quiet]
dmesg | grep pinctrl-single
[    1.062037] pinctrl-single 44e10800.pinmux: 142 pins at pa f9e10800 size 568
dmesg | grep gpio-of-helper
[    1.063214] gpio-of-helper ocp:cape-universal: ready
END



And, after powering it down, the code no longer runs....

Code: Select all | TOGGLE FULL SIZE
debian@beaglebone:~$ python -u OMCB_IO_9A_works.py
Traceback (most recent call last):
  File "OMCB_IO_9A_works.py", line 9, in <module>
    ADC.setup()
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
debian@beaglebone:~$

Denys.

denys
 
Posts: 50
Joined: Fri Aug 10, 2018 1:08 am

Re: Adafruit_BBIO problems

by drewfustini on Wed Oct 03, 2018 2:36 am

denys wrote:Hi again Drew.
Here is the result...
Code: Select all | TOGGLE FULL SIZE
bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot 2016.01-00001-g4eb802e]:[location: dd MBR]


This version is u-boot bootloader on the eMMC is too old.

Please run this command on your BeagleBone to disable the old version of the u-boot bootloader on the eMMC:
sudo dd if=/dev/zero of=/dev/mmcblk1 bs=1M count=10

This will cause the newer u-boot bootloader on the SD card to be used.

denys wrote:And, after powering it down, the code no longer runs....

Code: Select all | TOGGLE FULL SIZE
debian@beaglebone:~$ python -u OMCB_IO_9A_works.py
Traceback (most recent call last):
  File "OMCB_IO_9A_works.py", line 9, in <module>
    ADC.setup()
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
debian@beaglebone:~$

Denys.


Please paste the contents of OMCB_IO_9A_works.py so that I can try to run it.

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

Re: Adafruit_BBIO problems

by denys on Wed Oct 03, 2018 3:14 am

Thanks Drew :)
that " sudo dd if=/dev/zero of=/dev/mmcblk1 bs=1M count=10" made the code run again.

Here is the code my son got going, all but the PWM.

Code: Select all | TOGGLE FULL SIZE
# run as unbuffered...
# python -u OMCB_IO_9A_works.py
# same as version 5 but much longer loop.
# also added counter reset to each loop so I can see the FET switching.
# try to read input and compare it to expected result.
# add error counter

import Adafruit_BBIO.ADC as ADC
ADC.setup()
import Adafruit_BBIO.PWM as PWM
import time
import smbus
import Adafruit_GPIO.I2C as I2C

i2c_bus_number = 2
mcp_address = 0x27

mcp = I2C.Device(mcp_address, i2c_bus_number)

iodira = 0x00
iodirb = 0x10
gpioa = 0x09
gpiob = 0x19
gppua = 0x06
gppub = 0x16
olata = 0x0a

mcp.write8(iodira,0x3f) # 8-13 inputs, 14 & 15 outputs
mcp.write8(iodirb,0xff) # 0-7 inputs
mcp.write8(gpioa,0x3f)  # 8-13 high, 14 & 15 low
mcp.write8(gpiob,0xff)  # 0-7 high
mcp.write8(gppua,0x3f)  # pullups 8-13
mcp.write8(gppub,0xff)  # pullups 0-7

mcp.write8(olata,0)      # both FETs off
mcp.write8(olata,64)    # FET2 on = reset counter
time.sleep(.01)
mcp.write8(olata,0)      # both FETs off

test_pwm = False # flag to enable/disable PWM so the rest of the code can run.

# enable PWM but with motor off.
#optionally, you can set the frequency as well as the polarity from their defaults:
if test_pwm:
    PWM.start("P9_14", 0, 2000, 1)
    PWM.start("P9_16", 0, 2000, 1)

error_count = 0
for j in range(1000000):  # a loop sounter
       if (j&31) == 0:       # wink the reset?
          mcp.write8(olata,64)    # FET2 on = reset counter
          time.sleep(.01)
          mcp.write8(olata,0)    # both FETs off.
          Expected = 0x3ffe     # expected read back of inputs.


       print('\r'),

       PA = (mcp.readU8(gpioa))
       PB = (mcp.readU8(gpiob))
       PX = PB + (PA * 256)
       if (PX == Expected):

        print("PortA="),
        print'{:06b}'.format (PA),  # print PortA inputs
        print("  PortB="),
        print'{:08b}'.format (PB),  # printb PortB inputs

        print("  Anl1="),
        print'{:4.2f}'.format (23.8*(ADC.read("AIN0"))),    #print Analog 1 input
        print("  Anl2="),
        print'{:4.2f}'.format (23.8*(ADC.read("AIN1"))),    #print Analog 2 input
        print("  Supply="),
        print'{:2.2f}'.format (35.9*(ADC.read("AIN2"))),    #print Volts
        print("V "),
        print("  Motor_I="),
        print'{:4.2f}'.format (3.125*(ADC.read("AIN3"))), #print AUX cutrrent
       else:
          error_count = error_count + 1
          print
          print("Expected="),
          print'{:14b}'.format (Expected),
          print("  Read="),
          print'{:14b}'.format (PX),
          print(" Errors="),
          print error_count

       # ramp the AUX PWM up and down, switching the o/p FETS as indicators.
       if (j&192) == 0:
          if test_pwm:
             PWM.start("P9_14",((j&63)*1.56),2000,1)  # Motor fwd, ramp up
             PWM.start("P9_16",0,2000,1)
             if (j&192) == 64:        # FET1 on
                PWM.start("P9_14",((63-(j&63))*1.56),2000,1) #Motor fwd, ramp down
                PWM.start("P9_16",0,2000,1)
             if (j&192) == 128:    # FET2 on
                PWM.start("P9_14",0,2000,1)   # Motor rev, ramp up
                PWM.start("P9_16",((j&63)*1.56),2000,1)
             if (j&192) == 192:
                PWM.start("P9_14",0,2000,1)   # Motor rewv, ramp down.
                PWM.start("P9_16",((63-(j&63))*1.56),2000,1)

          if (j&1) == 1:         # inc input sounter every 2 loops
             mcp.write8(olata,128)    # FET1 on = pulse the counter
             time.sleep(.01)
             mcp.write8(olata,0)    # both FETs off
             Expected = (((Expected * 2) +1)& 0x3fff)
          time.sleep(.1)

if test_pwm:
    PWM.stop("P9_14")   # PWM off.
    PWM.stop("P9_16")


OOPS!
It was going. But after powering it off and on again,
Code: Select all | TOGGLE FULL SIZE
debian@beaglebone:~$ sudo python -u OMCB_IO_9A_works.py
Traceback (most recent call last):
  File "OMCB_IO_9A_works.py", line 9, in <module>
    ADC.setup()
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
debian@beaglebone:~$


I don't know why it worked first time tonight then failed yet again.

denys
 
Posts: 50
Joined: Fri Aug 10, 2018 1:08 am

Re: Adafruit_BBIO problems

by drewfustini on Fri Oct 12, 2018 6:37 am

Also, it would be helpful if you could run strace so that I can better understand what is happening.

Install strace (if it doesn't already exist):
sudo apt-get install strace

Then run strace with python, replace test.py with the name of your test program:
strace -f -o strace.log python test.py

Paste the contents of strace.log into a separate GitHub Gist and post the link in a reply here.

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

Re: Adafruit_BBIO problems

by denys on Tue Nov 20, 2018 9:35 pm

Thanks for the attempted help.
A work around that I'm now using is my board is being driven by an Arduino Pro Mini so I can test the boards ok.
I have completely given up on the Beagle Bone Blacks. They are now just too hard to drive.

denys
 
Posts: 50
Joined: Fri Aug 10, 2018 1:08 am

Please be positive and constructive with your questions and comments.