besp9510 / dma_pwm

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

`Bus error` Raspberry Pi 4b #9

Open jeff5343 opened 3 months ago

jeff5343 commented 3 months ago

Hello, I followed the instructions on the readme and when I ran the test project I received this error:

root@raspberrypi:/home/pi/dma_pwm/test# ./bin/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
Setting PI board version as 4
BCM peripheral base physical address = 0xFE000000
BCM peripheral base bus address = 0x7E000000
GPSET0 bus address = 0x7E20001C
GPCLR0 bus address = 0x7E200028
PWMFIF1 bus address = 0x7E200028
Setting pulse width to 4995.900 us
Mapped peripherals into virtual memory:
GPIO base virtual address = 0x7f8bd8e000
DMA CTL base virtual address = 0x7f8bd8d000
PWM CTL base virtual address = 0x7f8bd8c000
PWM CLK base virtual address  = 0x7f8bd8b000
PWM CTL and CM initialized:
PWM CM Register: PWMDIV = 0x00FFF000
PWM CM Register: PWMCTL = 0x00000096
PWM CTL Register: CTL = 0x00000021
PWM CTL Register: DMAC = 0x80000F0F
PWM CTL Register: RNG1 = 0x00000262
Initialized dma_pwm.c
Initializing channel 0
Setting page size to 4096 bytes
Setting channel 0 selected CB buffer to 1
Channel 0 initialized with 65536 bytes allocated (x2)
Channel 0 requested
PWM signal to be set on channel 0
Selecting CB buffer 0 for channel 0 
Setting GPIO masks
GPIO set mask = 0x04000000
GPIO clear mask = 0x04000000
Setting PWM signal and CB sequence properties:
Pulse width = 4995.8999 us
Subcycle = 1000000 us
Actual frequency = 1.0008206 Hz
Duty cycle resolution = 0.9999990%
Actual duty cycle = 74.9999313%
CB sequence "set" number = 75
CB sequence "clear" number = 25
CB sequence total number = 102
Building CB sequence for channel 0 on buffer 0 
Bus error
besp9510 commented 3 months ago

Hi Jeff,

What operating system are you using? Does this error occur every time you run the test or is it sporadic?

I haven’t encountered this bus error before. I developed and tested this against a Pi 3b running Raspberry PI OS/Raspian, so the Pi hardware or operating system may be causing this. Specifically, I’m thinking there could be a difference in how Broadcom implemented VideoCore uncached memory allocation (via dev/mem) because the bus error is occurring during this allocation.

jeff5343 commented 3 months ago

I am using Debian GNU/Linux 12 (bookworm) and this error occurs every time I run the test.