The latest FreeRTOS V10.2.0 release comes with basic support for the RISC-V ISA. This post describes how to add FreeRTOS to a VEGA SDK application and run it with the NXP MCUXpresso IDE or any other Eclipse IDE using the GNU MCU Eclipse plugins:
In that same file the pins for the LEDs on the VEGA board can be configured too:
/* red LED */ #define McuLED1_CONFIG_IS_LOW_ACTIVE (0) #define LEDpin1_CONFIG_GPIO_NAME GPIOA #define LEDpin1_CONFIG_PORT_NAME PORTA #define LEDpin1_CONFIG_PIN_NUMBER 24u #define LEDpin1_CONFIG_DO_PIN_MUXING 1
/* green LED */ #define McuLED2_CONFIG_IS_LOW_ACTIVE (0) #define LEDpin2_CONFIG_GPIO_NAME GPIOA #define LEDpin2_CONFIG_PORT_NAME PORTA #define LEDpin2_CONFIG_PIN_NUMBER 23u #define LEDpin2_CONFIG_DO_PIN_MUXING 1
/* blue LED */ #define McuLED3_CONFIG_IS_LOW_ACTIVE (0) #define LEDpin3_CONFIG_GPIO_NAME GPIOA #define LEDpin3_CONFIG_PORT_NAME PORTA #define LEDpin3_CONFIG_PIN_NUMBER 22u #define LEDpin3_CONFIG_DO_PIN_MUXING 1
/* sts LED */ #define McuLED4_CONFIG_IS_LOW_ACTIVE (0) #define LEDpin4_CONFIG_GPIO_NAME GPIOE #define LEDpin4_CONFIG_PORT_NAME PORTE #define LEDpin4_CONFIG_PIN_NUMBER 0u #define LEDpin4_CONFIG_DO_PIN_MUXING 1
Replace the standard startup code with the version specific for FreeRTOS. This version uses freertos_risc_v_trap_handler as the default trap handler. This version is taken from the FreeRTOS distribution for V10.2.0:
// Copyright 2017 ETH Zurich and University of Bologna. // Copyright and related rights are licensed under the Solderpad Hardware // License, Version 0.51 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License at // http://solderpad.org/licenses/SHL-0.51. Unless required by applicable law // or agreed to in writing, software, hardware and materials distributed under // this License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR // CONDITIONS OF ANY KIND, either express or implied. See the License for the // specific language governing permissions and limitations under the License.
Currently I have to use OpenOCD to debug the VEGA board, and OpenOCD is not rather slow (compared to a true J-Link). If debugging fails, try to re-power to board and debug probe. If this does not help, try reboot the host machine helps.
OpenOCD replaces the Windows USB drivers which obviously affects working with a J-Link in a normal way. Try reverting the USB drivers back to the original ones and reboot your host machine.
Debugging task code with OpenOCD usually steps into the interrupt service routine: the workaround is to set a breakpoint and run to it.
FreeRTOS V10.2.0 has changed (again 🙁 ) the internal data structure, potentially breaking RTOS debug awareness. For example the FreeRTOS timers might not be shown properly in the debugger. As a workaround, I have added a define to FreeRTOS timers.c to support the previous API:
#define TIMER_LEGACY_API (1) /* << EST: needed to have TAD working */
Error: Could not find target in FreeRTOS compatibility list
I’m now able to run FreeRTOS V10.2.0 on the VEGA board, using Eclipse (MCUXpresso IDE). The IDE has very useful FreeRTOS debugging views. The biggest Achilles heel is OpenOCD. It works, but it is slow and very limiting when using an RTOS. I might have to explore other options than OpenOCD to make debugging a better experience. I hope I can report on this soon in a next article.