Zephyr RTOS Application Development
Zephyr is an open-source Real-Time Operating System (RTOS) designed to support multiple architectures and embedded systems. It provides a lightweight, scalable, and modular framework, making it ideal for real-time applications. Zephyr includes extensive driver support, networking capabilities, and security features, ensuring robust performance across various hardware platforms.
PHYTEC offers Zephyr board support for the co-processor located in the MCU domain, enabling developers to leverage Zephyr’s capabilities for efficient and reliable embedded solutions. This integration allows seamless execution of real-time tasks, making it suitable for industrial, automotive, and IoT applications.
For more details on PHYTEC’s Zephyr board support, refer to the official Zephyr documentation, which provides comprehensive information on setup, configuration, and usage.
Interface |
Detail |
Status |
Notes |
---|---|---|---|
Timer |
timer0 |
Unsupported |
|
timer1 |
Unsupported |
||
timer2 |
Unsupported |
||
timer3 |
Unsupported |
||
UART |
uart0 |
Supported |
|
uart1 |
Supported |
||
I2C |
i2c0 |
Unsupported |
|
i2c1 |
Unsupported |
||
SPI |
spi0 |
Unsupported |
|
spi1 |
Unsupported |
||
GPIO |
gpio0 |
Supported |
No interrupt support |
Warning
Please keep in mind our Zephyr port is currently not ready for production and is still work in progress!
Host Setup
Zephyr provides a pre-configured container image that includes all necessary packages and dependencies. However, some additional tools must be installed on the host system. Run the following commands to ensure they are available:
sh-host:~$ sudo apt-get update
sh-host:~$ sudo apt-get install podman
Note
Podman may not be available for Ubuntu 20.04 by default. Refer to this Guide for instructions on obtaining it from alternative sources.
Setting Up the Source Directory
Create a dedicated directory on your host machine to store the files and navigate to it:
sh-host:~$ mkdir -p ~/BSP-Yocto-Ampliphy-AM64x-PD24.1.1/zephyr/mcu_m4fss
sh-host:~$ cd ~/BSP-Yocto-Ampliphy-AM64x-PD24.1.1/zephyr/mcu_m4fss
Podman
Zephyr provides a container image with all required dependencies pre-installed. To get started, pull the latest image from GitHub:
sh-host:~$ podman pull ghcr.io/zephyrproject-rtos/zephyr-build:v0.27.4
To start the container, use:
sh-host:~$ podman run --rm=true -v $PWD:/workdir --userns=keep-id -it ghcr.io/zephyrproject-rtos/zephyr-build:v0.27.4
The startup process may take a few seconds. Once ready, the shell prompt will change, indicating that you are inside the container. You need to run this command each time you open a new shell session.
Note
Type exit to leave the container.
Downloading the Example Application
PHYTEC provides an example application for Texas Instruments co-processors. To download the application and its dependencies, including Zephyr and necessary Hardware Abstraction Layers, run:
sh-container:~$ west init -m https://github.com/phytec/zephyr-phytec-ti-examples --mr main .
sh-container:~$ west update
sh-container:~$ west west-export
Building the Firmware
To compile the firmware, navigate to the application directory and execute:
sh-container:~$ cd zephyr-phytec-ti-examples/
sh-container:~$ west build -p auto -b phyboard_electra/am6442/m4 app
Additional Configuration Options
You can enable or disable specific configurations by passing additional parameters. For example:
Enable an interactive shell:
sh-container:~$ west build -p auto -b phyboard_electra/am6442/m4 app -- -DEXTRA_CONF_FILE=shell.conf
Include debug information in the firmware:
sh-container:~$ west build -p auto -b phyboard_electra/am6442/m4 app -- -DEXTRA_CONF_FILE=debug.conf
Flashing and Running the Firmware
After building, the firmware is located in the build directory as:
build/zephyr/zephyr.elf
To transfer the firmware to the target device, follow the instructions in the Copying Files to the Device section. The firmware must be placed in the following location on the target:
/lib/firmware/am64-mcu-m4f0_0-fw
Currently, only U-Boot can start the firmware. To run it, manually update the SD card, power up the board, and stop in the U-Boot prompt. Then, execute the following commands:
sh-uboot:~# load mmc 1:2 ${loadaddr} /lib/firmware/am64-mcu-m4f0_0-fw
sh-uboot:~# rproc load 0 ${loadaddr} 0x${filesize}
sh-uboot:~# rproc start 0
Once started, the second stdout console on connector X4 should display the Zephyr boot banner and the example application running. The baud rate for this console is set to 115200.