MCUXpresso VSCode Helper Script: Difference between revisions
Line 52: | Line 52: | ||
$ ./var_add_vscode_support.sh -b {{#var:BOARD_SDK}} -e all -t ddr -d /opt/SEGGER/JLink (for DDR target) | $ ./var_add_vscode_support.sh -b {{#var:BOARD_SDK}} -e all -t ddr -d /opt/SEGGER/JLink (for DDR target) | ||
==Disable | ==Disable LMEM caches to debug demos mapped in DDR== | ||
{{Note|'''Note:''' to debug applications mapped in DDR, is mandatory to not enable | {{Note|'''Note:''' to debug applications mapped in DDR, is mandatory to not enable LMEM caches<br> | ||
the function to be changed is SystemInit() in the {{#var:SDK_PATH}}/freertos-variscite/{{#var:DEVICE_SPECIFIC_CFG_FILE}} | the function to be changed is SystemInit() in the {{#var:SDK_PATH}}/freertos-variscite/{{#var:DEVICE_SPECIFIC_CFG_FILE}}<br> | ||
The changed function will be: | |||
void SystemInit(void) | |||
{ | |||
#if ((__FPU_PRESENT == 1) && (__FPU_USED == 1)) | |||
SCB->CPACR |= ((3UL << 10 * 2) | (3UL << 11 * 2)); /* set CP10, CP11 Full Access */ | |||
#endif /* ((__FPU_PRESENT == 1) && (__FPU_USED == 1)) */ | |||
#if 0 | |||
/* Initialize Cache */ | |||
/* Enable Code Bus Cache */ | |||
/* set command to invalidate all ways, and write GO bit to initiate command */ | |||
LMEM->PCCCR |= LMEM_PCCCR_INVW1_MASK | LMEM_PCCCR_INVW0_MASK; | |||
LMEM->PCCCR |= LMEM_PCCCR_GO_MASK; | |||
/* Wait until the command completes */ | |||
while ((LMEM->PCCCR & LMEM_PCCCR_GO_MASK) != 0U) | |||
{ | |||
} | |||
/* Enable cache, enable write buffer */ | |||
LMEM->PCCCR |= (LMEM_PCCCR_ENWRBUF_MASK | LMEM_PCCCR_ENCACHE_MASK); | |||
/* Enable System Bus Cache */ | |||
/* set command to invalidate all ways, and write GO bit to initiate command */ | |||
LMEM->PSCCR |= LMEM_PSCCR_INVW1_MASK | LMEM_PSCCR_INVW0_MASK; | |||
LMEM->PSCCR |= LMEM_PSCCR_GO_MASK; | |||
/* Wait until the command completes */ | |||
while ((LMEM->PSCCR & LMEM_PSCCR_GO_MASK) != 0U) | |||
{ | |||
} | |||
/* Enable cache, enable write buffer */ | |||
LMEM->PSCCR |= (LMEM_PSCCR_ENWRBUF_MASK | LMEM_PSCCR_ENCACHE_MASK); | |||
__ISB(); | |||
__DSB(); | |||
#endif | |||
SystemInitHook(); | |||
} | |||
}} | }} | ||
Revision as of 18:26, 6 January 2022
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.
Setup Host Computer Environment
Follow the steps below to prepare a fresh Ubuntu 20.04 installation for VS Code debugging:
Install Dependencies
$ sudo apt-get -y update $ sudo apt-get -y install build-essential gdb gdb-multiarch git cmake
Install VS Code
$ sudo snap install --classic code
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
Install Segger JLink
$ Download JLink_Linux_V760b_x86_64.deb from https://www.segger.com/downloads/jlink/ $ sudo dpkg -i JLink_Linux_V760b_x86_64.deb
The software will be installed in /opt/SEGGER folder
Install MCUXpresso Toolchain and SDK
Download and install GNU-ARM bare-metal toolchain:
$ mkdir ~/var-mcuxpresso $ cd ~/var-mcuxpresso $ wget https://developer.arm.com/-/media/Files/downloads/gnu-rm/10-2020q4/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2 $ 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 https://github.com/varigit/freertos-variscite -b mcuxpresso_sdk_2.10.x-var01 $ cd freertos-variscite
Add Visual Studio Code support to the Variscite examples
Available Demos
All of the Variscite examples are located under the following folder.
~/var-mcuxpresso/freertos-variscite/boards/dart_mx8mm
Variscite provides a script to simplify the Project Configuration
Configure a single Project
For this example, we will configure the hello_world demo. However, the process is the same for all demos.
$ ./var_add_vscode_support.sh -b dart_mx8mm -e boards/dart_mx8mm/demo_apps/hello_world -t tcm -d /opt/SEGGER/JLink (for TCM target) $ ./var_add_vscode_support.sh -b dart_mx8mm -e boards/dart_mx8mm/demo_apps/hello_world -t ddr -d /opt/SEGGER/JLink (for DDR target)
Configure all Projects
$ ./var_add_vscode_support.sh -b dart_mx8mm -e all -t tcm -d /opt/SEGGER/JLink (for TCM target) $ ./var_add_vscode_support.sh -b dart_mx8mm -e all -t ddr -d /opt/SEGGER/JLink (for DDR target)
Disable LMEM caches to debug demos mapped in DDR
Open a Demo in VS Code
For this example, we will use the hello_world demo. 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:
Build Demo using VS Code
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) ~/var-mcuxpresso/freertos-variscite/boards/dart_mx8mm/demo_apps/hello_world/armgcc/debug/hello_world.elf (for TCM target) ~/var-mcuxpresso/freertos-variscite/boards/dart_mx8mm/demo_apps/hello_world/armgcc/ddr_debug/hello_world.bin (for DDR target) ~/var-mcuxpresso/freertos-variscite/boards/dart_mx8mm/demo_apps/hello_world/armgcc/ddr_debug/hello_world.elf (for DDR target)
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
Used Hardware
JTAG Debbugger: J-Link PLUS: https://www.segger.com/products/debug-probes/j-link/models/j-link-plus/ ARM-JTAG-20-10 adapter: https://www.digikey.it/it/products/detail/olimex-ltd/ARM-JTAG-20-10/3471401 Variscite Board: VAR-DT8MCutomBoard
Connect Hardware
Connect J-Link PLUS to JTAG connector of Variscite board Connect J-Link PLUS to Development PC via USB cable
U-Boot Enviroment
Please visit Variscite's MCUXpresso Guide for instructions to load a dedicated device tree
For this example we will use:
$ setenv imx8mm-var-dart-dt8mcustomboard-m4.dtb
$ saveenv
Saving Environment to MMC... Writing to MMC(1)... OK
$ Power off / Power on the board
Start Debugging
Add Breakpoint opening source code page
Start Debugging
if everything worked well the program will stop at the configured breakpoint