summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ports/esp32/boards/ESP32_GENERIC_C2/board_init.c35
-rw-r--r--ports/esp32/boards/ESP32_GENERIC_C2/mpconfigboard.cmake5
-rw-r--r--ports/esp32/boards/ESP32_GENERIC_C2/mpconfigboard.h3
-rw-r--r--ports/esp32/boards/sdkconfig.c26
4 files changed, 49 insertions, 0 deletions
diff --git a/ports/esp32/boards/ESP32_GENERIC_C2/board_init.c b/ports/esp32/boards/ESP32_GENERIC_C2/board_init.c
new file mode 100644
index 000000000..355fe2bf0
--- /dev/null
+++ b/ports/esp32/boards/ESP32_GENERIC_C2/board_init.c
@@ -0,0 +1,35 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2025 Angus Gratton
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#include "py/mpconfig.h"
+
+void GENERIC_C2_board_startup(void) {
+ // With a 26MHz crystal the ESP32-C2 ROM prints output at 74880 which is
+ // interpreted mostly as noise, then boot.py output and/or the REPL banner
+ // prints at the end of a line of noise unless we inject a newline here
+ printf("\n");
+
+ boardctrl_startup();
+}
diff --git a/ports/esp32/boards/ESP32_GENERIC_C2/mpconfigboard.cmake b/ports/esp32/boards/ESP32_GENERIC_C2/mpconfigboard.cmake
index d935c22b8..7a8b0e0b3 100644
--- a/ports/esp32/boards/ESP32_GENERIC_C2/mpconfigboard.cmake
+++ b/ports/esp32/boards/ESP32_GENERIC_C2/mpconfigboard.cmake
@@ -7,3 +7,8 @@ set(SDKCONFIG_DEFAULTS
# C2 has unusably low free RAM without these optimisations
boards/sdkconfig.free_ram
)
+
+set(MICROPY_SOURCE_BOARD
+ ${MICROPY_BOARD_DIR}/board_init.c
+)
+
diff --git a/ports/esp32/boards/ESP32_GENERIC_C2/mpconfigboard.h b/ports/esp32/boards/ESP32_GENERIC_C2/mpconfigboard.h
index ee918aaba..999465373 100644
--- a/ports/esp32/boards/ESP32_GENERIC_C2/mpconfigboard.h
+++ b/ports/esp32/boards/ESP32_GENERIC_C2/mpconfigboard.h
@@ -5,3 +5,6 @@
#define MICROPY_HW_ENABLE_SDCARD (0)
#define MICROPY_PY_MACHINE_I2S (0)
+
+#define MICROPY_BOARD_STARTUP GENERIC_C2_board_startup
+void GENERIC_C2_board_startup(void);
diff --git a/ports/esp32/boards/sdkconfig.c2 b/ports/esp32/boards/sdkconfig.c2
index e85bcdba3..194d815b6 100644
--- a/ports/esp32/boards/sdkconfig.c2
+++ b/ports/esp32/boards/sdkconfig.c2
@@ -4,6 +4,12 @@
CONFIG_XTAL_FREQ_26=y
# CONFIG_XTAL_FREQ_40 is not set
CONFIG_XTAL_FREQ=26
+
+# When using 26MHz crystal the baud rate defaults to 74880,
+# same as ESP8266 - MicroPython uses 115200, so switch early
+CONFIG_ESP_CONSOLE_UART_CUSTOM=y
+CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200
+
# Increase NimBLE stack size for functional BT
CONFIG_BT_NIMBLE_TASK_STACK_SIZE=5120