Skip to content

Commit 476ef1f

Browse files
authored
Added Event Recorder information to work_with_examples.md (#83)
1 parent 57189dc commit 476ef1f

File tree

2 files changed

+93
-30
lines changed

2 files changed

+93
-30
lines changed

Documentation/Doxygen/General/src/work_with_examples.md

Lines changed: 87 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ For a detailed list of available examples and their detailed description, see th
1818

1919
This chapter gives a generic overview on how to access, configure and build an MDK-Middleware example project for your target hardware.
2020

21-
## Using VS Code
21+
## Using VS Code {#using-vs-code}
2222

2323
This section explains how to use MDK-Middleware with the [Arm CMSIS Solution](https://marketplace.visualstudio.com/items?itemName=Arm.cmsis-csolution) for VS Code. This extension is for example part of [Keil Studio](https://www.keil.arm.com/).
2424

@@ -107,6 +107,59 @@ Use the VS Code menu command **Terminal - Run Task...** to Start uVision. uVisi
107107

108108
Refer to [Application Note 320: Using Event Recorder for debugging a network performance issue](https://developer.arm.com/documentation/kan320/latest/) for an tutorial on how to analyze MDK-Middleware issues.
109109

110+
### Configure for Debugging
111+
112+
The MDK-Middleware components have extensive debug capabilities. For example, the Network component offers [debug output via STDOUT (printf) and/or annotations for the Event Recorder](../Network/create_app.html#nw_debugging). Each component has therefore a section **Create Applications » Debugging**. These debug features are today fully supported by the uVision Debugger.
113+
114+
By default, the MDK-Middleware examples are not configured for debugging. The steps below explain how to add these debug capablities.
115+
116+
**Enable Event Recorder:**
117+
118+
To Event Recorder functionality is provided by the pack `ARM::CMSIS-View`. Add this pack and the related software component to the `cproject.yml` file:
119+
120+
```yml
121+
packs:
122+
- pack: ARM::CMSIS-View
123+
:
124+
components:
125+
- component: ARM::CMSIS-View:Event Recorder&DAP
126+
```
127+
128+
- Each MDK Middleware component has options to [enable Debug via Event Recorder](../Network/create_app.html#nw_debugging) in the `<component>_Debug.h` (for example `Network_Debug.h`) configuration file.
129+
130+
- Initialize and start the [Event Recorder](https://arm-software.github.io/CMSIS-View/latest/evr.html). When using RTX this can be configured in the file [`RTX_Config.h`](https://arm-software.github.io/CMSIS-RTX/latest/config_rtx5.html#evtrecConfig).
131+
132+
### Redirect STDOUT to Event Recorder
133+
134+
The board layers may configure STDOUT to a UART port. In some cases, it might be desired to [redirect printf output to the Event Recorder](https://arm-software.github.io/CMSIS-View/latest/er_use.html#printf_redirect).
135+
136+
**Disable "Custom" Output:**
137+
138+
Remove the following components and the related file `retarget_stdio.c` in the `*.clayer.yml` or `*.cproject.yml` file.
139+
140+
```yml
141+
# - component: CMSIS-Compiler:STDERR:Custom
142+
# - component: CMSIS-Compiler:STDOUT:Custom
143+
# - component: CMSIS-Compiler:STDIN:Custom
144+
145+
# - file: ./retarget_stdio.c
146+
```
147+
148+
In the source code of the application (usually in the file `main.c`) remove the call to `stdio_init()`.
149+
150+
Add the pack `ARM::CMSIS-Compiler` and the related components to the file `*.clayer.yml` or `*.cproject.yml` as shown below.
151+
152+
```yml
153+
packs:
154+
- pack: ARM::CMSIS-Compiler
155+
:
156+
components:
157+
- component: CMSIS-Compiler:STDERR:Event Recorder
158+
- component: CMSIS-Compiler:STDOUT:Event Recorder
159+
```
160+
161+
Refer to [CMSIS-Compiler](https://arm-software.github.io/CMSIS-Compiler/latest/index.html) for more information about I/O retargeting.
162+
110163
## Using uVision IDE
111164

112165
The [uVision v5.41](https://www.keil.arm.com/mdk-community/) IDE or higher allows to directly work with *csolution projects*. Source code can be modified, build commands can be executed, and after configuration the [uVision Debugger](https://developer.arm.com/documentation/101407/0541/Debugging) can be used. Adding files or software components is possible by modifying the *csolution project yml files*. It is not directly supported with a user interface.
@@ -115,38 +168,36 @@ The [uVision v5.41](https://www.keil.arm.com/mdk-community/) IDE or higher allow
115168

116169
### Create a native uVision Project
117170

118-
As uVision IDE is easy-to-use and powerful many developers want to use this IDE for productive software development. The MDK-Middleware Reference Applications can be recreated as clean, native uVision project by following the steps listed below, once configured with a compatible board layer. Such a board layer can be copied from an existing working csolution project in VS Code by following the section [Using VS Code](https://arm-software.github.io/MDK-Middleware/latest/General/working_with_examples.html#autotoc_md1) above, or from an exisitng BSP pack that contains a board layer.
171+
As uVision IDE is easy-to-use and powerful many developers want to use this IDE for productive software development. The MDK-Middleware Reference Applications can be recreated as clean, native uVision project by following the steps listed below, once configured with a compatible board layer. Such a board layer can be copied from an existing working csolution project in VS Code by following the section [Using VS Code](#using-vs-code) above, or from an existing BSP pack that contains a board layer.
119172

120173
1. Create a new folder and copy the source files of the MDK-Middleware Reference Application and the software layer, e.g. the board layer. It is recommended to keep the folder structure. In this new folder create a new uVision project for the selected target device.
121174
2. Add source files and software components listed in the `*.cproject.yml` of the MDK-Middleware Reference Application and `*.clayer.yml`
122175
of the software layer e.g. the board layer into the new µVision project using the uVision dialogs.
123176
3. Copy the existing Run-Time-Environment (RTE) configuration files as well as the board layer files to the correct subdirectory of the new uVision project.
124177
4. Configure tool settings using the uVision *Options for Target* dialogs and add linker script.
125178

179+
**These steps are described in more detail below.**
126180

181+
MDK-Middleware Reference Applications contain a collection of projects. The steps below are exemplified on the USB Device HID project.
127182

128-
**These steps are described in more detail below.**
183+
The tables contain two different use cases:
129184

130-
MDK-Middleware Reference Applications contain a collection of projects. Taking the USB Device HID project from the MDK-Middleware Reference Applications as an example. Case 1 represents the case with an existing csolution project created in VS Code by following the section [Using VS Code](https://arm-software.github.io/MDK-Middleware/latest/General/working_with_examples.html#autotoc_md1) above. Case 2 represents the case without an existing csolution project when copying from the Examples subfolder of the MDK-Middleware pack v8.x as well as from a BSP pack containing the board layer.
185+
- **From csolution project**: assumes that a working csolution project is created [Using VS Code](#using-vs-code).
186+
187+
- **From packs**: assumes that the user has located the source code of the packs. The term BSP refers to the Board Support Pack. The BSP may have different folder structure, typically `./Layers/Default/` contains board layer files.
131188

132189
#### Create new Project Folder
133190

134-
Create a new folder for the µVision project and copy the source files from the MDK-Middleware Reference Application.
135-
191+
Create a new folder for the µVision project and copy the source files from the MDK-Middleware Reference Application.
136192

137-
Case 1: from csolution project | copy to new uVision project folder | Notes
193+
From csolution project | Copy to new uVision project folder | Notes
138194
:------------------------------|:-------------------------------------|:------
139195
`./HID` | `<MyFolder>/HID` | Only copy content from the root directory without subfolders
140196
`./Board/<board_name>` | `<MyFolder>/Board/<board_name>` | Only copy source files (`*.c` and `*.h`) from the root directory without subfolders
141-
142-
Case 2: from packs | copy to new uVision project folder | Notes
143-
:------------------------------|:-------------------------------------|:------
197+
. | . | .
198+
**From packs** | **copy to new uVision project folder** | **Notes**
144199
`./Examples/USB/Device/HID` from MDK-Middleware pack| `<MyFolder>/HID`| Only copy content from the root directory without subfolders
145-
`./Layers/Default/` from a BSP pack| `<MyFolder>/Board/<board_name>` | Only copy source files (`*.c` and `*.h`) from the root directory without subfolders
146-
147-
> **Note:**
148-
>
149-
> - Different BSP pack may have different folder struture other than `./Layers/Default/` that contains board layer files.
200+
`./Layers/.../` from BSP pack| `<MyFolder>/Board/<board_name>` | Only copy source files (`*.c` and `*.h`) from the root directory without subfolders
150201

151202
From the uVision menu use *Project - New uVision Project...* dialog to select the device that you are using and create a new µVision project.
152203

@@ -166,22 +217,20 @@ The `*.cproject.yml` of the reference application and `*.clayer.yml` of the soft
166217

167218
The RTE configuration files and generator files (for STM32CubeMX or MCUXpresso Config) are fully compatible with uVision. Follow the table below to copy these configuration files to the µVision project folder
168219

169-
Case 1: from csolution project | copy to new uVision project folder | Notes
220+
From csolution project | copy to new uVision project folder | Notes
170221
:--------------------------------|:-----------------------------------------|:------------
171-
`./HID/RTE` | `<MyFolder>/RTE` | Only copy component folders excluding folders that start with `_`
172-
`./Board/<board_name>/RTE` | `<MyFolder>/RTE` | Only copy component folders excluding folders that start with `_`
222+
`./HID/RTE` | `<MyFolder>/RTE` | Only copy component folders excluding folders that start with `_`
223+
`./Board/<board_name>/RTE` | `<MyFolder>/RTE` | Only copy component folders excluding folders that start with `_`
173224
`./Board/<board_name/CubeMX>` | `<MyFolder>/STM32CubeMX/<uVision_target_name>` | Rename the `*.cgen.yml` file
174-
175-
Case 2: from packs | copy to new uVision project folder | Notes
176-
:--------------------|:-----------------------------------------|:------------
225+
. | . | .
226+
**From packs** | **copy to new uVision project folder** | **Notes**
177227
`./Examples/USB/Device/HID/RTE` from MDK-Middleware pack| `<MyFolder>/RTE` | Only copy component folders excluding folders that start with `_`
178-
`./Layers/Default/RTE` from a BSP pack | `<MyFolder>/RTE` | Only copy component folders excluding folders that start with `_`
179-
`./Layers/Default/CubeMX` from a BSP pack | `<MyFolder>/STM32CubeMX/<uVision_target_name>` | Rename the `*.cgen.yml` file
228+
`./Layers/Default/RTE` from BSP pack | `<MyFolder>/RTE` | Only copy component folders excluding folders that start with `_`
229+
`./Layers/Default/CubeMX` from BSP pack | `<MyFolder>/STM32CubeMX/<uVision_target_name>` | Rename the `*.cgen.yml` file (see note below)
180230

181231
> **Note:**
182232
>
183233
> - The `*.cgen.yml` file copied from the existing csoution project or from the BSP pack must be renamed to match your µVision project name, i.e. `<MyProject>.cgen.yml`.
184-
> - Different BSP pack may have different folder struture other than `./Layers/Default/` that contains board layer files.
185234

186235
#### Configure Tool Settings
187236

@@ -195,17 +244,25 @@ In the Case 1 the compiler toolchain relevant settings of the *csolution project
195244

196245
![Typical Compiler Options Settings](Options-C.png)
197246

198-
- *Linker*: Configure Scatter File and adjust warnings.
199-
- In the Case 1 with an existing csolution project, a read-to-use linker scatter file that has already been preprocessed by CMSIS-Toolbox in VS Code, typically located in `.\tmp\1\ac6_linker_script.sct`, should be copied to `<MyFolder>/Board/<board_name>` . In the Case 2 without an existing csolution project, since the native uVision project manager does not offer the same [linker script management](https://github.com/Open-CMSIS-Pack/cmsis-toolbox/blob/main/docs/build-overview.md#linker-script-management) as a csoution project in VS Code IDE. follow these steps to configure a scatter file in µVision.
200-
1. Copy Linker Script Templates file e.g. `ac6_linker_script.sct.src` from the directory <cmsis-toolbox-installation-dir>/etc of the CMSIS-Toolbox or from the RTE directory of the BSP pack, such as `./Layers/Default/RTE`, to `<MyFolder>/Board/<board_name>`.
201-
2. Copy the memory regions header file e.g. regions_xxx.h from the same RTE directory of the BSP pack to `<MyFolder>/Board/<board_name>`.
202-
3. Add C preprocessor, such as `#! armclang --target=arm-arm-none-eabi -march=armv7-m -E -x c`, as the first line of `ac6_linker_script.sct.src`
203-
4. Add `#include "regions_xxx.h"` as the second line to `ac6_linker_script.sct.src`
247+
- *Linker*: Configure Scatter File and adjust warnings: The native uVision project manager does not offer the same [linker script management](https://github.com/Open-CMSIS-Pack/cmsis-toolbox/blob/main/docs/build-overview.md#linker-script-management) that is available in the CMSIS-Toolbox. Follow these steps to import the linker settings.
248+
- When copying files **from a csolution project**, the preprocessed linker scatter file that is ready-to-use is typically located in `.\tmp\1\ac6_linker_script.sct`. Copy this file to `<MyFolder>/Board/<board_name>` and add it as *Scatter File*.
249+
250+
- Without an existing csolution project, follow these steps to configure a linker scatter file in µVision.
251+
1. Copy the [Linker Script Template](https://github.com/Open-CMSIS-Pack/cmsis-toolbox/blob/main/docs/build-overview.md#linker-script-templates) file `ac6_linker_script.sct.src` from the directory `<cmsis-toolbox-installation-dir>/etc` of the CMSIS-Toolbox.
252+
2. Copy the memory regions header file e.g. regions_xxx.h from the same RTE directory of the BSP pack to `<MyFolder>/Board/<board_name>`.
253+
3. Add at the beginning of the file `ac6_linker_script.sct.src` the following statements to enable the linker integrated C preprocessor:
254+
255+
```c
256+
#! armclang --target=arm-arm-none-eabi -march=armv7-m -E -x c
257+
#include "regions_xxx.h" // defines the memory available to the application
258+
```
259+
204260
- In `cdefault.yml` included in some MDK-Middleware Reference Applications there may be some linker controls that should be reflected in this dialog, for example `--diag_suppress=L6314W`.
205261

206262
![Typical Linker Options Settings](Options-Linker.png)
207263

208264
#### Expand with additional components
265+
209266
Once the new project is created, it may be expanded with additional software components or modified to custom hardware as shown in the picture below. Note that uVision projects have no dependency on specify hardware boards.
210267

211268
![Create new project in uVision](Create-uVision-Project.png)

Documentation/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,9 @@ The software components that are part of this [CMSIS-Pack](https://open-cmsis-pa
2424
## Availability
2525

2626
The MDK-Middleware is available free-of-charge to all users of Arm Cortex-M-based processors. It does not require a specific toolchain or IDE license and can be built with major toolchains, such as Arm Compiler 6, GCC, and LLVM.
27+
28+
## Links
29+
30+
- [Documentation](https://arm-software.github.io/MDK-Middleware/latest/General/index.html)
31+
- [Repository](https://github.com/ARM-software/MDK-Middleware)
32+
- [Issues](https://github.com/ARM-software/MDK-Middleware/issues)

0 commit comments

Comments
 (0)