Thread: Accessing a physical memory address

  1. #1
    Registered User
    Join Date
    Dec 2022
    Posts
    2

    Accessing a physical memory address

    Hi

    I want to read and write from a physical memory, the method I used is
    ex: if memory address is 0x58000000
    int a = 10;
    int b;
    * (volatile int * ) 0x58000000 = a;
    b = *( volatile int * ) 0x58000000;
    printf( " %d ", b );

    in this way I am getting segmentation fault. What is right way to do this operation.

    Thanks

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    You don't have access to physical memory unless you're deep in the kernel.

    Normal user-space programs get given virtual memory by the kernel, and it's the kernel that's responsible for mapping virtual memory to physical memory.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Dec 2022
    Posts
    2
    Quote Originally Posted by Salem View Post
    You don't have access to physical memory unless you're deep in the kernel.

    Normal user-space programs get given virtual memory by the kernel, and it's the kernel that's responsible for mapping virtual memory to physical memory.
    Actually, I am working on a SoC which has Cortex R52 as real time core and Cortex A76 as application core and yocto Linux is running on that. I want to read value from the Linux side from a shared memory address, the value is written by R52.How can I do that

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Then you need to write yourself a little kernel driver to run on the A76.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Physical and Logical Memory.
    By TheUmer in forum General Discussions
    Replies: 3
    Last Post: 11-04-2010, 04:28 AM
  2. Accessing variables with memory address
    By ITAmember in forum C Programming
    Replies: 54
    Last Post: 06-28-2009, 03:35 AM
  3. physical address or logical ??
    By agarwaga in forum C++ Programming
    Replies: 1
    Last Post: 02-25-2006, 02:36 PM
  4. Editing of physical memory
    By Sang-drax in forum Windows Programming
    Replies: 0
    Last Post: 11-15-2003, 09:09 AM
  5. Accessing physical memory
    By Greg in forum C++ Programming
    Replies: 5
    Last Post: 07-20-2002, 09:04 AM

Tags for this Thread