Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk3 min

How to Access Device Registers Through Memory-Mapped I/O

Memory-mapped I/O gives devices an address range in the CPU’s memory space. Learn how it works, how it differs from port I/O, and why MMIO is not ordinary RAM.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Memory-mapped input/output (MMIO) assigns a range of CPU-visible addresses to a device. Software accesses those addresses to read or write device registers or memory; the transaction reaches the device rather than ordinary RAM.

How memory-mapped I/O works

Think of an address as selecting a destination. For an ordinary memory access, the address selects RAM. With MMIO, hardware recognizes an assigned address range and routes the access to a device. The processor may use instructions that look like normal memory operations, but the target and the rules governing the access are different. Linux’s device-I/O documentation describes part of the CPU address space being interpreted as accesses to a device.

As an Amazon Associate I earn from qualifying purchases.

A device’s physical address is not automatically a pointer that driver software can safely use. In Linux, a driver obtains an appropriate mapping, commonly with ioremap(), and accesses it with I/O-aware functions such as readl() and writel(). The exact API and rules depend on the operating system and platform.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

MMIO versus port-mapped I/O

Both mechanisms let software communicate with hardware, but they use different address spaces and access interfaces.

#1 Best Overall
ESP-WROOM-32 ESP32 ESP-32S Development Board 2.4GHz Dual-Mode WiFi + Bluetooth Dual Cores Microcontroller Processor Integrated with Antenna RF AMP Filter AP STA Compatible with Arduino IDE (3PCS)
  • 2.4GHz Dual Mode WiFi + Bluetooth Development Board
  • Support LWIP protocol, Freertos
  • SupportThree Modes: AP, STA, and AP+STA
  • Ultra-Low power consumption, Compatible with Arduino IDE
  • ESP32 is a safe, reliable, and scalable to a variety of applications
Comparison Memory-mapped I/O Port-mapped I/O
Address space A device resource occupies a range in the CPU memory address space. Device ports occupy a separate I/O address space.
Example access Linux drivers can use readl() and writel() after mapping. The historical x86 80386 reference describes memory-reference instructions for MMIO. Linux provides helpers such as inb() and outb(). The x86 80386 reference describes dedicated IN and OUT instructions.
Main concern Map the resource correctly and follow the device’s access-width, ordering, and completion requirements. Use the separate port-access mechanism supported by the platform.

The Linux device-I/O documentation says port space may be smaller and often slower than memory-mapped addresses, while requiring no preparation like ioremap() for port-space access in that Linux API. This is a general comparison in Linux documentation, not a performance guarantee for every system. The Intel 80386 programmer reference is a historical x86 example, not a description of every current processor.

Why MMIO is not ordinary RAM

A device register may trigger an action when read or written, and device memory can have specific rules for access width, alignment, ordering, caching, and completion. Do not assume that a memory operation behaves as it would on ordinary RAM.

Rank #2
ESP-WROOM-32 ESP32 ESP-32S Development Board 2.4GHz Dual-Mode WiFi + Bluetooth Dual Cores Microcontroller Processor Integrated with Antenna RF AMP Filter AP STA Compatible with Arduino IDE (1 PCS)
  • 2.4GHz Dual Mode WiFi + Bluetooth Development Board
  • Support LWIP protocol, Freertos;ESP32 is a safe, reliable, and scalable to a variety of applications
  • SupportThree Modes: AP, STA, and AP+STA
  • Ultra-Low power consumption, Compatible with Arduino IDE
  • 1PCS 30Pin ESP32 Development Board 2.4GHz WiFi Dual Cores Microcontroller Integrated with Antenna RF Low Noise Amplifiers Filters
  • Use I/O-aware accessors. Linux documents accessors such as readl() and writel() for mapped device addresses. Generic memcpy() and memset() are not guaranteed to copy to I/O addresses in order; Linux provides memcpy_toio(), memcpy_fromio(), and memset_io() for applicable cases.
  • Check alignment and access width. Requirements vary by platform. Misaligned accesses can cause exceptions or unpredictable results.
  • Account for asynchronous writes. A bus can post a write, so the write may not have reached the device when the CPU continues. Linux notes that a driver needing to establish that a PCI write arrived may need to read from the same device.

Linux’s accessor guarantees do not mean every bus write completes immediately, and mappings do not all share identical caching behavior. Follow the operating system’s documentation and the device’s requirements rather than applying a blanket rule.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

MMIO is different from memory-mapped files

Memory-mapped device I/O concerns addresses used to access hardware. Memory-mapped file I/O instead associates file contents with part of a process’s virtual address space so a program can access the file through that view. Microsoft Learn describes the separate file-mapping facility in its file mapping documentation, last updated January 7, 2021. The shared word “mapped” does not make the two mechanisms equivalent.

Quick Recap

Bestseller No. 1
ESP-WROOM-32 ESP32 ESP-32S Development Board 2.4GHz Dual-Mode WiFi + Bluetooth Dual Cores Microcontroller Processor Integrated with Antenna RF AMP Filter AP STA Compatible with Arduino IDE (3PCS)
ESP-WROOM-32 ESP32 ESP-32S Development Board 2.4GHz Dual-Mode WiFi + Bluetooth Dual Cores Microcontroller Processor Integrated with Antenna RF AMP Filter AP STA Compatible with Arduino IDE (3PCS)
2.4GHz Dual Mode WiFi + Bluetooth Development Board; Support LWIP protocol, Freertos; SupportThree Modes: AP, STA, and AP+STA
$16.99
Bestseller No. 4
STM32 Nucleo Development Board with STM32F446RE MCU NUCLEO-F446RE
STM32 Nucleo Development Board with STM32F446RE MCU NUCLEO-F446RE
On-board ST-LINK/V2-1 debugger/programmer with SWD connector; Can be powered from USB; Three LEDs, Two Push-buttons
$33.11
Best Value
With Pre-Soldered Header Raspberry Pi Pico Microcontroller Development Board Based on Raspberry Pi RP2040 Chip,Dual-Core ARM Cortex M0+ Processor
  • with pre-soldered header Raspberry Pi Pico. RP2040 microcontroller chip designed by Raspberry Pi in the United Kingdom
  • Dual-core Arm Cortex M0+ processor, flexible clock running up to 133 MHz. 264KB of SRAM, and 2MB of on-board Flash memory.
  • Castellated module allows soldering direct to carrier boards. USB 1.1 with device and host support. Low-power sleep and dormant modes. Drag-and-drop programming using mass storage over USB. 26 × multi-function GPIO pins.
  • 2 × SPI, 2 × I2C, 2 × UART, 3 × 12-bit ADC, 16 × controllable PWM channels.Accurate clock and timer on-chip.Temperature sensor.
  • Accelerated floating-point libraries on-chip.8 × Programmable I/O (PIO) state machines for custom peripheral support
Rank #4
STM32 Nucleo Development Board with STM32F446RE MCU NUCLEO-F446RE
  • High-performance foundation line, ARM Cortex-M4 core with DSP and FPU, 512 Kbytes Flash, 180 MHz CPU, ART Accelerator, Dual QSPI
  • On-board ST-LINK/V2-1 debugger/programmer with SWD connector
  • Can be powered from USB
  • Three LEDs, Two Push-buttons
  • Support of wide choice of Integrated Development Environments (IDEs) including IAR, ARM Keil, GCC-based IDEs
Rank #3
ELEGOO ESP-32 Super Starter Kit with Tutorial Compatible with Arduino IDE
  • Powerful ESP-32 Board: Unlock the world of Internet of Things (IoT) and advanced electronics with the heart of this kit: the ESP-32 board. It features a powerful dual-core processor, integrated Wi-Fi and Bluetooth 4.2, making it perfect for building connected, smart devices that communicate with your phone or the cloud. It's fully compatible with the Arduino IDE for easy programming.
  • Super Starter Kit: This kit contains over 35 different modules and electronic components, including sensors, displays, motors, and input devices. From LEDs and buttons to an OLED screen, servo motor, and keypad, you have everything needed to explore a vast range of projects in one box.
  • Step by Step Online Tutorial: Jump right in with our detailed, beginner-friendly tutorial. Access 30+ projects with complete code, clear circuit diagrams, and step-by-step instructions. Learn the fundamentals of electronics, coding, and how to utilize the ESP-32's unique capabilities without any prior experience.
  • Hands-on Learning for All Skill Levels: Perfect for students, makers, engineers, and hobbyists. Start with basic circuits and coding, then progress to intermediate and advanced IoT applications. Build practical projects like weather stations, smart home controllers, remote-controlled devices, and interactive gadgets. The skills you learn are the foundation for real-world innovation.
  • Quality & Great Support: Elegoo is committed to quality. We provide a clear, detailed tutorial guide, refined code, and a well-organized component kit. All modules are carefully selected for reliability and ease of use. Our dedicated technical support team and active online community are ready to help you succeed in your learning journey.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.