BlackMagic + FreeRTOS: yes we can


Sometimes it really helps to have RTOS support in the debugger (i.e. gdb), that would be FreeRTOS in our case.
But sadly, my beloved blackmagic does not support it and i dont like much St link v2+ openOcd (tastes & colors...)

So let's modify a github project to add the function we need  : new  Git Hub Project: armFreeRTOS-GDB

Short version : List the tasks, their status and be able to switch the active one (sort of)

Current state

 (gdb) source ~/FreeRTOS-GDB/src/FreeRTOS.py 
 (gdb) show Task-List 
   0   TCB: 0x20001160 Name:    MainTask State:Delay1 TopOfStack:0x200010f0
                   LR=0x8005fa7 PC=0x8006078 SP=0x20001130 function=vTaskDelay
  1   TCB: 0x20001348 Name:      dummy1 State:Delay1 TopOfStack:0x200012f0
                   LR=0x8005fa7 PC=0x8006078 SP=0x20001330 function=vTaskDelay
  2   TCB: 0x20001530 Name:      dummy2 State:Delay1 TopOfStack:0x200014d8
                 LR=0x8005fa7 PC=0x8006078 SP=0x20001518 function=vTaskDelay
  3 * TCB: 0x20001988 Name:        IDLE 

  (gdb)bt
  #0  0x08005c22 in prvCheckTasksWaitingTermination () at /home/fx/Arduino_stm32/tester/FreeRTOS/Source/tasks.c:3589
  #1  prvIdleTask (pvParameters=<optimized out>) at /home/fx/Arduino_stm32/tester/FreeRTOS/Source/tasks.c:3351
  #2  0x08006360 in pvTaskIncrementMutexHeldCount () at /home/fx/Arduino_stm32/tester/FreeRTOS/Source/tasks.c:4558



switch to Task 2

  (gdb) switchTCB 2
  (gdb) show Task-List
  0   TCB: 0x20001160 Name:    MainTask State:Delay1 TopOfStack:0x200010f0
                 LR=0x8005fa7 PC=0x8006078 SP=0x20001130 function=vTaskDelay
  1   TCB: 0x20001348 Name:      dummy1 State:Delay1 TopOfStack:0x200012f0
                 LR=0x8005fa7 PC=0x8006078 SP=0x20001330 function=vTaskDelay
  2 * TCB: 0x20001530 Name:      dummy2 
  3   TCB: 0x20001988 Name:        IDLE State:Ready  TopOfStack:0x20001938
                 LR=0x8006361 PC=0x8005c22 SP=0x20001978   function=prvCheckTasksWaitingTermination

(gdb) bt
  #0  vTaskDelay (xTicksToDelay=xTicksToDelay@entry=101) at   /home/fx/Arduino_stm32/tester/FreeRTOS/Source/tasks.c:1365
  #1  0x080065a6 in xDelay (ms=ms@entry=100) at  /home/fx/Arduino_stm32/tester/FreeRTOS/MapleFreeRTOS1000_pp.cpp:80
  #2  0x0800042e in dummyTask (b=<optimized out>) at /home/fx/Arduino_stm32/tester/myCode.cpp:40
  #3  0x08006360 in pvTaskIncrementMutexHeldCount () at /home/fx/



Good enough for me !



Comments

Popular posts from this blog

Component tester with STM32 : Part 1 ADC, Resistor

Fixing the INA3221

INA3221, weird wiring