Run and debug the project¶
Run¶
Manage the serial console after upload¶
By default, the Fast target opens a serial console in a Terminal window once the sketch has been uploaded to the board.
In case you prefer not to open the serial console,
-
Open the main
Makefile
. -
Set the variable
NO_SERIAL_CONSOLE
in the mainMakefile
totrue
.
# Serial console for Fast target
# ----------------------------------
# For Fast target, open serial console, false or true
#
NO_SERIAL_CONSOLE = true
- Otherwise, comment the line with a leading
#
, set the value tofalse
or leave it empty.
NO_SERIAL_CONSOLE = false
NO_SERIAL_CONSOLE =
Use external serial console applications¶
As an alternative to the serial console on a Terminal window, I recommend CoolTerm and PuTTY .
The variable NO_SERIAL_CONSOLE
option only affects the Fast target. The All and Serial targets are not concerned.
Some boards use the same serial port for upload and serial console.
- Ensure the serial console is disconnected before proceeding with the upload.
Debug¶
Debugging involves two phases:
-
First, define the breakpoints with the associated conditions and actions within the standard Visual Studio Code interface.
-
Then, launch the debugging session while the sketch is running on the board.
Check the configuration¶
Debugging requires a board with a built-in debugger or a board connected to an external debugger.
Examples of boards with a built-in debugger include Arduino M0 Pro, LaunchPad, BBC micro:bit, Microsoft Azure IoT DevKit.
Examples of boards connected to an external debugger include ESP32 board with the external ESP-Prog programmer-debugger, Adafruit Feather nRF52840 with the Segger J-Link emulator.
Debugging relies on the Cortex-Debug extension.
Define the breakpoints¶
- Use the Visual Studio Code interface to define breakpoints with the associated conditions and actions.
For more information about debugging with Visual Studio Code,
- Please refer to Debug C++ in Visual Studio Code and Configure C/C++ debugging .
Power the board with the Segger J-Link debug probe¶
Some Segger J-Link debug probes can power the board with +5 V (300mA maximum, pin 19), while the logic level is set through VTref
(target reference voltage, pin 1).
- On the main
Makefile
, set the variableJLINK_POWER
to1
.
JLINK_POWER = 1
- Alternatively, launch JLinkExe.
$ |
|
- Enter the corresponding command.
J-Link> J-Link> |
|
- Or enter the corresponding command on Ozone.
Edit.SysVar(VAR_TARGET_POWER_ON,1);
For more information,
- Please refer to the section JTAG Interface Connection (20 pin) on the page Interface Description .
Re-route a serial console through the Segger J-Link debug probe¶
Additionally, some Segger J-Link debug probes feature VCOM and re-route a serial console through J-Link TX
(pin 5) and J-Link RX
(pin 17).
This feature is only valid with SWD and is disabled by default. To enable it,
-
Connect the Segger J-Link debug probe.
-
Launch JLinkConfig.
-
Select the debug probe and call the contextual menu Configure.
-
Click on Enable below Virtual COM-Port, then on OK.
-
Power-cycle the debug probe.
Alternatively,
-
Open a Terminal window,
-
Launch J-Link.
$ |
|
- Run the following commands after the
J-Link>
prompt.
J-Link> J-Link> |
|
If the probe has the serial number 123456789
, the serial port is re-routed to /dev/tty.usbmodem000123456789
.
- Just open a Terminal window and launch the following command with the correct speed.
$ |
|
To disable it,
- Proceed as before, but select Disable below Virtual COM-Port instead.
Alternatively,
-
Open a Terminal window,
-
Launch J-Link.
$ |
|
- Run the following commands after the
J-Link>
prompt.
J-Link> J-Link> |
|
For more information,
- Please refer to the section VCOM Functionality on the page J-Link Debug Probes .
Add support for RTOS¶
Plug-ins bring RTOS support on Ozone.
- Enter the corresponding command.
Project.SetOSPlugin("FreeRTOSPlugin_CM4");
For more information,
- Please refer to the page RTOS aware debugging.
Launch the debugging session¶
To launch the debugging session, the first time,
-
Press Ctrl+Shift+D to display the debug pane;
-
Select the configuration on the drop-down list;
-
Hit Start Debugging or press F5.
After the first time,
- Press the short-key Ctrl+Shift+D.
Manage specific boards¶
Some boards require a specific procedure.
- Please refer to the Debug section for the board under Manage the boards.
Debug the project with Ozone¶
A great alternative for debugging is Ozone with a Segger J-Link debugger. Ozone provides a GUI to program and debug a board.
For more information about the platforms and MCUs supported,
- Please refer to the page Supported Devices - J-Link :octicons-exernal-link-16:.
For some boards running on FreeRTOS, Ozone manages FreeRTOS better than the command-line J-Link utility and is thus strongly recommended.
For more information on how to use Ozone,
- Please refer to the Ozone User Manual (UM08025) from Segger.
For more information about the debugging tools,
- Please refer to the Segger J-Link and Segger Ozone documentations.