Zephyr RTOS Practical Application on the OK-MX9352-C Development Board
by yir65681 in Circuits > Linux
17 Views, 0 Favorites, 0 Comments
Zephyr RTOS Practical Application on the OK-MX9352-C Development Board
Zephyr is an open-source real-time operating system (RTOS) incubated by the Linux Foundation, backed by industry giants such as Intel, NXP, Nordic Semiconductor, Google, Qualcomm, Synopsys, and Meta. To date, Zephyr has evolved to the v4.x series, supporting over 700 development boards across mainstream architectures including ARM, ARM64, RISC-V, ARC, Xtensa, and x86. It features a comprehensive driver framework, a hardware description mechanism using Devicetree, and a vibrant community ecosystem.
Zephyr is not merely a replacement for traditional RTOSes; instead, it introduces cloud-era development concepts into the resource-constrained embedded world. As a next-generation foundational software, it addresses challenges such as fragmentation, security, and development efficiency. Its design philosophy emphasizes modularity, scalability, and out-of-the-box usability.
The i.MX 9352, a lightweight edge AI processor from NXP, integrates two Cortex-A55 cores and one Cortex-M33 real-time core. Its architecture is designed to balance real-time performance with complex task-handling capabilities. To help developers fully leverage the real-time capabilities of the i.MX 9352's M33 core, this article provides a comprehensive development experience using VSCode with MCUX extensions. It guides readers through validating the PWM driver for the M33 core on Zephyr, enabling quick onboarding for porting and testing Zephyr on industrial-grade SoCs.
Tool Preparation
It is recommended to use the NXP MCUXpresso for VS Code extension, which includes:
CMakePresets.json for one-click builds
SEGGER J-Link / LinkServer debugging support
Device Tree visualization (preview .overlay files)
Installation Steps:
1. Install VS Code.
2. Search for and install the MCUXpresso for VS Code extension in the Extensions Marketplace.
3. Follow the plugin's prompts to install west, the Zephyr SDK, and arm-none-eabi-gcc.
Project Structure
Use CMakePresets.json to manage build configurations. Each application follows a unified structure as shown below:
CMakePresets.json example:
In VSCode, click the ''Build'' button in the bottom status bar to compile, eliminating the need for manual command entry.
Devicetree Overlay
The Core of Zephyr's Hardware Abstraction
Zephyr describes hardware through Devicetree, where board-specific differences are added via .overlay files, leaving the main DTSI files unmodified. This is a key design element for Zephyr's portability.
Overlay Description for an RTC Peripheral
The RTC (Real-Time Clock) is an essential peripheral in industrial and consumer electronics. In Zephyr, external RTC chips are connected via an I2C bus and are fully described in an .overlay file. The application layer can then use the unified RTC API without needing to understand the underlying hardware differences.
Taking the example of connecting an EPSON RX8010 to the i.MX93 EVK, the overlay needs to accomplish two things:
In the application code, you only need:
Demonstration of Portability: If you replace the RX8010 with another RTC chip supported by Zephyr (e.g., DS3231, PCF8563), you only need to modify the compatible and reg properties in the overlay. The application code requires zero changes.
Driver Verification Practice
This section demonstrates a validated PWM driver example on the i.MX93 M33 core.
Example: pwm_api — Outputting PWM signals using the TPM2 controller
After importing the pwm_api project via Import Example from Repository,
The overlay only needs to declare an alias:
Kconfig Configuration:
The test uses pwm_set_cycles() / pwm_set() to set the duty cycle, and the output waveform can be verified with an oscilloscope. The TPM (Timer/PWM Module) on i.MX93 maps directly to the Zephyr nxp,kinetis-tpm driver, requiring no custom code.
Common Debugging Techniques in Zephyr Development
5.1. Kconfig Configuration Check
Check debug/zephyr/.config in the VSCode project file directory. This file contains the final, merged configuration for the project.
5.2. Final Devicetree Output Check
Check debug/zephyr/zephyr.dts in the VSCode project file directory. This is the final, merged Devicetree content and is the most direct way to verify if your overlay merged successfully.
5.3. Log Level
5.4. ztest Test Framework
All driver examples use the ztest framework. After running, results are output via the serial port. Taking the PWM test as an example, the serial output after flashing is as follows:
Output Description:
- test_pwm_nsec: Sets the following duty cycles sequentially in nanoseconds (each maintained for 1 second):
- 50% duty cycle (1.65V)
- 100% duty cycle (3.3V)
- 0% duty cycle (0V)
- test_pwm_cycle: Repeats the verification of the above three duty cycles in units of ''cycles,'' with period=64000 cycles and pulse widths of 32000 / 64000 / 0 cycles sequentially.
- Each [PWM] line in the output corresponds to one call to pwm_set() / pwm_set_cycles(). The actual voltage can be verified on the TPM2 output pin using an oscilloscope or multimeter.
Summary
Through this Zephyr porting practice on the i.MX93 M33 core, we have validated: the native Zephyr application pwm_api works on the i.MX93 M33 core.
The core value of Zephyr lies in:
1. One set of driver APIs covering all platforms — Changing the SoC only requires modifying the overlay, not the application code;
2. Devicetree-driven development — Clear separation between hardware configuration and software logic;
3. Complete testing infrastructure — ztest + testcase.yaml support CI/CD integration;
4. Native security and low-power design — Not an afterthought patch, but a system-level infrastructure;
5. Active upstream community — Over 1,600 contributors worldwide, with hundreds of merges weekly.
Forlinx Embedded OK-MX9352-C Development Board, based on NXP i.MX93, is a high-performance industrial-grade hardware platform. It demonstrates exceptional adaptability and outstanding stability with Zephyr RTOS. Leveraging Zephyr's engineering capabilities, developers can rapidly implement peripheral driver development, system porting, and functional verification on the Forlinx Embedded OK-MX9352-C development board, significantly shortening the R&D and mass production cycles of industrial products.
For teams engaged in embedded RTOS selection and industrial-grade product development, the combination of the Forlinx Embedded OK-MX9352-C Development Board + Zephyr RTOS offers an optimal solution that balances development efficiency, system security, and hardware reliability.
Forlinx Embedded OK-MX9352-C Development Board: Providing a stable, efficient, and industrial-grade hardware foundation for Zephyr implementation.