Memory accesses

From SEGGER Wiki
Revision as of 10:50, 23 July 2019 by Leon (talk | contribs) (Memory access map)
Jump to: navigation, search

Modes when accessing memory while CPU is running

Memory on the target device can be accessed in different modes. Some modes are not available on all devices. The modes only matter in case a memory access is performed while the target CPU is running.

Memory can be accessed in the following modes:

  • Background mode
  • Stop mode
  • Legacy stop mode

Background mode

In this mode, J-Link can access the memory of the target system while the MCU + application keeps running (background memory access), effectively not impacting the real time behavior of the application.

Cores with background mode support

  • Cortex-M based devices (all cores from the series)
  • Renesas RX based devices (all cores from the series)

J-Links with background mode support

  • All that support the cores listed above. More...

Stop mode

In this mode, J-Link temporarily halts the CPU (interrupts the execution of the target application) to access the memory and continues operation automatically after the memory access is done. The actual impact (halted time) on the real time behavior depends on the setup (target interface speed used, target interface used, length of JTAG chain, actual core that is used, ...).

Note: The whole operation (halt + acc + go) is performed inside the J-Link firmware, reducing the halted time of the CPU to a minimum.

In this mode, J-Link temporarily halts the CPU (interrupts the execution of the target application) to access the memory and continues operation automatically after the memory access is done. The actual impact (halted time) on the real time behavior depends on the setup (target interface speed used, target interface used, length of JTAG chain, actual core that is used, ...).

Cores with stop mode support

  • Cortex-A based devices
  • Cortex-R based devices
  • RISC-V based devices

J-Links with stop mode support

Legacy stop mode

In this mode, J-Link temporarily halts the CPU (interrupts the execution of the target application) to access the memory and continues operation automatically after the memory access is done. The actual impact (halted time) on the real time behavior depends on the setup (target interface speed used, target interface used, length of JTAG chain, actual core that is used, ...).

Note: The single operations (halt + acc + go) are triggered from the PC side. This adds significant CPU halt times because there is USB latency between the single operations. The CPU is usually halted for >= 20ms.

Cores with legacy stop mode support

  • All

J-Links with legacy stop mode support

  • All

Memory access map

J-Link can be configured to use different methods of accessing memory depending on the address range and if the core is halted or running.
The memory access map to be used by J-Link can be set by passing the path to an .xml file using the following J-Link command string:

JLinkMemAccMapXMLPath = <PathToFile>

Note: When passing a file path, be sure to encapsulate it in quotation marks (") if the path contains one ore more spaces.

The XML file is expected to have the following structure:

 <MemMap>
   <CoreRunning>
     <Range ...>
     <!-- [...] -->
   </CoreRunning>
   <CoreHalted>
     <Range ...>
     <!-- [...] -->
   </CoreHalted>
 </MemMap>

Between the <CoreRunning> tags, ranges can be defined that determine the memory access method J-Link should use when the core is running. Between the <CoreHalted> tags, ranges can be defined that determine the memory access method J-Link should use when the core is halted.

Each range consists of a <Range> tag with the attributes Start, Size and Zone.

  • Start defines the start address of the memory range (e.g "0x1FFF0000")
  • Size defines the size of the memory range in bytes (e.g. "0x400")
  • Zone defines the memory access method J-Link shoud use for that range (e.g. "AHB-AP (AP0)")

Example:

 <MemMap>
   <!-- When using AHB-AP accesses it is like a DMA accesses the memory. -->
   <!-- This means that this bypasses any MMU settings and will access the physical address, -->
   <!-- while "Default" goes through the CPU and sees the same as the core -->
   <CoreRunning>
     <Range Start="0x00000000" Size="0x100" Zone="AHB-AP (AP0)"/>
     <Range Start="0x00000100" Size="0x300" Zone="Default"/>
   </CoreRunning>
   <CoreHalted>
     <Range Start="0x00000000" Size="0x400" Zone="AHB-AP (AP0)"/>
   </CoreHalted>
 </MemMap>