Zephyr - #2389
Draft
petermm wants to merge 68 commits into
Draft
Conversation
Setup a freestanding `west` application project for `Zephyr SDK`. Signed-off-by: Winford <winford@object.stream>
Prototype ESP32, ESP32-S3, and Raspberry Pi Pico targets on the Zephyr port, including early Wi-Fi bring-up. Signed-off-by: Peter M <petermm@gmail.com>
Enable SMP for qemu_x86_64 so scheduler tests can run on the Zephyr simulator. Signed-off-by: Peter M <petermm@gmail.com>
Implement a Zephyr UART NIF collection with resource lifecycle handling, devicetree-backed UART lookup, runtime serial configuration, and read/write/state/error operations. Keep synchronous polling bounded so long or infinite UART waits do not stall the AtomVM scheduler indefinitely, and preserve partial read data on timeout or device error. Compile the driver when CONFIG_SERIAL is enabled. Signed-off-by: Peter M <petermm@gmail.com>
Add a Zephyr-backed i2c resource NIF collection, enable CONFIG_I2C in the Zephyr port, and wire the driver into the platform library build. Introduce avm_zephyr with an i2c_hal implementation and atomvmlib-zephyr packaging so I2C examples can dialyze against the Zephyr API. Signed-off-by: Peter M <petermm@gmail.com>
Signed-off-by: Peter M <petermm@gmail.com>
Add a native_sim Twister scenario that embeds a small Erlang test AVM and registers a Zephyr I2C emulator target to exercise the AtomVM Zephyr I2C NIF path. Teach the Zephyr test app how to boot an embedded test AVM and exit for simulator harnesses, and install the Erlang/rebar tooling needed to build test BEAMs in the Docker image. Verified with: - ./docker-test.sh -b native_sim - ./docker-test.sh -b qemu_x86_64 - ./docker-test.sh -b esp32_devkitc/esp32/procpu - git diff --check Signed-off-by: Peter M <petermm@gmail.com>
Wire ASan/UBSan, Wokwi, and the Zephyr GitHub workflow so the new port is built and simulated in CI. Signed-off-by: Peter M <petermm@gmail.com>
Free hashtable buckets and remaining global context state on teardown so native_sim ASan stays clean. Signed-off-by: Peter M <petermm@gmail.com>
Signed-off-by: Peter M <petermm@gmail.com>
Signed-off-by: Peter M <petermm@gmail.com>
Signed-off-by: Peter M <petermm@gmail.com>
Signed-off-by: Peter M <petermm@gmail.com>
Signed-off-by: Peter M <petermm@gmail.com>
Port three high-priority tests from the ESP32 platform runner to Zephyr: - test_md5: verifies erlang:md5/1 NIF (direct copy, no platform deps) - test_crypto: verifies crypto:hash/2 and crypto:crypto_one_time/4,5 (adapted to remove esp32_chip_info call, uses non-AES-192 cipher set) - test_file: verifies POSIX file I/O and FD garbage collection (adapted to use Zephyr RAM FAT FS via zephyr:mkfs/mount/umount) Enable mbedTLS in the test Kconfig via Zephyr PSA Crypto symbols (MBEDTLS_HASH_ALL_ENABLED, MBEDTLS_CIPHER_ALL_ENABLED, etc.). Signed-off-by: Peter M <petermm@gmail.com>
Signed-off-by: Peter M <petermm@gmail.com>
Signed-off-by: Peter M <petermm@gmail.com>
Signed-off-by: Peter M <petermm@gmail.com>
Signed-off-by: Peter M <petermm@gmail.com>
Signed-off-by: Peter M <petermm@gmail.com>
Signed-off-by: Peter M <petermm@gmail.com>
Signed-off-by: Peter M <petermm@gmail.com>
Signed-off-by: Peter M <petermm@gmail.com>
Signed-off-by: Peter M <petermm@gmail.com>
Signed-off-by: Peter M <petermm@gmail.com>
Signed-off-by: Peter M <petermm@gmail.com>
Signed-off-by: Peter M <petermm@gmail.com>
Signed-off-by: Peter M <petermm@gmail.com>
Signed-off-by: Peter M <petermm@gmail.com>
Signed-off-by: Peter M <petermm@gmail.com>
Enable ADC, SPI, power management, and task watchdog support in the standard platform configuration so test builds inherit the same public feature set. Keep application-specific bus wiring and pin assignments in devicetree overlays, and require an explicit default SPI choice instead of falling back to SPI0. Move the custom idle power policy into the platform library and document the configuration boundary. Signed-off-by: Peter M <petermm@gmail.com>
Expose Zephyr's PWM subsystem through a portable Erlang pwm module and resource NIFs (set in nanoseconds, set_cycles, get_cycles_per_sec), with controller selection via atomvm,pwm, index, or device name. Enable PWM on standard and test board fragments, and cover the API on native_sim with Zephyr's fake PWM driver. Also apply the test app.overlay for the shared ramdisk, split the I2C emulator overlay so it is only used by the I2C suite, and provide FFF globals required by the fake PWM driver. Signed-off-by: Peter M <petermm@gmail.com>
Remove the qemu_x86_64 retained-memory configuration and runtime scenario because its reserved physical tail is not writable through Zephyr's runtime MMU mapping. Avoid substituting a simulator-only mock that would test different behavior from the hardware retention backend. Keep retention runtime coverage on supported ESP targets and RP2040 build verification. Signed-off-by: Peter M <petermm@gmail.com>
The shared test app.overlay was applied to every board, so ESP32 Wokwi images paid for a 64 KiB RAM disk they never use (file tests use SPI microSD). That alone overflowed dram0_0_seg on ESP32, C3, and S3. Limit the ramdisk overlay to QEMU, native_sim, and RP2040, and shrink it to 16 KiB for the short-file mount tests those hosts still need. Signed-off-by: Peter M <petermm@gmail.com>
Shrinking the shared test ramdisk to 16 KiB made fs_mkfs fail with -EIO on hosts that still use it (test_mount). Keep the previous 64 KiB volume size; ESP test images continue to skip this overlay entirely. Signed-off-by: Peter M <petermm@gmail.com>
The shared test defaults (~124 KiB heap pool + ~124 KiB libc arena) are sized for QEMU/native_sim and overflow dram0_0_seg once Wi-Fi and the portable peripheral stack are linked. Size each ESP test board from remaining DRAM and max it out: classic ESP32 (~253 KiB free after dropping the unused RAM disk) gets 128+124.7 KiB; C3 (~190 KiB free) gets 128+62 KiB; S3 (~222 KiB free) gets 160+61.5 KiB. Signed-off-by: Peter M <petermm@gmail.com>
Replace the fixed ~124 KiB dual-heap test defaults (and the per-board ESP/Pico overrides they forced) with CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=-1 so libc malloc claims leftover SRAM after BSS/stacks/drivers. AtomVM already allocates via malloc, so a second large static HEAP_MEM_POOL was mostly waste on embedded targets. Leave the system heap at the Kconfig default (0) unless a board needs k_malloc; QEMU keeps a modest pool for DYNAMIC_THREAD_ALLOC. ESP32 Wokwi still uses a smaller main stack so more of the auto arena is available to mbedTLS. Signed-off-by: Peter M <petermm@gmail.com>
Signed-off-by: Peter M <petermm@gmail.com>
Signed-off-by: Peter M <petermm@gmail.com>
Signed-off-by: Peter M <petermm@gmail.com>
Signed-off-by: Peter M <petermm@gmail.com>
Signed-off-by: Peter M <petermm@gmail.com>
The Erlang TLS client was already packaged but commented out. Run it as its own ZTEST on Wi-Fi boards, share the github.com cipher/PSA settings with ESP32-C3 and ESP32-S3, and give Wokwi 180s so handshake plus the later Wi-Fi cases still fit. Also drop leftover otp_ssl tracing from the WIP enablement. Signed-off-by: Peter M <petermm@gmail.com>
A delayed connect-result after sta_got_ip was overwriting connected with associated. test_ssl leaves the radio up, so test_wifi_managed then failed on sta_status(). Signed-off-by: Peter M <petermm@gmail.com>
Ship the platform NIF wrappers with atomvmlib-zephyr so applications can call mount, socketpair, PM, and the task watchdog without a test-only module. Signed-off-by: Peter M <petermm@gmail.com>
Expose the portable sys_reboot, hwinfo reset-cause, net_if link address, and uptime-microsecond APIs through zephyr.erl so applications have the same platform hooks they use on ESP32. Signed-off-by: Peter M <petermm@gmail.com>
Store binary values under Namespace/Key via Zephyr Settings and NVS. ESP32 boards use the existing storage partition, Pico W carves 24 KiB from flash, and native_sim uses the simulated-flash storage partition. Signed-off-by: Peter M <petermm@gmail.com>
GitHub resets the TCP connection mid-handshake after about 75s on C3. Classic ESP32 still runs the TLS client case. Signed-off-by: Peter M <petermm@gmail.com>
Expose deep_sleep, GPIO wakeup, and wakeup cause through zephyr.erl. ESP32 uses sys_poweroff plus the Espressif timer and GPIO wakeup sources. Signed-off-by: Peter M <petermm@gmail.com>
Sleep on first boot and continue the suite when sleep_get_wakeup_cause returns timer. Ignore the ESP UNDEFINED bit so a cold boot is not unknown. Signed-off-by: Peter M <petermm@gmail.com>
network:start([{ap, ...}]) enables Zephyr AP mode and waits
for ap_started. ESP32 boards add a second wifi_ap iface so
STA and AP can run together. The AP is given 192.168.4.1 and
CONFIG_NET_DHCPV4_SERVER leases from 192.168.4.2, emitting
sta_ip_assigned. Raise poll/eventfd limits so the DHCP
server does not starve STA DNS.
Signed-off-by: Peter M <petermm@gmail.com>
Keep the module name so ESP32 boot images stay unchanged. Persist settings through zephyr:settings_* on Zephyr and esp:nvs_* on ESP32. Default gen_tcp/gen_udp to the otp_socket backend on Zephyr, which has no legacy socket port driver. Fold start_network into the existing ESP32 Wokwi suite as test_wifi_z_devmode so leftover AP sockets cannot starve STA. Signed-off-by: Peter M <petermm@gmail.com>
Expose open/write/close through dac.erl. Controllers are selected by atomvm,dac, index, or device name. native_sim uses zephyr,dac-emul; classic ESP32 enables the on-chip DAC on GPIO25. ESP32-C3 and ESP32-S3 have no DAC. Signed-off-by: Peter M <petermm@gmail.com>
Use GPIO10 on C3 instead of GPIO0. Stop wokwi-cli as soon as the suite prints PROJECT EXECUTION FAILED instead of waiting the full 180s for SUCCESSFUL. Signed-off-by: Peter M <petermm@gmail.com>
C3 reports riscv64-espressif-zephyr, not esp32c3, so the previous match kept using GPIO0. Match the architecture tuple instead. Signed-off-by: Peter M <petermm@gmail.com>
Handshake returns {error,-2} after about 7s. Classic ESP32
still runs the TLS client case.
Signed-off-by: Peter M <petermm@gmail.com>
Force PLATFORM_VENDOR esp for the Espressif SoC family so C3 reports riscv64-esp-zephyr and Xtensa reports xtensa-esp-zephyr, matching the xtensa-esp-esp_idf shape. Update tests that matched espressif in the vendor field. Signed-off-by: Peter M <petermm@gmail.com>
Return the same model/cores/features/revision map as ESP-IDF for Espressif SoC series. Model comes from CONFIG_SOC_SERIES_*; cores and features use the typical values for that series. native_sim still returns undefined. Signed-off-by: Peter M <petermm@gmail.com>
Zephyr RISC-V compiler dumpmachine is always riscv64-zephyr-elf. Override PLATFORM_ARCH using CONFIG_RISCV and CONFIG_64BIT so ESP32-C3 reports riscv32-esp-zephyr, matching riscv32-esp-esp_idf. Signed-off-by: Peter M <petermm@gmail.com>
petermm
force-pushed
the
pr/958-rebased
branch
from
August 23, 2026 12:49
43a5220 to
7398003
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Based on #958
These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).
SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later