Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REPL on Espressif ESP32-S2 board appears on wrong USB port #8418

Closed
peterhinch opened this issue Mar 16, 2022 · 11 comments
Closed

REPL on Espressif ESP32-S2 board appears on wrong USB port #8418

peterhinch opened this issue Mar 16, 2022 · 11 comments

Comments

@peterhinch
Copy link
Contributor

I flashed the generic ESP32-S2 firmware to this Espressif board. The board uses a UART-USB bridge to provide USB connectivity. Component placements to provide the internal USB interface are not populated.

Flashing was successful. On reset, the board's USB port emits debug information but no REPL. In this forum thread user ash10 explained that the REPL appears on the built-in software USB port on GPIO19-20. It seems that the board could be used by connecting a USB breakout to those pins (waiting for hardware to try this). This seems clunky.

I had naively assumed that the Espressif board would be a reference board as per ESP32. Is support for this board planned?

@dpgeorge
Copy link
Member

Since the S2 has native USB it was assumed that generic S2 boards would provide USB hardware, and so the GENERIC_S2 board was defined in this way, to have USB enabled on the REPL.

I don't have one of those Espressif S2 dev boards (because they were very hard to buy when they came out) and instead I use a UM FeatherS2 for development, which does have native USB wired up.

But it does make sense to support the Espressif S2 boards, even if they don't use native USB. I can think of two options to do this:

  1. enable UART and USB on the GENERIC_S2 board
  2. have separate GENERIC_S2 and GENERIC_S2_USB board definitions

If it can be made to work, I'd rather option 1 because it's simpler.

@peterhinch, if possible could you please test the following patch on the S2 board you have:

--- a/ports/esp32/main.c
+++ b/ports/esp32/main.c
@@ -90,6 +90,7 @@ void mp_task(void *pvParameter) {
     #endif
     #if CONFIG_USB_ENABLED
     usb_init();
+    uart_stdout_init();
     #elif CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG
     usb_serial_jtag_init();
     #else

This should enable UART REPL as well as USB REPL.

@peterhinch
Copy link
Contributor Author

peterhinch commented Mar 17, 2022

@dpgeorge Unfortunately I've never succeeded in building ESP32 firmware. If you (or anyone else) could let me have a binary I'd be glad to try it.

@jej
Copy link

jej commented Mar 17, 2022

Here: https://drop.infini.fr/r/zbXnqgnd14#ggkoTB/ZZBl1Vkw4sLo5u9NqYyd8RrmxIRitNwMO/I4=
firmware.bin here: https://drop.infini.fr/r/ajjsQy37UW#EwX7IR6MjC/62fd4Zu90UV/KQwpP0r6xVmwh0AWOPKM=

idf.py -D MICROPY_BOARD=GENERIC_S2 -B build-GENERIC_S2  build
Executing action: all (aliases: build)
Running ninja in directory /usr/local/src/MicroPython/micropython/ports/esp32/build-GENERIC_S2
Executing "ninja all"...
[2/5] cd /usr/local/src/MicroPython/micropython/ports/esp32/build-G...icroPython/micropython/ports/esp32/build-GENERIC_S2/micropython.bin
micropython.bin binary size 0x11b6a0 bytes. Smallest app partition is 0x1f0000 bytes. 0xd4960 bytes (43%) free.
[3/5] Performing build step for 'bootloader'
[1/1] cd /usr/local/src/MicroPython/micropython/ports/esp32/build-GENERIC_S2/bootloader/esp-idf/esptool_py && /home/jej/.espressif/python_env/idf4.4_py3.9_env/bin/python /usr/local/src/MicroPython/esp-idf/components/partition_table/check_sizes.py --offset 0x8000 bootloader 0x1000 /usr/local/src/MicroPython/micropython/ports/esp32/build-GENERIC_S2/bootloader/bootloader.bin
Bootloader binary size 0x41f0 bytes. 0x2e10 bytes (41%) free.

Project build complete. To flash, run this command:
/home/jej/.espressif/python_env/idf4.4_py3.9_env/bin/python ../../../esp-idf/components/esptool_py/esptool/esptool.py -p (PORT) -b 460800 --before default_reset --after hard_reset --chip esp32s2  write_flash --flash_mode dio --flash_size detect --flash_freq 80m 0x1000 build-GENERIC_S2/bootloader/bootloader.bin 0x8000 build-GENERIC_S2/partition_table/partition-table.bin 0x10000 build-GENERIC_S2/micropython.bin
or run 'idf.py -p (PORT) flash'
bootloader  @0x001000    16880  (   11792 remaining)
partitions  @0x008000     3072  (    1024 remaining)
application @0x010000  1160864  (  870752 remaining)
total                  1226400

@peterhinch
Copy link
Contributor Author

Thank you. I'm not sure which image has the patch. I tried both with different (unsuccessful) outcomes. firmware.bin produced the same result as I get with official firmware (with no REPL):

--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ESP-ROM:esp32s2-rc4-20191025
Build:Oct 25 2019
rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3ffe6100,len:0xe70
load:0x4004c000,len:0x8ac
load:0x40050000,len:0x2a78
entry 0x4004c190

micropython.bin went into a loop:

--- Miniterm on /dev/ttyUSB0  115200,8,N,1 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ESP-ROM:esp32s2-rc4-20191025
Build:Oct 25 2019
rst:0x7 (TG0WDT_SYS_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x4000f254
SPIWP:0xee
mode:DIO, clock div:1
load:0x3f000020,len:0x2a92c
Panic at 4001126a
Fatal exception (3): LoadStoreError
epc1=0x4000ff4b, epc2=0x00000000, epc3=0x00000000, excvaddr=0x3f000020, depc=0x00000000
ESP-ROM:esp32s2-rc4-20191025
Build:Oct 25 2019
rst:0x10 (RTCWDT_RTC_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3f000020,len:0x2a92c
Panic at 4001126a

Please could you confirm that micropython.bin has the patch.

@jej
Copy link

jej commented Mar 17, 2022

In fact both .bin are patched according to #8418 (comment) suggestion. It's just that I did not know what .bin file from build dir was necessary (I always deploy with the command line).
Tell me if you need another file or compilation.

@jej
Copy link

jej commented Mar 17, 2022

Note: I just compiled with the main.c modification. I didn't modify anything in the board definition. I don't know if enable UART and USB on the GENERIC_S2 board should be done before compilation.
Here is a firmware.bin from a clean compilation. It looks the same but in case...
https://drop.infini.fr/r/F3ZWNwWT75#4KCjiOmG3H0VHT96ZELMJ2TWGK8RBFT3jj74lFlD80E=

@ruihua-code
Copy link

I also have the same problem, I hope to get help, thank you

It's not working.:
ampy -b 115200 -p /dev/cu.usbserial-1420 -d 1 put main.py

no REPL:
sudo picocom -b 115200 /dev/ttyUSB0:

system:mac OSX
board:ESP32-S3
firmware:https://micropython.org/download/GENERIC_S3/

dpgeorge added a commit to dpgeorge/micropython that referenced this issue Apr 13, 2022
Some S2/S3 modules don't use the native USB interface but instead have an
external USB-UART.  To make the GENERIC_S3/S3 firmware work on these boards
the UART REPL is enabled in addition to the native USB CDC REPL.

Fixes issues micropython#8418 and micropython#8524.

Signed-off-by: Damien George <damien@micropython.org>
dpgeorge added a commit to dpgeorge/micropython that referenced this issue Apr 14, 2022
Some S2/S3 modules don't use the native USB interface but instead have an
external USB-UART.  To make the GENERIC_S3/S3 firmware work on these boards
the UART REPL is enabled in addition to the native USB CDC REPL.

Fixes issues micropython#8418 and micropython#8524.

Signed-off-by: Damien George <damien@micropython.org>
@dpgeorge
Copy link
Member

Fixed by fe9eaf1

@peterhinch
Copy link
Contributor Author

Now working well!

@dpgeorge
Copy link
Member

Now working well!

Great! Thanks for confirming.

@matlawsky
Copy link

matlawsky commented Aug 26, 2022

Hello, I encountered similar problem on a ESP32 - S2 - WROVER, build v1.19.1 (2022-06-18). REPL is not showing up and I only get this:
ESP-ROM:esp32s2-rc4-20191025
Build:Oct 25 2019
rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3ffe6100,len:0xf5c
load:0x4004c000,len:0xaec
load:0x40050000,len:0x2be4
entry 0x4004c1b0

I'll try the generic build for now but if it's easy to fix maybe someone would be intrested in helping in that.

tannewt pushed a commit to tannewt/circuitpython that referenced this issue Sep 29, 2023
…_user_disconnect

Fix MDNS after the user turns off wifi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants