I am trying to test SEGGER FreeRTOS plugin with Nordic SDK v15.0's example `blinky_freertos` on nRF52840 DevKit. Nordic says they use an unmodified version of FreeRTOS V10.0.0 in their SDK v15.0. The example is pretty simple 1 RTOS task, 1 RTOS periodical timer.
I was excepted to see all FreeRTOS tasks with this plugin. I am using the latest SEGGER (V6.34b (DLL compiled Aug 13 2018 16:38:47))
I started SEGGER GDBServer:
It seems to start correctly:
Display All
And then I connected GDB to the GDB server with my ELF file:
I can see in GDB server:
Display All
And in GDB it sees only one thread (the idle task):
Display All
As you might notice there are few mandatory symbols that are NULL:
For your information here is the source code of the example:
Display All
I was excepted to see all FreeRTOS tasks with this plugin. I am using the latest SEGGER (V6.34b (DLL compiled Aug 13 2018 16:38:47))
I started SEGGER GDBServer:
/opt/SEGGER/JLink/JLinkGDBServer -Device nrf52840_XXAA -If SWD -Speed 4000 -rtos /opt/SEGGER/JLink/GDBServer/RTOSPlugin_FreeRTOS.so
It seems to start correctly:
Source Code
- -----GDB Server start settings-----
- GDBInit file: none
- GDB Server Listening port: 2331
- SWO raw output listening port: 2332
- Terminal I/O port: 2333
- Accept remote connection: yes
- Generate logfile: off
- Verify download: off
- Init regs on start: off
- Silent mode: off
- Single run mode: off
- Target connection timeout: 0 ms
- ------J-Link related settings------
- J-Link Host interface: USB
- J-Link script: none
- J-Link settings file: none
- ------Target related settings------
- Target device: nrf52840_XXAA
- Target interface: SWD
- Target interface speed: 4000kHz
- Target endian: little
- Connecting to J-Link...
- J-Link is connected.
- Firmware: J-Link OB-SAM3U128-V2-NordicSemi compiled Jul 12 2018 11:44:41
- Hardware: V1.00
- S/N: 683670808
- Checking target voltage...
- Target voltage: 3.30 V
- Listening on TCP/IP port 2331
- Connecting to target...Connected to target
- Waiting for GDB connection...Connected to 127.0.0.1
And then I connected GDB to the GDB server with my ELF file:
arm-none-eabi-gdb _build/nrf52840_xxaa.out --eval-command='target remote localhost:2331'
I can see in GDB server:
Source Code
- Reading all registers
- Read 4 bytes @ address 0x000006C0 (Data = 0x4100F8D2)
- Reading 64 bytes @ address 0x20000800
- Read 4 bytes @ address 0x000017F0 (Data = 0xBF00E7EC)
- Loading RTOS plugin: /opt/SEGGER/JLink/GDBServer/RTOSPlugin_FreeRTOS.so...
- RTOS plugin (API v1.0) loaded successfully
- RTOS plugin initialized successfully.
- Received symbol: pxCurrentTCB (0x20001094)
- Received symbol: pxReadyTasksLists (0x200010A0)
- Received symbol: xDelayedTaskList1 (0x200010F4)
- Received symbol: xDelayedTaskList2 (0x20001108)
- Received symbol: pxDelayedTaskList (0x20001098)
- Received symbol: pxOverflowDelayedTaskList (0x2000109C)
- Received symbol: xPendingReadyList (0x20001128)
- Received symbol: xTasksWaitingTermination (0x20001154)
- Received symbol: xSuspendedTaskList (0x20001140)
- Received symbol: uxCurrentNumberOfTasks (0x200010DC)
- Received symbol: uxTopUsedPriority (0x00000000)
- Received symbol: uxTopReadyPriority (0x200010F0)
- Received symbol: vPortEnableVFP (0x00000000)
- Received symbol: FreeRTOSDebugConfig (0x00000000)
- All mandatory symbols successfully loaded.
- Reading all registers
Source Code
- Remote debugging using localhost:2331
- vPortSuppressTicksAndSleep (xExpectedIdleTime=200) at ../../../../../../external/freertos/portable/CMSIS/nrf52/port_cmsis_systick.c:255
- 255 } while (0 == (NVIC->ISPR[0] | NVIC->ISPR[1]));
- (gdb) where
- #0 vPortSuppressTicksAndSleep (xExpectedIdleTime=200) at ../../../../../../external/freertos/portable/CMSIS/nrf52/port_cmsis_systick.c:255
- #1 0x000017f0 in prvIdleTask (pvParameters=<optimized out>) at ../../../../../../external/freertos/source/tasks.c:3321
- #2 0x0000050c in ?? ()
- Backtrace stopped: previous frame identical to this frame (corrupt stack?)
- (gdb) info threads
- Id Target Id Frame
- * 1 Thread 57005 vPortSuppressTicksAndSleep (xExpectedIdleTime=200) at ../../../../../../external/freertos/portable/CMSIS/nrf52/port_cmsis_systick.c:255
As you might notice there are few mandatory symbols that are NULL:
For your information here is the source code of the example:
C Source Code
- #include <stdbool.h>
- #include <stdint.h>
- #include "FreeRTOS.h"
- #include "task.h"
- #include "timers.h"
- #include "bsp.h"
- #include "nordic_common.h"
- #include "nrf_drv_clock.h"
- #include "sdk_errors.h"
- #include "app_error.h"
- #if LEDS_NUMBER <= 2
- #error "Board is not equipped with enough amount of LEDs"
- #endif
- #define TASK_DELAY 200 /**< Task delay. Delays a LED0 task for 200 ms */
- #define TIMER_PERIOD 1000 /**< Timer period. LED1 timer will expire after 1000 ms */
- TaskHandle_t led_toggle_task_handle; /**< Reference to LED0 toggling FreeRTOS task. */
- TimerHandle_t led_toggle_timer_handle; /**< Reference to LED1 toggling FreeRTOS timer. */
- /**@brief LED0 task entry function.
- *
- * @param[in] pvParameter Pointer that will be used as the parameter for the task.
- */
- static void led_toggle_task_function (void * pvParameter)
- {
- UNUSED_PARAMETER(pvParameter);
- while (true)
- {
- bsp_board_led_invert(BSP_BOARD_LED_0);
- /* Delay a task for a given number of ticks */
- vTaskDelay(TASK_DELAY);
- /* Tasks must be implemented to never return... */
- }
- }
- /**@brief The function to call when the LED1 FreeRTOS timer expires.
- *
- * @param[in] pvParameter Pointer that will be used as the parameter for the timer.
- */
- static void led_toggle_timer_callback (void * pvParameter)
- {
- UNUSED_PARAMETER(pvParameter);
- bsp_board_led_invert(BSP_BOARD_LED_1);
- }
- int main(void)
- {
- ret_code_t err_code;
- /* Initialize clock driver for better time accuracy in FREERTOS */
- err_code = nrf_drv_clock_init();
- APP_ERROR_CHECK(err_code);
- /* Configure LED-pins as outputs */
- bsp_board_init(BSP_INIT_LEDS);
- /* Create task for LED0 blinking with priority set to 2 */
- UNUSED_VARIABLE(xTaskCreate(led_toggle_task_function, "LED0", configMINIMAL_STACK_SIZE + 200, NULL, 2, &led_toggle_task_handle));
- /* Start timer for LED1 blinking */
- led_toggle_timer_handle = xTimerCreate( "LED1", TIMER_PERIOD, pdTRUE, NULL, led_toggle_timer_callback);
- UNUSED_VARIABLE(xTimerStart(led_toggle_timer_handle, 0));
- /* Activate deep sleep mode */
- SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
- /* Start FreeRTOS scheduler. */
- vTaskStartScheduler();
- while (true)
- {
- /* FreeRTOS should not be here... FreeRTOS goes back to the start of stack
- * in vTaskStartScheduler function. */
- }
- }