When writing embedded software applications on top of an operating system it is often difficult to detect certain timing issues or explain some weird behavior. What is exactly going wrong? Another thing is when studying embedded operating systems it is useful to have a visual presentation of the running behavior of your system. Learning about task priorities, scheduler settings, queue management,...
I have found Percepio Tracealyzer a perfect tool for this kind of things. Tracealyzer can work in 2 ways: in snapshot mode (this is what this tutorial is about) or in streaming mode.
For this guide you are in need for an Avnet MiniZed board (Xilinx Zynq based), the Xilinx vivado tools and Percepio tracealyzer 4 (evaluation version on their website).
Hardware Design (FPGA)Let's get started developing the hardware part (FPGA design) for this guide. If you are new to FPGA design you can just open my hardware design. Otherwise start building the ZYNQ7 based design below:
Place the following components on your block diagram:
- ZYNQ7 Processing System
- AXI GPIO with 2 channels connected to pl_led_g and pl_led_r
- AXI GPIO with 1 channel connected to pl_sw_1bit
You can use auto configuration (using presets) for the ZYNQ7 Processing System) but then you have to add manually the M_AXI_GP0_ACLK port to connect the AXI Slave peripherals.
Use the "auto connection" function to connect the AXI_GPIO blocks to the AXI bus.
Don't forget to add a HDL Wrapper on top of your "block design". Generate the bitstream and export your hardware design to Vivado SDK (including the bitstream).
Software Design and SDK SettingsSelect Xilinx => "Application Project"
Be sure to select FreeRTOS as OS Platform for this Application Project and click Next not "Finish"
Select the FreeRTOS Hello World template.
Change the Board Support Package Settings to use ps7_uart_1 as stdin and stdout
If you make changes to your FreeRTOSConfig.h file when using Vivado SDK for FreeRTOS Application development it gets overwritten every time you generate your application. So you have to copy/paste the libscr files from the bsp to your application.
it is now time for importing the tracealyzer library for using it in our application. This step requires you have succesfully installed Percepio Tracealyzer 4 on your development PC. Click on your application project and select import.
Select File System
Browse to your Tracealyzer installation directory and select the TraceRecoder directory, Add the following files:
Also add all the files in the config and include directory
Now set in FreeRTOSConfig.h (FreeRTOS libscr files in your application project that where copy/pasted; not in your BSP) > configUSER_TRACE_FACILITY to 1
add trcRecoder.h in FreeRTOSConfig.h
Change trcConfig.h We don't have to include the processor header file in Vivado SDK and make TRC_CFG_HARDARE_PORT equal to TRC_HARDWARE_PORT_ARM_CORTEX_A9 (processor on MiniZed)
Change the code in trcKernelPort.h
Move the declaration of uiTraceSystemState up in trcKernelPort.h
Change trcHardwarePort.h
Now it is time to look into our demo FreeRTOS Application. We started with the FreeRTOS Hello World Template from Xilinx SDK. Be sure to start your code with vTraceEnable(TRC_START) in your main function; add some user event code to see them in Tracealyzer.
In the TX Task, RX Task and TimerCallback:
Change C/C++ Build Settings of your Application project
We have to install the Percepio Trace Exporter Plugin that is available for eclipse IDE's.; Select help and click on "Install New Software".
After an SDK reboot you have a new option "Percepio" where you can check and change your preferences.
- Program your FPGA and Start "Debug on Hardware using GDB Debugger"
when you have problems running GDB debugger in Vivado SDK 2019.1 consider the following Xilinx fix: https://www.xilinx.com/support/answers/72549.html
See the "Exporter View" for more information
To take a snapshop Trace click on Percepio => Save Snapshot Trace (do this after you have let the software run for some time).
Start your Percepio Tracealyzer 4 Application and open your save bin file. You can change the views and zoom in.
•https://github.com/pxltech/Embedded-Operating-System/tree/master/Zynq/MiniZED_FreeRTOS_Trace
•https://percepio.com/tracealyzer/
•https://percepio.com/gettingstarted/
•https://percepio.com/rtos-debug-portal/
•https://percepio.com/gettingstarted-freertos/
•https://percepio.com/tracealyzer-application-notes/
Have fun developing FPGA-based real-time applications on MiniZed! ;-)
Kind regards
Vincent
Comments