[Zephyr ® Series] Part 2: First build and running on a real device (Japanese blog)
In the second installment of the Zephyr series, we will actually set up a Zephyr development environment and create an environment where we can build.
Next, we will build the Zephyr application and write it to a real device to check that it works.
Don't worry, setting up your development environment is incredibly easy.
And finally, in the third session, we will create a program to blink an LED and experience Zephyr-style coding.
So let's get started.
table of contents
Preparing your Zephyr development environment
Installation Instructions
Step 1: Install VS Code and the extension
Step 2: Setting up your Zephyr development environment
Step 3: Import the Zephyr repository
Step 4: Import the Zephyr sample application
Building HelloWorld
Debugging and operation check
summary
Preparing your Zephyr development environment
This article will introduce how to install the Zephyr project in a Windows environment and prepare the build environment. In addition, this time we will install Visual Studio Code using Windows 11.
Note: Here we will introduce the steps for Windows 11, but you can set it up in the same way on other operating systems by installing VS Code.
Preparing the development evaluation board
Here we will use the FRDM-MCXA153 . The same steps can be followed for NXP microcontrollers (MCX series) and crossover microcontrollers (i.MX RT series).
FRDM-MCXA/C/N/E series
i.MX RT10xx-EVK Series
LPC series (partially supported)
Installation Instructions
We will install the following items:
VS Code and MCUXpresso for VS Code extension
Zephyr development environment including Zephyr SDK
VS Code Zephyr repository
Step 1: Install VS Code and the "MCUXpresso for VS Code" extension
If you don't already have Visual Studio Code (VS Code) installed, search for "visual studio code" in the Microsoft Store and install it.
Next, install "MCUXpresso For VS Code".
Extensions view in VS Code Alternatively, click Ctrl+Shift+X. Click the search field at the top of the Extensions view and type "mcuxpresso" .
Select MCUXpresso for VS Code and click the "Install" button to install the extension. Once the installation is successful, it will be added to the installed list.
拡張機能ビューボタンExtended Functions View Button
VS Code 拡張機能 マーケットプレイスVS Code Extension Marketplace
MCUXpresso for VS CodeのインストールInstalling MCUXpresso for VS Code
Step 2: Zephyr development environment including the Zephyr SDK
Open the MCUXpresso for VS Code extension. Click "Open MCUXpresso Installer" in the Quick Start panel.
Quick StartパネルQuick Start Panel
MCUXpressoツールの選択オプションMCUXpresso Tool Selection Options
MCUXpressoツール選択オプション2MCUXpresso Tool Selection Option 2
Now click on the tool you need to select it.
Zephyr Developer
Arm GNU Toolchain
LinkServer
Here we will be using the NXP onboard ICE for debugging, so the LinkServer option is required.
Tips:
NXP EVK uses LinkServer by default. Install the necessary tools for your debug probe.
LinkServer, Segger JLink and PEmicro tools are available for installation.
Once you have selected your installation options, click the "Install" button. The status bar at the bottom will display the installation status.
Restart VS Code.
Step 3: Import the Zephyr repository
Next, import the Zephyr repository.
Open the MCUXpresso view in VS Code and click Import Repository in the Quickstart panel.
リポジトリのインポートImporting a Repository
Zephyr is open source and available on github. You can import this github repository.
Release tag : A stable version. You can specify various versions by specifying a tag.
main branch : latest head of Zephyr
Here, we will import the release tag v4.0.0.
Location : Select the folder location where you want to import the Zephyr repository.
Repository : Select "Zephyr" as the repository. The github URL will also be displayed.
Revision : In the revision field, use v4.0.0. Change it to another release if necessary.
Once you've finished entering the information, click Import. If you want to import the Zephyr main branch, change the revision field to main.
Note:
Importing the Zephyr repository takes time, typically around an hour. Although not required for Zephyr projects, the MCUXpresso SDK can be imported as well.
Step 4: Import the Zephyr sample application
By completing the steps up to Step 3, you are now ready to start developing applications for Zephyr OS. Finally, you will be able to import, build, and debug Zephyr sample applications.
To import a sample application from the Zephyr repository, click "Import Sample from Repository" from the Quick Start panel.
レポジトリからExampleのインポートImporting an Example from the Repository
Hello_WorldプロジェクトのインポートImporting the Hello_World Project
Application type: We chose Repository application. We will use the original sample project folder in the Zephyr repository.
Name: Set the project name.
Zephyr SDK: This is the software package that provides the Zephyr compiler, libraries, and tools. Select "Default Zephyr SDK".
Building HelloWorld
To compile and build the program, click the Build button to build the Hello World project.
It's very easy.
Zephyr is usually built using the command line, with the build started with the West command, but it can also be built with a single build button in the GUI.
There's no need to remember complicated command options.
ビルドボタンBuild button
Once the build is complete, the memory capacity and usage will be listed.
Hello Worldプロジェクトのビルド結果Hello World project build results
Debugging and actual device operation
Now, we will finally write the Zephyr program to the actual device and check its operation.
Before checking the operation, connect the PC to the USB Type-C cable as shown in the photo.
There are two USB connectors installed, but connect to the J15 USB connector side.
FRDM-MCXA153FRDM-MCXA153
To start debugging, click the play button "▷".
デバッグ開始Start Debugging
It will stop at the entry of the main() function, allowing you to perform step execution.
Here, press the play button for step execution to run.
ステップ実行の様子Step execution
Among the multiple tabs at the bottom center of VS Code, there is a serial monitor function. Set it as shown below and click "Start Monitoring" to check the Printf output (standard output).
シリアルモニターSerial Monitor
summary
This time, we installed the Zephyr development environment, built a Hello World project, and checked its operation on an actual device.
Using "MCUXpresso for VS Code" simplified the installation of the Zephyr development environment, dependent libraries, and tools, allowing me to set up the environment very easily and quickly.
In the next issue, we will finally introduce the world of Zephyr regarding software reusability through an LED blinking program.
(Please wait until it is released.)
Click here for the previous article
[Zephyr ® Series] Part 1: What is the popular Zephyr OS? (Japanese blog)
=========================
We are currently unable to respond to comments in the " Comment " section of this post . We apologize for the inconvenience, but when making inquiries, please refer to " How to contact NXP with technical questions ( Japanese blog ) " . (If you are already an NXP distributor or have a relationship with NXP , you may contact the person in charge directly. )
In this second installment of the Zephyr series, "Building for the first time and running it on a real device," we will introduce how to install the Zephyr development environment and build it. We will then flash it onto a real device and check that it works. MCX SW | Downloads Japanese Blog
View full article