WRITE and READ memory mapped device registers in Linux on ARM

前端 未结 2 1405
广开言路
广开言路 2021-01-13 05:01

I am trying to read and write registers on my ARM9 (SAM9X25) following those steps : http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka3750.html
I ended

相关标签:
2条回答
  • 2021-01-13 05:30

    busybox devmem

    busybox devmem is a tiny CLI utility that mmaps /dev/mem.

    You can get it in Ubuntu with: sudo apt-get install busybox

    Usage: read 4 bytes from the physical address 0x12345678:

    sudo busybox devmem 0x12345678
    

    Write 0x9abcdef0 to that address:

    sudo busybox devmem 0x12345678 w 0x9abcdef0
    

    See this for a few tips on how to test it out: Accessing physical address from user space

    Also mentioned at: https://unix.stackexchange.com/questions/4948/shell-command-to-read-device-registers

    0 讨论(0)
  • 2021-01-13 05:41

    You can't access registers directly, because Linux use MMU and this create for your application virtual address space which is different than physical MCU address space and access outside this virtual address space cause segmentation fault.

    Only Way to access these registers in Linux (if you don't want to write kernel drivers) is to open file /dev/mem as file and map it with mmap

    For example I have small python library for access GPIO registers on Atmel SAM MCU gpiosam. You can inspire and port it to C.

    0 讨论(0)
提交回复
热议问题