On a Raspberry PI 4 with 8 gig memory, I have upgraded the OS to Bookworm. Now when I execute the function init_gpio()
it gives me the error Could not map /dev/gpiomem . Make sure you have the required permissions.
When I look at the permissions of /dev/gpiomem, it is rw-rw----. I changed this to rw-rw-rw- to no avail. When I reboot the PI it goes back to the original permissions of rw-rw----.
This function was working on the previous OS, so that may be an option. Anything that I am overlooking? Perhaps @Ronis_BR can help.
Initially I thought the error may have something to do with the upgrade in OS from Bullseye to Bookworm. This turns out not to be the case.
Some internet searching indicates that gpio should be a member of the group logged in (use the groups command to find out). This seems to be the case by default. Also I did all testing as a normal user, not as root.
In using Bullseye, I went back to Julia 1.10.0, and the error is not present. Then I tried Julia 1.10.2 and the error is present. The error occurs in the line with the function call Mmap.mmap in the function init_gpio(), shown below, in BaremetalPi file gpio.jl, so it seems that the Mmap function call has changed.
Is this something that an issue should be raised for?
"""
init_gpio()
Initialize the GPIO.
"""
function init_gpio()
# Open and map /dev/gpiomem.
try
gpiomem_io = open("/dev/gpiomem", "w+")
gpiomem_map = Mmap.mmap(
gpiomem_io,
Vector{UInt32},
(GPIOMEM_SIZE,),
0,
grow = false
)
objects.gpiomem_io = gpiomem_io
objects.gpiomem_map = gpiomem_map
objects.gpio_init = true
catch
error("Could not map `/dev/gpiomem`. Make sure you have the required permissions.")
end
return nothing
end
edit: I added to the title to more accurately reflect the problem
To see what the actual error is, copy paste first 2 function calls to julia repl. Otherwise, you see the error thrown in the catch block and it suppresses the one in try block.
OK. How many bytes can you actually read on the /dev/gpiomem and how many bytes filesize reports? If the filesize result matches correct size then 1024 is very long to request. Small internet search showed that people use 0xB4 for mmap block size. Nevermind, I found some uses 4096 so it might be different thing then I thought. Maybe, GPIOMEM_SIZE is not set to the correct value.
I will only have access to a Raspeberry Pi this weekend to test. However, I have no ideia if there is any workaround. Let’s see what the devs say in that issue.