In this chapter, you will learn about embedded operating system flows and discover the tools used to build a complex software application to run on an FPGA SoC. You will use the design tools available to create the SoC board support package (BSP) for the desired embedded operating system – in this case, FreeRTOS. You will go through the process of generating the SoC bootloader, which runs when the SoC is powered up and launches the embedded software. This chapter is also hands-on, so you will be guided through every step of the design process. Here, you will go through all the embedded software development phases, starting from the initial concept, followed by the actual software building, and then running it on a hardware board or a virtual platform.
In this chapter, we’re going to cover the following topics:
The GitHub repo for this title can be found here: https://github.com/PacktPublishing/Architecting-and-Building-High-Speed-SoCs.
Code in Action videos for this chapter: http://bit.ly/3WHLVJd.
In Chapter 8, FPGA SoC Software Design Flow, we covered the design flow of a piece of bare-metal embedded software targeting the Electronic Trading System (ETS) SoC. In this chapter, we will go over the steps required to build a Real-Time Operating System (RTOS)-based software application targeting an FPGA SoC. We will perform the entire design flow within the Vitis environment and choose FreeRTOS as the embedded operating system (OS). The design flow can start from a hardware design previously performed in the Vivado environment that has been exported as an XSA archive file (such as the ETS SoC design example). This is then chosen in the Vitis IDE as hosting hardware for the SoC. An alternative method is to choose a Zynq-7000 SoC demo board as the target hardware and perform the necessary steps to create the required framework, as will be detailed in this chapter. Follow these steps to design a FreeRTOS-based SoC software:
$ sudo /<install path of Vitis>/Xilinx/Vitis/2022.1/bin/vitis
Figure 12.1 – Creating a new platform project in the Vitis IDE
Figure 12.2 – Creating a new platform project from XSA in the Vitis IDE
Figure 12.3 – Selecting the OS and the processor for the new platform project in the Vitis IDE
Figure 12.4 – Newly created RTOS_SoC platform project in the Vitis IDE
Figure 12.5 – Launching the New Application Project wizard in the Vitis IDE
Figure 12.6 – Specifying the platform for the new application project in the Vitis IDE
Figure 12.7 – Specifying the new application project name in the Vitis IDE
Figure 12.8 – Specifying the domain to associate with the new application project
Figure 12.9 – Selecting the FreeRTOS Hello World template for the application project
Figure 12.10 – FreeRTOS application project added in Vitis Explorer
With that, we have generated the BSP, the bootloader, and the FreeRTOS application projects. Next, we will delve into the BSP and the bootloader, before examining the application software building process in the last section of this chapter.
It is important to understand the layout of an RTOS-based software implementation of an FPGA-based SoC and its different components within the Vitis environment. We know from the previous chapter that on Power-on-Reset (PoR) or following a global system reset, the Cortex-A9 core 0 processor boots from the BootROM in a secure way. Depending on the security settings, a secure boot is started if instructed to do so; if not, a Non-Secure (NS) boot takes place. However, under whichever specified boot mode (secure or NS) by eFuse or the Battery-Backed RAM (BBRAM), the First Stage Boot Loader (FSBL) is the next image to be loaded by the BootROM from Non-Volatile Memory (NVM) NAND, NOR, or QSPI Flash. We also know that an FPGA bitstream can optionally be loaded from the NVM and prepared for configuring the FPGA logic according to the security settings. Finally, it is the FSBL that decides what other images to load from NVM and how to prepare them according to the system security settings. These images include the application software to run on the SoC. Also, running software on FreeRTOS requires the use of a specific BSP that Xilinx has ported using the FreeRTOS packages and its own libraries, as well as the IP drivers used in the design. The Vitis IDE automates a lot of customization under the hood and lets you choose the components you want services from, as well as the minimum required to boot FreeRTOS and run its services on the FPGA SoC. The following steps will show you how to create the BSP for our FreeRTOS application project, as well as provide an insight into its visual structure and included components that we can customize if needed by our end application:
Figure 12.11 – BSPs for the FSBL and FreeRTOS application projects
Figure 12.12 – BSPs for the FreeRTOS application project summary
Figure 12.13 – The Board Support Package Settings window
Figure 12.14 – Building the BSP components for FSBL and FreeRTOS
This will generate the necessary FSBL components and libraries required by the application building process for FreeRTOS.
Now, we will build the FreeRTOS Hello World application and run it on the virtual platform within the Vitis IDE. By doing so, we can revisit the application template source code and build upon it so that it matches our software requirements. For the ETS SoC project, we can generate another FreeRTOS application based on a UDP client template provided by the Vitis project creation wizard and use it as a starting example. It is by itself a proper software project that requires modifying the Xilinx Ethernet drivers so that they match the microarchitecture requirements of our design. We have access to the driver’s source code and the UDP client template to achieve this. As an exercise for any embedded software developers using this book, it can be a nice challenge to implement the software design presented in Chapter 8, , FPGA SoC Software Design Flow, by using the knowledge you’ve accumulated thus far. From the Electronic Trading Market (ETM) side, the User Datagram Protocol (UDP) server example can be used as a starting template, though any other UDP server software from the open source community can be implemented on a Linux host to act as the ETM and provide the UDP streams as per the defined ETM protocol.
To build the FreeRTOS software application in the Vitis IDE and run it on the virtual platform, follow these steps:
Figure 12.15 – Building the FreeRTOS project application
Figure 12.16 – Vitis IDE console showing the FreeRTOS software image being built
Figure 12.17 – Launching the FreeRTOS application image on the virtual platform in the Vitis IDE
Figure 12.18 – Running the FreeRTOS application image on the virtual platform in the Vitis IDE
The FreeRTOS Hello World application will run on the virtual platform to completion, as shown in the preceding screenshot.
This will complete the complex software design flow in the Vitis IDE, from the initial platform specification to running the FreeRTOS application generated as a template by the Vitis IDE. In this example, we used the Vitis-included QEMU virtual platform, which will help greatly in learning the details of developing an RTOS-based embedded software for advanced high-speed SoCs targeting the Xilinx Zynq-7000 SoC FPGAs.
In this chapter, we looked at the key steps required to build a complex RTOS-based software application and specifically its associated software design flow within the Vitis IDE. We covered all the steps required in this process. We also looked at the platform generation using an existing XSA file for a known demo board to generate a platform and its associated project domain. Then, we learned how to generate a software application associated with the created domain and showed the necessary settings for the FreeRTOS embedded OS. We also generated an application software project example to run on FreeRTOS. We delved into the bootloader topic and how to create and customize the BSP for both the FSBL and FreeRTOS software application projects. Then, we built and ran these software projects on the QEMU virtual platform within the Vitis IDE. The output loggings from the software application on the QEMU console echoed a successful software application run.
In the next chapter, we will explore more topics related to FPGA-based SoC advanced applications with a focus on digital signal, image, and video processing.
Answer the following questions to test your knowledge of this chapter:
3.239.76.211