micropython icon indicating copy to clipboard operation
micropython copied to clipboard

Disabling REPL on ESP32

Open hetvishah08 opened this issue 7 years ago • 14 comments

Can we disable REPL on ESP32 for security purposes? I don't want the main.py to be accessed through REPL.

hetvishah08 avatar Jun 13 '19 13:06 hetvishah08

See this forum thread -- https://forum.micropython.org/viewtopic.php?t=6482 That's for ESP8266, but the ESP32 is much the same, have a look at mp_task() in ports/esp32/main.c

jimmo avatar Jun 13 '19 13:06 jimmo

uos.dupterm(None, 1) would be the way to do it but at this moment the esp32 port doesn't use dupterm to configure the REPL UART (it's hard coded). This would be good to fix, to make it like the esp8266.

dpgeorge avatar Jun 14 '19 03:06 dpgeorge

Thank you @jimmo and @dpgeorge I'll look into it.

hetvishah08 avatar Jun 17 '19 13:06 hetvishah08

@hetvishah08 hallo, Could u please tell me how to do it?I have the same need like yours.

leozlee avatar Jul 11 '19 12:07 leozlee

I also have this problem. Would it be enough to uncomment uart_init() in mp_task()? I really need serial communcation through USB.

Splitframe avatar Nov 29 '19 16:11 Splitframe

Is there any update on this?

89jd avatar Apr 13 '21 19:04 89jd

I think switched to an ESP8266 for this. I'd look into the micropython sources and check if dupterm is properly implemented now.

Splitframe avatar Apr 13 '21 19:04 Splitframe

Is there any update on this?

Sorry, this is still not implemented. But with the ESP32-S2 with USB support it should be done soon.

dpgeorge avatar Apr 14 '21 00:04 dpgeorge

i have it somewhat working here, but there are some unrelated changes, so i wont start a pull / merge. last time i checked it worked, but i'm not sure if i committed all my changes.

zeilenschubser avatar May 15 '21 16:05 zeilenschubser

Is there a way to do this now?

jonnor avatar Jul 27 '24 11:07 jonnor

Not for the plain ESP32. But since most (all?) newer ESP32 support USB, it may be less of a problem,

robert-hh avatar Jul 27 '24 14:07 robert-hh

@dpgeorge @robert-hh hoping for an assist if possible. As highlighted here, os.dupterm doesn't work in ESP32 (S3). I need to change the default pin assignement as a result during the build process. I've tried to update this in the sdkconfig.board during my MP build process, but nothing seems to change the boot behvaiour.

I've tried UART 0 and 1, but the board always boots to the default pins once flashing with the new build. I can succesfully kill the hardware console in config, but changing the pins don't seem to have any effect.

os.dupterm(uart) - routes output to the new target uart, but does not allow interactive REPL commands to come back.

Last attempt - sdkconfig in the build-ESP32-GENERIC-S3 dir. These settings where set in sdkconfig.base and I've also tried in sdkconfig.board

CONFIG_CONSOLE_UART_CUSTOM=y CONFIG_CONSOLE_UART=y CONFIG_CONSOLE_UART_CUSTOM_NUM_1=y CONFIG_CONSOLE_UART_NUM=1 CONFIG_CONSOLE_UART_TX_GPIO=42 CONFIG_CONSOLE_UART_RX_GPIO=41 CONFIG_CONSOLE_UART_BAUDRATE=115200

zzfjean avatar Jul 29 '24 14:07 zzfjean

CONFIG_CONSOLE_UART_NUM=1 CONFIG_CONSOLE_UART_TX_GPIO=42 CONFIG_CONSOLE_UART_RX_GPIO=41

I don't know if this is the problem but at least for recent ESP-IDF and MicroPython versions the prefix is CONFIG_ESP_CONSOLE not CONFIG_CONSOLE_

If you're not sure if custom config is being applied properly, take a look in the generated sdkconfig file in the build directory after building.

projectgus avatar Jul 30 '24 01:07 projectgus

I would like to reuse GPIO pins 18 and 19 on ESP32-C3 but looks like they're allocated for the USB/UART interface, any chance of making it possible to reconfigure it on the fly using Python code?

laurivosandi avatar Apr 08 '25 04:04 laurivosandi