MCUXpresso VSCode

From Variscite Wiki
DART-MX8M-MINI - MCUXpresso 2.10.0 Development with VS Code

1 Overview

This guide demonstrates how to develop and cross compile applications for the DART-MX8M-MINI Cortex-m4 co-processor using Microsoft Visual Studio Code.

Please visit Variscite's MCUXpresso Guide for additional information about manually building demos, integration with Yocto, running applications from U-Boot and Linux, and JTAG debugging.

2 Setup Host Computer Environment

Follow the steps below to prepare a fresh Ubuntu 20.04 installation for VS Code debugging:

2.1 Install Dependencies

$ sudo apt-get -y update
$ sudo apt-get -y install build-essential gdb gdb-multiarch git cmake

2.2 Install VS Code

$ sudo snap install --classic code

2.3 Install VS Code Extensions

VS Code has a graphical interface for installing and managing extensions. To learn more, please see Using extensions in Visual Studio Code

For this guide, we will install the required extensions using the command line:

$ code --install-extension ms-vscode.cpptools
$ code --install-extension marus25.cortex-debug
$ code --install-extension dan-c-underwood.arm

2.4 Install Segger JLink

$ Download JLink_Linux_V760b_x86_64.deb from
  Direct Download:
$ sudo dpkg -i JLink_Linux_V760b_x86_64.deb

The software will be installed in /opt/SEGGER folder

2.5 Install MCUXpresso Toolchain and SDK

Download and install GNU-ARM bare-metal toolchain:

$ mkdir ~/var-mcuxpresso
$ cd ~/var-mcuxpresso
$ wget
$ tar xvf gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2

Download MCUXpresso SDK for the SOM:

$ cd ~/var-mcuxpresso
$ git clone -b mcuxpresso_sdk_2.10.x-var01
$ cd freertos-variscite

3 Add Visual Studio Code support to the Variscite examples

3.1 Available Demos

All of the Variscite examples are located under the following folder.


Variscite provides a script to simplify the Project Configuration

3.2 Configure a single Project

For this example, we will configure the hello_world demo. However, the process is the same for all demos.

$ ./ -b dart_mx8mm -e boards/dart_mx8mm/demo_apps/hello_world -t tcm -d /opt/SEGGER/JLink  (for TCM target)
$ ./ -b dart_mx8mm -e boards/dart_mx8mm/demo_apps/hello_world -t ddr -d /opt/SEGGER/JLink  (for DDR target)

3.3 Configure all Projects

$ ./ -b dart_mx8mm -e all -t tcm -d /opt/SEGGER/JLink  (for TCM target)
$ ./ -b dart_mx8mm -e all -t ddr -d /opt/SEGGER/JLink  (for DDR target)

Note: Some J-Link debuggers support connecting to your host computer via Ethernet or Wi-Fi. To enable this, add the IP Address of your J-Link to launch.json:
$ vi ~/var-mcuxpresso/freertos-variscite/boards/dart_mx8mm/demo_apps/hello_world/.vscode/launch.json
   "configurations": [
     "ipAddress": "<J-Link IP Address>"

3.4 Disable LMEM caches to debug demos mapped in DDR

Note: to debug applications mapped in DDR, is mandatory to deactivate the LMEM caches
$ cd ~/var-mcuxpresso/freertos-variscite
$ git apply patches/0001-iMX8M-MINI-deactivated-the-LMEM-caches-to-debug-in-e.patch

Please visit the SEGGER forum to additional information

3.5 Open a Demo in VS Code

For this example, we will use the hello_world demo mapped in TCM. However, the process is the same for all demos. From a terminal, launch VS Code and open the hello_world demo directory:

$ code ~/var-mcuxpresso/freertos-variscite/boards/dart_mx8mm/demo_apps/hello_world

VS Code should open and look similiar too:

Vscode mcuxpresso.png

4 Build Demo using VS Code

Vscode mcuxpresso run build task.png

If the build task completes successfully, the following output files will be generated:

~/var-mcuxpresso/freertos-variscite/boards/dart_mx8mm/demo_apps/hello_world/armgcc/debug/hello_world.bin  (for TCM target, load in U-Boot)
~/var-mcuxpresso/freertos-variscite/boards/dart_mx8mm/demo_apps/hello_world/armgcc/debug/hello_world.elf  (for TCM target, load using debugger or remoteproc)
~/var-mcuxpresso/freertos-variscite/boards/dart_mx8mm/demo_apps/hello_world/armgcc/ddr_debug/hello_world.bin  (for DDR target, load in U-Boot)
~/var-mcuxpresso/freertos-variscite/boards/dart_mx8mm/demo_apps/hello_world/armgcc/ddr_debug/hello_world.elf  (for DDR target, load using debugger or remoteproc)

Please visit Variscite's MCUXpresso Guide for instructions to run the demo using U-Boot or the Linux Remote Processor Framework.

5 Debugging with VS Code

5.1 Test Enviroment


JTAG Debbugger: J-Link PLUS:
ARM-JTAG-20-10 adapter:
Variscite Board: VAR-DT8MCustomBoard

You can see the Yocto release details at link:

5.2 Connect Hardware

Connect J-Link PLUS to JTAG connector of Variscite board
Connect J-Link PLUS to Development PC via USB cable

5.3 Load dedicated device tree

Please visit Variscite's MCUXpresso Guide for instructions to load a dedicated device tree.

For this example we will use imx8mm-var-dart-dt8mcustomboard-m4.dtb:

From U-Boot

 => setenv fdt_file imx8mm-var-dart-dt8mcustomboard-m4.dtb 
 => saveenv
 Saving Environment to MMC... Writing to MMC(1)... OK
 Power off / Power on the board

Or, from Linux

 $ fw_setenv fdt_file imx8mm-var-dart-dt8mcustomboard-m4.dtb 
 $ reboot

5.4 Start Debugging

Open source code and add a breakpoint

Vscode MCUXpresso SettingBreakPoint.png

Start Debugging

Vscode MCUXpresso StartDebugging.png

if everything worked well the program will stop at the configured breakpoint

Vscode MCUXpresso StoppedAtBreakPoint.png

5.5 Debug RPMSG demos

The RPMSG demos can be debugged only starting from U-Boot.
You need even to change M4 Kernel Device Tree enabling rpmsg node and disabling cortex-m node.

5.6 Change M4 Kernel Device Tree

Edit arch/arm64/boot/dts/freescale/imx8mm-var-dart-dt8mcustomboard-m4.dtsi

imx8mm-cm4 {
    status = "disabled";

&rpmsg {
    status = "okay";

Save the changes.
Compile the device tree and update the SD card/eMMC.

Note: If rpmsg node is missing in the arch/arm64/boot/dts/freescale/imx8mm-var-dart-dt8mcustomboard-m4.dtsi file discard the Change M4 Kernel Device Tree section above

For this example, we will debug pingpong demo mapped in DDR.

$ cd ~/var-mcuxpresso/freertos-variscite
$ git apply patches/0001-iMX8M-MINI-deactivated-the-LMEM-caches-to-debug-in-e.patch
$ ./ -b dart_mx8mm -e boards/dart_mx8mm/multicore_examples/rpmsg_lite_pingpong_rtos/linux_remote -t ddr -d /opt/SEGGER/JLink
$ code ~/var-mcuxpresso/freertos-variscite/boards/dart_mx8mm/multicore_examples/rpmsg_lite_pingpong_rtos/linux_remote/
Note: Debugging applications mapped in the DDR, the use of SDK_DelayAtLeastUs function is not recommended because it produces a long delay time.

You can use vTaskDelay() instead.

Vscode MCUXpresso SDK DelayAtLeastUs Replaced.png

Build application following the guide at the Build Demo using VS Code section above:

Power on the Board and interrupt the boot in the U-Boot prompt.
From Visual Studio Code start Debugging.
From U-Boot prompt:

=> boot

Waiting for completed boot kernel
From Userspace prompt:

$ sysctl kernel.printk=7
$ modprobe imx_rpmsg_pingpong

If everything worked well the program will stop at the configured breakpoint:

Vscode MCUXpresso RPMSG StoppedAtBreakPoint.png

Note: Debugging RPMSG demos be careful to set breakpoint or debug step by step because when the M core is stopped even A core is blocked