Skip to content

Commit 01a42d4

Browse files
authored
Merge branch 'main' into test-PR
2 parents 5ddbd07 + ccbdca8 commit 01a42d4

File tree

6 files changed

+90
-95
lines changed

6 files changed

+90
-95
lines changed

README.md

Lines changed: 90 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -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,64 @@ 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](https://github.com/Open-CMSIS-Pack/vscode-cmsis-debugger/raw/main/images/CPU_Time.png)
229+
230+
> 📝 **Notes:**
231+
>
232+
> - The first program stop (typically at function `main`) is the initial reference time (zero point).
233+
> - `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.
234+
> - Each processor in a multi-processor system has and independent `DWT->CYCCNT` register.
235+
236+
### Multi-Core Debug
237+
238+
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.
239+
240+
```txt
241+
0000680 I Target device: MCXN947VDF [cbuild_run]
242+
0001585 I core 0: Cortex-M33 r0p4, pname: cm33_core0 [cbuild_run]
243+
0001585 I core 1: Cortex-M33 r0p4, pname: cm33_core1 [cbuild_run]
244+
0001585 I start-pname: cm33_core0 [cbuild_run]
245+
0001600 I Semihost server started on port 4444 (core 0) [server]
246+
0001636 I GDB server started on port 3333 (core 0) [gdbserver]
247+
0001641 I Semihost server started on port 4445 (core 1) [server]
248+
0001642 I GDB server started on port 3334 (core 1) [gdbserver]
249+
0007560 I Client connected to port 3333! [gdbserver]
250+
```
251+
252+
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.
253+
254+
1. Select a processor and **Start Debug**. This connects the debugger.
255+
2. **Select a Processor** in the debug toolbar, or
256+
3. Click in **CALL STACK** on a thread or function name to select a processor.
257+
4. The selected processor is also shown in the **CPU Time Status bar**. This processor context is used in the VARIABLES and WATCH view.
258+
259+
![Multicore Debug](https://github.com/Open-CMSIS-Pack/vscode-cmsis-debugger/raw/main/images/multicore.png)
260+
261+
> 📝 **Notes:**
262+
>
263+
> - The SEGGER JLink GDB server uses a _launch_ command to connect to a running processor whereas other GDB servers use an _attach_ command.
264+
> - A [Disassembly View](#disassembly) opens only for a selected processor; otherwise the command is shown as disabled.
265+
216266
### Peripherals
217267

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).
268+
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).
219269

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

@@ -232,7 +282,7 @@ The **Memory Inspector** provides a powerful and configurable memory viewer that
232282
- Multiple Memory Formats: Shows memory data on hover in multiple formats.
233283
- Edit Memory: Allows in-place memory editing if the debug adapter supports the WriteMemoryRequest.
234284
- 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.
285+
- Customized Views: Create and customize as many memory views as you need.
236286
- Lock Views: Keep views static, unaffected by updates from the debug session.
237287
- Periodic Refresh: Automatically refresh the memory data.
238288
- Multiple Debug Sessions: Switch between multiple debug sessions using a dropdown in the memory view.
@@ -248,6 +298,10 @@ The command **Open Disassembly View** (available from [command palette](https://
248298

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

301+
> 📝 **Note:**
302+
>
303+
> - 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.
304+
251305
### Debug Console
252306

253307
The **Debug Console** enables viewing and interacting with the output of your code running in the debugger.
@@ -283,22 +337,26 @@ for the type `gdbtarget` which comes with the [CDT GDB Debug Adapter Extension](
283337
This provider manages the use of tools shipped with the extension:
284338
- If option `target`>`server` is set to `pyocd`, then it expands to the absolute path of the built-in pyOCD distribution.
285339
- 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.
340+
It depends on the actually used debug adapter type if this information is known and utilized.
291341

292342
## Known Limitations and Workarounds
293343

344+
### Internal Errors on stepping through code
345+
346+
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.
347+
348+
**Workaround/Solution**:
349+
350+
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.
351+
294352
### pyOCD fails to load `*.cbuild-run.yml` in the default configuration
295353

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

299357
**Possible Reasons**:
300358

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

324382
**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.
383+
Arm Compiler 6 generates section and program header information when scatter loading is used.
326384

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

373431
**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`.
432+
your toolchain's user reference manual. This may require updates to all build tools like compiler and assembler.
433+
For example use `-gdwarf-5` for `armclang`.
376434

377435
### Broken debug illusion
378436

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

402460
**Possible reason**: A running instance of pyOCD
403461

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.
462+
This error might occur if a previous debug session has ended prematuerly and pyOCD has not exited. The orphaned instance
463+
will still keep the port open (usually 3333) and thus you won't be able to open the port again in the new session.
406464

407465
**Solution**: Check open files and kill pyOCD
408466

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

411469
```sh
412470
sudo lsof -i -n -P | grep 3333
@@ -426,14 +484,24 @@ On Windows systems, use the
426484
or the [Process Explorer](https://learn.microsoft.com/en-us/sysinternals/downloads/process-explorer) to find orphaned
427485
processes.
428486

487+
## Requirements
488+
489+
- **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.
490+
491+
- **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.
492+
493+
- **SEGGER® J-LINK®** is an alternative GDB server for target connection. Install the latest
494+
[J-LINK Software and Documentation Pack](https://www.segger.com/downloads/jlink/#J-LinkSoftwareAndDocumentationPack)
495+
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.
496+
429497
## Related projects
430498

431499
Related open source projects are:
432500

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
501+
- The [Open-CMSIS-Pack](https://www.open-cmsis-pack.org/) project includes the CMSIS Debugger extension.
502+
- [Eclipse® CDT.cloud™](https://eclipse.dev/cdt-cloud/) hosts a number of components and
435503
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®
504+
- [pyOCD](https://pyocd.io/), a Python based tool and API for debugging, programming, and exploring Arm Cortex®
437505
microcontrollers.
438506
- [GDB](https://www.sourceware.org/gdb/), the debugger of the GNU Project.
439507

@@ -447,76 +515,3 @@ Related open source projects are:
447515
- SEGGER and J-LINK are registered trademarks of SEGGER Microcontroller GmbH.
448516
- Node.js is a registered trademark of the OpenJS Foundation.
449517
- GDB and GCC are part of the GNU Project and are maintained by the Free Software Foundation.
450-
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)