Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Segmentation fault in embedded application writing to register

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?

like image 350
user846566 Avatar asked Feb 02 '26 18:02

user846566


1 Answers

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.

like image 167
Steve Avatar answered Feb 04 '26 10:02

Steve



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!