The following tools must be installed:
- cmake
- dtc
- python
mkdir esp32-zephyr-scaffold-wscd esp32-zephyr-scaffold-ws
git clone https://github.com/yourname/your-app.git`
python3 -m venv .venvsource .venv/bin/activatepip install westcd esp32-zephyr-scaffold
west init -l .cd ..
west updatepip install -r deps/zephyr/scripts/requirements.txtsource deps/zephyr/zephyr-env.shcd esp32-zephyr-scaffold-ws
west build -b esp32_devkitc_wroom/esp32/procpu .MCUboot must be built and flashed at least once. It can be built with sysbuild with:
west build -p always -b esp32_devkitc_wroom/esp32/procpu --sysbuild .and flashed with:
west flashThe application only can be built with:
west build -p always -b esp32_devkitc_wroom/esp32/procpu .View the serial output with:
west espressif monitorInstall TKinter in the system inorder to use the guiconfig:
sudo apt install python3-tkThis can be used for setting debug flags: https://docs.zephyrproject.org/latest/develop/tools/clion.html#configure-zephyr-parameters-for-debug
Use the guiconfig target and click the hammer icon.
When making these changes, they are "temporarily" saved: Configuration saved to '/home/mchernosky/dev/hello_world/cmake-build-esp32/zephyr/.config' To permanently make the changes, you would add them to a .conf file.
Open the project at the workspace directory (the topdir) -- not the application.
Right click on the CMakeLists.txt file in the application directory and select "Load West Project."
Configure a new toolchain which uses the environment script from the project directory instead of the global installation. Use a west build, but configure it to use the new toolchain. Then you can select the board in the west settings.
Configure a run configuration for the native sim build by setting the "Target" to native_runner_executable and the "Executable" to build/zephyr/zephyr.exe.
The application can be built for the native_sim target with:
west build -p always -b native_sim .And started by running:
./build/zephyr/zephyr.exeThis will log output to the console, and show the device used for the UART simulation. Then you can connect to it with minicom or similar.
In order to use networking with the native sim build, before running the application use the network setup script ot configure the host network interface:
sudo deps/tools/net-tools/net-setup.sh --config nat.conf startThis runs the net-setup.sh script from the net-tools directory with the nat.conf configuration file.
This sets up the host interface that the application will connect to, runs a DHCP server on the interface and configures network address translation (NAT) for internet access.
Now when the application is run, it will get an IP address from the host.
You should be able to ping the host address with:
uart:~$ net ping 192.0.2.2
PING 192.0.2.2
28 bytes from 192.0.2.2 to 192.0.2.13: icmp_seq=1 ttl=64 time=60 ms
28 bytes from 192.0.2.2 to 192.0.2.13: icmp_seq=2 ttl=64 time=10 ms
28 bytes from 192.0.2.2 to 192.0.2.13: icmp_seq=3 ttl=64 time=20 ms You should also be able to ping out the internet, for example with:
uart:~$ net ping 8.8.8.8
PING 8.8.8.8
28 bytes from 8.8.8.8 to 192.0.2.24: icmp_seq=1 ttl=114 time=30 ms
28 bytes from 8.8.8.8 to 192.0.2.24: icmp_seq=2 ttl=114 time=40 ms
28 bytes from 8.8.8.8 to 192.0.2.24: icmp_seq=3 ttl=114 time=50 msDNS resolution should also work. For example:
uart:~$ net dns www.google.com
Query for 'www.google.com' sent.
dns: 142.250.72.36
dns: All results receivedWhen finished running the application, then run:
sudo deps/tools/net-tools/net-setup.sh --config nat.conf stopto remove the network configuration.
Configure your WiFi network by setting the CONFIG_WIFI_SSID and CONFIG_WIFI_PASSWORD Kconfig variables.
For security, this can be done in an overlay config file and added to the build with:
west <commands> -- -DOVERLAY_CONFIG=overlay-wifi-file.conf
To connect the serial console on the ESP32, run west espressif monitor.
- Only pull espressif dependencies for Zephyr? This would make
west updatefaster.
