esp32: Fix first line ESP32-C2 serial output after reset or deepsleep.
ESP32-C2 ROM prints at 74880bps (same as ESP8266), so need a newline before first MicroPython output to avoid it being appended on end of a line of noise. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
This commit is contained in:
parent
77c9eb7795
commit
d4399b3230
4 changed files with 49 additions and 0 deletions
35
ports/esp32/boards/ESP32_GENERIC_C2/board_init.c
Normal file
35
ports/esp32/boards/ESP32_GENERIC_C2/board_init.c
Normal file
|
|
@ -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();
|
||||
}
|
||||
|
|
@ -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
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue