feat(esp8266): Add config to choose console UART none

This commit is contained in:
Dong Heng
2018-12-18 15:07:48 +08:00
parent 01d32b73d4
commit e3dde84949
4 changed files with 36 additions and 4 deletions

View File

@ -568,7 +568,7 @@ static void update_flash_config(const esp_image_header_t* pfhdr);
static void uart_console_configure(void)
{
#if CONFIG_CONSOLE_UART_SWAP_IO
#if CONFIG_UART0_SWAP_IO
while (READ_PERI_REG(UART_STATUS(0)) & (UART_TXFIFO_CNT << UART_TXFIFO_CNT_S));
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, FUNC_UART0_CTS);
@ -595,7 +595,9 @@ static void uart_console_configure(void)
CLEAR_PERI_REG_MASK(UART_CONF0(CONFIG_CONSOLE_UART_NUM), UART_RXFIFO_RST | UART_TXFIFO_RST);
#endif
#ifdef CONFIG_CONSOLE_UART_BAUDRATE
uart_div_modify(CONFIG_CONSOLE_UART_NUM, BOOTLOADER_CONSOLE_CLK_FREQ / CONFIG_CONSOLE_UART_BAUDRATE);
#endif
}
esp_err_t bootloader_init()

View File

@ -81,8 +81,27 @@ config SOC_IRAM_SIZE
default 0x8000 if SOC_FULL_ICACHE
default 0xC000 if !SOC_FULL_ICACHE
choice CONSOLE_UART
prompt "UART for console output"
default CONSOLE_UART_DEFAULT
help
Select whether to use UART for console output (through stdout and stderr).
- Default is to use UART0.
- If "Custom" is selected, UART0 or UART1 can be chosen.
- If "None" is selected, there will be no console output on any UART.
config CONSOLE_UART_DEFAULT
bool "Default: UART0"
config CONSOLE_UART_CUSTOM
bool "Custom"
config CONSOLE_UART_NONE
bool "None"
endchoice
choice CONSOLE_UART_NUM
prompt "UART peripheral to use for console output (0-1)"
depends on CONSOLE_UART_CUSTOM
default CONSOLE_UART_CUSTOM_NUM_0
help
Configrate output console UART for "ets_printf", "printf", "ESP_LOGX" and so on.
@ -95,15 +114,17 @@ endchoice
config CONSOLE_UART_NUM
int
default 0 if CONSOLE_UART_DEFAULT || CONSOLE_UART_NONE
default 0 if CONSOLE_UART_CUSTOM_NUM_0
default 1 if CONSOLE_UART_CUSTOM_NUM_1
config CONSOLE_UART_BAUDRATE
int "UART console baud rate"
depends on CONSOLE_UART_DEFAULT || CONSOLE_UART_NONE
default 74880
range 1200 4000000
config CONSOLE_UART_SWAP_IO
config UART0_SWAP_IO
bool "Swap UART0 I/O pins"
default n
help

View File

@ -23,6 +23,7 @@
#include "esp8266/uart_register.h"
#include "esp8266/rom_functions.h"
#ifndef CONFIG_CONSOLE_UART_NONE
static void uart_putc(int c)
{
while (1) {
@ -34,8 +35,11 @@ static void uart_putc(int c)
WRITE_PERI_REG(UART_FIFO(CONFIG_CONSOLE_UART_NUM) , c);
}
#else
#define uart_putc(_c) { }
#endif
int ets_putc(int c)
int __attribute__ ((weak)) ets_putc(int c)
{
#ifdef CONFIG_NEWLIB_STDOUT_LINE_ENDING_CRLF
if (c == '\n')

View File

@ -69,6 +69,11 @@ esp_err_t esp_phy_rf_init(const esp_phy_init_data_t *init_data, esp_phy_calibrat
esp_err_t status = ESP_OK;
uint8_t sta_mac[6];
uint8_t *local_init_data = calloc(1, 256);
#ifdef CONFIG_CONSOLE_UART_BAUDRATE
const uint32_t uart_baudrate = CONFIG_CONSOLE_UART_BAUDRATE;
#else
const uint32_t uart_baudrate = 74880; // ROM default baudrate
#endif
memcpy(local_init_data, init_data->params, 128);
@ -84,7 +89,7 @@ esp_err_t esp_phy_rf_init(const esp_phy_init_data_t *init_data, esp_phy_calibrat
}
esp_efuse_mac_get_default(sta_mac);
chip_init(local_init_data, sta_mac, CONFIG_CONSOLE_UART_BAUDRATE);
chip_init(local_init_data, sta_mac, uart_baudrate);
get_data_from_rtc((uint8_t *)calibration_data);
memcpy(rx_gain_dc_table, calibration_data->rx_gain_dc_table, 4 * 125);