22
33[ ![ rustscript-embedded on crates.io] ( https://img.shields.io/crates/v/rustscript-embedded.svg )] ( https://crates.io/crates/rustscript-embedded )
44
5- A directly flashable RustScript runtime for ESP32-C3. One image contains the bootloader ,
6- partition table, Arduino-ESP32 runtime, ` pd-vm-nostd ` , framework host API, and a default VMBC
7- script partition .
5+ A portable RustScript VMBC runtime with release targets for ESP32-C3, ESP32-S31 preview hardware ,
6+ and a native Arduino API simulator. Each ESP factory image contains its bootloader, partition table,
7+ platform runtime, ` pd-vm-nostd ` , framework host bridge, and a default VMBC program .
88
9- ## Flash the complete image
9+ ## Flash complete images
10+
11+ ### ESP32-C3
1012
1113Download ` micro-rustscript-esp32-c3.factory.bin ` from the latest GitHub Release and flash it at
1214offset zero:
@@ -16,7 +18,7 @@ python -m esptool --chip esp32c3 erase_flash
1618python -m esptool --chip esp32c3 write_flash 0x0 micro-rustscript-esp32-c3.factory.bin
1719```
1820
19- The boot order is fixed:
21+ The ESP32-C3 boot order is fixed:
2022
21231 . ` /rustscript/main.vmbc ` on an SD card connected with CS on GPIO 7.
22242 . The dedicated 64 KiB ` rustscript ` flash partition at ` 0x110000 ` .
@@ -26,18 +28,49 @@ An absent, unreadable, or missing SD script automatically falls through to the f
2628The release factory image already contains ` esp32-blinky.vmbc ` in that partition.
2729` RUSTSCRIPT_SD_CS ` and ` RUSTSCRIPT_SD_PATH ` can be overridden with PlatformIO build flags.
2830
31+ ### ESP32-S31 preview
32+
33+ Download ` micro-rustscript-esp32-s31.factory.bin ` and flash the merged image at offset zero:
34+
35+ ``` bash
36+ python -m esptool --chip esp32s31 write_flash 0x0 micro-rustscript-esp32-s31.factory.bin
37+ ```
38+
39+ The S31 preview image currently embeds the default VMBC program into the application at build time.
40+ Its runtime does not yet implement the C3 SD-card lookup, replaceable flash VMBC partition, or serial
41+ VMBC REPL. The release also includes the S31 ELF for debugging.
42+
43+ ## Targets and source layout
44+
45+ | PlatformIO environment | Purpose | Platform integration | Main source |
46+ | ---| ---| ---| ---|
47+ | ` esp32-c3-devkitm-1 ` | Flashable ESP32-C3 firmware | Official PlatformIO board plus Arduino-ESP32 and selected ESP-IDF APIs | shared ` firmware/ ` sources |
48+ | ` esp32s31 ` | Flashable ESP32-S31 preview firmware | Pinned ESP-IDF master preview toolchain | ` esp32s31/ ` CMake project |
49+ | ` arduino ` | Native host simulation of a small Arduino API subset | PlatformIO ` native ` plus ` firmware/simulator/ ` | ` firmware/arduino/main.cpp ` |
50+
51+ Only ESP32-S31 has a top-level target directory because current PlatformIO releases do not provide
52+ an ESP32-S31 board definition or framework package. Its directory supplies the ESP-IDF project
53+ files that PlatformIO cannot generate: ` CMakeLists.txt ` , ` sdkconfig.defaults ` , partition layout, and
54+ the pure ESP-IDF application entry point. ESP32-C3 can use PlatformIO's standard
55+ ` esp32-c3-devkitm-1 ` board and therefore shares the normal ` firmware/ ` project. The ` arduino ` target
56+ is a native simulator rather than separate hardware; its target-specific source already lives under
57+ ` firmware/arduino/ ` and reuses the simulator compatibility layer.
58+
59+ All three are still first-class PlatformIO and release targets. The directory shape reflects their
60+ different build systems, not a difference in release status.
61+
2962## Framework API from RSS
3063
31- Hardware functions are exposed through RSS modules, keeping board ABI names private. Import only the
32- capabilities a script uses:
64+ Hardware functions are exposed through built-in RSS modules, keeping the C host ABI private. Import
65+ only the capabilities a script uses:
3366
3467``` rust
35- use framework :: gpio as gpio;
36- use framework :: i2c as i2c;
37- use framework :: mcu as mcu;
38- use framework :: serial as serial;
39- use framework :: wifi as wifi;
40- use framework :: bluetooth as bluetooth;
68+ use gpio;
69+ use i2c;
70+ use mcu;
71+ use serial;
72+ use wifi;
73+ use bluetooth;
4174
4275let ok : bool = gpio :: configure (8 , 1 );
4376let written : bool = gpio :: digital_write (8 , true );
@@ -57,48 +90,14 @@ let address: string = wifi::local_ip();
5790let ble_ready : bool = bluetooth :: enable ();
5891```
5992
60- ### GPIO
61-
62- | Function | Result |
63- | ---| ---|
64- | ` gpio::configure(pin, mode) ` | ` bool ` ; modes: input ` 0 ` , output ` 1 ` , pull-up ` 2 ` , pull-down ` 3 ` , open-drain ` 4 ` |
65- | ` gpio::digital_write(pin, high) ` | ` bool ` |
66- | ` gpio::digital_read(pin) ` | ` bool ` |
67- | ` gpio::analog_read(pin) ` | ADC value as ` int ` |
68- | ` gpio::pwm_write(pin, duty, frequency, resolution_bits) ` | ` bool ` ; six channels, 1–16 bits |
69-
70- ### I2C
71-
72- | Function | Result |
73- | ---| ---|
74- | ` i2c::open(sda, scl, frequency) ` | ` bool ` |
75- | ` i2c::close() ` | ` null ` |
76- | ` i2c::transmit(address, data) ` | Wire status as ` int ` |
77- | ` i2c::transmit_register(address, register, data) ` | Wire status as ` int ` |
78- | ` i2c::receive(address, length) ` | Up to 255 bytes |
79- | ` i2c::receive_register(address, register, length) ` | Up to 255 bytes |
80-
81- ### MCU and serial
82-
83- ` mcu ` exports ` delay_ms ` , ` delay_us ` , ` millis ` , ` micros ` , ` cpu_frequency_mhz ` , ` free_heap ` ,
84- ` flash_size ` , ` random ` , ` restart ` , and ` deep_sleep_us ` . ` serial ` exports ` write_line ` , ` available ` ,
85- and ` read_bytes ` .
86-
87- ### Wi-Fi and Bluetooth LE
88-
89- The ` wifi ` API exports ` connect ` , ` disconnect ` , ` is_connected ` , ` rssi ` , and ` local_ip ` . ` connect `
90- returns whether ESP-IDF accepted the asynchronous connection request; poll ` is_connected ` before
91- using ` rssi ` or ` local_ip ` . The ` bluetooth ` API exports BLE-controller lifecycle operations:
92- ` enable ` , ` disable ` , and ` is_enabled ` . Both use ESP-IDF APIs and are registered only on supported
93- ESP targets.
94-
95- ` wifi ` and ` bluetooth ` are independent Cargo/PlatformIO features. ESP release targets enable both
96- by default through ` custom_rust_features ` ; removing either feature also removes its ESP-IDF includes
97- and RSS host exports. The host ` arduino ` target exports neither API.
93+ API coverage is target-dependent. ESP32-C3 provides GPIO, ADC, PWM, I2C, MCU, serial, Wi-Fi, and BLE
94+ controller functions. ESP32-S31 currently provides digital GPIO, core MCU timing/status, serial
95+ output, Wi-Fi, and BLE controller functions. The Arduino host target provides a small GPIO,
96+ ` delay_ms ` , and serial-output simulation subset.
9897
99- The private host ABI lives in ` firmware/host_framework.cpp ` ; the public RSS modules live under
100- ` programs/framework/ ` . This keeps script-facing APIs namespaced while allowing the VM to dispatch a
101- compact static function table .
98+ See ** [ Framework API reference ] ( docs/framework-api.md ) ** for the complete support matrix, RSS
99+ signatures, argument limits, return behavior, asynchronous Wi-Fi semantics, BLE scope, and C host
100+ callback contract .
102101
103102## Replace only the VMBC partition
104103
@@ -161,15 +160,17 @@ Outputs:
161160.pio/build/esp32-c3-devkitm-1/firmware.elf
162161.pio/build/esp32-c3-devkitm-1/firmware.bin
163162.pio/build/arduino/program
163+ .pio/build/esp32s31/program
164164.pio/generated/esp32-blinky.vmbc
165165.pio/generated/rustscript.partition.bin
166166dist/micro-rustscript-esp32-c3.factory.bin
167167dist/micro-rustscript-esp32-s31.factory.bin
168+ /mnt/TEMP/micro-rustscript-esp32s31/build/micro_rustscript_esp32s31.elf
168169```
169170
170- The factory image merges the ESP32 boot components, application, and default script partition . The
171- release includes the factory image, ELF, VMBC, packed script partition, flash helpers, partition CSV,
172- and SHA-256 checksums.
171+ Each ESP factory image merges its bootloader, partition table, and application . The C3 factory image
172+ also includes the packed default script partition. The release includes both factory images, both
173+ ELFs, the Arduino host executable, VMBC assets and helpers for C3, and SHA-256 checksums.
173174
174175The ` esp32s31 ` target uses pinned ESP-IDF master preview support. ESP-IDF source, Python environment,
175176toolchains, caches, Rust target artifacts, generated files, and build output are all kept under
@@ -179,9 +180,9 @@ The `arduino` environment links `pd-vm-nostd` through an Arduino-compatible GPIO
179180and allocator bridge. It runs the bridge and compiled VMBC program on the host before a board is
180181connected. A successful simulation ends with ` rss:status=0 ` .
181182
182- ## ESP32 image size
183+ ## ESP32-C3 image size
183184
184- The ESP32 partition table uses a 1 MiB factory application slot and a 64 KiB VMBC slot. OTA data
185+ The ESP32-C3 partition table uses a 1 MiB factory application slot and a 64 KiB VMBC slot. OTA data
185186and SPIFFS partitions are omitted because this image is flashed directly and script updates use the
186187dedicated VMBC partition. With ` wifi ` and ` bluetooth ` enabled, the measured factory image is
1871881,115,607 bytes, down from 2,164,183 bytes (48.45%), while retaining SD boot, the flash script,
0 commit comments