tinygo-org / tinygo

Go compiler for small places. Microcontrollers, WebAssembly (WASM/WASI), and command-line tools. Based on LLVM.
https://tinygo.org
Other
15.26k stars 901 forks source link

No serial output on xiao-esp32c3 #3631

Closed scottfeldman closed 5 months ago

scottfeldman commented 1 year ago

I'm not seeing any serial output for xiao-esp32c3.

sfeldma@nuc:~/work/tinygo$ tinygo flash -monitor -target xiao-esp32c3 -size short  src/examples/serial/serial.go 
   code    data     bss |   flash     ram
   4502       0    8818 |    4502    8818
esptool.py v4.6-dev
Serial port /dev/ttyACM0
Connecting...
Chip is ESP32-C3 (revision v0.4)
Features: WiFi, BLE
Crystal is 40MHz
MAC: 34:85:18:00:2b:b8
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Flash will be erased from 0x00000000 to 0x00001fff...
Compressed 4592 bytes to 3264...
Wrote 4592 bytes (3264 compressed) at 0x00000000 in 0.1 seconds (effective 380.6 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
Connected to /dev/ttyACM0. Press Ctrl-C to exit.

I expected to see "hello world!" printed to monitor every second.

No output.

Tried same on xiao board (not xiao-esp32c3) and I see output.

sago35 commented 1 year ago

USB Serial on ESP32-C3 is not available because USB Serial/JTAG Controller is not implemented now.

https://wiki.seeedstudio.com/XIAO_ESP32C3_Getting_Started/#resources

scottfeldman commented 1 year ago

USB Serial on ESP32-C3 is not available because USB Serial/JTAG Controller is not implemented now.

https://wiki.seeedstudio.com/XIAO_ESP32C3_Getting_Started/#resources

What would it take to add this support?

sago35 commented 1 year ago

I don't know much about it because there is not much documentation.

https://files.seeedstudio.com/wiki/XIAO_WiFi/Resources/esp32-c3_datasheet.pdf

image

Perhaps there is a hint in the source code around

https://github.com/espressif/arduino-esp32

It will probably finally be implemented in machine/machine_atsamd51.go, for example. But first, we need to make sure that code like xxx.WriteByte('a') works.

deadprogram commented 1 year ago

@sago35 you are quite correct.

Further dev info can be found here:

https://github.com/espressif/esp-idf/blob/master/components/soc/esp32c3/include/soc/usb_serial_jtag_reg.h https://github.com/espressif/esp-idf/blob/master/components/hal/esp32c3/include/hal/usb_serial_jtag_ll.h

aykevl commented 1 year ago

I think I looked into this once, and IIRC it was very similar to the UART but shows up as a USB-CDC endpoint.

deadprogram commented 5 months ago

This was already implemented in release v0.31 so now closing. Thank you!