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

Small fixes: use /dev instead of /tmp for mailbox, fixed unmapmem() to avoid exit(-1) at ws2811_fini, use 249 as device major to avoid crash on Kernel >=4.1 #2

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

Conversation

plan44
Copy link

@plan44 plan44 commented Aug 21, 2015

No description provided.

…e a file system that does not allow creating character devices.
…uests.

In particular, munmap() often failed because in case of a non-page-aligned mapping, the value passed to munmap() was different from what mmap() originally returned. This caused programs to exit with -1 at ws2811_fini(). This is a problem when exit codes are actually evaluated.
@Gadgetoid
Copy link

I've started getting reports of issues with this library and permissions errors/missing devices in /tmp, is this fix somewhat related? I'm going to give it a try in our Unicorn HAT library either way.

@tejonbiker
Copy link

I have the same behavior, seems like the program can create the /tmp/mailbox-XXXX but can't open it. I added this code to the mbox_open() function in mailbox.c:

if (file_desc < 0) {
sprintf(system_qry,"file %s",filename);
system(system_qry);
printf("Can't open device file %s: %m\n", filename);
unlink(filename);
return -1;
}

And return this:

/tmp/mailbox-3725: character special
Can't open device file /tmp/mailbox-3725: No such device or address.

@tejonbiker
Copy link

Sorry, I forgot mention my kernel info:

uname -a
Linux raspberrypi 4.1.6-v7+ #810 SMP PREEMPT Tue Aug 18 15:32:12 BST 2015 armv7l GNU/Linux

@plan44
Copy link
Author

plan44 commented Aug 24, 2015

@Gadgetoid yes, this fix is related. The regular tmpfs (ram disk file system) cannot have character device nodes, so if /tmp is mapped to a tmpfs (as it is on minibian, a stripped down flavor of the Raspian distribution) the original library does not work.
However, /dev seems always located on a special flavor of tmpfs called devtmpfs which can have character device nodes, so it works for the mailbox.

@Gadgetoid
Copy link

Looks like this fix is related to the Minibian issue, but not to the new one that has developed as of Kernel 4.1.6 which is what @tejonbiker is referring to. I've updated the firmware on a Pi and confirmed the problem- since there's no way of raising issues against this repository, and it's off-topic for this PR, I've raised a new one upstream for discussion: jgarff#41

…e for mailbox must not use reserved major number 100 (telephony for linux).

Fix is to use a number in the 240..254 range (local/experimental use), as a commenter on github recommended, I chose 249.

See "devices.txt" Linux doc file for a list of device major numbers
@plan44 plan44 changed the title Small fixes: use /dev instead of /tmp for mailbox, fixed unmapmem() to avoid exit(-1) at ws2811_fini Small fixes: use /dev instead of /tmp for mailbox, fixed unmapmem() to avoid exit(-1) at ws2811_fini, use 249 as device major to avoid crash on Kernel >=4.1 Oct 1, 2015
@plan44 plan44 closed this Oct 1, 2015
@plan44 plan44 reopened this Oct 1, 2015
@ghost
Copy link

ghost commented Oct 1, 2015

Take a look at this, with the changes from the link rpi_ws281x works fine for me.

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