Skip to content

Commit 122a6e8

Browse files
Added multicore, CPU Time; other corrections (#489)
* Added multicore, CPU Time, and workaround for issue #159. Several minor corrections * Added Note for issue #374 --------- Co-authored-by: Jens Reinecke <jens.reinecke@arm.com>
1 parent a5a7c71 commit 122a6e8

6 files changed

Lines changed: 88 additions & 95 deletions

File tree

README.md

Lines changed: 88 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
The Arm® CMSIS Debugger extension pack is a comprehensive debug platform for Arm Cortex-M processor-based devices that uses the GDB/MI protocol.
88

9-
- Supports single and multi-core processor systems.
9+
- Supports single and [multi-core](#multi-core-debug) processor systems.
1010
- Built-in RTOS kernel support for FreeRTOS, RTX, ThreadX, and Zephyr.
1111
- Wide debug adapter support for CMSIS-DAP (ULink, MCULink, NuLink, etc.), JLink, and ST-Link.
1212
- Can be combined with other VS Code debug extensions, such as those for Linux application debugging.
@@ -33,6 +33,7 @@ To start debugging, the CMSIS Solution offers action buttons and menu commands.
3333

3434
- **Load & Debug application** starts the CMSIS Debugger with _launch_ configuration.
3535
- **Load & Run application** starts program execution and the GDB server; use then _attach_ configurations to connect to the running system.
36+
- **Target Information** (...) shows the available debugger adapters.
3637

3738
## Debugger User Interface
3839

@@ -56,12 +57,14 @@ The **Run and Debug** view provides:
5657
> **TIP**<br>
5758
> Click on a _line number badge_ to navigate to the source code line.
5859
59-
Other debugger-specific views:
60+
Other debugger specific views or features:
6061

61-
- [**Disassembly**](#disassembly) shows assembly instructions and supports run control, for example, with stepping and breakpoints.
62+
- [**Disassembly**](#disassembly) shows assembly instructions and supports run control, for example with stepping and breakpoints.
6263
- [**Debug Console**](#debug-console) lists debug output messages and allows entering expressions or GDB commands.
6364
- [**Peripherals**](#peripherals) show the device peripheral registers and allow changing their values.
6465
- [**Serial Monitor**](#serial-monitor) uses serial or TCP communication to interact with application I/O functions (`printf`, `getc`, etc.).
66+
- [**CPU Time**](#cpu-time) shows execution timing and statistics of the past five breakpoints.
67+
- [**Multi-Core Debug**](#multi-core-debug) to view and control several processors in a device.
6568

6669
### Debug toolbar
6770

@@ -74,9 +77,9 @@ During debugging, the **Debug toolbar** contains actions to control the flow of
7477
| Continue/Pause | **Continue**: Resume normal program execution (up to the next breakpoint).<br>**Pause**: Inspect code executing at the current location. |
7578
| Step Over | Execute the next statement as a single command without inspecting or following its component steps. |
7679
| Step Into | Enter the next statement to follow its execution line-by-line. |
77-
| Step Out | When inside a function, return to the earlier execution context by completing the remaining lines of the current method as though it were a single command. |
80+
| Step Out | When inside a function, return to the earlier execution context by completing remaining lines of the current method as though it were a single command. |
7881
| Restart | Terminate the current program execution and start debugging again using the current run configuration. |
79-
| Stop/Disconnect | **Stop**: Terminate the current debug session.<br>**Disconnect:** Detach debugger from a core without changing the execution status (running/paused). |
82+
| Stop/Disconnect | **Stop**: Terminate the current debug session.<br>**Disconnect:** Detach debugger from a core without changing the execution status (running/pause). |
8083
| Debug Session | For multi-core devices, the list of active debug sessions and switch between them. |
8184
| Reset Target | Reset the target device. |
8285

@@ -205,17 +208,62 @@ debug console. Logpoints can help you save time by not having to add or remove l
205208
A logpoint is represented by a diamond-shaped icon. Log messages are plain text, but can also include expressions to be
206209
evaluated within curly braces ('{}').
207210

208-
To add a logpoint, right-click in the editor's left margin and select Add Logpoint, or use the
211+
To add a logpoint, right-click in the editor left margin and select Add Logpoint, or use the
209212
**Debug: Add Logpoint...** command in the Command Palette (**Ctrl/Cmd + Shift + p**).
210213

211214
![Creating a logpoint](https://github.com/Open-CMSIS-Pack/vscode-cmsis-debugger/raw/main/images/create-logpoint.gif)
212215

213216
Just like regular breakpoints, logpoints can be enabled or disabled and can also be controlled by a condition
214217
and/or hit count.
215218

219+
### CPU Time
220+
221+
Most Arm Cortex-M processors (except Cortex-M0/M0+/M23) include a `DWT->CYCCNT` register that counts CPU states. In combination with the CMSIS variable [`SystemCoreClock`](https://arm-software.github.io/CMSIS_6/latest/Core/group__system__init__gr.html) the CMSIS Debugger calculates execution time and displays it along with the selected processor core in the CPU Time Status bar. A click on the CPU Time Status bar opens the related [VS Code command palette](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette).
222+
223+
Command | Description
224+
:--------------|:-------------
225+
CPU Time | Print CPU execution time and history of past program stops.
226+
Reset CPU Time | Reset CPU execution time and history. Set new reference time (zero point).
227+
228+
![CPU Time](images/CPU_Time.png)
229+
230+
> 📝 **Notes:**
231+
> - The first program stop (typically at function `main`) is the initial reference time (zero point).
232+
> - `DWT->CYCCNT` is a 32-bit register incremented with [`SystemCoreClock`](https://arm-software.github.io/CMSIS_6/latest/Core/group__system__init__gr.html) frequency. The time calculation copes with one overflow between program stops. Multiple overflows between program stops deliver wrong time information.
233+
> - Each processor in a multi-processor system has and independent `DWT->CYCCNT` register.
234+
235+
### Multi-Core Debug
236+
237+
A GDB server provides multiple connections to the processor cores (identified with `pname`) of a device. The list below shows the output of pyOCD in the DEBUG CONSOLE of VS Code.
238+
239+
```txt
240+
0000680 I Target device: MCXN947VDF [cbuild_run]
241+
0001585 I core 0: Cortex-M33 r0p4, pname: cm33_core0 [cbuild_run]
242+
0001585 I core 1: Cortex-M33 r0p4, pname: cm33_core1 [cbuild_run]
243+
0001585 I start-pname: cm33_core0 [cbuild_run]
244+
0001600 I Semihost server started on port 4444 (core 0) [server]
245+
0001636 I GDB server started on port 3333 (core 0) [gdbserver]
246+
0001641 I Semihost server started on port 4445 (core 1) [server]
247+
0001642 I GDB server started on port 3334 (core 1) [gdbserver]
248+
0007560 I Client connected to port 3333! [gdbserver]
249+
```
250+
251+
The `start-pname` indicates the processor that starts first and boots the system. A debug *launch* command connects to this processor. Use a debug *attach* command to connect to processors that are running. The picture below highlights the parts of the user interface that interact with processors.
252+
253+
1. Select a processor and **Start Debug**. This connects the debugger.
254+
2. **Select a Processor** in the debug toolbar, or
255+
3. Click in **CALL STACK** on a thread or function name to select a processor.
256+
4. The selected processor is also shown **CPU Time Status bar**. This processor context is used in the VARIABLES or WATCH view.
257+
258+
![Multicore Debug](images/multicore.png)
259+
260+
> 📝 **Notes:**
261+
> - The SEGGER JLink GDB server uses a *launch* command to connect to a running processor whereas other GDB servers use a *attach* command.
262+
> - A [Disassembly View](#disassembly) opens only for a selected processor; otherwise the command is shown as disabled.
263+
216264
### Peripherals
217265

218-
The **Peripherals** view shows the device peripheral registers and allows you to change their values. It uses the CMSIS-SVD files that are provided by silicon vendors and distributed as part of the CMSIS Device Family Packs (DFP).
266+
The **Peripherals** view shows the device peripheral registers and allows to change their values. It uses the CMSIS-SVD files that are provided by silicon vendors and distributed as part of the CMSIS Device Family Packs (DFP).
219267

220268
![Peripheral Inspector](https://github.com/Open-CMSIS-Pack/vscode-cmsis-debugger/raw/main/images/peripheral-inspector.png)
221269

@@ -232,7 +280,7 @@ The **Memory Inspector** provides a powerful and configurable memory viewer that
232280
- Multiple Memory Formats: Shows memory data on hover in multiple formats.
233281
- Edit Memory: Allows in-place memory editing if the debug adapter supports the WriteMemoryRequest.
234282
- Memory Management: Enables saving and restoring memory data for specific address ranges (Intel Hex format).
235-
- Customised Views: Create and customise as many memory views as you need.
283+
- Customized Views: Create and customize as many memory views as you need.
236284
- Lock Views: Keep views static, unaffected by updates from the debug session.
237285
- Periodic Refresh: Automatically refresh the memory data.
238286
- Multiple Debug Sessions: Switch between multiple debug sessions using a dropdown in the memory view.
@@ -248,6 +296,9 @@ The command **Open Disassembly View** (available from [command palette](https://
248296

249297
![Disassembly View](https://github.com/Open-CMSIS-Pack/vscode-cmsis-debugger/raw/main/images/disassembly-view.png)
250298

299+
> 📝 **Note:**
300+
> - Enable the [VS Code setting](https://code.visualstudio.com/docs/configure/settings) **Features > Debug > Disassembly View: Show Source Code** to show assembler instructions interleaved with source code.
301+
251302
### Debug Console
252303

253304
The **Debug Console** enables viewing and interacting with the output of your code running in the debugger.
@@ -283,22 +334,26 @@ for the type `gdbtarget` which comes with the [CDT GDB Debug Adapter Extension](
283334
This provider manages the use of tools shipped with the extension:
284335
- If option `target`>`server` is set to `pyocd`, then it expands to the absolute path of the built-in pyOCD distribution.
285336
- CMSIS specific _launch_ configuration items for the `*` debugger type, i.e. visible for all debugger types.
286-
It depends on the actually used debug adapter type if this information is known and utilised.
287-
288-
> 📝 **Note:**
289-
> The built-in version of pyOCD supports the command line option `--cbuild-run`, which isn't available
290-
> in releases outside this extension.
337+
It depends on the actually used debug adapter type if this information is known and utilized.
291338

292339
## Known Limitations and Workarounds
293340

341+
### Internal Errors on stepping thru code
342+
343+
There is an [chip errata](https://developer.arm.com/documentation/SDEN1068427/latest/) that single stepping on Cortex-M7 r0p1 processors enters the pending exception handler incorrectly which may result in error messages. Check the processor revision that is shown at debug start in the DEBUG CONSOLE.
344+
345+
**Workaround/Solution**:
346+
347+
Some devices allow to stop timer interrupts with control registers. For the example the STM32 devices have `DbgMCU_APB1_Fz` registers. Stop all timers that are active in your application. This can be typially configured in the [`*.dbgconf` file](https://open-cmsis-pack.github.io/cmsis-toolbox/build-overview/#device-configuration) of your project.
348+
294349
### pyOCD fails to load `*.cbuild-run.yml` in the default configuration
295350

296351
When I use the default debug configuration for pyOCD, I get errors that pyOCD cannot find the solutions
297352
`*.cbuild-run.yml` file.
298353

299354
**Possible Reasons**:
300355

301-
1. The application's CMSIS solution was initially built with a CMSIS-Toolbox version prior to v2.8.0, which is
356+
1. The application's CMSIS solution was initially built with a CMSIS-Toolbox version prior to v2.8.0 which is
302357
the first version to generate `*.cbuild-run.yml` files.
303358
1. You are using an [Arm CMSIS Solution](https://marketplace.visualstudio.com/items?itemName=Arm.cmsis-csolution) extension
304359
prior to v1.52.0 which is the first version to fully support the `${command:cmsis-csolution.getCbuildRunFile}` command.
@@ -322,7 +377,7 @@ warning: Loadable section "RW_RAM0" outside of ELF segments
322377
```
323378

324379
**Possible Reason**: `arm-none-eabi-gdb` does not correctly load ELF program segments due to the way that
325-
Arm Compiler 6 generates section and program header information when scatterloading is used.
380+
Arm Compiler 6 generates section and program header information when scatter loading is used.
326381

327382
**Workaround**: You can generate a HEX file for the program download, and the ELF file for debug purposes only.
328383
The following steps are required if you build a [CSolution](https://open-cmsis-pack.github.io/cmsis-toolbox/build-overview/)-based
@@ -371,8 +426,8 @@ warning: (Internal error: pc 0x8006a18 in read in CU, but not in symtab.)
371426
**Possible Reason**: `arm-none-eabi-gdb` works best with DWARF debug information of standard version 5.
372427

373428
**Solution**: Make sure to build your application ELF file with DWARF version 5 debug information. Please refer to
374-
your toolchain's user reference manual. This may require updates to all build tools, like the compiler and assembler.
375-
For example, use `-gdwarf-5` for `armclang`.
429+
your toolchain's user reference manual. This may require updates to all build tools like compiler and assembler.
430+
For example use `-gdwarf-5` for `armclang`.
376431

377432
### Broken debug illusion
378433

@@ -401,12 +456,12 @@ When starting a debug session, you might see this error:
401456

402457
**Possible reason**: A running instance of pyOCD
403458

404-
This error might occur if a previous debug session has ended prematurely and pyOCD has not exited. The orphaned instance
405-
will still keep the port open (usually 3333), and thus you won't be able to open the port again in the new session.
459+
This error might occur if a previous debug session has ended prematuerly and pyOCD has not exited. The orphaned instance
460+
will still keep the port open (usually 3333) and thus you won't be able to open the port again in the new session.
406461

407462
**Solution**: Check open files and kill pyOCD
408463

409-
On Linux and macOS, you can check the running open files using the [`lsof`](https://de.wikipedia.org/wiki/Lsof) command:
464+
On Linux and macOS you can check the running open files using the [`lsof`](https://de.wikipedia.org/wiki/Lsof) command:
410465

411466
```sh
412467
sudo lsof -i -n -P | grep 3333
@@ -426,14 +481,24 @@ On Windows systems, use the
426481
or the [Process Explorer](https://learn.microsoft.com/en-us/sysinternals/downloads/process-explorer) to find orphaned
427482
processes.
428483

484+
## Requirements
485+
486+
- **GDB** supporting the GDB remote protocol. `arm-none-eabi-gdb` is included in CMSIS Debugger extension. To use a different GDB installation, enter the full path/filename to the executable in the `gdb:` node of the `launch.json` file.
487+
488+
- **pyOCD** for connecting to a target. pyOCD is included in CMSIS Debugger extension. To use a different pyOCD installation, enter the full path/filename to the executable in the `target:` `server:` node of the `launch.json` file.
489+
490+
- **SEGGER® J-LINK®** is an alternative GDB server for target connection. Install the latest
491+
[J-LINK Software and Documentation Pack](https://www.segger.com/downloads/jlink/#J-LinkSoftwareAndDocumentationPack)
492+
from [SEGGER](https://www.segger.com/). Ensure all required drivers and host platform-specific settings are done. The extension expects that the `PATH` environment variable is set to the J-Link executables.
493+
429494
## Related projects
430495

431496
Related open source projects are:
432497

433-
- [Open-CMSIS-Pack](https://www.open-cmsis-pack.org/) of which this extension is part.
434-
- [Eclipse® CDT.cloud™](https://eclipse.dev/cdt-cloud/), an open-source project that hosts a number of components and
498+
- The [Open-CMSIS-Pack](https://www.open-cmsis-pack.org/) project includes the CMSIS Debugger extension.
499+
- [Eclipse® CDT.cloud™](https://eclipse.dev/cdt-cloud/) hosts a number of components and
435500
best practices for building customizable web-based C/C++ tools.
436-
- [pyOCD](https://pyocd.io/), a Python-based tool and API for debugging, programming, and exploring Arm Cortex®
501+
- [pyOCD](https://pyocd.io/), a Python based tool and API for debugging, programming, and exploring Arm Cortex®
437502
microcontrollers.
438503
- [GDB](https://www.sourceware.org/gdb/), the debugger of the GNU Project.
439504

@@ -448,75 +513,3 @@ Related open source projects are:
448513
- Node.js is a registered trademark of the OpenJS Foundation.
449514
- GDB and GCC are part of the GNU Project and are maintained by the Free Software Foundation.
450515

451-
-----
452-
453-
## Debug Setup
454-
455-
The debug setup requires a GDB installation supporting the GDB remote protocol and that can connect to a
456-
GDB server like pyOCD.
457-
458-
This extension includes `arm-none-eabi-gdb`, which is used in the Arm CMSIS Debugger default debug configurations.
459-
460-
If you wish to use a different GDB installation, enter the full path to the executable (including the file name)
461-
in the `gdb` setting in the `launch.json` file.
462-
463-
### pyOCD Debug Setup
464-
465-
This extension includes a pyOCD distribution, which is used by default.
466-
467-
If you wish to use a different pyOCD installation, enter the full path to the executable (including the file name)
468-
in the `target`>`server` setting.
469-
470-
### SEGGER® J-LINK® Debug Setup
471-
472-
Install the latest
473-
[J-LINK Software and Documentation Pack](https://www.segger.com/downloads/jlink/#J-LinkSoftwareAndDocumentationPack)
474-
from [SEGGER](https://www.segger.com/). Ensure all required drivers and host platform-specific settings are done.
475-
476-
The extension expects the installation folder to be on your system `PATH` environment variable. Alternatively, update
477-
your debug configuration's `target`>`server` setting to contain the full path to the J-LINK GDB server executable
478-
(including the file name).
479-
480-
## Start Debugging
481-
482-
There are two ways to start a debug session:
483-
484-
1. If you have installed the CMSIS Solution extension, in the **CMSIS view**
485-
![CMSIS view](https://github.com/Open-CMSIS-Pack/vscode-cmsis-debugger/raw/main/images/cmsis-view-icon.png),
486-
click on the **Debug** icon
487-
![Debug icon in the CMSIS view](https://github.com/Open-CMSIS-Pack/vscode-cmsis-debugger/raw/main/images/debug-icon.png).
488-
The configuration for the debugger configured in the active `target-set` is written to the launch.json file and will
489-
be used to start the debug session.
490-
491-
2. In the **Run and debug view**
492-
![Run and debug view](https://github.com/Open-CMSIS-Pack/vscode-cmsis-debugger/raw/main/images/run-debug-view-icon.png),
493-
click the **Play** icon
494-
next to the selected debug connection
495-
![Play button](https://github.com/Open-CMSIS-Pack/vscode-cmsis-debugger/raw/main/images/play-debug-button.png).
496-
The debug starts with the selected configuration.
497-
498-
The debugger loads the application program and executes the startup code. When program execution stops (by default at
499-
`main`), the source code opens at the next executable statement, which is marked with a yellow arrow in the editor:
500-
501-
![Execution stopped at main](https://github.com/Open-CMSIS-Pack/vscode-cmsis-debugger/raw/main/images/stop-at-main.png)
502-
503-
Most editor features are available in debug mode. For example, developers can use the Find command and can correct program
504-
errors.
505-
506-
## Flash and Run
507-
508-
If you do not wish to enter a debug session, you can issue a flash download only, followed by a reset of the device.
509-
510-
In the **CMSIS view** ![CMSIS view](https://github.com/Open-CMSIS-Pack/vscode-cmsis-debugger/raw/main/images/cmsis-view-icon.png),
511-
click on the **Run** icon
512-
![Run icon in the CMSIS view](https://github.com/Open-CMSIS-Pack/vscode-cmsis-debugger/raw/main/images/run-icon.png).
513-
514-
## Run and Debug view
515-
516-
![Run and Debug view](https://github.com/Open-CMSIS-Pack/vscode-cmsis-debugger/raw/main/images/run-debug-view.png)
517-
518-
> 📝 **Note:**
519-
> The following is using information from
520-
> [Debug code with Visual Studio Code](https://code.visualstudio.com/docs/debugtest/debugging#_debugger-user-interface),
521-
> [Eclipse CDT Cloud - Memory Inspector](https://github.com/eclipse-cdt-cloud/vscode-memory-inspector),
522-
> [Eclipse CDT Cloud - Peripherals Inspector](https://github.com/eclipse-cdt-cloud/vscode-peripheral-inspector).

images/CPU_Time.png

69.2 KB
Loading

images/VARIABLES-section.png

-14.7 KB
Loading

images/call-stack-section.png

-41.3 KB
Loading

images/disassembly-view.png

-84.4 KB
Loading

images/multicore.png

151 KB
Loading

0 commit comments

Comments
 (0)