adafruit / adafruit-beaglebone-io-python

Adafruit's BeagleBone IO Python Library
http://learn.adafruit.com/setting-up-io-python-library-on-beaglebone-black
477 stars 217 forks source link

BeagleBone Green - "RuntimeError: Unknown error" python PWM.start #342

Closed deelerke closed 3 years ago

deelerke commented 4 years ago

Hi, I'm trying to get this working on a Beaglebone Green with Debian Buster (Linux beaglebone 5.4.38-ti-r8)

root@beaglebone:~# python pwmtest.py
Traceback (most recent call last):
  File "pwmtest.py", line 2, in <module>
    pwm.start("P9_14",50);
RuntimeError: Unknown error

root@beaglebone:~# cat pwmtest.py
import Adafruit_BBIO.PWM as pwm
pwm.start("P9_14",50);
pwm.stop("P9_14");

root@beaglebone:~# /opt/scripts/tools/version.sh
git:/opt/scripts/:[ef16ffa8c27225005cc2b2c974a83da3dee6c1ef]
eeprom:[A335BNLTBBG1BBG217110074]
model:[TI_AM335x_BeagleBone_Green]
dogtag:[BeagleBoard.org Debian Buster Console Image 2020-05-18]
bootloader:[microSD-(push-button)]:[/dev/mmcblk0]:[U-Boot 2019.04-00002-g31a8ae0206]:[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:[M-BB-BBG-00A0]
kernel:[5.4.38-ti-r8]
/boot/uEnv.txt Settings:
uboot_overlay_options:[enable_uboot_overlays=1]
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:[uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-19-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.14.20200814.0-0~buster+20200814]
pkg:[bb-wl18xx-firmware]:[1.20200813.1-0~buster+20200813]
pkg:[kmod]:[26-1]
WARNING:pkg:[librobotcontrol]:[NOT_INSTALLED]
pkg:[firmware-ti-connectivity]:[20190717-2rcnee1~buster+20200305]
groups:[debian : debian adm kmem dialout cdrom floppy audio dip video plugdev users systemd-journal input bluetooth netdev gpio pwm eqep remoteproc admin spi iio i2c docker tisdk weston-launch xenomai cloud9ide]
cmdline:[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 quiet]
dmesg | grep remote
[    2.534070] remoteproc remoteproc0: wkup_m3 is available
[    2.757005] remoteproc remoteproc1: 4a334000.pru is available
[    2.758730] remoteproc remoteproc2: 4a338000.pru is available
[    2.763043] remoteproc remoteproc0: powering up wkup_m3
[    2.763202] remoteproc remoteproc0: Booting fw image am335x-pm-firmware.elf, size 217168
[    2.767376] remoteproc remoteproc0: remote processor wkup_m3 is now up
dmesg | grep pru
[    2.757005] remoteproc remoteproc1: 4a334000.pru is available
[    2.757173] pru-rproc 4a334000.pru: PRU rproc node /ocp/interconnect@4a000000/segment@0/target-module@300000/pruss@0/pru@34000 probed successfully
[    2.758730] remoteproc remoteproc2: 4a338000.pru is available
[    2.758899] pru-rproc 4a338000.pru: PRU rproc node /ocp/interconnect@4a000000/segment@0/target-module@300000/pruss@0/pru@38000 probed successfully
dmesg | grep pinctrl-single
[    1.765188] pinctrl-single 44e10800.pinmux: 142 pins, size 568
dmesg | grep gpio-of-helper
[    1.779887] gpio-of-helper ocp:cape-universal: ready
END

and this is my /boot/uEnv.txt

root@beaglebone:~# cat /boot/uEnv.txt | grep -v '#'

uname_r=5.4.38-ti-r8

enable_uboot_overlays=1
disable_uboot_overlay_emmc=1
disable_uboot_overlay_video=1
disable_uboot_overlay_audio=1
disable_uboot_overlay_wireless=1
uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-19-TI-00A0.dtbo
enable_uboot_cape_universal=1

cmdline=coherent_pool=1M net.ifnames=0 lpj=1990656 rng_core.default_quality=100 quiet

thanks in advance for your suggestions

Dieter

pdp7 commented 3 years ago

@deelerke could you please either pull the latest commit or just edit that line and let me know if it works for you?

deelerke commented 3 years ago

hi pdp7 , that looks really promising! sorry for the delays, I'm in Belgian timezone

I did a fresh install with the Linux beaglebone 4.19.94-ti-r57 image, and did a git clone git://github.com/adafruit/adafruit-beaglebone-io-python.git and then edited that line pwm_path[66] -> pwm_path[67] and a "python3 setup.py install" and tried the pwm-test again

root@beaglebone:/home/debian/adafruit-beaglebone-io-python# python3 pwm-test.py
Traceback (most recent call last):
  File "pwm-test.py", line 1, in <module>
    import Adafruit_BBIO.PWM as pwm
ModuleNotFoundError: No module named 'Adafruit_BBIO.PWM'
root@beaglebone:/home/debian/adafruit-beaglebone-io-python# cat pwm-test.py
import Adafruit_BBIO.PWM as pwm
pwm.start("P9_42",50);
pwm.stop("P9_42");

I haven't installed anything yet via pip3, but it seems like I must be missing something very trivial and silly. Or does the module have a different name now? thanks !

pdp7 commented 3 years ago

@deelerke hmm, that is weird. have you tried moving the script to your home the directory and running again?

Instead of entering root shell, you also might want to run "sudo python3 ./setup install" and then "sudo python3 ./pwm-test.py". I don't normally run in a root shell. I don't think it should be a problem but there might be something going on with the environment variables.

Side note: I forgot to actually merge my pull request with the fix so I have done that now. https://github.com/adafruit/adafruit-beaglebone-io-python/commit/7361d9a997bce4ab79c83c4ef30442e8dd13f363

pdp7 commented 3 years ago

Here what it looks like for me:

debian@beaglebone:~$ cd adafruit-beaglebone-io-python/
debian@beaglebone:~/adafruit-beaglebone-io-python$ sudo python3 ./setup.py install

debian@beaglebone:~$ cat pwm-test.py 
import Adafruit_BBIO.PWM as pwm
pwm.start("P9_42",50);
pwm.stop("P9_42");

debian@beaglebone:~$ sudo python3 pwm-test.py

It completes with no error.

Just to make sure there were no unintended changes, what does git diff and git status show inside of adafruit-beaglebone-io-python?

deelerke commented 3 years ago

allright!!!!! moving to the home dir fixed it and NO ERRORS !!! :) :) I'll check tonight if I got an actual PWM signal on the pin. but no doubt about it.

fantastic work pdp7 !!!!!

deelerke commented 3 years ago

yes! pwm signal confirmed!

thanks again for your efforts on this!

pdp7 commented 3 years ago

@deelerke thanks for testing. I'm glad we finally got this one solved.

stoller2122 commented 1 year ago

Same issue here on the latest BBB image and latest version (built from most recent git update) of the adafruit library. Running BeagleBoard.org Debian Bullseye IoT Image 2023-09-02

debian@BeagleBone:~$ sudo python3 Python 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110] on linux Type "help", "copyright", "credits" or "license" for more information. '>>> import Adafruit_BBIO.PWM as PWM '>>> PWM.start("P9_14",5,50) Traceback (most recent call last): File "", line 1, in RuntimeError: Unknown error