スクリーンショット 2026-06-11 15.39.32.png
When using network functionality with embedded microcontrollers, traditionally, you had to start by figuring out "how to make it work." You'd have to find the SDK and sample code provided by the vendor of the microcontroller you wanted to use, and then write code according to its API. Since the API changes with each different microcontroller, you often end up having to research everything from scratch every time you want to do something similar. With network functionality, there's a lot to learn, such as initializing the TCP stack and using the socket API, and I'm sure many people have experienced running out of steam before they could even write their own application.
Zephyr OS can be one solution to these problems. Zephyr provides a standard API as an RTOS, and a major advantage is that once you learn how to use it, the same code will run on different boards. Among the abundant sample code available, there is also the HTTP server sample that we will be discussing, and it was surprisingly easy to get running.
This article provides a step-by-step guide on how to run the HTTP server sample on the NXP FRDM-MCXN947 evaluation board. Once the sample is running, you will be able to access the FRDM-MCXN947 from your PC's web browser and turn the LEDs on the board ON/OFF using buttons on the page.
goal:
Access the HTTP server on the FRDM-MCXN947 from your browser and control the LEDs using the "LED on" and "LED off" buttons on the page.
Before reading this article
This assumes that the Zephyr build environment is already installed and that you are familiar with the basic operations ofwest buildandwest flash.
If you're starting from setting up the environment, you can refer to the " Getting Started Guide " on the Zephyr official website, or the guide video that allows you to easily set it up using MCUXpresso for VSC.Let's get started! See "MCUXpresso with VS Code and Zephyr OS".
| Product name | remarks |
| FRDM-MCXN947 Evaluation Board | Zephyr Documentation |
| USB cable (included with the FRDM board mentioned above) | This connects the board's J17 connector to the PC. |
| LAN cable | This connects the board's Ethernet connector to the network. |
This time, we'll proceed using commands from the macOS Terminal screen.
Once you open the terminal, first execute the following two commands.
First, activate the Python execution environment:
source ~/zephyrproject/.venv/bin/activate
If installed using MCUXpresso for VSC
The location ofbin/activateis different from the standard.
On macOS, it's located in~/.mcuxpressotools/.venv_3_14/.
On Windows, it was located inC:\Users\<ユーザ名>\.mcuxpressotools\.venv_3_12\Scripts.*When using Windows PowerShell, the commands and filenames used will differ from those on Linux and macOS, so please refer to the " Getting Started Guide " before proceeding.
Next, we'll set the environment variables required to build Zephyr. This command will allow you to build Zephyr from any folder:
source ~/zephyrproject/zephyr/zephyr-env.sh
Next, navigate to the sample folder:
cd ~/zephyrproject/zephyr/samples/net/sockets/http_server
The prj.conf file in this folder contains network settings. Please choose from the following three methods according to your connection type.
| section | Connection type | IP setting method |
| Section 3.1 | Connect to the LAN via a router | Manually configure a static IP address. |
| Section 3.2 | Connect to the LAN via a router | Automatic acquisition via DHCP (easy) |
| Section 3.3 | Connect the PC and the board directly with a single LAN cable. | Set a static IP address for both the PC and the board. |
This method involves connecting to the LAN via a router and assigning a fixed IP address to the board. Open prj.conf in a text editor and rewrite the following two lines to match your network environment.
Before change (default):
CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.0.2.1"
CONFIG_NET_CONFIG_MY_IPV4_GW="192.0.2.2"
After the change (example):
CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.168.1.100"
CONFIG_NET_CONFIG_MY_IPV4_GW="192.168.1.1"
| Setting items | meaning |
CONFIG_NET_CONFIG_MY_IPV4_ADDR |
The IP address to assign to the board (specify an address within the router's subnet that does not overlap with other devices). |
CONFIG_NET_CONFIG_MY_IPV4_GW |
The IP address of the gateway (router). This is not strictly necessary if you are only accessing it from a PC within the same LAN. |
The subnet mask is not specified here, but in the environment I tested, it was set to 255.255.255.0.This article uses "192.168.1.100" as an example. Please change it to match your network environment.
When connecting the FRDM-MCXN947 to a router (wireless router), it can automatically obtain an IP address from the router. To do this, make the following changes to prj.conf :
CONFIG_NET_DHCPV4=y # 追加
CONFIG_NET_CONFIG_MY_IPV4_ADDR="" # 空文字列に変更
Alternatively, you can choose not to edit
prj.confand instead specify the configuration file using the build command described later (see Section 4.2 ).
It can also be operated by directly connecting the PC and the FRDM-MCXN947 with a single LAN cable, without using a router. In this case, since there is no DHCP server, you will need to manually set a static IP address on both the PC and the board.
The key points are the following two:
Here is an example of the settings:
| subject | IP address | Subnet mask |
| PC (wired LAN adapter) | 192.168.100.1 |
255.255.255.0 |
| FRDM-MCXN947 | 192.168.100.2 |
255.255.255.0(Automatic setting) |
On the board side, edit prj.conf in the same way as in Section 3.1. Example settings when using the values from the table above:
CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.168.100.2"
CONFIG_NET_CONFIG_MY_IPV4_GW="192.168.100.1"
The IP address of the wired LAN adapter on the PC side is set manually from the OS settings screen:
192.168.100.1 and subnet mask 255.255.255.0If DHCP is available ,
the standard configuration of connecting to a router (Section 3.2) is easier as it does not require changing the PC's IP settings. Direct connection is useful for testing in locations without a router or when you don't want to change the PC's network settings.
Once the setup is complete, proceed with the build (compilation and linking).
The working directory is "~/zephyrproject/zephyr/samples/net/sockets/http_server".
Build it with the following command.
west build -p auto -b frdm_mcxn947/mcxn947/cpu0
prj.confTo enable DHCP without editing the file, run the following command:
west build -p auto -b frdm_mcxn947/mcxn947/cpu0 -- -DEXTRA_CONF_FILE="overlay-dhcpv4.conf"
-DEXTRA_CONF_FILE="overlay-dhcpv4.conf"This will result in the configuration file for enabling DHCP being added to prj.conf during the build process.
In this configuration, if the DHCP server is not enabled, the static IP address written in prj.conf will be set by default.
Once the build is complete, write it to the board.
Connect the board's J17 (USB) connector (to the left of the Ethernet connector) to your PC using a USB cable, and connect a LAN cable to the Ethernet connector .
IMG_1415.JPG
Run the following command:
west flash
Once the writing process is complete, the board will start operating.
Open a serial terminal (such as Tera Term, PuTTY, or VS Code's Serial Monitor), select the FRDM-MCXN947 port, and set the baud rate to 115200 .
There are several types of serial terminals available, and you can use whichever you prefer. Please refer to separate articles for information on their installation and usage.
uart:~$When you see the prompt, enter the following command:
net iface
A list of network settings will be displayed. If you specified a static IP address, that value will be displayed; if you used DHCP, the IP address assigned by the router will be displayed, so please check that address.
スクリーンショット 2026-06-11 14.18.15.png
If you miss the startup log, you can
restart the board by pressing the SW1 (RESET) button on the board. You can also check the IP address in the output immediately after restarting.
スクリーンショット 2026-06-11 14.17.59.png
Enter the confirmed IP address into your browser's address bar and access it (in this example, http://192.168.1.100 ).
If it is working correctly, a page containing " LED on " and " LED off " buttons will be displayed. Pressing these buttons will turn the green LED on/off on the FRDM-MCXN947.
スクリーンショット 2026-06-11 15.33.47.png
IMG_1419.JPG
Change history:
2026-06-16: First Edition
=========================
We are currently unable to respond to comments left in the "Comment" section of this post.
We apologize for the inconvenience, but please refer to "Technical Questions to NXP - How to Contact Us (Japanese Blog)" when making an inquiry.
(If you are already an NXP distributor or have a business relationship with NXP, you may ask your representative directly.)
This guide provides a step-by-step explanation of how to run the Zephyr HTTP server sample on the FRDM-MCXN947 and turn the LEDs on the board ON/OFF from a PC browser. It supports both fixed IP/DHCP connections via a router and direct connections between the PC and the board using a single LAN cable. If the Zephyr build environment is already installed, you can verify operation from editing the configuration file to building and flashing with just a few commands.
(Estimated time: 15 minutes *Assuming Zephyr development environment is installed and you are familiar with PC networking)
スクリーンショット 2026-06-11 15.39.32.png