Synchronization

Zephyr OS projects synchronization examples

This chapter covers the basics of the Zephyr RTOS Synchronization sample application including creating, building, running, and debugging steps. A simple application that demonstrates basic sanity of the kernel. Two threads (A and B) take turns printing a greeting message to the console and use sleep requests and semaphores to control the rate at which messages are generated. This application can also be built and run on QEMU emulator.


Note: To build, run and debug ZephyrRTOS applications with QEMU emulator, please install the xplor-studio-zephyr blueprint first. Please refer to Guidelines for more information.


Create a new project

Select “File - New - C/C++ Project” choose Zephyr application then Next.

example image

Select Toolchains: RISC-V Custom Toolchains and enter the Project name. Then click Next.

example image

Enter Author then click Next button.

example image

Then click the Finish button. Select Zephyr Base Path then click Next:

example image

Select target board configuration:

example image

example image

Select toolchain path then click Next and Finish.

example image

Build project

The build step is the same as the quick-start project’s step. Please refer to Build project for more information.

If there is any problem related to the CMake, such as:

example image

Please make sure that the version of CMake is 3.20 or higher.

After building successfully, you will see the messages in the Console view:

example image

Running and Debugging project with QEMU emulator

Run project on QEMU Emulator

  • Right-click on current project > Run As > RISV-C application with QEMU

example image

The output of the application is shown in the Console view:

example image

Debug project on QEMU Emulator

The XploR Studio offers several ways to debug applications:

  • Select the Helloworld project entry in the Project Explorer then open the Debug Configuration Dialog. Doing so will enable eclipse to automatically fill out the necessary debug configuration information.

example image

In Debug Configuration Dialog, create new one by double click on RISC-V Debugging:

example image

On tab Debugger, choose option QEMU in Virtual Platforms. Click Apply then click Debug.

example image

  • Select the Helloworld project entry in the Project Explorer then clicking Debug As/RISC-V application with QEMU

example image

  • Right-click on current project > Debug As > RISV-C application with QEMU

example image

After selecting Debug As RISC-V application with QEMU, the IDE changes to the debug perspective and automatically sets a breakpoint in the first line of code in the main() function.

example image

Other functions of debugging (such as Resume, Step Into, Step Over, Step Return, Terminate, …) are the same as the quick-start project’s. Please refer to Running and Debugging project with QEMU emulator for more information.

About other ZephyrRTOS views (Thread view, … ), please refer to Zephyr OS views for more information.