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.
- OpenOCD 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
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": "Nuvoton Debug",
"type": "cortex-debug-nuvoton",
"request": "launch",
"cwd": "${workspaceFolder}",
"executable": "${command:embedded-debug.getApplicationFile}",
"servertype": "openocd",
"serverpath": "${command:openocd-helper.getOpenOcdPath}",
"svdFile": "${command:openocd-helper.getSvdPath}",
"configFiles": [
"interface/cmsis-dap.cfg",
"${command:openocd-helper.getOpenOcdConfigPath}"
],
"runToEntryPoint": "main",
"overrideLaunchCommands": [
"monitor reset halt"
]
}
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:
Nuvoton Debug
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
Install Required Extension Packs
Install the following extension packs:
- Nuvoton NuMicro Cortex-M Pack
- Zephyr IDE Extension Pack
Use the Zephyr IDE buttons in the following steps to create the environment.
Creating a Zephyr Project from Sample Code
Create a new project using sample code.
Choose a project template provided by the Zephyr IDE.
Add a build configuration and choose your target board, e.g., NuMaker-PFM-M467 .
Add Runner Configuration (OpenOCD)
Configure the project runner to use OpenOCD.
Update Zephyr Project Runner Settings
Go to View → Command Palette and run Update Zephyr Project Runner . Select the project to update the runner settings and refresh the settings.
Set the target type
Please choose the target type for debugging according to the project.
Build Project and Flash to Target
Use the build button to build and flash the firmware to your target board.
Create launch.json
Create the launch.json file used for debugging.
Set the runToEntryPoint (optional)
If you don’t want execution to stop at the main function when running in debug mode, set the runToEntryPoint parameter and specify the symbol function where you want it to stop (for example, Zephyr’s execution entry point z_arm_reset; for Nuvoton BSP projects, the entry point is Reset_Handler).
Select Debug Settings
Select Nuvoton Debug Zephyr.
Enter Debug Mode and Start Monitor for Output
Launch the debugger and open the monitor or terminal to view runtime output.
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
https://github.com/OpenNuvoton/Nuvoton_Tools/blob/master/Documents/NuLink2Pro.md
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 rtos options to launch.json file
Add variable to main function of the project
static volatile int uxTopUsedPriority;
uxTopUsedPriority = configMAX_PRIORITIES - 1;
| |