Skip to content

Create itm.md #413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 22, 2018
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions docs/reference/contributing/target/itm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
### Instrumented Trace Macrocell
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this API have spaces in it, or does it follow the same formatting as the others ("InstrumentedTraceMacrocell")?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the question. Instrumented Trace Macrocell is the name of the module like Low Power Ticker.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have the ResetReason API, which is has no space and both Rs capitalized because we're referring to the class. Is it the same with this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, no. This is a physical component defined in the architecture: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0314h/Chdegecg.html

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marcuschangarm - Looks good, it would be great if you can add that ITM link in the documentation itself. Its not a blocker though, so I'll approve.


For targets with Arm CoreSight (for example, Cortex-M3 and Cortex-M4), the Instrumented Trace Macrocell provides a lightweight, nonintrusive way to collect debug trace output.

#### Assumptions

- The target supports Arm CoreSight.
- The target has SWO connected either to a compatible interface chip or exposed as a debug pin.

##### Defined behavior

- Targets must implement the function `void itm_init(void)` and add `ITM` to the `device_has` section in `target.json`.
- When `void itm_init(void)` is called, the debug clock for the ITM must be initialized and the SWO pin configured for debug output.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Query: Who or what is calling that function? Also, who or what is initializing the debug clock for the ITM and configuring the SWO pin for debug output? You, the user, or something else?

- `void itm_init(void)` only has to modify the clock prescaler in the generic register `TPI->ACPR`. The helper function `mbed_itm_init` initializes the generic ITM registers.
- `void itm_init(void)` is only called once during startup and doesn't have to be protected for multiple calls.

##### Undefined behavior

- The debug clock frequency is left undefined because the most optimal frequency varies from target to target. It is up to each target's owner to choose a frequency that doesn't interfere with normal operation and that the owner's preferred debug monitor supports.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Query: Why are there no notes, dependencies or implementations? Please complete these sections.

#### Testing

You can use the `SerialWireOutput` to send `stdout` to the SWO stimulus port on the ITM by including this override function:

```
#include "SerialWireOutput.h"

FileHandle* mbed::mbed_override_console(int fd) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style update

FileHandle *mbed::mbed_override_console(int fd)
{
}

static SerialWireOutput swo;
return &swo;
}
```

You can place the function in any C++ compilation unit, including `main.cpp`.