Hi to all,
I'm trying to convert a code that works, into a class.
This code maps the memory to manage the GPIO of the Raspberry Pi, and I can use it in a "normal" way, but If I convert the code into a class I get the error:
mmap: Operation not permitted
Failed to map the physical GPIO registers into the virtual memory space.
I attach the original code and the class. What can be the cause?
Thanks in advance!
mmap: Operation not permitted
- Attachments
-
- src.tar.gz
- (10 KiB) Downloaded 196 times
Re: mmap: Operation not permitted
You need to run with permission to mmap /dev/mem....
mmap: Operation not permitted
...
The simplest way is to run the program with sudo.
Re: mmap: Operation not permitted
Yes, I run the program with sudo in both cases.joan wrote: The simplest way is to run the program with sudo.
Re: mmap: Operation not permitted
You may be redefining the struct...
maybe should be
Code: Select all
class RpiMemory
{
struct bcm2835_peripheral gpio;
Code: Select all
class RpiMemory
{
bcm2835_peripheral gpio;
Re: mmap: Operation not permitted
Thanks, it compiles, but happens the same error.StuartF wrote: maybe should beCode: Select all
class RpiMemory { bcm2835_peripheral gpio;
Re: mmap: Operation not permitted
No, that fixes it. At the time of the mmap, you just need the variable gpio that is in scope to be the one whose .addr_p you have actually initialized.fpalma wrote:Thanks, it compiles, but happens the same error.
Re: mmap: Operation not permitted
Also you make the same redefinitions throughout the class.
I was hoping that the hint would of made you look through the whole code.
Once you have defined the struct, there is no need to use 'struct', just the name.
I was hoping that the hint would of made you look through the whole code.
Once you have defined the struct, there is no need to use 'struct', just the name.
Re: mmap: Operation not permitted
OK, I have deleted "struct bcm2835_peripheral" from the constructor of the class, and now I can map the memory. Has been a basic mistake ...
Thanks a lot!
Thanks a lot!