This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Sitara: R/W Physical Addresses with Linux CLI

I have a request to use the Linux command line interface (CLI) to read or write the Sitara AM335x registers at a memory mapped physical address (not virtual address).  I searched this forum and found regrw and memutils, but they were specifically written for the Davinci microprocessors.

Currently, we are wanting to adjust the slew control on a specific pin in the pinctrl register.  There was some software added to the kernel recently (https://lkml.org/lkml/2013/4/18/599) to modify the /sys/kernel/debug/pinctrl/44e10800.pinmux/pinconf-config file, but there is no explanation on what data is needed for <devname> <state> <pinname> <value> and how to write to it. 

Anyone know of a utility or howto on reading and writing physical addresses on the Linux CLI?

Thanks.

  • You can write your own application to use /dev/mem to read/write to a custom memory region:

    int memfd;
    memfd = open("/dev/mem", O_RDWR|O_SYNC);
    if (memfd == -1) {
        ERR("Cannot open /dev/mem (%s)\n", strerror(errno));
        return FAILURE;
    }
    unsigned char *memread;
    memread = (unsigned char*)malloc(512);
    memread = (unsigned char*)mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, memfd, 0xABCD1234);
    printf("%08x\n", *(unsigned int*)memread);

    Best regards,
    Miroslav

  • Thanks Miroslav for the code snippet.

        I debugged and built it with the TI SDK7 ARM GNU tools to find out that the TI SDK7 root file system running on a BBB does not support mmap, mumap, or mem so there is a "Segmentation fault" on mmap when running this snippet.  Sorry, I did not specify that we need this to run under the SDK7 for BBB.

    Any suggestions?

  • devmem2 will work reading and setting most physical registers in the AM335x. This app is in the file system that comes with the SDK.

    I am attaching a source file that has an mmap example and runs on the BBB and was compiled with the SDK 7.0 toolchain.

    5775.mmap_access.c