• Home
  • Robotics
  • 3D Printing
  • Web
  • Microcontrollers
  • Frameworks
  • Protocols
  • Other
  • Explore knowledge
  • Loading graph.
    Depth
    …
    … visible
  • Home
  • Robotics
  • 3D Printing
  • Web
  • Microcontrollers
  • Frameworks
  • Protocols
  • Other
Tools
    Pages
    • Frameworks
      • Raspi IoT
      • Home Assistant
      • micro Python
      • Zephyr RTOS
    Pages
    • Frameworks
      • Raspi IoT
      • Home Assistant
      • micro Python
      • Zephyr RTOS
    Home/Frameworks/zephyr
    Metadata
    description
    The linux style RTOS for microcontrollers
    date
    2021-02-20
    Thread Protocol
    Project Matter

    Trace with with SystemView

    • Segger SystemView : Real time OS Tracing
    • SystemView user manual : Getting started, API reference,...

    Caution

    It's highly recommended to read the SystemView user manual to understand how the RT OS concepts are displayed

    Steps :

    • Install SystemView

    • compile the target with the overlay overlay-tracing.conf and flash, reset

    • SystemView Recorder configuration J-Link, NRF52840_XXAA, SWD, 4000 KHz

    • SystemView Start Recording the Stop Recording

    • if SystemViewer keeps crashing try closing the window CPU load

    image-systemview.webp
    ×

    content of overlay-tracing.conf

    Conf
    #Tracing
    CONFIG_TRACING=y
    CONFIG_SEGGER_SYSTEMVIEW=y
    CONFIG_THREAD_NAME=y
    CONFIG_SEGGER_SYSTEMVIEW_BOOT_ENABLE=y
    # careful adjustment as long as there is enough SRAM use it for tracing 128 KB
    CONFIG_SEGGER_SYSVIEW_RTT_BUFFER_SIZE=131072

    Hints

    • power on tracing : In case a power-on startup has to be traced, it is necessary to increase the target local RTT buffer size, because it keeps bauffering the tracing until the user has the time to start SystemView recording. For that, it is important to check how much free memory the system has, and then adjust the RTT buffer

    • ISR ID Identification : the function sysview_get_interrupt() is using SCB->ICSR VECTACTIVE

    • not the same as IRQn_Type defined in modules\hal\nordic\nrfx\mdk\nrf52840.h

    No table data available.

    Debug with OZone

    • Ozone : performance analyzer
    • RTOS Awareness : debug an RTOS

    Steps :

    • make sure to use Ozone version 3.22d or higher

    • in the new project wizard, make sure an svd file is selected e.g. from the Zephyr projecz modules\hal\nordic\nrfx\mdk\nrf52840.svd

    • For a Segger j-link edu, select the Target interface SWD

    • compile with CONFIG_DEBUG_THREAD_INFO=y

    • select the elf file of the Zephyr build hsm/hsm/samples/tag_power/build/zephyr/zephyr.elf

    • in the bottom left console type Project.SetOSPlugin("ZephyrPlugin_CM4"). That will load the Zephyr RTOS awareness plugin

    • you should now be able to access the Zephyr debug window from the menu View then in the Advanced section Zephyr

    image-ozone_zephyr.png
    ×

    Serial Debug

    • Log : CONFIG_LOG creates a logging thread and enables LOG_INF(), LOG_DBG(),... functions

      • needs a backend e.g. CONFIG_LOG_BACKEND_RTT, CONFIG_LOG_BACKEND_UART

    • Shell : CONFIG_SHELL creates a shell_xxx thread that enables an interactive command line e.g. rtt:~$ kernel threads

      • needs a backend e.g. CONFIG_SHELL_BACKEND_RTT, CONFIG_SHELL_BACKEND_SERIAL

    shell command examples

    Shell
    >help
    >kernel threads
    >kernel stacks
    >log enable dbg main
    

    Windows Install

    Getting Started details...

    The details are in the link above, the summary of the step for installing on windows are

    • Installing choco

    • Installing west dependencies with choco

    • installing west with pip

    • the retrieving the repo and building are performed through west

    • The compiler toolchain as multiple options

      • Zephyr own SDK, not available on windows

      • GNU ARM Embedded : to be installed on a path without spaces

    e.g. for a path "D:\tools\gnu_arm_embedded\9_2020-q2-update\bin\arm-none-eabi-gcc.exe" GNUARMEMB_TOOLCHAIN_PATH shall be set to D:\tools\gnu_arm_embedded\9_2020-q2-update

    Linux Install

    • installing Zephyr with its own compiler toolchain Zephyr SDK

    • install Zephyr dependencies - Ubuntu
    • install nRF Command Line tools
    Bash
    tar -xf nRFCommandLineTools10121Linuxamd64.tar.gz
    sudo dpkg -i nRF-Command-Line-Tools_10_12_1_Linux-amd64.deb

    Build and Flash

    Testing blinky sample

    add CONFIG_BOARD_HAS_NRF5_BOOTLOADER=n to prj.conf

    tested version 2.5.99

    Bash
    cd ~/zephyrproject/zephyr/samples/basic/blinky
    west build -p auto -b nrf52840dongle_nrf52840 -- -DCONF_FILE=prj.conf
    west flash
    nrfjprog -f nrf52 --reset

    RTT config

    required configuration to have logs running over the segger j-link RTT (log through the same SWD interface used for programming)

    prj.conf
    Conf
    CONFIG_GPIO=y
    CONFIG_SERIAL=n
    CONFIG_BOARD_HAS_NRF5_BOOTLOADER=n
    
    # Logging
    CONFIG_LOG=y
    CONFIG_LOG_BACKEND_RTT=y
    CONFIG_LOG_BACKEND_UART=n
    CONFIG_BOOT_BANNER=y
    CONFIG_USE_SEGGER_RTT=y
    CONFIG_CONSOLE=y
    CONFIG_UART_CONSOLE=n
    CONFIG_RTT_CONSOLE=y
    main.c
    C
    #include <zephyr.h>
    #include <logging/log.h>
    LOG_MODULE_REGISTER(main, LOG_LEVEL_INF);
    void main(void)
    {
    	LOG_INF("Starting");
    	int count = 0;
    	while (1) {
    		LOG_INF("loop: %d",count++);
    	}
    }
    
    pio zephyr log example
    ← PreviousHome AssistantNext →micro Python
    On this page
    • Trace with with SystemView
      • Hints
    • Debug with OZone
    • Serial Debug
      • shell command examples
    • Windows Install
    • Linux Install
    • Build and Flash
      • RTT config
    Open page ×