tinygo-org / drivers

TinyGo drivers for sensors, displays, wireless adaptors, and other devices that use I2C, SPI, GPIO, ADC, and UART interfaces.
https://tinygo.org
BSD 3-Clause "New" or "Revised" License
584 stars 180 forks source link

espradio: implement support for wifi/BLE on the ESP32-C3 #650

Open aykevl opened 5 months ago

aykevl commented 5 months ago

This is a work in progress. It does not yet work. It supersedes #320.

It is based on the work done by Rust people: https://github.com/esp-rs/esp-wifi/tree/main/esp-wifi-sys

To compile, use:

tinygo flash -target=xiao-esp32c3 -monitor  ./examples/espradio/

Right now it doesn't quite work yet:

Connected to /dev/ttyACM0. Press Ctrl-C to exit.
entry 0x4038a4dc
initializing radio...
espradio pp: pp rom version: (null)
espradio net80211: net80211 rom version: (null)
panic: espradio: todo: _task_create_pinned_to_core
aykevl commented 5 months ago

Update: I got a bit further.

Connected to /dev/ttyACM0. Press Ctrl-C to exit.
entry 0x4038a5b8
initializing radio...
espradio pp: pp rom version: (null)
espradio net80211: net80211 rom version: (null)
I (1002) wifi:wifi driver task: 3fc8b2d4, prio:253, stack:6656, core=0
W (1012) wifi:pp q full: 6-3fc8baf4

W (1012) wifi:ioctl: failed to post WiFi task 38
W (1022) wifi:pp q full: 15-0

espradio TODO: delete task 0x3fc8b2d4
could not enable radio: espradio: unknown wifi error

So apparently a send on a queue timed out (pp q full and failed to post WiFi task 38). I think the next step is implementing the various interrupt handlers and setting up the system timer (it probably times out because it expects one of those interrupts to trigger). This requires a change in gen-device-svd because it doesn't list some required interrupts in the generated Go file (while they exist in the SVD file).

EDIT: actually the interrupts aren't present in the SVD file, they need an update: https://github.com/cmsis-svd/cmsis-svd-data/pull/3

deadprogram commented 2 months ago

@aykevl the SVD file was updated, so this PR should be unblocked. :smile_cat: