besp9510 / dma_pwm

Pulse width modulation (PWM) via direct memory transfer (DMA) on the Raspberry PI
MIT License
28 stars 6 forks source link

pi 4B with Ubuntu Desktop 22.04.1 LTS #6

Closed bpesun closed 1 year ago

bpesun commented 2 years ago

Thanks for you example. I am using Pi 4b in ubuntu desktip 22.04.1 os. I run the executable dma_pwm_test under /bin ,but the result showed that could not request channel.

pi@pi-desktop:~/Downloads/dma_pwm-master/test/bin$ ./dma_pwm_test dma_pwm.c configured Could not request channel

I have add the snd-blacklist.conf file with the content blacklist snd_bcm2835 , but get the same result. Hope to get your suggestion, thanks!

besp9510 commented 2 years ago

Hi bpsesun, there could be a few possibilities. First, make sure you are either running as root or with a user that has privileges to access the devices /dev/mem/ and /dev/vcio.

If the example still does not work, then let's have you enable debug logs, run the example again, and post the output for me to review. To enable debug logs, recreate the Makefile by adding in the option --enable-debug-logs like so: ./configure --enable-debug-logs

Then remake and reinstall dma_pwm

  1. sudo make uninstall && make clean && make && sudo make install

At this point you can rerun the example and post the debug logs printed to the the screen here.

bpesun commented 2 years ago

Thanks a lot. please check the log:

root@pi-desktop:/home/pi/Desktop/dma_pwm-master# cd test
root@pi-desktop:/home/pi/Desktop/dma_pwm-master/test# cd bin
root@pi-desktop:/home/pi/Desktop/dma_pwm-master/test/bin# sudo ./dma_pwm_test
Configuring dma_pwm.c
Setting pulse width to 4995.900 us
Setting number of allocated pages to 16
Configured dma_pwm.c
dma_pwm.c configured
DEBUG logs enabled for dma_pwm.c!
Initializing dma_pwm.c
Signal 1 registered with signal handler
Signal 3 registered with signal handler
Signal 2 registered with signal handler
Signal 15 registered with signal handler
ERROR: get_pi_version() could not get PI board version
ERROR: Could not initialize dma_pwm.c
Could not request channel
root@pi-desktop:/home/pi/Desktop/dma_pwm-master/test/bin# 
besp9510 commented 2 years ago

Could you look and see if the file "/proc/cpuinfo" exists? If so, can you cat it and post the contents?

bpesun commented 2 years ago
root@pi-desktop:/proc# cat cpuinfo
processor   : 0
BogoMIPS    : 108.00
Features    : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part    : 0xd08
CPU revision    : 3

processor   : 1
BogoMIPS    : 108.00
Features    : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part    : 0xd08
CPU revision    : 3

processor   : 2
BogoMIPS    : 108.00
Features    : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part    : 0xd08
CPU revision    : 3

processor   : 3
BogoMIPS    : 108.00
Features    : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part    : 0xd08
CPU revision    : 3

Hardware    : BCM2835
Revision    : c03115
Serial      : 10000000bb943a5f
Model       : Raspberry Pi 4 Model B Rev 1.5
root@pi-desktop:/proc# 
besp9510 commented 2 years ago

Ah, so turns out dma_pwm wasn't picking up on the "Pi 4 Model B Rev 1.5" revision. I've just pushed an update to the main branch to include this, hopefully everything will work for you now. You can go ahead and pull the latest commit, reinstall, and try the example again.

bpesun commented 2 years ago

Thank you for your kind help. Yes ,it can work now. In your test, you set and read the same channel, if it is possible to read other channel's pwm properties(like get_duty_cycle_pwm(19))? In other words, if it is possible to read one or some pwm sigals from external remote controller and get their properties like duty?
Thanks.

besp9510 commented 2 years ago

Great to hear!

Unfortunately get_duty_cycle_pwm() is internal to dwm_pma so it is only able to tell you the duty cycle of channels that were requested and configured via request_pwm() & set_pwm().

bpesun commented 2 years ago

Thank you very much for your great work and help.