[SOLVED] SystemView in FreeRTOS not starting

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [SOLVED] SystemView in FreeRTOS not starting

    Hi there,

    Since several days I'm trying to get SystemView running but it always ends up in a configASSERT() = endless loop. I suppose that this issue has to do with interrupts or a misconfigured NVIC.
    So far I've checked the SystemView documentation "System View User Guide" (UM08027) and compared what's written on page 54 with my config which seems to be "equal". Prior trying out SystemView I've checked out RTT which is running.
    As background information I want let you know that I'm working at a non-profit organization on a research project which makes use of FreeRTOS 10.x on the new STM32WB55 Nucleo board, because we want make use of the Bluetooth 5 standard.

    In the source code are currently two task implemented. Without starting SEGGER_SYSVIEW_Start() these two task are running as expected. If I start SEGGER_SYSVIEW_Start() first this function will never return.

    The main function is the following:

    C Source Code: main.cpp

    1. #include "SEGGER_RTT.h"
    2. #include "FreeRTOS.h"
    3. #include "task.h"
    4. #include "cmsis_os.h"
    5. void vTask1(void*);
    6. void vTask2(void*);
    7. main()
    8. {
    9. HAL_Init(); // this function finally does only SET_BIT(FLASH->ACR, FLASH_ACR_PRFTEN) and HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
    10. SystemClock_Config(); // several RCC_* initialization and peripheral clock initialization
    11. HAL_NVIC_SetPriority(PendSV_IRQn, 15, 0); // originally this is HAL_MspInit(); //
    12. DWT->CTRL |= (1 << 0); // enable CYCCNT (Cycle Counter Register, DWT_CYCCNT, address 0xE0001024@Cortex-M4) for Segger SystemView
    13. SEGGER_SYSVIEW_Conf();
    14. SEGGER_SYSVIEW_Start(); // here it ends if not commented out
    15. SEGGER_RTT_printf(0, "%sCounter: %s%d\n", RTT_CTRL_TEXT_BRIGHT_WHITE, RTT_CTRL_TEXT_BRIGHT_GREEN, 4); // some text to check if J_Link RTT Viewer is working
    16. xTaskCreate(vTask1, "Task-1", configMINIMAL_STACK_SIZE, NULL, 2, &xTaskHandle1);
    17. xTaskCreate(vTask2, "Task-2", configMINIMAL_STACK_SIZE, NULL, 2, &xTaskHandle2);
    18. vTaskStartScheduler();
    19. while(1)
    20. {};
    21. }
    22. void vTask1(void *params)
    23. {
    24. SEGGER_RTT_WriteString(0, "Hello from task A!\n");
    25. while(true)
    26. {
    27. SEGGER_RTT_WriteString(0, "task 1\n");
    28. }
    29. }
    30. void vTask2(void *params)
    31. {
    32. SEGGER_RTT_WriteString(0, "Hello from task B!\n");
    33. while(true)
    34. {
    35. SEGGER_RTT_WriteString(0, "task 2\n");
    36. }
    37. }
    Display All



    The call stack (in reverse order) is this:

    main() at main.cpp: 166
    SEGGER_SYSVIEW_Start() at SEGGER_SYSVIEW.c: 1684
    SEGGER_SYSVIEW_RecordSystime() at SEGGER_SYSVIEW.c: 1825
    _cbGetTime() at SEGGER_SYSVIEW_FreeRTOS.c: 117
    xTaskGetTickCountFromISR() at tasks.c: 2329
    vPortValidateInterruptPriority() at port.c: 776
    vPortRaiseBASEPRI() at portmacro.h: 195

    In the last functions the interesting variables are:

    C Source Code: port.c

    1. static void vPortEnableVFP( void )
    2. {
    3. ...
    4. __asm volatile( "mrs %0, ipsr" : "=r"( ulCurrentInterrupt ) :: "memory" ); // ulCurrentInterrupt = 0
    5. ...
    6. if( ulCurrentInterrupt >= portFIRST_USER_INTERRUPT_NUMBER ) // portFIRST_USER_INTERRUPT_NUMBER = 16 ==> not true
    7. { ... }
    8. configASSERT( ( portAIRCR_REG & portPRIORITY_GROUP_MASK ) <= ulMaxPRIGROUPValue ); // portAIRCR_REG = 0xFA050300, portPRIORITY_GROUP_MASK = 0x700, ulMaxPRIGROUPValue = 0
    9. --> portFORCE_INLINE static void vPortRaiseBASEPRI( void )
    (only the first number reflects the number in the original source code)

    Because ulCurrentInterrupt is always '0' I suppose that there is a mistake within the NVIC configuration but I don't know what's wrong with it. Has someone any clue what's wrong?
  • Hi CharlesDias,

    That was the solution for my problem also! Good job! :thumbsup: I wrote you a personal message with the question if your fix is final or did you experienced any issues with it. And I rode your answer about this (nothing added so far). I suppose there's an incompatibility issue between Segger's SystemView and FreeRTOS 10.2.1 of something inside FreeRTOS that (in specific circumstances?) the variable ulCurrentInterrupt will not be set to it's correct value. The call to the added function void vSetVarulMaxPRIGROUPValue(void) I've added in rule 725 of port.c (see below) of the FreeRTOS kernel sources and until now I've experienced no issues. Ok, I did not do a lot of thing in the meantime.

    C Source Code: port.c

    1. #if( configASSERT_DEFINED == 1 )
    2. void vPortValidateInterruptPriority( void )
    3. {
    4. vSetVarulMaxPRIGROUPValue(); // added function call to set ulMaxPRIGROUPValue otherwise it will end up in an endless loop
    5. uint32_t ulCurrentInterrupt;
    6. uint8_t ucCurrentPriority;
    7. /* Obtain the number of the currently executing interrupt. */
    8. __asm volatile( "mrs %0, ipsr" : "=r"( ulCurrentInterrupt ) :: "memory" );
    9. ...
    Display All
    So far, I would say it's solved for me also but I would like to check additional things out to make this final.