You are viewing an older revision! See the latest version

Memory Model

Table of Contents

  1. Memory Model

Memory Model

This is a basic overview of the memory model of the mbed, with a focus on how RAM is used. Please note that for the purposes of this discussion, I am conveniently forgetting about the special RAM blocks used for USB, CAN and Ethernet etc., and the memory mapped peripheral space. For a more detailed breakdown, have a look at the User Manual for the processor in your mbed NXP LPC1768 User Manual, NXP LPC2368 User Manual

The Sections

The information in your program is made up of several sorts:

  • Executable code
  • Constants and other read-only data
  • Initialised static and global variables
  • Uninitialised static and global variables
  • Local variables
  • Dynamically created data

Each of these groups of information get allocated to a region of the memory space called a section. The executable code, constants and other read-only data get put in a section called "RO" (for read-only), which is stored in the flash memory of the device. Initialised static and global variables go into a section called "RW" (read-write), and the unitialised ones in to one called "ZI" (Zero Initialise). I'll come on to the local and dynamic data in a bit, but these along with RW and ZI need to live in RAM.

On reset, RAM is an undefined state. However, those initialised variables have to have some data in, for your program to work correctly. What happens is that when you compile your program, a data block with all these variables with their initialised values is defined, and put into the image that you program into the flash. When the mbed starts excuting code, one of the first things it does is copy this data block into the beginning of RAM, and this becomes the runtime RW section. One of the other things it does is to zero fill the next section of RAM, which is where the ZI section lives.


All wikipages