Trying to access the sensor's registers using memory-mapped I/O in a flat memory model
Hi, I'm working on a small embedded system project using x86-64 assembly on an Intel Atom E3845 microprocessor. The program aims to read temperature data from an Adafruit BMP280 sensor connected with I2C
9 Replies
I'm trying to access the sensor's registers using memory-mapped I/O in a flat memory model, and I'm encountering a segmentation fault when I run the program, saying:
My relevant code :
Can you help me identify the cause of the segmentation fault and suggest appropriate methods to access the BMP280 sensor registers in x86-64 assembly, considering the limitations of a flat memory model? Additionally, are there recommended practices or libraries for I2C sensor interaction on Intel Atom processors in a Linux environment?
@Helper
Hi @Marvee Amasi , it looks like you’re encountering a segmentation fault due to trying to access memory that your program doesn’t have permission to access.
What am I doing wrong?
Incorrect Use of Memory-Mapped I/O in User Space and Incorrect Register Access
Yup @Enthernet Code I had to implement memory-mapped I/O using the
mmap
system call@Marvee Amasi Accessing hardware registers directly through memory-mapped I/O in user-space is not allowed in modern operating systems like Linux. This is due to the protection mechanisms in place to prevent unauthorized access to hardware resources.The segmentation fault occurs because the memory address 0x10000 you are trying to access is not allocated to your program, and hence, the operating system prevents access.
Solution
No more error message, it worked:
Had to dig deep with some resources using
Had to dig deep with some resources using
mmap
Thanks man @Enthernet Code