Nuvoton NuMicro Cortex-M Pack
Description
Nuvoton NuMicro Cortex-M Pack is a complete development toolkit for Nuvoton’s NuMicro Cortex-M microcontrollers in Visual Studio Code.
Outline
Features
The extension pack integrates essential components to simplify embedded development, including:
- Essential extensions for VS Code.
- Configuration files.
- SVD (System View Description) support.
- PYOCD setup for debugging.
- The PinView and LCDView help you with debugging.
- Template projects to help you get started.
- Extension version control prevents automatic extension upgrades from causing usage issues.
- Caveat: You might be forced to use specific, fixed versions of the relevant extensions. For details, please see the sub-extension: Nuvoton Extension Version Manager.
Requirements
- Visual Studio Code: Version 1.95.0 or higher.
- Nu-Link_USB_Driver: Version 1.11 or higher. (Nu-Link_USB_Driver download link)
- Nu-Link2 firmware version: Version 7675r (v3.16) or higher.
- Ensure that your corporate or personal firewall does not block VS Code's network access during the installation of extensions.
Getting Started
NuMicro Cortex-M Pack Environment Setup Guide
This guide walks you through setting up a NuMicro Cortex-M Pack project.
Launch the VS Code application.
Install the VS Code extension Nuvoton NuMicro Cortex-M Pack.
- Nuvoton
NuMicro Cortex-M Pack
- Fix
Arm CMSIS Solution version at 1.56.0
- Fix
Arm Debugger version at 1.4.4
Prepare NuMicro BSP project
Open the VSCode folder in your downloaded NuMicro BSP
- In Visual Studio Code, go to File → Open Folder…
- Select the VSCode folder inside your project directory.
Add Nuvoton Debug configuration (Optional — the BSP may have already done this for you)
- Open
.vscode/launch.json file, and insert the debug configuration in configurations
- insert the debug configuration in configurations
{
"name": "CMSIS_DAP@pyOCD (launch)",
"type": "gdbtarget",
"request": "attach",
"cwd": "${workspaceFolder}/",
"program": "${command:embedded-debug.getApplicationFile}",
"gdb": "arm-none-eabi-gdb",
"preLaunchTask": "LaunchpyOCDServer",
"initCommands": [
"monitor reset halt",
"set breakpoint pending on",
"tbreak main"
],
"customResetCommands": [
"monitor reset halt",
"tbreak main"
],
"target": {
"port": "3333"
},
"cmsis": {
"cbuildRunFile": "${command:cmsis-csolution.getCbuildRunFile}",
"updateConfiguration": "auto"
}
}
Ensure your settings in "Manage Solution" are properly configured (Optional — the BSP may have already done this for you)
- Click on
CMSIS in the active bar and then click on Manage Solution to set a context for your solution.
- configure the Run & Debug settings.
- Debug Configuration:
CMSIS_DAP@pyOCD (launch)
Check Device Status
- Make sure the device is connected and recognized in Device Manager.
- Only one NuMicro device can be connected at a time.
- If a new VS Code instance is opened, the device in the Device Manager may be taken over by the newly opened VS Code. Close all instances of VS Code and restart to ensure proper device recognition.
Execute Build, Run and Debug
(Optional) Zephyr Project Setup Guide for Nuvoton NuMicro Cortex-M
Please refer to Zephyr Project Setup Guide
(Optional) Using Multiple Devices for Download and Debug in VS Code
Please refer to Using Multiple Devices for Download and Debug in VS Code
Trouble Shooting
Build project
CMSIS-Toolbox cannot find the path (missing vcpkg-configuration.json file)
Clicking "Add to Arm Tools" buuton will generate vcpkg-configuration.json in VSCode.
When connected to the Internet, it will download and install the related Arm tool settings.
Flash target
Button becomes disabled
Modify the cmsis-toolbox version in vcpkg-configuration.json and reactivate the environment - this will regenerate launch.json and task.json
"arm:tools/open-cmsis-pack/cmsis-toolbox": "2.9.0",
Waiting for a debug probe
Install the latest version of Nu-Link_USB_Driver
Check whether the CMSIS-DAP device is connected
Verify that the CMSIS-DAP option is enabled
Check whether any other application is using the CMSIS-DAP device
Memory region at address is not writable
Check whether the latest version of the pack has been updated
Check that the region to be programmed is defined in the .cbuild-run.yml file
Make sure the connected device matches the model defined in csolution.yml — this affects flash size and SRAM size.
Steps to update the pack settings in the project
Modify the cbuild-pack.yml file to update the pack and version to the latest
Refresh to reload the pack and rebuild the solution
Debug target
Cannot halt at the main function
It depends on AC6 optimization results. Not needed for GCC.
Modify cproject.yml and add -fno-inline build option.
Setup RTOS View
Add some define to the RTOS project
gcc_arm.ld
Add the following to .data and .bss sections:
KEEP(*(.freertos_tasks)) and KEEP(*(.freertos_globals))
FreeRTOSConfig.h
#define configUSE_TRACE_FACILITY 1
Enable FreeRTOS trace facility, which is required to display thread and task status information.
#define configUSE_STATS_FORMATTING_FUNCTIONS 1
Enable formatted statistics functions, used to generate tables like those returned by uxTaskGetSystemState(), making it easier to display the running status of each task.
#define configRECORD_STACK_HIGH_ADDRESS 1
Record the stack end address.
#define INCLUDE_vTaskList 1
Enable the vTaskList() function, which lists the status of all tasks in the system.
#define INCLUDE_uxTaskGetStackHighWaterMark 1
Enable the uxTaskGetStackHighWaterMark() function, which returns each task’s stack high-water mark.
#define configGENERATE_RUN_TIME_STATS 0
This option controls whether run-time statistics are generated.
#define configGENERATE_RUN_TIME_STATS 1
This option controls whether run-time statistics are generated.
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() /* Define this to initialize your timer/counter */
#define portGET_RUN_TIME_COUNTER_VALUE() /* Define this to sample the timer/counter */
These macros must be defined to set up and read the timer/counter used for collecting run-time statistics.
Add variable to main function of the project
static volatile int uxTopUsedPriority;
uxTopUsedPriority = configMAX_PRIORITIES - 1;
Enter Debug mode, and you will be able to see the task status in the RTOS view.
| |