multiapp internals¶
Previous: multiapp · Up: Applications · Next: micropython
The design and measurement log of multiapp, one firmware that runs the others. Its README has the usage: building and flashing, the shell commands, adding an app, the S31 board. This page follows it in Applications.
Status:
All six apps (
capture,rfprobe,wpan,stream,osmosdr,link) run as llext extensions from PSRAM, built from their unchanged sources, one app per boot, on the image ofapps/multiapp/(“the host”).The radio is extensions as well: the PHY,
lib/esp_sdrandlib/ieee802154are modules a boot loads only if its app needs them (The radio as modules).So is the stock Wi-Fi driver, which the small
wifitestapp uses (The stock Wi-Fi driver as a module).MicroPython is an app too: on the XIAO with its display, LVGL, knob, SD card and two USB drives, on the Communicator with its display and keyboard, on boards without a display headless (MicroPython as an app).
The host loads each one from its
<name>.llextfile on a FAT volume in flash, which the PC sees as a USB drive in boots without an app; built-in copies are the fallback (Apps as files).It needs Zephyr changes that are on the fork
west.ymlpins (Zephyr changes).On the ESP32-S31 the extensions are RISC-V relocatable objects and the board boots into
osmosdr_hs(ESP32-S31: RISC-V extensions).
Constraints¶
Every app still builds and runs standalone, with its own
prj.conf, overlay andmain(), unchanged in behavior. multiapp compiles the same sources; no app source moves.Internal RAM is the binding constraint. IRAM and DRAM share one pool, and the image must end below the dump banks the configured apps reserve (Code placement). Extensions therefore run from PSRAM.
Kernel configuration cannot differ per app. USB classes, network buffers, SMP and heap sizes are fixed when the host is built; the host carries the union of what its apps need.
Constructs that register through linker iterable sections do not work in an extension as written, because its sections do not join the host’s:
SHELL_CMD_REGISTER,USBD_DEFINE_CLASS,SYS_INIT,LOG_MODULE_REGISTER,K_THREAD_STACK_DEFINE, static memory slabs,NET_BUF_POOL_DEFINE.Exit is a reboot. The Wi-Fi PHY, ring and DAC state cannot be torn down cleanly.
multiapp runwith an app loaded leaves the name in RTC memory and resets.
How it works¶
Code in PSRAM¶
The S3’s cache MMU maps the data bus window (0x3c000000) and the instruction bus window (0x42000000) through one table.
So a PSRAM page written at data address D executes at D + 0x06000000, after a data cache write-back and an instruction cache invalidate.
llext keeps one address per region. A local Zephyr change (
CONFIG_LLEXT_EXEC_ALIAS,llext_heap_init_harvard_exec()) copies and patches through the writable address and uses the alias for relocations, the symbol table and the init/fini check.The ESP cache driver has no instruction cache operations: the host syncs the range itself after
llext_load()(sync_text()insrc/apps.c).
Both heaps are in PSRAM and not zeroed at boot:
Heap |
Option |
Size |
|---|---|---|
Code |
|
1344 KiB |
Data |
|
1024 KiB |
Prelude, host glue and app Kconfig¶
The prelude¶
include/multiapp/ext.h, put in front of every C source with -include, turns what an extension
cannot do into what it can:
SHELL_CMD_REGISTER()andSYS_INIT()become constructors.LOG_MODULE_REGISTER()becomes a declaration.Slabs are initialized in a constructor.
NET_BUF_POOL_DEFINEleaves a descriptor in.multiapp_host, from which the host defines the pool: net_buf finds pools by their index in a host section..noinitand the PSRAM section attributes join.bss, because llext loads only one NOBITS section.The app’s
app_usb_init()becomes a call that does nothing (Flash access from a PSRAM stack).
Generated host glue¶
exports.pymakes the host export exactly the symbols the extensions import, in its own export group, and register their log modules.Zephyr’s default export groups, every syscall kept in IRAM, are off.
A symbol the host lacks fails the host’s link.
With
CONFIG_LLEXT_IMPORT_ALL_GLOBALSthe host finds an app’s hooks by name, such asapp_usb_dfu_prepare().
The app’s own Kconfig values¶
An extension compiles against the host’s autoconf.h. appconfig.py writes the app’s
CONFIG_APP_* values into a header included after it.
Proxy shell roots¶
The host (
src/apps.c) registers the apps’ root commands (probe,wpan,sdr,link,ofdm,hello) as dynamic commands that forward to the loaded app.So the shell, and the tools that drive it, look as standalone.
The app’s
main()runs in a host thread (CONFIG_MULTIAPP_STACK_SIZE, stack in PSRAM).
Modules¶
Modules (multiapp_module()) are extensions without a main() that other extensions call.
Each is named by the apps and modules that need it (
REQUIRES).The host loads them in order before the app, each from its file with its trailer checked as an app’s, and runs their constructors.
llext finds what an extension imports in the host first, then among the loaded extensions.
exports.pyleaves what a module defines out of the host’s exports, and modules link with-Bsymbolic, so their own globals stay theirs even where the host has the same name.
Modules in internal RAM¶
INTERNAL places a module as a standalone image places the same code:
IRAM_ATTRcode (.module_fast,ext/module_fast.ld), data and bss in internal RAM;the rest of its code and its read-only data in PSRAM, where a standalone image has flash.
Loading it:
CONFIG_LLEXT_REGION_HEAPSlets one load take each region from a heap of its own, andLLEXT_MEM_TEXT_ALTgives llext the second code region.That region comes from
module_heap(src/apps.c, below bank 0, see Internal RAM: bank 0 and the area) and runs at the instruction bus alias of its data bus address (SOC_I_D_OFFSET): the same trick as PSRAM, without a cache to sync.HIGH_BSSputs bss in the high region (Code placement):sdr’s DAC state.What llext only reads while loading stays in PSRAM.
Linking internal modules¶
INTERNALmodules link with--no-relax.fastcheck.pyfails the build if a blob’s fast code reaches other sections PC-relative. The linker leaves no relocation for that, so it would point elsewhere once the two regions are loaded apart.The PLT stays at the start of the cold code, where the linker’s own script puts it next to
.got.plt. llext writes each import straight into the caller’s literal (R_XTENSA_JMP_SLOT), so the PLT’s lazy-binding stubs should never run (The PLT in internal RAM).
The radio as modules¶
Module |
Holds |
|---|---|
|
|
|
|
|
|
The host has none of them and no Wi-Fi driver (
CONFIG_ESP_SDR_PHY_ONLY,CONFIG_ESP_SDR_AS_EXTENSION).A boot loads what its app names, and a boot without an app brings no radio up.
The sources come from each library’s
sources.cmake, so standalone apps and modules build the same files.
Devices in a module¶
DEVICES marks a module that defines devices. Its DEVICE_DEFINE() cannot join the host’s
sections, so:
ext/module_devices.ldkeeps its init entries in the kernel’s order, and the host runs them after the module’s constructors (do_device_init()).The prelude sends
device_get_binding()tomultiapp_device_get_binding(), which also searches the loaded modules.The table’s bounds reach the host through an object (
ext/module_devices.c), because llext exports only functions and objects, not the untyped symbols of a linker script.A
DEVICESmodule whose table is missing or empty refuses to load.
Blobs in a module¶
multiapp_blob(), LIBS and VERSION_SCRIPT bring Espressif’s libraries into a module:
They are not built for a shared object. Their pointer tables in
.rodata*need dynamic relocations, which the linker refuses in a read-only section, so a copy of the archive gets them writable.llext then merges sections by flags into regions, and writable data in front of
.got.locwould make the data region enclose it:ext/module_blobs.ldmoves it behind.got.The archives also hold test code calling functions the host does not have. A version script names the exports and
--gc-sectionsdrops the rest.ext/phy.verleaves 36 KB of code against 84 KB, and 132 bytes of bss against 42 KB.
USB profiles¶
All class code lives in the host.
The S3’s OTG controller has 4 IN endpoints for classes (
GHWCFG4.INEps), and the union of the apps’ classes needs 6.So the host registers a subset per boot:
app_usb_classes(), a weak hook inapps/commonbetween registering the classes andusbd_init(), unregisters what the boot’s app does not name in itsUSBmask.
Class |
Used by |
IN endpoints |
|---|---|---|
CDC-ACM (shell) |
every boot |
2 |
CDC-NCM |
stream |
2 |
vendor bulk ( |
osmosdr |
1 |
MSC (the volume as a drive) |
boots without an app |
1 |
DFU |
every boot |
0 |
osmosdr’s vendor class is built in the host. Its calls into the app go through forwarders in
src/osmosdr.c that look the app’s functions up by name, so the boot’s app is loaded before USB
starts.
Internal RAM: bank 0 and the area¶
NCM’s buffers in bank 0¶
NCM’s DMA buffers are in bank 0 (multiapp_bank0.ld): USB DMA needs internal RAM, and stream
never runs the ring, so bank 0 is free in its boots.
The area¶
An internal RAM area has one user per boot.
Buffers an app must keep in internal RAM (
ESP_SDR_HIGH_BUF_DEFINE(),ESP_SDR_HIGH_STACK_DEFINE()) become host objects inmultiapp_area, 24 KB of the high region (AREAinmultiapp_extension()).osmosdr takes 23 KB; the 802.15.4 driver gets the area in the other boots (
CONFIG_ESP_SDR_IEEE802154_HIGH_RAM_APP).multiapp runreboots when the USB profile or the area’s owner changes.
Apps as files¶
The volume¶
A FAT volume in the upper 4 MB of the flash holds
<name>.llext(src/drive.c). The board’s 4 MB partition table leaves that part out (partitionfatat 0x400000, flash diskFLASH).The host mounts it read-only at boot, before USB starts and before an app runs, and compares every file with the built-in copy (
multiapp list).It reads the boot’s app whole into a PSRAM buffer (
CONFIG_MULTIAPP_FILE_MAX_KB); llext then loads it from there.That mount’s FATFS object and the drive’s SCSI buffer are in bank 0, which the ring overwrites once an app runs: nothing of the host touches the volume after that.
Reads go in 256-byte chunks through the FATFS window, so the flash driver never gets a PSRAM buffer.
The trailer¶
apptrail.pyputs a trailer on every file: ELF size, CRC-32, the stack the app’smain()needs and a 16-byte build id.The build id (
buildid.py) is a hash ofautoconf.h, the devicetree, the extensions’ imports, the headers both sides compile against and the compiler.The host checks the trailer before llext reads the file. A truncated, damaged or foreign file (built for another host) is refused and the built-in copy runs.
CONFIG_MULTIAPP_EMBEDDED(default y) keeps the built-in copies. They hold 340 KB of the image; the multiapp README gives them as 165 KB of flash.Without them, a boot whose file is refused comes up without an app.
multiapp infosays where the app came from.
Crash loops¶
A boot that dies on the way to its app is skipped once, to end a crash loop.
A file refused cleanly is not: it is tried again at the next boot, so a correct volume takes effect at once.
The drive¶
A boot without an app (no request, no autostart, or an app that failed to start) registers USB mass storage on the volume next to the shell and DFU, for copying app files from the PC.
Boots with an app unregister it, and
multiapp runfrom a drive boot reboots into the app.The PC must eject the drive first: the host cannot see what the PC still caches.
west dfu --storagewrites the build’s volume image to the DFU targetfat.mkfat.pybuilds that image: deterministic FAT12, 4 KiB clusters on the erase page, long names.west dfu --esptooland the shell commandusjare in the multiapp README.
The stock Wi-Fi driver as a module¶
The module is built by wifi.cmake. The host is built without the driver, so neither fork
changes.
What it builds¶
What a build with
CONFIG_WIFI_ESP32adds to one without: the driver, the hal’s glue, 108 supplicant files and the blobs.The supplicant uses its internal crypto, so there is no mbedTLS (
ext/wifi_shim).It has its own copy of the PHY’s blob and glue, compiled for Wi-Fi, and such a boot loads neither
phynorsdr.
Its Kconfig¶
A second Kconfig pass runs on the host’s fragments with
ext/wifi.confon top.extconfig.pywrites the difference as a header each source includes afterautoconf.h.It fails the build if a symbol that is not the module’s own differs, because that could change what host and module agree on, such as a kernel struct.
Placement¶
It is placed as an image with the driver and its IRAM options off (
ext/module_wifi.ld)..wifi*iramand the blobs’ read-only data go to PSRAM, where such an image has flash.Only
.iram1,.dram1, data and bss go to internal RAM.The read-only data needs dynamic relocations, so its input sections are writable. A
(READONLY)output section tells llext to load it with the rest of the read-only data.
Its memory¶
The driver’s
k_malloc()and thread stacks come from a private heap in the area, through--wrap(ext/wifi_glue.c), since no other module uses the area in such a boot.The blobs’ own buffers are in PSRAM (
CONFIG_ESP_WIFI_HEAP_SPIRAM).The host’s kernel heap stays small.
Its interface¶
A
net_ifmust be in a host section, so the host defines one (src/wifi_netif.c), down, on a device that does nothing.As the module loads, its private device takes over
iface->if_dev->dev, and the stack reaches the driver through that pointer on every call.The driver’s own name for its interface is pointed at the host’s (
ext/wifi_prelude.h), and aNET_IF_DECLARE()left in it fails the build.wifi_mgmt.cstays in the host, along with IPv4 and DHCPv4.
Its core¶
The blob wants its task and interrupt on one core. A host without the driver reserves that
interrupt on core 1 (esp_cpu_intr.c), so the module pins its task there.
No built-in copy¶
The module is FILE_ONLY: it runs from its file or not at all, and the boot then falls back to the
drive. The file is only stat-ed at each boot, not read.
MicroPython as an app¶
The app is built by micropython.cmake and ext/mp/. The host stays CONFIG_MICROPYTHON=n, so the
module’s own build does not run.
What it builds¶
The port’s sources (
ports/zephyr/sources.cmake, on the MicroPython fork), the C modules inapps/micropython/cmod,boot.c,setjmp.S,usb_disks.cand the frozen Python.They build with the same flags as the port, through MicroPython’s own
py/mkrules.cmakeon the extension’s target.That file reads a target’s flags as plain lists, which an llext target’s generator expressions are not, so
micropython.cmakegives the qstr scan its flags itself.-Bsymbolicis not needed:ext/mp/micropython.verexports onlymultiapp_info, and--gc-sectionsdrops the rest.
Its Kconfig¶
The second pass, as for Wi-Fi, with
ext/mp/micropython.conf.The port’s
mpconfigport.hincludesautoconf.hagain, which undoes any#undefmade before it, so those are inext/mp/mpconfigport_multiapp.h.
The console¶
CONSOLE: before its constructors run, the boot’s host stops the serial shell (shell_uninit(),k_thread_join()), which also ends its log backend, so nothing prints into the REPL.multiapp_usb_up()starts itsmain()once USB is up, as the standalone app’s order is.The host’s console driver has no input path, so
ext/mp/mp_glue.cprovides the two functions the port’szephyr_getchar.ccalls, on the CDC-ACM port’s callback.multiapp runalways reboots into such an app, since it runs on the shell that has to go.
esdr.shell()¶
Zephyr’s
shell_dummy.cis built into the extension, its stack and buffers in PSRAM, so every other boot pays nothing.west dfudrives the host’s commands through it, as standalone.It must not become a log backend (
CONFIG_SHELL_DUMMY_INIT_LOG_LEVEL_NONE), since the host’s list of those cannot take one.
The heap¶
The heap is
multiapp_psram_spare(): everything from the end of what the linker placed in PSRAM to the top.That space holds the shared heap, which only the
wifimodule imports, and the buffer that held the app’s file. That is why that buffer is the top of PSRAM and not an array of its own.It is one block, so a large buffer fits.
CONFIG_APP_MP_PSRAM_HEAP_KBis a token here.
The stack¶
The stack stays in internal RAM, in the area, because Python writes the flash: mp_stack,
fast_heap and the radio threads’ stacks take 24064 of its 24128 bytes.
The file system¶
/FLASH:is the host’s FatFs with MicroPython’s settings (8 files, 4 directories, long names up to 64) and an fstab entry, with its own FATFS object in internal RAM.The flash disk’s cache moved out of bank 0, because the ring may run while Python reads a file.
The host’s read-only mount for the app files is gone by then.
The display and the board’s peripherals¶
CONFIG_MULTIAPP_MICROPYTHON_GUI, set by the board’s fragment, compiles LVGL and the board’s drivers into the extension (DEVICES), so no other boot pays for them.On the XIAO: SPI, MIPI-DBI, ST7789V, the knob’s input drivers and the SD stack.
On the Communicator: SPI, MIPI-DBI, NV3007, I2C and the TCA8418 keyboard.
micropython.cmakepicks them from what the extension’s Kconfig pass enabled, and a device without its driver fails the link.The host’s
.confighas none of them. The XIAO’s devicetree would otherwise switch the SD stack on in the host, which the second Kconfig pass caught (CONFIG_DISK_DRIVER_SDMMC=nthere).The peripherals come from
apps/micropython/boards/<board>_periph.dtsi, shared with the standalone app, and the extension reads the same board fragment the standalone app does.A display board without a fragment fails at configure time: without it the panel’s colours come out wrong (Wrong colours).
Two USB drives¶
The host defines two LUNs, because their list is a host section (
src/drive.c).In a drive boot the first is the volume, and the second, on a board with
sd_fs, has no medium.A MicroPython boot points the first at
UFLASHand the second atUSD, the proxiessrc/usb_disks.cregisters from the extension, unchanged from the standalone app.They report no medium while the board writes a volume.
Design choices¶
No new partition table. The volume takes the upper 4 MB the board’s 4 MB table leaves unused, so MCUboot, the slots and DFU stay compatible with the standalone apps.
No
fs_loader. It reads the symbol table and every relocation entry by entry (about four times the file size in flash reads) and would overflow main’s stack. The host reads the file whole into PSRAM and keeps the buffer loader.The module builds its own list of the driver’s sources (
wifi.cmake), not the hal’s. A host withCONFIG_WIFI_ESP32and those sources taken off its targets would leave the hal’s global Wi-Fi definitions on everything the host compiles, and the radio’s PHY-only path depends on the driver being off.A build id, not an ABI hash with a manual bump. llext binds by name only, so a file is accepted only from a host built from the same inputs.
Built-in copies stay on (
CONFIG_MULTIAPP_EMBEDDED) until the volume has proven itself on more boards; off, the image shrinks by 340 KB.wifihas none: at 540 KB it would be most of the image.
Memory budget¶
The host¶
Internal RAM¶
The host’s image ends 12120 bytes below bank 0 (0x3fcb0000) on the devkit.
On the XIAO it ends 10096 bytes below: its host also carries a second LUN, exFAT and a larger drive thread.
The image holds
module_heap(31744 bytes), the volume, the drive (2.2 KB) and what MicroPython’s/FLASH:needs from the host (5.5 KB: the flash disk’s cache, a FATFS object and the extra file slots).The signed image is 880 KB, against 1096 KB with the radio in the host.
Serving Wi-Fi costs every boot about 4 KB of internal RAM and 80 KB of flash (IPv4, DHCPv4,
net_mgmtand its thread, the interface).
What got the image there:
no radio and no Wi-Fi driver in the host;
a kernel heap of 3072 bytes (peak 2144 in any boot, 236 in a drive boot, against 12216 with the driver);
CONFIG_ESP32_WIFI_NET_ALLOC_SPIRAM;the export group (Generated host glue);
CONFIG_NUM_MBOX_ASYNC_MSGS=0;the app’s
main()stack in PSRAM.
PSRAM¶
Of the 8192 KiB:
3.4 MiB the linker places, mostly the code heap (1344 KiB), the data heap (1024 KiB) and the transmit ring (1 MiB);
the shared heap only
wifiallocates from (1 MiB);the top 2048 KiB (
CONFIG_MULTIAPP_FILE_MAX_KB) for the file being loaded.
In a MicroPython boot everything above the first of those is its heap: 4785664 bytes, one block, against 5126144 standalone, the same with a display. On the XIAO the app takes 1116427 bytes of the 2368 KiB of code and data heaps.
Module sizes¶
In bytes:
Module |
Code in PSRAM |
Code internal |
Data |
Bss |
Read-only in PSRAM |
File |
|---|---|---|---|---|---|---|
|
31721 |
5931 |
3948 |
120 |
1616 |
55892 |
|
22750 |
7110 |
328 |
14384 (high region) |
824 |
50860 |
|
16024 |
722 |
768 |
1216 |
452 |
27224 |
|
324221 |
8477 |
5460 |
15580 |
62134 |
539948 |
The micropython app, in PSRAM:
Build |
Code |
Read-only data |
Data |
Bss |
File |
Relocations |
Imported symbols |
|---|---|---|---|---|---|---|---|
Headless |
168558 bytes |
113 KB |
38 KB |
163 KB |
441656 bytes |
8.7 k |
181 |
With display and LVGL (the XIAO) |
586195 bytes |
236 KB |
122 KB |
164 KB |
1275216 bytes |
26.4 k |
220 |
esdr’s FFT and monitor buffers are 128 KB of the headless bss. The symbols are imported from the
host and the modules.
module_heap and the high region¶
module_heapholds 29532 of 31640 bytes in a Wi-Fi boot and 20168 in awpanboot (multiapp info), and is empty in a drive boot.The high region is full: the area (24128 bytes, of which osmosdr takes 24064) and
module_high_mem(14528, of whichsdrtakes 14372).micropython takes 24064 of the area too.
The log queue holds 256 messages; link’s shell stack is 3072 bytes.
Stacks¶
Internal RAM stacks are sized so their peak with every app exercised is at most 85 %. The peaks
come from kernel thread stacks; main’s is in multiapp info, the USB thread’s in the last DFU
download in multiapp crash. In bytes:
Stack |
Peak of size |
Note |
|---|---|---|
main |
1936 of 2432 |
the PHY calibrates on it as its module loads |
|
1792 of 2560 |
|
|
800 of 2048 |
|
the driver’s event thread |
1152 of 1536 |
|
network receive thread |
1680 of 2560 |
in PSRAM |
USB thread |
1008 of 1280 |
|
drive thread |
880 of 1152 |
while the PC copies 2 MB |
drive thread, with the display |
1264 of 1728 on the XIAO (73 %) |
the SD stack runs on it |
|
77 % |
the highest of the others |
kernel heap |
2364 of 3072 |
|
|
512 of 768 |
|
|
13696 of 16384 (83 %) |
the highest; with the |
The drive thread’s peak with the display comes from a card that never reports an error. The SD stack’s error paths have not run on this stack, which is why it has more room than the rule asks.
Python’s own check stops recursion at about 15520, and C code called from Python at that depth has about 860 bytes left.
The standalone apps, 2026-10-09¶
Each app’s S3 build, read from zephyr.elf. The gap is from the end of the DRAM image to the first
dump bank the app reserves.
App |
IRAM |
DRAM |
Gap to first bank |
High region |
Flash code |
Flash rodata |
PSRAM |
|---|---|---|---|---|---|---|---|
capture |
61 KB |
170 KB |
125 KB |
0 |
341 KB |
447 KB |
0 |
rfprobe |
67 KB |
189 KB |
106 KB |
0 |
408 KB |
528 KB |
0 |
wpan |
89 KB |
164 KB |
0.2 KB |
37 KB |
430 KB |
532 KB |
2.6 MB |
osmosdr |
87 KB |
163 KB |
0.4 KB |
37 KB |
413 KB |
530 KB |
2.6 MB |
stream |
84 KB |
228 KB |
1.7 KB |
20 KB |
491 KB |
628 KB |
2.6 MB |
link |
92 KB |
228 KB |
1.0 KB |
39 KB |
460 KB |
599 KB |
1.7 MB |
The part every app has (kernel, drivers, Wi-Fi and PHY blobs) is 60 to 75 KB of IRAM and 60 to 90 KB of DRAM; the apps’ own DRAM is mostly buffers.
Imports per app from the host: capture 17, rfprobe 56, wpan 60, osmosdr 68, stream 108, link 92; 197 symbols in the union.
Measurements¶
Radio in modules¶
On an ESP32-S3 devkit (N16R8) behind a USB hub, which limits bulk transfers to about 890 kB/s, on the production image. The right column is the same app built standalone with the Wi-Fi driver, on the same bench. The XIAO has built this host, not run it (its runs: XIAO with display, Radio in the host, older design).
Test |
Modules |
Standalone with driver |
|---|---|---|
|
780, 796, 788 kB/s |
788 kB/s |
|
799, 798, 799 |
799 |
|
794, 799, 800 |
799 |
|
197, 196, 197 |
196 |
|
1599, 1599 |
not on this script |
|
10567 to 14657 us |
10414 to 14279 us |
|
5661 to 9361 us |
5423 to 8883 us |
The plain frames lost were on channels 20 and 25, which are busy here.
With or without modules, a batch of 50 frames asking for an ACK usually misses one, as a missing ACK or a transmit error (-5). That has not been looked into.
osmosdr¶
esdr_usb, each test from a fresh boot:
test-in893 kB/s.Receive at 250 kS/s 8 bit and 125 kS/s 16 bit with 0 gaps and 0 overflows.
1.26 M samples transmitted with none dropped.
250 kS/s 16 bit overflows as it does with the driver: it exceeds this link.
Ring 10.7 to 11.3 cycles per pair, and 11.3 to 12.3 at 32x, varying from run to run with or without modules.
capture and rfprobe¶
capture’s survey: 0 failed.rfprobe: tune, gain, tone and receive work.probe tempreturns -ENOTSUP, because the host has no temperature sensor driver.
wifitest¶
The Wi-Fi module on its own PHY, on a WPA2 access point on channel 6 at -44 dBm:
It joins and gets IPv4 by DHCP and IPv6 by router advertisement.
The board’s pings to the gateway: 100 of 100, the replies sampled taking 4 to 11 ms.
A PC’s pings to the board: 160 of 160, at 56 and 1000 bytes, up to about 240 ms round trip (not looked into; Wi-Fi power save is a likely cause).
Leaving and rejoining works, and so does a reboot with the link up (reset reason 12).
10 scans in a row found 13 to 16 access points.
Updating the image and the volume with the link up and pings running: both confirmed, reset reason 12, 119 of 120 pings answered over about the first 6 s of each.
sample.esp_sdr.multiapp.wifi.hilpasses; it scans, since joining needs credentials.
After an abrupt reset the access point still has the board associated:
The first join fails with status 1 in 1.2 s, and the next one works (4 of 4).
After
wifi disconnectthe first join works (3 of 3).An app should try again. Not compared with a standalone image.
App switches and boot time¶
56 app switches on the image with Wi-Fi scanning, 28 more on the final one, each into the requested app, all with reset reason 12 (a software reset).
DFU with the ring running.
The liveness watchdog fires with its feeder suspended, and the next boot falls back to the drive.
A drive boot loads no module and starts no radio thread.
From the kernel’s start to the app’s
main(), with its modules loaded and the PHY calibrated: 177 ms (capture) to 238 ms (link), 386 ms forwifitest.link bench’s float loop and power sum are 1.4 and 1.9 times slower than standalone. This is the shell on CPU 0 (Radio in the host, older design).
MicroPython on the devkit¶
On the same devkit, with manifest_headless.py, against a standalone apps/micropython built
headless for this board. The XIAO is in XIAO with display. The
Communicator builds this host and has not run it; its runs are in
Communicator with display.
Start and resets¶
From the host’s
multiapp runthe REPL answers within about 1.5 s. Its boot takes 84 ms forphyandsdrand 222 ms for the app (multiapp info).Three soft resets give the same heap each time, and files and
esdr.shell()keep working.A 4.69 MB buffer reaching within 11 KB of the top of PSRAM takes a pattern every 4 KiB and reads it back.
/FLASH:: 128 KiB written, read back whole and from a seek, directories made and removed, files still there after soft resets, the apps’ files still loading after that.Leaving: three times to
wpanand back withesdr.shell("multiapp run wpan"), andmachine.reset(), all with reset reason 12 and no crash recorded.
Firmware updates from the REPL¶
west dfu,west dfu --storage,west dfu --no-confirmandwest dfu --esptoolall work from the REPL.A new image boots as a drive boot, so its check and confirm go through the shell. With an autostarted REPL the confirm goes through
esdr.shell(), which works (the Communicator).--storagehit “Cannot claim interface - LIBUSB_ERROR_BUSY” on its first try in 3 of 11 updates from the REPL and in 0 of 6 from a shell boot; the retry worked each time.Later three tries in one second all failed and left the board in DFU mode (
west dfu --dfu-boardrecovers it).fwupd’s DFU plugin logged a probe of the new device at that moment, so
west dfunow waits 2 s between tries.
Stack¶
mp_stackpeaks at 4880 of 16384 bytes at the REPL, against 4912 standalone.Deep recursion takes it to 15520, where Python’s own stack check stops it, and the same applies standalone.
Python speed¶
Python runs slower, because the interpreter runs from PSRAM and is built position independent. Three rounds of the same script, in milliseconds, each stable to 1 ms except one wrapped reading on the standalone image (a negative time, left out):
Loop |
Calls |
Float |
List |
String |
Dict |
Bytes |
Allocate |
|
|---|---|---|---|---|---|---|---|---|
Standalone |
179 |
115 |
128 |
104 |
138 |
62 |
218 |
74 |
As an app |
203 |
127 |
141 |
116 |
143 |
67 |
247 |
70 |
Change |
+13 % |
+10 % |
+10 % |
+12 % |
+4 % |
+8 % |
+13 % |
-5 % |
Receiving and transmitting¶
Receiving through
esdr: 0 gaps at every rate from 500 kS/s to 15.6 kS/s, and at 250 kS/s counting for 15 s, into a 4 MB PSRAM buffer, into a wrapping ring for 15 s, and withrx_latest()polled as a display does while Python allocates on the other CPU.Ring cycles per pair match standalone within 0.1 (12.63 counting, 13.12 to a buffer, 13.30 wrapping), and with the monitor they are lower (13.6, against 14.0).
So the sink running from PSRAM has not cost anything yet; a display was still to come (XIAO with display).
Transmitting: 0 underruns at 500, 250 and 125 kS/s, generated or from a buffer.
At 500 kS/s a 10 s session usually has one DAC restart, dropping about 550 samples: 9 restarts in 12 sessions over three runs here, 3 in 4 standalone. None at the lower rates.
Over the air and GNU Radio¶
From Python, against the WHY2025 badge’s radio: the badge hears the S3’s tone at -44 dB and the S3 hears the badge’s at -50 to -52 dB, on this image and standalone alike.
A flowgraph on the frozen GNU Radio shim (
soapy.source,head,null_sink): 500000 samples, 0 gaps.Resets, leaving for another app and firmware updates with the ring or the transmitter on: all clean. A soft reset leaves the next capture at 0 gaps.
File reads with the ring on¶
File reads with the ring on return correct data. But the flash operation parks CPU 1, and a bank switch can come late (
RING_LATE), which restarts the ring with about 3 ms lost.A 4 KiB read every 100 ms restarted it 41 to 63 times per 145 reads, against 9 to 26 standalone, losing about 1 % of the samples.
That difference is not explained: reads are faster here (694 us against 908 us), and pinning
maindid not change it.A tight read loop breaks the ring on both images (750 to 1010 and 584 to 875 restarts in 15 s).
Writing 2 MiB with the ring on took 12 s and read back correctly, with 285 restarts; not compared with standalone.
Neither image is gapless while files are in use.
The other apps¶
On this image the other apps match the numbers above.
wpan against the C6:
799 of 799 received.
785 of 800 sent.
199 of 200 ACKs.
1586 of 1600 ACKs sent by the S3.
The losses nearly all on channel 20, which is busy here.
The rest:
stream779 kB/s.osmosdrwith the same ring cycles and 0 gaps.capture,rfprobeandlinkas well.28 app switches, all reset reason 12.
XIAO with display¶
A XIAO ESP32S3 with the ST7789V panel (320x240), knob and SD slot, panel and card on one SPI bus, against the standalone app built from the same tree. That standalone image is byte for byte the one built before this work moved its overlay and source lists. Panel, colours, launcher and knob were checked by eye.
Starting it¶
multiapp run micropythontakes 87 to 95 ms forphyandsdrand 781 ms for the app.The REPL answers 1.95 s after the reset, against 1.31 s standalone.
Since 2026-11-10 it boots to the launcher by itself (
CONFIG_MULTIAPP_AUTOSTART, as the Communicator).That was checked after
west dfuwith--storage, aftermachine.reset()and after a soft reset; Scan started from it (launcher.run("scan")) and ended by Ctrl-C back to it.esdr.shell("multiapp run <name>")starts another app.
Python speed¶
Slower as on the devkit, because the interpreter runs from PSRAM and position independent. Strings are faster here. Three rounds of the same script, in milliseconds:
Loop |
Calls |
Float |
List |
String |
Dict |
Bytes |
Allocate |
|
|---|---|---|---|---|---|---|---|---|
Standalone |
179 |
115 |
129 |
105 |
179 |
64 |
218 |
500 |
As an app |
203 |
127 |
141 |
117 |
150 |
70 |
247 |
520 |
Change |
+13 % |
+10 % |
+9 % |
+11 % |
-16 % |
+9 % |
+13 % |
+4 % |
The display and the ring¶
The eggs ran from the launcher, in their own interpreter. The sink running from PSRAM costs nothing measurable here: 12.99 to 13.02 cycles per pair, against 13.00 to 13.02, so it stays there.
Run |
As an app |
Standalone |
|---|---|---|
|
0 gaps, 1 run each |
the same |
|
0 gaps, 954 frames per sink, loop 78 % busy |
0 gaps, 945, 86 % |
The same for 600 s with a retune every 2 s |
296 retunes, 0 gaps at every reading (twice a second), 4731 frames, 79 % |
292, 0 gaps, 4671, 87 % |
Heap in those 600 s, 10th reading to the last |
-4032 B |
-3840 B |
|
0 gaps |
0 gaps |
|
2 gaps (2 samples, 17 pairs lost) in 1 of 4 runs |
0 gaps in 3 runs |
The 1 MS/s gaps are one event, not explained; there are too few runs to tell it from chance.
About half of the heap’s fall is the test’s own list of readings. The rest is on both images, so in the shared Python.
LVGL and the heap¶
LVGL: six cycles of 24 objects sharing a style, each with an event callback and an animation, and a timer that ends itself, with Python holding no reference and the heap filled with poison and collected in between.
Every event, tick and animation still fires, and the heap ends 16 B lower.
Python’s free heap in an egg: 4.53 MB against 4.87 MB.
The USB drive¶
The volume’s drive in a MicroPython boot: 256 KiB from the PC at 87 kB/s (59 kB/s with
spectrumrunning), read back at 670 kB/s after a remount, identical on the PC and on the board.1 MiB from the board, identical on the PC.
A drive boot shows the volume and a second drive with no medium.
The other apps¶
capture,rfprobeandlinkrun;stream780 kB/s.osmosdr:test-in890 kB/s with 0 gaps at 250 kS/s 8 bit and 125 kS/s 16 bit, and none dropped on transmit.28 app switches, and both desk checks pass.
This USB port gives standalone
osmosdr893 kB/s as well, so the 1154 kB/s of Radio in the host, older design was another port. 250 kS/s 16 bit overflows here for that reason.wpanboots, but has not met the C6 on this image, which was not on the desk.Open from the devkit, not repeated here: file reads restarting the ring more often than standalone.
Later changes¶
After these runs the drivers’ list in
micropython.cmakechanged for the Communicator, and the layout gainedfit().The XIAO’s host stayed byte for byte the same through the first, and its eggs have the same plots as before through the second.
That final build runs
waterfallandspectrumwith 0 gaps.
SD writes untested¶
The only card to hand keeps nothing it is given (SD cards), so no file written to an SD card has been read back on this image.
What has run: the card mounts, the files list, raw reads at 903 kB/s at 12 MHz.
The path from USB to the card: 16 MiB at 217 kB/s, and 4 MiB at 126 kB/s with
spectrumdrawing on the same bus, with 0 gaps and 1 run.A boot with no card comes up normally, though the port’s message is “FS is invalid”.
Communicator with display¶
The Hackaday Communicator: NV3007 panel (428x142) on SPI, TCA8418 keyboard on I2C, no SD card and no knob, against the standalone app from the same tree. Panel, colours, keys, starting an app from the keyboard and Esc back to the launcher were checked by hand. This board is on a port without a hub.
Starting it¶
95 ms for
phyandsdr, 947 ms for the app, in a 1267392-byte file.The REPL answers 2.35 s after the reset, against 1.64 s standalone.
The host’s image ends 11888 bytes below bank 0.
It boots to the launcher by itself (
CONFIG_MULTIAPP_AUTOSTART): from a power-on, aftermachine.reset(), after another app and a reset, afterwest dfuand--storage.The runs here were before that, with a host otherwise the same; both desk checks’ autostarts override it.
Python speed¶
A fresh interpreter against standalone, in milliseconds:
Calls |
Float |
List |
String |
Dict |
Bytes |
|
|---|---|---|---|---|---|---|
Standalone |
115 |
128 |
105 |
148 |
63 |
218 |
As an app |
128 |
141 |
117 |
156 |
68 |
247 |
The display and the ring¶
Run |
As an app |
Standalone |
|---|---|---|
|
0 gaps, 1 run each |
the same |
|
0 gaps, 961 frames per sink, loop 51 % busy |
0 gaps, 955, 59 % |
|
0 gaps |
0 gaps |
The stress for 600 s with a retune every 2 s |
299 retunes, 0 gaps at every reading |
not run |
Those runs had
spectrumbefore the layout’sfit(), with its plots stacked.With it,
spectrum’s plots are 171x41 instead of 428x15 andwaterfall’s 171x124, and each ran for 20 s with 0 gaps and 1 run.The plots beside the rows, the keys reaching every control and retuning from the slider were checked by hand.
LVGL’s stress as on the XIAO: everything still fires, and the heap ends 16 B lower.
The USB drive¶
256 KiB from the PC at 101 kB/s (96 kB/s with
spectrumrunning), read back at 760 kB/s after a remount, identical on the PC and on the board.1 MiB from the board, identical on the PC.
Writing with the ring on restarts the ring, as on the XIAO.
Radio¶
Over the air, from Python, against the WHY2025 badge’s radio: the badge hears the tone at -49 to -50 dB, and the Communicator hears the badge’s at -46 to -52 dB.
wpanagainst the badge’s C6, 200 frames each way on channels 11, 15, 20 and 25: the S3 received 799 of 799 sent, and the C6 784 of 799, 12 of the losses on channel 25.194 of 200 ACKs came back to the S3, and the S3’s own ACKs reached the C6 for 1599 of 1600 frames.
The other apps¶
capture,rfprobeandlinkrun.stream1027 kB/s.28 app switches, and both desk checks pass.
osmosdr:
test-in1173 kB/s.Receive at 250 kS/s 8 and 16 bit and 125 kS/s 16 bit with 0 gaps and 0 overflows.
1254692 samples transmitted with none dropped.
Stacks¶
At their peak over all of that, keys pressed included, in bytes:
Stack |
Peak |
|---|---|
|
13680 of 16384 (83 %, |
drive thread |
944 of 1152 (81 %) |
main |
1808 of 2432 |
|
896 of 1152 (77 %, in |
|
512 of 768 |
kernel heap |
2392 of 3072 |
Radio in the host, older design¶
On the XIAO, with the radio in the host.
wpan¶
Against the C6 (interop.py, 100 frames of 100 bytes), on channels 11, 15, 20 and 25:
100 of 100 frames each way.
50 of 50 ACKs.
stream¶
947 kB/s of VITA 49.2 over NCM (standalone 968 kB/s).
vrt_tx.pypasses as standalone.
osmosdr¶
esdr_usb:
test-in1154 kB/s.Receive at 250 kS/s (8 and 16 bit) without overflow or gaps.
1.25 M samples transmitted with none dropped.
Ring at 13.3 of 15 cycles per pair.
link¶
QAM build and decode within 1 to 4 % of standalone.
FFT and RS the same.
OFDM test frame 5583 us (standalone 5589).
link bench’s float loop and power sum are 1.4 and 2.1 times slower: the shell runs them on CPU 0 here, CPU 1 standalone (not isolated).PSRAM reads miss the cache once, then match internal RAM.
Not tested: a link between two boards.
App switches and DFU¶
48 app switches, each into the requested app.
All six apps run from their files with the same results.
DFU while the ring runs.
The volume¶
west dfu --storagereads back byte for byte (DFU upload), and fsck.vfat is clean.Copying through the drive runs at about 63 kB/s (every 4 KiB page erased and rewritten). Files read back identical after a remount and run after ejecting.
west dfu --esptool --storagewrites MCUboot, image and volume in 27 s.A host built with one Kconfig value changed refuses the old files.
The desk check
sample.esp_sdr.multiapp.hilpasses (Testing).
Other chips¶
ESP32-C6: complete images¶
multiapp does not exist for the C6. What the WHY2025 badge’s C6 has instead does the same job differently; its usage is in osmosdr_serial.
This design cannot move there: no PSRAM for code, about 13 KB left in SRAM block 0 with the SDR’s image, blocks 1 and 2 the gapless capture’s, and loader options and module linking built around Xtensa shared objects.
So MCUboot holds five complete images, and
lib/boot_selectstarts the SDR unless a flash sector asks for another, until the next power-on.
Capture under MCUboot¶
The SDR had to move from the ROM’s simple boot to MCUboot, and its capture was measured on both, 15 s each:
Through the P4 |
Simple boot |
Under MCUboot |
|---|---|---|
Gapless 80 MS/s: radio pairs, ring errors, bad blocks |
1199765484, 0, 0 |
1199766546, 0, 0 |
Gapless 40 MS/s: radio pairs, ring errors, bad blocks |
1799686878, 0, 0 |
1799680769, 0, 0 |
|
0, 0 |
0, 0 |
Over the air against the Communicator, two rounds on the same desk: about -55 dB on both images in the first, about -65 dB on both in the second. The level moves with the room, not the image.
Each app ran from its slot:
capture’s survey, 0 failed;rfprobeandwpananswer on their shells;zstackboots.A damaged image fell back to the SDR, and a power-on ended a request.
ESP32-S31: RISC-V extensions¶
On the ESP32-S31-Function-CoreBoard-1 the host has one core, 16 MB of octal PSRAM and the USB 2.0
HS port J4 for the shell, the drive, DFU and osmosdr_hs’s stream. It boots into osmosdr_hs, and
hello, capture and rfprobe are the other apps. Where it differs from the S3:
Relocatable objects¶
On RISC-V llext loads only those (
ld -r).A shared object’s
.rela.dynnames no section, so llext skips it, and its PLT reaches.got.pltPC-relative across regions llext places apart.ext/llext_riscv.ldgroups each kind in one section per llext region and makes one.bss(llext takes a single NOBITS section; libphy alone has six).It also collects the IRAM_ATTR code as
.module_fastand drops.eh_frame(its SET6/SUB6 relocations are not llext’s).An extension with archives links with
--gc-sections: what it compiles is kept, and of the archives only what it reaches.So are the hal’s sources it compiles, built with a section per function: the PHY glue’s antenna helper calls
gpio_config(), which the host lacks.exports.pyreads the objects’ symbol tables.
No alias¶
Code runs where llext writes it: one heap of 2368 KiB in PSRAM (
.ext_ram_noinit, not zeroed at boot).This SoC’s
EXT_RAM_NOINIT_ATTRis internal RAM, soesp_sdr_place.hnames the section.sync_text()writes the data cache back, invalidates both instruction caches (Cache_*_Addr()with this SoC’s cache map) and runsfence.i.PMA marks PSRAM executable and PMP’s entries are unlocked, so the code runs from PSRAM and internal RAM alike.
TLS¶
The libc uses thread-local storage, and llext relocates no TLS access:
CONFIG_CURRENT_THREAD_USE_TLS=n makes k_current_get() a call.
The radio as one module¶
sdrholds the hal’s PHY glue, the library and the blobs.The PHY library’s calls into two ROM functions go to wrappers in the library (
--wrapin the partial link), which only a module holding both can link; the host links the ROM’s PHY symbols.9.2 KB of it is internal RAM (IRAM_ATTR code, data, bss), the rest PSRAM.
It comes up in about 116 ms.
osmosdr_hs¶
It is built from its own sources as
INTERNAL, so its 104 KB of USB batches, which carry 40 MB/s, are internal RAM.ext/usbd_prelude.hgives it the host’s USB device where it brings up its own, andCONFIG_APP_USB_MSG_HOOKpasses it the device’s messages (a suspend stops the stream).Its crystal calibration lives in settings, a file on the volume. An app’s boot mounts the volume read-write before its modules load (a boot with an app never hands it to the PC), and
ext.hregisters settings handlers as the extension loads.west dfu --storagewrites the volume anew, calibration included.
Memory¶
The image ends 12.9 KB below the receive ring at 0x2F040000, with a module heap of 120 KB of which the radio and osmosdr_hs take 116 KB.
Measurements on the CoreBoard¶
Against the standalone builds on the same board (2026-11-13 and 14):
multiapp |
standalone |
|
|---|---|---|
osmosdr_hs, 300 s at 20 MS/s |
5,993 M samples, 0 gaps, 0 bad blocks |
5,986 M samples, 0 gaps |
osmosdr_hs, free CPU at 20 MS/s (loadlog) |
83 %, idle reads 102 to 107 % |
79 %, idle reads 96 to 101 % |
osmosdr_hs, overflows the device counts |
0 while streaming, 3 to 4 at the stop (0 since, below) |
0 while streaming, 4 at the stop |
rfprobe, bursts at the six rates |
duration 1.000 of the rate’s |
1.000 |
rfprobe, ring at 20 and 40 MS/s, 3 s |
0 gaps |
0 gaps |
The overflows at the stop were
esdr_usb’s: it cancelled its transfers before it turned the device off, which then streamed on into nothing.It turns the device off first now: three 10 s runs at 20 MS/s each way, alternating, counted 2 overflows at every stop before and none after (2026-11-15).
More osmosdr_hs runs¶
osmosdr_hs under multiapp also:
ran 30 s at 10 and 5 MS/s with 0 gaps;
showed the 2400 MHz crystal harmonic at -3.000 MHz from LO 2403 and +5.000 MHz from LO 2395;
kept a stored calibration across a reboot;
streamed through 360 random retunes and a 3 s host stall without a fault, and through SoapySDR.
Its vendor interface is number 3 there (0 standalone); esdr_usb and the SoapySDR module find it
by its class.
Bugs found¶
Loader and relocations¶
A pointer past a section¶
R_XTENSA_RELATIVElooks a GOT entry’s target up by section. A table’s end pointer, one past its last object, lies in no section when padding follows.llext said “0x136204 not found in any of the sections”,
Failed to link, ret -2, and the app did not start. Small extensions never had a table end at such a place.The lookup now accepts one past the end of an allocated section (
arch/xtensa/core/elf.c).
An unseen init table¶
A module’s init table bounds were linker script symbols, which llext does not export.
So
wpan’s radio device never initialized, and nothing reported it untilwpansaid “no radio”.See Devices in a module;
hello modcovers it now.
The PLT in internal RAM¶
The PLT in internal RAM was a mistake, and hid a limit. It sat with the fast code, on the belief that fast code called the host through it.
Its stubs only do lazy binding, which llext does not use. It cost
sdr3.2 KB.For
wifi, whose code is over 256 KB, it failed the link: a stub’sl32rreaches only 256 KB back to.got.plt, andldreports that as a bare assertion.
Extensions built at -O0¶
Zephyr drops -Os from Xtensa extensions. A 1472-byte frame (32 at -Os) overflowed a 2048-byte
stack. multiapp keeps the host’s -Os.
llext relocations¶
Local Zephyr fixes for:
R_XTENSA_GLOB_DATdropping its addend;alignment padding making
.bssclaim.exported_sym’s relocations;a shared object’s
.bss12 bytes off its 16-byte alignment, which the S3’s 128-bit loads round down silently.
Stale extensions¶
Zephyr’s llext CMake rule never rebuilt <target>_debug.elf after an edit. Local Zephyr fix.
The freed symbol table¶
llext frees an extension’s symbol table after loading; the shell recognizes dynamic entries by host section address.
USB, CPUs and threads¶
USB on the radio’s CPU¶
maincould start USB on the radio’s CPU. USB’s and the watchdog’s interrupts land on the CPU that allocates them, and a thread can come back from any wait on the other CPU.A
captureboot reported CPU 1.With MicroPython’s ring on, a firmware update then died part way through on a watchdog reset (reset reason 7) in 2 of 3 tries, with no crash record, because the ring masks interrupts on that CPU.
mainnow pins itself to CPU 0 first (app_cpu_pin_self()): 6 of 6 updates with the ring on and 3 of 3 with the transmitter on.Every boot had this hazard, not only this app.
NCM unregistered before init¶
Unregistering NCM before init crashed: its shutdown removed a descriptor it never added. Local Zephyr fix.
link’s shell stack¶
link decode and link bench overflowed the shell stack (a 3.6 KB decode chain). They run on the
paused MAC thread now (link_mac_run_paused()). osmosdr’s receive thread has 2560 bytes.
Updates and the volume¶
Refusals taken for crashes¶
After a new image, a file-only module’s old file is refused and the boot comes up as a drive.
The guard against crash loops then skipped the autostart once more, even with the right volume written.
Now only a boot that dies is skipped.
The volume 4 KiB off¶
flash_img writes an MCUboot image, from the start the swap-using-offset layout gives the update
slot: the volume landed 4 KiB into its partition. Its DFU target uses stream_flash.
Wi-Fi and network¶
A zeroed interface¶
The driver names its interface through a
NET_IF_DECLARE()thatNET_DEVICE_DT_INST_DEFINE()fills in.With that macro replaced it was a zeroed
net_ifof the module’s own, which links and scans: scans never use it.The first join crashed in
net_if_dormant_off().
The network receive stack¶
The network receive stack overflowed on real traffic. 1024 bytes were enough for
stream, and the first router advertisement over Wi-Fi used all of them.It lies directly above
net_mgmt’s stack in PSRAM, which an overflow would corrupt.One update failed while such an image was connected, and none has since.
Now 2560, in PSRAM, peak 1680.
One IPv4 slot¶
CONFIG_NET_IF_MAX_IPV4_COUNT=1 went to NCM’s interface, unused, so DHCP on Wi-Fi never finished.
With CONFIG_WIFI_STA_AUTO_DHCPV4 the result of a join comes only then.
The hal’s name mapping¶
The hal’s name mapping ran too early: zephyr_compat.h maps Zephyr’s Wi-Fi options to ESP-IDF’s and
comes first on every compile line, before an extension’s own values. ext/wifi_compat.h runs it
again.
SD cards¶
Three cards, no writes¶
None of three SD cards could test writes on the XIAO.
After the two below, a 32 GB card that reads fine in the WHY2025 badge’s native SD mode holds MISO low whenever it is selected on the XIAO’s SPI bus, power cycled or not, so even CMD0 reads 00.
It is not the slot: another 32 GB card passed writes there in October, and the 4 GB one below initialized.
The card was sent only reset and identify commands. Not explained.
Two faulty cards¶
One, sold as 64 GB, presents 1.9 GB and sets the high capacity bit, yet is byte addressed. So LBA n reads sector n/512, and
/SD:reports “FS is invalid”.One, 4 GB, went read-only without saying so: every write is acknowledged, with no error at any level, and the old data reads back, in a PC’s card reader too.
On it, 4 MiB “written” in 0.6 s were gone after a remount, and Linux said “not properly unmounted” at every mount, since the flag never clears.
Both behave so on the standalone image as well. Before suspecting the driver, read whole sectors and write one.
MicroPython port and display¶
The standalone app on the Communicator¶
The standalone app no longer fit the Communicator, by 32 bytes: “DRAM image overlaps the ring banks”, with code that had come in since (
corr_modeland friends inlib/esp_sdr).The board’s fragment gives up 64 bytes of the kernel heap’s 15872, which the host’s
extconfig.pypass is told to ignore.That heap’s peak cannot be read on the image (no runtime statistics). It boots and runs the whole set of tests above, and 13312 once failed to bring USB up, so there is not much more to take from it.
waterfall on the Communicator¶
waterfalldid not start on the Communicator, as an app or standalone:ValueErrorfromframebuf.FrameBufferingnuradio/qtgui.py.Its rows take 130 of the 142-pixel panel’s 124, which left a plot of no height.
spectrumstarted, with 6 pixels of plot under each label.Now
_layout.fit()puts plots that would get less than 30 pixels beside the rows, using the panel’s width. Displays with room keep the stack.
Wrong colours¶
Colours were wrong, and nothing said so. The extension looked for the board’s Kconfig fragment under a wrong name, because
BOARD_QUALIFIERShas no leading slash, soCONFIG_LV_COLOR_16_SWAPwas missing.The panel worked, in the wrong colours.
A missing fragment now fails configure.
esdr.init() during a capture¶
esdr.init() with a capture running never returns. It waits for the radio’s lock, which the
running ring holds, and Ctrl-C cannot reach it: the REPL goes silent. The standalone app has the
same code. Not fixed: stop the capture first.
os.rename()¶
The port’s os.rename() cannot work. zephyr_fs_make_path() returns one shared buffer, so both
names are the second one and it fails with ENOENT. The standalone app does the same. Not fixed.
Long prints¶
Long prints lose their middle. uart_poll_out() on CDC-ACM discards what does not fit its TX
buffer unless flow control is on, and the REPL’s output goes that way. The standalone app does the
same. Not fixed: with flow control, a print with no PC attached could block for good.
Memory rules¶
The rules behind these three are in Code placement.
PHY code with the cache off¶
The ROM calls PHY code with the cache off. With
phy’s code in PSRAM, a reboot with the radio up ended in a double exception (reset reason 16, not the software reset’s 12).The fault was an illegal instruction in
ram_chip_i2c_readReg, on the way down inrtc_clk_cpu_set_to_default_config.This placed blob code in internal RAM, and
test_reset_was_cleanwatches for it.
Atomics in PSRAM¶
Atomics in PSRAM are not atomic (hello atomic). Local Zephyr fix.
Flash access from a PSRAM stack¶
No flash access from a PSRAM stack: the app’s main() raced the host’s app_usb_init() and ran
MCUboot’s image check on its PSRAM stack. Double fault; the board hung after some app switches.
Zephyr changes¶
Commits on the fork’s zsdr branch, which west.yml pins, on top of the SMP port. They are
candidates for upstream Zephyr:
exec alias;
llext repackage dependency;
NCM/ECM unregister before init;
Xtensa GLOB_DAT addend;
alignment padding;
PSRAM atomics (two commits);
shared object region alignment.
For modules¶
The modules add
CONFIG_LLEXT_REGION_HEAPSwithLLEXT_MEM_TEXT_ALT(subsys/llext).CONFIG_ESP32_WIFI_NET_ALLOC_SPIRAMmoves tosoc/espressif/common/Kconfig.spiram, because it also serves the network stack without Wi-Fi.
For the display¶
arch/xtensa/core/elf.ctakes a pointer one past the end of a section (A pointer past a section).LVGL’s source lists move to
modules/lvgl/sources.cmake, in the same order, so that an application can build LVGL its own way.
On the MicroPython fork¶
The port’s source lists move to ports/zephyr/sources.cmake, for micropython.cmake to use.
For the ESP32-S31¶
Two more, both in the pinned zsdr with the S31’s support itself:
CONFIG_LLEXT_REGION_HEAPSdepends onCONFIG_LLEXT_HEAP_DYNAMICalone (the exec alias is Xtensa’s), part of the region heaps commit.arch/riscv/core/elf.cchecksR_RISCV_JALagainst the J type’s +-1 MiB instead of the 2 GiB of anauipcpair, which let a jump between regions too far apart through.
Risks¶
Extension code cannot run while flash is written (cache off): interrupt handlers and code that runs then stay in the host.
No clean unload: exit is a reboot.
The local Zephyr commits above, until upstream.
link throughput between two boards is untested.
A hal update can change what the Wi-Fi driver needs. A renamed source fails the build and a missing symbol fails the host’s link, but
wifi.cmake’s list and definitions are ours to keep in step.The PC’s write cache: files copied onto the drive reach the flash only when the PC writes them out, which ejecting guarantees.
multiapp runreminds of it in a drive boot.
USB that stops answering¶
USB has stopped answering twice on the devkit, and this has not been explained.
The first time was a
wpanboot idle after a shell session: no shell output and failed control requests for at least 6 minutes, with no reset from the liveness watchdog.The second was a drive boot with no app or radio, after 12 idle hours. A standalone
rfprobehas shown the same symptom.The second time, the chip answered normally over its UART, but its USB failed to enumerate even in ROM mode, with none of this firmware running, until a later replug.
So the USB path or the chip’s USB pins are involved, not only the firmware. A reset through the devkit’s UART bridge recovered it after that.
Previous: multiapp · Up: Applications · Next: micropython