MCUXpresso VSCode extension: Difference between revisions
(Update 'Open a Demo in VS Code') |
No edit summary |
||
(7 intermediate revisions by 2 users not shown) | |||
Line 80: | Line 80: | ||
=Hardware= | =Hardware= | ||
JTAG Debbugger: J-Link PLUS: https://www.segger.com/products/debug-probes/j-link/models/j-link-plus/ | JTAG Debbugger: J-Link PLUS: https://www.segger.com/products/debug-probes/j-link/models/j-link-plus/ | ||
9-Pin Cortex-M Adapter: https://www.segger.com/products/debug-probes/j-link/accessories/adapters/9-pin-cortex-m-adapter/ | |||
Variscite Board: {{#var:DEBUG_BOARD}} | Variscite Board: {{#var:DEBUG_BOARD}} | ||
=Host Computer Environment Setup= | =Host Computer Environment Setup= | ||
Follow the steps below to prepare a fresh Ubuntu 22.04 installation for using the extension. | Follow the steps below to prepare a fresh Ubuntu 22.04 installation for using the extension. | ||
Line 92: | Line 93: | ||
The above command will print all group memberships of the current user. If ‘dialout’ it is not printed, add your user to it: | The above command will print all group memberships of the current user. If ‘dialout’ it is not printed, add your user to it: | ||
$ sudo usermod -a -G dialout $USER | $ sudo usermod -a -G dialout $USER | ||
and restart your computer. | and either logout or restart your computer for the changes to take effect. | ||
Download MCUXpresso SDK for the SOM: | Download MCUXpresso SDK for the SOM: | ||
Line 120: | Line 121: | ||
[[File:MCUXpresso-installer-window.png]] | [[File:MCUXpresso-installer-window.png]] | ||
=Open a Demo in VS Code= | |||
After the dependencies are installed, close the MCUXpresso Installer and click on ‘Import Software Repositories’: | After the dependencies are installed, close the MCUXpresso Installer and click on ‘Import Software Repositories’: | ||
[[File:MCUXpresso-import-repository-1.png]] | [[File:MCUXpresso-import-repository-1.png]] | ||
Go to the 'Local' tab, browse the previously git-cloned repository and import it: | Go to the 'Local' tab, browse the previously git-cloned repository and import it: | ||
Line 133: | Line 133: | ||
[[File:MCUXpresso-import-example-1.png]] | [[File:MCUXpresso-import-example-1.png]] | ||
Select the previously imported repository, the Arm GNU Toolchain (the Toolchain version might differ), the {{#var:HARDWARE_NAME}} board and the hello world demo. Use the previously created 'mcuxpresso-examples' directory for the 'Location': | |||
[[File:MCUXpresso-import-example-2-rc.png]] | |||
Click on 'Explorer' on the left upper corner to open the project source code: | |||
[[File:MCUXpresso-hello-world-1-highlighted-rc.png]] | |||
=Build Demo using VS Code= | =Build Demo using VS Code= | ||
To build the project click on MCUXpresso for VS Code icon on the left and on 'Build Selected': | |||
[[File:MCUXpresso-hello-world-2-highlighted-rc.png]] | |||
If the build task completes successfully, a similar output as below should be generated: | |||
[[File: | [[File:MCUXpresso-hello-world-3-rc.png]] | ||
Please visit [https://variwiki.com/index.php?title=MCUXpresso&release={{#var:RELEASE_PARAM}}#Running_a_demo Variscite's MCUXpresso Guide] for instructions to run the demo using U-Boot or the Linux Remote Processor Framework. | |||
=Debugging with VS Code= | =Debugging with VS Code= | ||
==Test Enviroment== | ==Test Enviroment== | ||
==Connect Hardware== | ==Connect Hardware== | ||
Line 202: | Line 196: | ||
==Start Debugging== | ==Start Debugging== | ||
Make sure the Debug Probe is correctly identified by the extension: | |||
[[File:MCUXpresso-debug-probe-rc.png]] | |||
If it is not, check your connections and restart VS Code. | |||
Open source code and add a breakpoint: | |||
[[File: | [[File:MCUXpresso-hello-world-4-rc.png]] | ||
Open the serial debugging port by clicking ‘View' → ‘Output’ → ‘…’ → 'Serial Monitor’: | |||
[[File: | [[File:MCUXpresso-hello-world-5-rc.png]] | ||
[[File:MCUXpresso-hello-world-6-rc.png]] | |||
Select the appropriate serial port (it is usually /dev/ttyUSBx) and click on 'Start Monitoring': | |||
[[File:MCUXpresso-hello-world-7-hightlighted-rc.png]] | |||
Click on 'Debug' to start debugging: | |||
[[File:MCUXpresso-hello-world-8-hightlighted-rc.png]] | |||
Click on 'Continue' (or press F5) until the breakpoint is reached: | |||
[[File:MCUXpresso-hello-world-9-highlighted-rc.png]] | |||
After reaching the breakpoint, click on 'Step Over' (or press F10) to go line by line: | |||
[[File:MCUXpresso-hello-world-10-hightlighted-rc.png]] | |||
Right after stepping over the PRINTF line, a 'hello world' string should be printed on the serial monitor: | |||
[[File:MCUXpresso-hello-world-11-hightlighted-rc.png]] | |||
To end the debugging session, press the ‘Stop’ button: | |||
[[File:MCUXpresso-hello-world-12-hightlighted-rc.png]] |
Latest revision as of 16:20, 13 May 2024
Overview
This guide demonstrates how to develop, cross compile and debug applications for the VAR-SOM-MX8M-NANO Cortex-m7 co-processor using NXP’s MCUXpresso for Visual Code extension.
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.
Hardware
JTAG Debbugger: J-Link PLUS: https://www.segger.com/products/debug-probes/j-link/models/j-link-plus/ 9-Pin Cortex-M Adapter: https://www.segger.com/products/debug-probes/j-link/accessories/adapters/9-pin-cortex-m-adapter/ Variscite Board: Symphony
Host Computer Environment Setup
Follow the steps below to prepare a fresh Ubuntu 22.04 installation for using the extension.
Install Dependencies
$ sudo apt-get -y update $ sudo apt-get -y install pip git
In order to access serial debugging ports your user must be in the ‘dialout’ group. To check this type:
$ groups
The above command will print all group memberships of the current user. If ‘dialout’ it is not printed, add your user to it:
$ sudo usermod -a -G dialout $USER
and either logout or restart your computer for the changes to take effect.
Download MCUXpresso SDK for the SOM:
$ mkdir -p ~/var-mcuxpresso/mcuxpresso-examples $ cd ~/var-mcuxpresso $ git clone https://github.com/varigit/freertos-variscite -b mcuxpresso_sdk_2.15.x-var01
Install VS Code
$ sudo snap install --classic code
Install MCUXpresso for VS Code Extension
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 MCUXpresso for VS Code extension:
Install MCUXpresso Dependencies
In the extension ‘Welcome' tab, click on ‘Check Tool Dependencies’, ‘Open Installer’ and then, on the bottom right notification, 'Download’:
Once the download finishes, the MCUXpresso Installer window will be displayed, showing multiple tools to install. For this guide we will install the following:
- MCUXpresso SDK Developer;
- SEGGER J-Link;
- Arm GNU Toolchain;
- Standalone Toolchain Add-ons.
Open a Demo in VS Code
After the dependencies are installed, close the MCUXpresso Installer and click on ‘Import Software Repositories’:
Go to the 'Local' tab, browse the previously git-cloned repository and import it:
Click on ‘Import Example from Repository’:
Select the previously imported repository, the Arm GNU Toolchain (the Toolchain version might differ), the VAR-SOM-MX8M-NANO board and the hello world demo. Use the previously created 'mcuxpresso-examples' directory for the 'Location':
Click on 'Explorer' on the left upper corner to open the project source code:
Build Demo using VS Code
To build the project click on MCUXpresso for VS Code icon on the left and on 'Build Selected':
If the build task completes successfully, a similar output as below should be generated:
Please visit Variscite's MCUXpresso Guide for instructions to run the demo using U-Boot or the Linux Remote Processor Framework.
Debugging with VS Code
Test Enviroment
Connect Hardware
Connect J-Link PLUS to JTAG connector of Variscite board Connect J-Link PLUS to Development PC via USB cable
Load dedicated device tree
Please visit Variscite's MCUXpresso Guide for instructions to load a dedicated device tree.
For this example we will use imx8mn-var-som-symphony-m7.dtb:
From U-Boot
=> setenv fdt_file imx8mn-var-som-symphony-m7.dtb => saveenv Saving Environment to MMC... Writing to MMC(1)... OK Power off / Power on the board
Or, from Linux
$ fw_setenv fdt_file imx8mn-var-som-symphony-m7.dtb $ reboot
Start Debugging
Make sure the Debug Probe is correctly identified by the extension:
If it is not, check your connections and restart VS Code.
Open source code and add a breakpoint:
Open the serial debugging port by clicking ‘View' → ‘Output’ → ‘…’ → 'Serial Monitor’:
Select the appropriate serial port (it is usually /dev/ttyUSBx) and click on 'Start Monitoring':
Click on 'Debug' to start debugging:
Click on 'Continue' (or press F5) until the breakpoint is reached:
After reaching the breakpoint, click on 'Step Over' (or press F10) to go line by line:
Right after stepping over the PRINTF line, a 'hello world' string should be printed on the serial monitor:
To end the debugging session, press the ‘Stop’ button: