I'm running debian with the 3.14.14 kernel on a Freescale iMX6 arm Processor.
I have this code in an embedded application that gives a segmentation fault.
volatile unsigned int& GPIO2IO26CTRL = *((volatile unsigned int*)0x20e0104);
GPIO2IO26CTRL = 0x5;
also tried:
volatile unsigned int* GPIO2IO26CTRL = (volatile unsigned int*)0x20e0104;
*GPIO2IO26CTRL = 0x5;
But I really do want to write 0x5 to location 0x20e0104. This tells the iMX6 chip that an io line is to be GPIO rather than spi;
How do I get around this?
This is possible from user space (although you may need to be root). The key is remapping the memory into the process's address space.
There is a program called devmem2 that can do this. Source code is here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With