Setup SystemView with FreeRTOS in IAR

  • I work on a project which uses Renesas RA6M5 MCU. The FreeRTOS version is 10.4.3. We use IAR 9.10. I installed the latest version of JLink V798a. The SystemView version is V3.54.

    I'm trying to setup the Segger SystemView with FreeRTOS. I followed https://wiki.segger.com/FreeRTOS_with_SystemView. I also followed the document "UM08027.pdf".

    Here are what I did:
    1. After Segger SystemView software installed. Copy these folders to my project:
    C:\Program Files\SEGGER\SystemView\Src\Config -> myProject\Segger\SystemView\Config
    C:\Program Files\SEGGER\SystemView\Src\Sample\FreeRTOSV10.4 -> myProject\Segger\SystemView\FreeRTOS
    C:\Program Files\SEGGER\SystemView\Src\SEGGER -> myProject\Segger\SystemView\Source

    2. Add these files in the IAR project. Please see attached "Segger_Integration_Files.png":
    /Config/Global.h
    /Config/SEGGER_RTT_Conf.h
    /Config/SEGGER_SYSVIEW_Conf.h
    /FreeRTOS/Config/Cortex-M/SEGGER_SYSVIEW_Config_FreeRTOS.c
    /FreeRTOS/SEGGER_SYSVIEW_FreeRTOS.c
    /FreeRTOS/SEGGER_SYSVIEW_FreeRTOS.h
    /Source/SEGGER.h
    /Source/SEGGER_RTT.c
    /Source/SEGGER_RTT.h
    /Source/SEGGER_RTT_ASM_ARMv7M.S
    /Source/SEGGER_RTT_printf.c
    /Source/SEGGER_SYSVIEW.c
    /Source/SEGGER_SYSVIEW.h
    /Source/SEGGER_SYSVIEW_ConfDefaults.h
    /Source/SEGGER_SYSVIEW_Int.h

    3. Add the files path in the project options:
    Project->Options->Runtime Checking->C/C++ Compiler->Preprocessor
    Project->Options->Runtime Checking->Assembler->Preprocessor

    4. At the end of FreeRTOSConfig.h or before every "FreeRTOS.h" add

    Code
    #include "SEGGER_SYSVIEW_FreeRTOS.h"

    5. Update the configurations:
    5.1) Change: configUSE_TRACE_FACILITY 1
    5.2) Change SEGGER_SYSVIEW_ConfDefaults.h: SEGGER_SYSVIEW_RTT_BUFFER_SIZE (1024*5)
    5.3) In SEGGER_SYSVIEW_Config_FreeRTOS.c

    Code
    #define SYSVIEW_APP_NAME        "FreeRTOS My Device"
    #define SYSVIEW_DEVICE_NAME     "My Device"
    #define SYSVIEW_RAM_BASE        (0x20000000)

    5.4) From the definition, the SEGGER_SYSVIEW_CORE is SEGGER_SYSVIEW_CORE_CM3. But MCU is Renesas R7FA6M5AH, which is Cortex-M33. But I don't see any definition for Cortex-M33. Is it okay to have SEGGER_SYSVIEW_CORE as SEGGER_SYSVIEW_CORE_CM3 for my MCU?

    6. Apply the Git path:
    6.1) In the path file line #9, there is no INCLUDE_pxTaskGetStackStart. But I added "#define INCLUDE_pxTaskGetStackStart 1"
    6.2) Maybe because I'm using the FreeRTOS from Renesas, I don't have "FreeRTOS/Source/portable/GCC/ARM_CM0/port.c", "FreeRTOS/Source/portable/GCC/ARM_CM3/port.c", or "FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c". Therefore, I don't have "xPortSysTickHandler()". But I have "Renesas\fsp_3.5.0\ra\fsp\src\rm_freertos_port\port.c". So I changed "void SysTick_Handler (void)" to apply the line #108 - #120.
    6.3) For the same reason, I don't have "FreeRTOS/Source/portable/GCC/ARM_CM0/portmacro.h", "FreeRTOS/Source/portable/GCC/ARM_CM3/portmacro.h", or "FreeRTOS/Source/portable/GCC/ARM_CM4F/portmacro.h". But I do have "Renesas\fsp_3.5.0\ra\fsp\src\rm_freertos_port\portmacro.h". So I added:

    Code
    // I have to add these in order to get it compile:
    #define portNVIC_INT_CTRL_REG     ( *( ( volatile uint32_t * ) 0xe000ed04 ) )
    #define portNVIC_PENDSVSET_BIT    ( 1UL << 28UL )
    
    
    #define portEND_SWITCHING_ISR( xSwitchRequired ) { if( xSwitchRequired ) \
            { traceISR_EXIT_TO_SCHEDULER(); portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT; } else { traceISR_EXIT(); } }

    6.4) For line #210, I can't find "void prvAddNewTaskToReadyList(". But I found the statements in "void vTaskSuspend( TaskHandle_t xTaskToSuspend )". So I added these. Not sure if I did it correctly or not:
    traceMOVED_TASK_TO_SUSPENDED_LIST(pxTCB);

    7. Add the following code before the task creations and "vTaskStartScheduler()":
    SEGGER_SYSVIEW_Conf();
    SEGGER_SYSVIEW_Start();

    After the above changes, I got the build passed. So I started my firmware and then paused it. I checked _SEGGER_RTT. I tried to export the data. But there is no way in IAR to export the data as "Raw Binary". I can't save it as SVdat format. Please see attached "IAR_Save_Memory.png". How can I export the memory data as binary in IAR?

    I also tried to get the Continuous Recording working. In SystemView, I configured the JLink. Please see attched "Segger_SystemView_RecorderConfig.png". I hit the "Start Recording" button. After running 1% for a couple of seconds, the execution stopped. There is nothing showing up in the SystemView. Could you please point out where I did it wrong?

    Thanks in advance!

  • Hi,

    I am also in similar situation. Also using FreeRTOS 10.4.3. I've been able to get some information back from the device before the SystemView (v3.54) crashes. See profile_log.PNG attached.

    One thing to add, is that I had to manually add

    C
    #define RTT_USE_ASM (0)


    to SEGGER_RTT_Config.h because it could not link the `.S` for ARMV7, since I am using Renesas R7FA6M5BH which is ARMV8, I thought that would be ok. I found this here (link).

    I can compile and run my FreeRTOS application, but cannot understand why the SystemViewer is crashing. If anyone from SEGGER could give some insights that would be very much appreciated. I have attached the crash log from Windows. WERF4A2.tmp.WERInternalMetadata.xml

    The application seems to crash after some data has been received from the FreeRTOS via J-Link. I have found that in the Recorder Configuration, I need to tell where the RTT Control Block is, so I just point it to the location in RAM (0x20000B3C).

    Regarding the patching steps, I went through the patch file manually and made the changes myself to the required files. Primarily because the project is not using e2 IDE and instead uses custom build using CMake.

    Like you said, I also don't have the CM3/CM4 ports header files. I just see one matching file port.c that says

    C
    /*-----------------------------------------------------------
    
    
     * Implementation of functions defined in portable.h for RA MCUs
    
    
     *----------------------------------------------------------*/

    I have followed steps from this SEGGER guide (link).

    The only way I can get data out, is to flash my .elf using Ozono, start the application, Disconnect Ozone from target. Start SystemView, configure Recorder, click Run. I can see some data for a short period of time before the application crashes.

    Just to add, this is what I see in the SystemView Log tab


    Would like to resolve this crashing issue to evaluate the tool more properly.

    Thanks

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!