Disabling REPL on ESP32
Can we disable REPL on ESP32 for security purposes? I don't want the main.py to be accessed through REPL.
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
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.
Thank you @jimmo and @dpgeorge I'll look into it.
@hetvishah08 hallo, Could u please tell me how to do it?I have the same need like yours.
I also have this problem.
Would it be enough to uncomment uart_init() in mp_task()?
I really need serial communcation through USB.
Is there any update on this?
I think switched to an ESP8266 for this. I'd look into the micropython sources and check if dupterm is properly implemented now.
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.
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.
Is there a way to do this now?
Not for the plain ESP32. But since most (all?) newer ESP32 support USB, it may be less of a problem,
@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
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.
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?