CrossStudio memory map files are structured using XML syntax to enable simple construction and parsing.
The first entry of the project file defines the XML document type which is used to validate the file format.
<!DOCTYPE Board_Memory_Definition_File>
The next entry is the Root element; there can only be one Root element in a memory map file.
<Root name="My Board" >
A Root element has a name attribute - every element in a memory map file has a name attributes. Names should be unique within a hierarchy level. Within a Root element there are MemorySegment elements which represent memory regions within the memory map.
<Root name="My Board" > <MemorySegment name="Flash" start="0x1000" size="0x200" access="ReadOnly" >
MemorySegment elements have the following attributes.
- start The start address of the memory segment. A 0x prefixed hexadecimal number.
- size The size of the memory segment. A 0x prefixed hexadecimal number.
- access The permissable access types of the memory segment. One of ReadOnly, Read/Write, WriteOnly, None.
- address_symbol A symbolic name for the start address.
- size_symbol A symbolic name for the size.
A MemorySegment can contain Register and RegisterGroup elements. RegisterGroup elements are used to group sets of registers. Register elements are used to define peripheral registers.
<Root name="My Board" > <MemorySegment name="System" start="0x2000" size="0x200" > <RegisterGroup name="Peripheral1" start="0x2100" size="0x10" > <Register name="Register1" start="+0x8" size="4" >
Register group elements have the same attributes as MemorySegment elements. Register elements have the following attributes.
- name Register names should be valid C/C++ identifier names i.e. alphanumeric and underscores but not starting with a number.
- start The start address of the memory segment. Either a 0x prefixed hexadecimal number or a + prefixed offset from the enclosing element's start address.
- size The size of the register in bytes - either 1, 2 or 4.
- access The same as the MemorySegment element.
- address_symbol The same as the MemorySegment element.
A Register element can contain BitField elements that represent bits within a peripheral register.
<Root name="My Board" > <MemorySegment name="System" start="0x2000" size="0x200" > <RegisterGroup name="Peripheral1" start="0x2100" size="0x10" > <Register name="Register1" start="+0x8" size="4" > <BitField name="Bits_0_to_3" start="0" size="4" />
BitField elements have the following attributes.
- name BitFields names should be valid C/C++ identifier names i.e. alphanumeric and underscores but not starting with a number.
- start The starting bit position 0-31.
- size The number of bits 1-31.
You can refer to other memory map files using the Import element.
<Root name="My Board" > <MemorySegment name="External SRAM" start="0x3000" size="0x200" access="ReadOnly" > <Import filename="$(StudioDir)/targets/Manufacturer1/Processor1.xml" />
The filename attribute is an absolute filename which is macro expanded using CrossWorks system macros. An imported memory map file must be an XML file (without a DOCTYPE). The Processor element can be used to group several MemorySegment elements for this purpose.
<Processor name="Processor1" > <MemorySegment name="Internal SRAM" start="0x1000" size="0x200" access="ReadOnly" > <MemorySegment name="System" start="0x2000" size="0x200" >