Skip to content

Conversation

@pdp7
Copy link
Collaborator

@pdp7 pdp7 commented Oct 31, 2017

For issue #170.

Commit 8e08a40 moved pwm_set_polarity() after pwm_set_frequency() and pwm_set_duty_cycle(). PWM.start() now runs OK after reboot.

Output from running test:

    debian@beaglebone:~/ssh/adafruit-beaglebone-io-python$ sudo python test/issue170-pwm.py; journalctl -p debug -t python --since "1 min ago"
    -- Logs begin at Tue 2017-10-31 06:56:00 UTC, end at Tue 2017-10-31 07:36:39 UTC. --
    Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: version <unknown> initialized
    Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_start: P9_14, 50.000000, 2000.000000, 1
    Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: lookup_exported_pwm: couldn't find 'P9_14'
    Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: initialize_pwm: OK
    Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: set_pin_mode() :: Pinmux file /sys/devices/platform/ocp/ocp:P9_14
    Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: set_pin_mode() :: Set pinmux mode to pwm for P9_14
    Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_start: P9_14, /sys/devices/platform/ocp/48302000.epwmss/48302
    Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_start: P9_14, /sys/devices/platform/ocp/48302000.epwmss/48302
    Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_setup: P9_14 OK
    Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_start: call pwm_set_frequency(key=P9_14 freq=2000.000000)
    Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_set_frequency: P9_14 2000.000000 OK
    Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_start: call pwm_set_duty_cycle(key=P9_14 duty=50.000000)
    Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_set_duty_cycle: P9_14 50.000000 OK
    Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_start: call pwm_set_polarity(key=P9_14 polarity=1)
    Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_set_polarity: P9_14 1 OK
    Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_start: write(pwm->enable_fd, buffer=1, len=1)
    Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_start: P9_14 OK
    Oct 31 07:35:57 beaglebone python[1997]: [40B blob data]
    Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_start: P9_14, 50.000000, 2000.000000, 0
    Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: lookup_exported_pwm: couldn't find 'P9_14'
    Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: set_pin_mode() :: Pinmux file /sys/devices/platform/ocp/ocp:P9_14
    Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: set_pin_mode() :: Set pinmux mode to pwm for P9_14
    Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_start: P9_14, /sys/devices/platform/ocp/48302000.epwmss/48302
    Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_start: P9_14, /sys/devices/platform/ocp/48302000.epwmss/48302
    Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_setup: P9_14 OK
    Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_start: call pwm_set_frequency(key=P9_14 freq=2000.000000)
    Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_set_frequency: P9_14 2000.000000 OK
    Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_start: call pwm_set_duty_cycle(key=P9_14 duty=50.000000)
    Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_set_duty_cycle: P9_14 50.000000 OK
    Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_start: call pwm_set_polarity(key=P9_14 polarity=0)
    Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_set_polarity: P9_14 0 OK
    Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_start: write(pwm->enable_fd, buffer=1, len=1)
    Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_start: P9_14 OK
    Oct 31 07:35:57 beaglebone python[1997]: [40B blob data]

pdp7 added 4 commits October 31, 2017 05:37
Output from running test:

debian@beaglebone:~/ssh/adafruit-beaglebone-io-python$ sudo python test/issue170-pwm.py; journalctl -p debug -t python --since "1 min ago"
-- Logs begin at Tue 2017-10-31 06:56:00 UTC, end at Tue 2017-10-31 07:36:39 UTC. --
Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: version <unknown> initialized
Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_start: P9_14, 50.000000, 2000.000000, 1
Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: lookup_exported_pwm: couldn't find 'P9_14'
Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: initialize_pwm: OK
Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: set_pin_mode() :: Pinmux file /sys/devices/platform/ocp/ocp:P9_14
Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: set_pin_mode() :: Set pinmux mode to pwm for P9_14
Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_start: P9_14, /sys/devices/platform/ocp/48302000.epwmss/48302
Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_start: P9_14, /sys/devices/platform/ocp/48302000.epwmss/48302
Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_setup: P9_14 OK
Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_start: call pwm_set_frequency(key=P9_14 freq=2000.000000)
Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_set_frequency: P9_14 2000.000000 OK
Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_start: call pwm_set_duty_cycle(key=P9_14 duty=50.000000)
Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_set_duty_cycle: P9_14 50.000000 OK
Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_start: call pwm_set_polarity(key=P9_14 polarity=1)
Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_set_polarity: P9_14 1 OK
Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_start: write(pwm->enable_fd, buffer=1, len=1)
Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_start: P9_14 OK
Oct 31 07:35:57 beaglebone python[1997]: [40B blob data]
Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_start: P9_14, 50.000000, 2000.000000, 0
Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: lookup_exported_pwm: couldn't find 'P9_14'
Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: set_pin_mode() :: Pinmux file /sys/devices/platform/ocp/ocp:P9_14
Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: set_pin_mode() :: Set pinmux mode to pwm for P9_14
Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_start: P9_14, /sys/devices/platform/ocp/48302000.epwmss/48302
Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_start: P9_14, /sys/devices/platform/ocp/48302000.epwmss/48302
Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_setup: P9_14 OK
Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_start: call pwm_set_frequency(key=P9_14 freq=2000.000000)
Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_set_frequency: P9_14 2000.000000 OK
Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_start: call pwm_set_duty_cycle(key=P9_14 duty=50.000000)
Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_set_duty_cycle: P9_14 50.000000 OK
Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_start: call pwm_set_polarity(key=P9_14 polarity=0)
Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_set_polarity: P9_14 0 OK
Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_start: write(pwm->enable_fd, buffer=1, len=1)
Oct 31 07:35:57 beaglebone python[1997]: Adafruit_BBIO: pwm_start: P9_14 OK
Oct 31 07:35:57 beaglebone python[1997]: [40B blob data]
@pdp7 pdp7 changed the title Fix polarity error in PWM.setup() for Linux 4.9 #170 Fix polarity error in PWM.setup() for Linux 4.9 Oct 31, 2017
@pdp7
Copy link
Collaborator Author

pdp7 commented Oct 31, 2017

pytest runs OK:

debian@beaglebone:~/ssh/adafruit-beaglebone-io-python/test$ sudo /opt/scripts/tools/version.sh 
git:/opt/scripts/:[6c2688b0be448b7bb9ca18849b430d496a84acb4]
eeprom:[A335BNLT000C3014BBBK1316]
model:[TI_AM335x_BeagleBone_Black]
dogtag:[BeagleBoard.org Debian Image 2017-10-17]
bootloader:[microSD-(push-button)]:[/dev/mmcblk0]:[U-Boot 2017.09-00002-g0f3f1c7907]
bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot 2017.09-rc2-00002-g84a7f2]
kernel:[4.9.57-ti-r71]
nodejs:[v6.11.4]
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.20171013.2-0rcnee1~stretch+20171013]
pkg:[bb-wl18xx-firmware]:[1.20170829-0rcnee1~stretch+20170829]
pkg:[firmware-ti-connectivity]:[20170823-1rcnee0~stretch+20170830]

debian@beaglebone:~/ssh/adafruit-beaglebone-io-python/test$ sudo python -mpytest 
================================================== test session starts ==================================================
platform linux2 -- Python 2.7.13, pytest-3.2.3, py-1.4.34, pluggy-0.4.0
rootdir: /home/debian/ssh/adafruit-beaglebone-io-python, inifile:
collected 58 items                                                                                                       

test_adc.py ......
test_gpio_input.py ..
test_gpio_output.py ......
test_gpio_setup.py ..........
test_led.py ..
test_pwm_setup.py ...........................
test_spi.py ..
test_uart.py ...

============================================== 58 passed in 13.53 seconds ===============================================

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants