Linux C Dev Mem

  1. Linux C Dev Memory
  2. C Dev Infection
  3. Linux C Dev Mem 2
  4. Dev File Linux
  5. Dev C++ Linux Mint

Oct 23, 2013 If you want to find a way for access physical memory in Linux there are only two solutions. The first is to develop a module running in kernel space with the correct privileges to access physical memory and the second is to use a special devices called '/dev/mem'. If your purpose is only to read or write some small parts of physical memory from user space this device is the right solution for you. Oct 23, 2013  If you want to find a way for access physical memory in Linux there are only two solutions. The first is to develop a module running in kernel space with the correct privileges to access physical memory and the second is to use a special devices called '/dev/mem'.If your purpose is only to read or write some small parts of physical memory from user space this device is the right solution for you.

Rev. 0.3

Command line

ADDRESS is a physical address: a number, like 0x12345678 (*)

VALUE is a number like 0x1234 or 42 (*)

The w|b|h designate the size of the value to read or write. W is 4-bytes (int32), H is two bytes (int16), B means one byte (int8). Reads and writes are performed as single operation.For reads, the size is W if not specified. For writes, the size must be specified. Letters W,B,H are not case sensitive.

The size parameter w|b|h can also be moved before ADDRESS:

(*) Decimal numbers for address and values are OK. Actually the numbers are read using C strtoul function, so it will interpret numbers like 0123 as octal! Probably not what you want!

Linux C Dev Mem

NOTE: It is not guaranteed that any physical address can be accessed by this program. Validity of the ADDRESS may be checked by the OS. See the source of the kernel driver which provides the /dev/mem device for details.

Some physical addresses are hardware registers; writing or even reading them can cause your computer/device crash or melt down or explode. You've been warned!

Switches

-r - read back after write, and print

-a - do not require correct alignment

-A - Absolute addresses. This does nothing in this version (it always works with absolute addresses)

-V, --version - show version

Linux C Dev Memory

-d - debug. print some debug spew.

--help - show usage

NOTE: The original program does not have switches. Giving it '--help' will read from address 0.

To check whether you have this or the original version, add a bogus 2nd parameter which will make the old version fail. For example: 'devmem -V -'.

C Dev Infection

Examples

Learning source code of utility 'devmem2'

Refer to 'AMDM37x Multimedia Device Silicon Revision 1.x Technical Reference Manual___sprugn4m.pdf'

Linux C Dev Mem 2

Page 2434: For OMAP37x (Beagle Board's processor), its pin gpmc_ncs4 (Mode 0, CONTROL_PADCONF_GPMC_NCS3[31:16]) can also be switched to gpt9_pwm_evt (Mode 3), whose physical address is 0x4800 20B4.

Dev File Linux

I run below command on Beagle Board(OMAP ):ubuntu@omap:~/tom/test$ sudo devmem2 0x480020b4 w/dev/mem opened.Memory mapped at address 0xb6f4b000.Value at address 0x480020B4 (0xb6f4b0b4): 0x180018

Dev C++ Linux Mint

Refer to page 2428: 0x18 (high 16 bits) means mode 0 = gpmc_ncs4. So to turn it to PWM functionality, (means mode 0 to mode 3 at high 16 bits), 0x18 -> 0x18+0x3=0x1bubuntu@omap:/tom/test$ sudo devmem2 0x480020b4 w 0x1b0018/dev/mem opened.Memory mapped at address 0xb6f31000.Value at address 0x480020B4 (0xb6f310b4): 0x180018Written 0x1B0018; readback 0x1B0018ubuntu@omap:/tom/test$ sudo devmem2 0x480020b4 w/dev/mem opened.Memory mapped at address 0xb6fa7000.Value at address 0x480020B4 (0xb6fa70b4): 0x1B0018