Difference between revisions of "MTB specifics"
Line 25: | Line 25: | ||
|- |
|- |
||
|MTB_MASTER.MASK |
|MTB_MASTER.MASK |
||
− | |5-bit bitfield that specifies the wrap-around point for the auto-inc logic of the MTB, on packet store |
+ | |5-bit bitfield that specifies the wrap-around point for the auto-inc logic of the MTB, on packet store. |
|} |
|} |
||
While the MTB_BASE register is read-only for J-Link, the MTB_POINTER and MTB_MASTER.MASK can be written by J-Link. This allows the MTB RAM usage to be configured. |
While the MTB_BASE register is read-only for J-Link, the MTB_POINTER and MTB_MASTER.MASK can be written by J-Link. This allows the MTB RAM usage to be configured. |
||
+ | |||
+ | == MTB_MASTER.MASK bit field == |
||
+ | Specifies the wrap-around point for the auto-inc logic of the MTB, on packet store. MASK specifies the MSB that exists in the buffer. A MASK Value of 7 means that bits 0-7 exist in the buffer, which means a max. value (buffer size) of 0xFF + 1 = 0x100. If the increment causes POINTER[MASK:MASK] to change from 1 to 0, POINTER[MASK:0] will be changed to 0, while leaving the rest of POINTER untouched(!). The MASK value is stored as MASK - 4 because the MTB buffer size has to be a multiple of 16 bytes anyhow. |
||
+ | |||
+ | Example calculation: |
||
+ | * 1 KB of RAM shall be used |
||
+ | * 1 KB = 0x400 (MSB == bit 10, counting starts at bit 0) |
||
+ | * MASK = 9 (Stored in register as: 10 - 4 = 6) |
||
+ | * Buffer usage: 0x0 - 0x3FF |
||
== Default J-Link config == |
== Default J-Link config == |
||
Line 34: | Line 43: | ||
# J-Link sets the POINTER register to 0 to start using the MTB buffer at MTB_BASE |
# J-Link sets the POINTER register to 0 to start using the MTB buffer at MTB_BASE |
||
# J-Link sets the MTB_MASTER.MASK to 4 to provide a 512 byte wrap-around (setting the RAM usage to 512 bytes, starting at MTB_BASE) |
# J-Link sets the MTB_MASTER.MASK to 4 to provide a 512 byte wrap-around (setting the RAM usage to 512 bytes, starting at MTB_BASE) |
||
+ | |||
+ | == Command strings for MTB configuration == |
||
+ | The following J-Link command strings are available for MTB configuration: |
||
+ | {| class="wikitable" |
||
+ | !Register / Bit field |
||
+ | !Min. J-Link software version |
||
+ | !Description |
||
+ | |- |
||
+ | |hhh |
||
+ | |hhh |
||
+ | |hhh |
||
+ | |- |
||
+ | |hhh |
||
+ | |hhh |
||
+ | |hhh |
||
+ | |- |
||
+ | |hhh |
||
+ | |hhh |
||
+ | |hhh |
||
+ | |} |
||
+ | |||
+ | |||
+ | == Example configurations == |
||
+ | TBD |
Revision as of 14:26, 9 July 2018
Contents
The ARM Micro Trace Buffer (MTB) is an on-chip trace buffer that allows to do post-mortem instruction trace via a regular J-Link with no need of a specific J-Trace unit. The MTB will use a specific amount of the on-chip RAM to store trace data while the core executes instructions. MTB is mainly used on smaller MCUs like Cortex-M0+/M23/M33 based ones.
Limitations
MTB is a very limited version of trace that has the following limitations:
- Instruction trace support only
- No streaming trace possible
- A portion of the target RAM may not be used by the application if MTB is used
RAM usage
Most MTBs have a trace buffer between 2 KB and 8 KB. By default, J-Link uses 512 bytes for MTB, starting at the MTB_BASE addr.
Configuration options provided by J-Link
An MTB consists of the following registers / bit fields that allow configuration of the MTB and the amount of RAM it uses:
Register / Bit field | Description |
---|---|
MTB_BASE | 32-bit register that specifies the base address of the MTB buffer |
MTB_POINTER | 32-bit register that specifies the offset (rel. to BASE) where the next trace packet will be stored by the HW |
MTB_MASTER.MASK | 5-bit bitfield that specifies the wrap-around point for the auto-inc logic of the MTB, on packet store. |
While the MTB_BASE register is read-only for J-Link, the MTB_POINTER and MTB_MASTER.MASK can be written by J-Link. This allows the MTB RAM usage to be configured.
MTB_MASTER.MASK bit field
Specifies the wrap-around point for the auto-inc logic of the MTB, on packet store. MASK specifies the MSB that exists in the buffer. A MASK Value of 7 means that bits 0-7 exist in the buffer, which means a max. value (buffer size) of 0xFF + 1 = 0x100. If the increment causes POINTER[MASK:MASK] to change from 1 to 0, POINTER[MASK:0] will be changed to 0, while leaving the rest of POINTER untouched(!). The MASK value is stored as MASK - 4 because the MTB buffer size has to be a multiple of 16 bytes anyhow.
Example calculation:
- 1 KB of RAM shall be used
- 1 KB = 0x400 (MSB == bit 10, counting starts at bit 0)
- MASK = 9 (Stored in register as: 10 - 4 = 6)
- Buffer usage: 0x0 - 0x3FF
Default J-Link config
- J-Link reads out MTB_BASE to determine the base addr. of the MTB buffer
- J-Link writes the POINTER register to find out the MTB buffer size
- J-Link sets the POINTER register to 0 to start using the MTB buffer at MTB_BASE
- J-Link sets the MTB_MASTER.MASK to 4 to provide a 512 byte wrap-around (setting the RAM usage to 512 bytes, starting at MTB_BASE)
Command strings for MTB configuration
The following J-Link command strings are available for MTB configuration:
Register / Bit field | Min. J-Link software version | Description |
---|---|---|
hhh | hhh | hhh |
hhh | hhh | hhh |
hhh | hhh | hhh |
Example configurations
TBD