Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix unmapping problem #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

usefulthink
Copy link

As discussed in jgarff#32 this patch solves an issue with memory unmapping.

I have to admit I am not proficient enough in C to fully understand what the issue exactly is and why this solves it, but it would be great if we could have this in your fork - as it happens to be the upstream for raspberry-pi 2 compatibility.

Also: Thanks a lot for your work, it did save me a lot of trouble :)

euang and others added 3 commits March 6, 2015 11:44
Control registers for DMA, PWM etc. are accessed
via memory-mapped IO. The structs which overlay the
m'mapped regions use __attribute__ ((packed)) to ensure
that there are no gaps between the structs fields.

GCC < 5.1.0 assembles the write operation to a int32_t
field inside a __attribute__ ((packed))'ed struct
in the form
	str	(write single 32-bit value to memory)
whereas GCC >= 5.1.0 does something like
	strb #0 (write byte 0 of 32-bit value)
	strb #1 (write byte 1 of 32-bit value)
	strb richardghirst#2 (...)
	strb richardghirst#3 (...)

The BCM2835's Clock Manager General Purpose Clock Control
and Clock Manager General Purpose Clock Divisor Registers
(both inside cm_pwm_t) only accept writes if bits 24-31
contain the value 0x5a, which obviously won't work if
the 32 bits aren't written at once.

As the struct already only contains 32-bit wide fields,
packing them should not be necessary.

For the sake of convenience, I also removed the attribute
from the other m'mapped structs.
Fix hang when compiled with gcc >= 5.1.0
@KuenzelIT
Copy link

This solves the memory unmapping problem. But are the LEDs intentionally staying lit?

spooots pushed a commit to spooots/rpi_ws281x that referenced this pull request Jun 20, 2021
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.

4 participants