Linux C Dev Mem
Rev. 0.3
Jan 29, 2020 README. Fmem 1.6.0 This repo is was originally a github mirror of the original fmem module. Later this repo became a maintained version of fmem to account for a changing Linux kernel. Bug reports and patches welcome. This module creates /dev/fmem device, that can be used for dumping physical memory, without limits of /dev/mem (1MB/1GB. 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.
Memory Usage. On linux, there are commands for almost everything, because the gui might not be always available. Download game cooking dash for laptop. When working on servers only shell access is available and everything has to be done from these commands. So today we shall be checking the commands that can be used to check memory usage on a linux system. Memory include RAM and swap. Dmidecode or other commands which require access to /dev/mem fail even for the root user # dmidecode # dmidecode 2.11 /dev/mem: Permission denied This is expected for non-root users but root should be able to run dmidecode.
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!
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)
Linux C Dev Mem Windows 7
-V, --version
- show version
-d
- debug. print some debug spew.
Linux C Dev Mem Software
--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 -'.
Examples
Linux Dev Mem
Learning source code of utility 'devmem2'
Refer to 'AMDM37x Multimedia Device Silicon Revision 1.x Technical Reference Manual___sprugn4m.pdf'
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.
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
Linux C Dev Memory
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