Moddable-OpenSource / moddable

Tools for developers to create truly open IoT products using standard JavaScript on low cost microcontrollers.
http://www.moddable.com
1.31k stars 236 forks source link

Serial not works on ESP-IDF5 #1367

Open stc1988 opened 1 month ago

stc1988 commented 1 month ago

Build environment: macOS Moddable SDK version: 3bf5202 Target device: M5Stack, M5Stack_core2, Moddable_two

Steps to Reproduce

  1. Build and install the appexamples/io/serial/echo using this build command: mcconfig -d -m -p esp32/m5stack
  2. Quit xsbug
  3. Open esp-web-tools in browser
  4. Connect device and see Logs & Console
  5. Reset Device

Device keeps restarting.

Other information

It works in Moddable V4.1 and ESP-IDF v.4.2.3, so it seem to be affected by updating to ESP-IDF v5

phoddie commented 1 month ago

This might not be a bug.

You are using a debug build. On Moddable Two, that means that pins 1 and 3 are reserved for xsbug communication. Those pins are the default for a new serial connection, so the echo example is trying to use them. The Moddable SDK was updated some time ago to reserve the pins used by xsbug so that a project cannot interfere with the xsbug communication.

Please try using an instrumented build (-i instead of -d) or set the transmit and receive serial constructor options to unused pins.

phoddie commented 2 weeks ago

This issue has been idle for a bit. Is there an update?

stc1988 commented 2 weeks ago

I’m sorry for the delayed report. The situation is stuck, and using the instrumented build or setting transmit and receive did not resolve it. To add a bit of context, this issue stems from the recent problem of the stack-chan’s serial servo motor not working.

phoddie commented 2 weeks ago

I looked into this a bit more. I used Moddable Two, since that was listed in your report.

For a debug build, using the default pins throws an exception as expected. Changing them (I used 16 for transmit and 17 for receive) does not throw an exception (as expected).

For an instrumented build, no exception is thrown with the default pins. But... it does seem to hang - at least the serial port is not responding. Changing the port from 2 to 1 allows it to work with the default pins. I don't know why. Changing the transmit and receive as above, does work with port 2.

After some further experimentation, it seems that in IDF v5 port 2 is incompatible with the default pins (transmit 1 and receive 3).

stc1988 commented 2 weeks ago

Instrumented build + using port 1 is works as expected. Debug build also does not throw an exception but it seems that serial communication does not works.