Commit 0dcdbab8 authored by Almir Okato's avatar Almir Okato Committed by Gustavo Henrique Nihei
Browse files

boot_serial: espressif: split serial adapter implementation for each chip



This commit also fixes array access on serial console read.

Signed-off-by: default avatarAlmir Okato <almir.okato@espressif.com>
parent 90be6e60
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -213,7 +213,6 @@ set(port_srcs
    ${CMAKE_CURRENT_LIST_DIR}/port/esp_mcuboot.c
    ${CMAKE_CURRENT_LIST_DIR}/port/esp_loader.c
    ${CMAKE_CURRENT_LIST_DIR}/os.c
    ${CMAKE_CURRENT_LIST_DIR}/serial_adapter.c
    )

if(CONFIG_ESP_MCUBOOT_SERIAL)
@@ -227,7 +226,7 @@ if(CONFIG_ESP_MCUBOOT_SERIAL)
        ${BOOT_SERIAL_DIR}/src/zcbor_common.c
        )
    list(APPEND port_srcs
        ${CMAKE_CURRENT_LIST_DIR}/serial_adapter.c
        ${CMAKE_CURRENT_LIST_DIR}/port/${MCUBOOT_TARGET}/serial_adapter.c
        ${MBEDTLS_DIR}/library/base64.c
        )
    list(APPEND CRYPTO_INC
@@ -247,6 +246,7 @@ target_include_directories(
    ${APP_EXECUTABLE}
    PUBLIC
    ${BOOTUTIL_DIR}/include
    ${BOOTUTIL_DIR}/src
    ${BOOT_SERIAL_DIR}/include
    ${CRYPTO_INC}
    ${CMAKE_CURRENT_LIST_DIR}/include
+1 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ list(APPEND include_dirs
    ${esp_idf_dir}/components/efuse/${MCUBOOT_TARGET}/include
    ${esp_idf_dir}/components/efuse/private_include
    ${esp_idf_dir}/components/efuse/${MCUBOOT_TARGET}/private_include
    ${esp_idf_dir}/components/esp_system/include
    ${esp_idf_dir}/components/newlib/platform_include
    )

+1 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ SECTIONS
    *libhal.a:bootloader_efuse_esp32.*(.literal .text .literal.* .text.*)
    *libhal.a:bootloader_utility.*(.literal .text .literal.* .text.*)
    *libhal.a:bootloader_sha.*(.literal .text .literal.* .text.*)
    *libhal.a:bootloader_console.*(.literal .text .literal.* .text.*)
    *libhal.a:bootloader_console_loader.*(.literal .text .literal.* .text.*)
    *libhal.a:bootloader_panic.*(.literal .text .literal.* .text.*)
    *libhal.a:bootloader_soc.*(.literal .text .literal.* .text.*)
+17 −9
Original line number Diff line number Diff line
@@ -11,9 +11,12 @@
#include <esp_rom_sys.h>
#include <soc/uart_periph.h>
#include <soc/gpio_struct.h>
#include <soc/io_mux_reg.h>
#include <soc/rtc.h>
#include <hal/gpio_types.h>
#include <hal/gpio_ll.h>
#include <hal/uart_ll.h>
#include <hal/clk_gate_ll.h>

#ifdef CONFIG_ESP_SERIAL_BOOT_GPIO_DETECT
#define SERIAL_BOOT_GPIO_DETECT     CONFIG_ESP_SERIAL_BOOT_GPIO_DETECT
@@ -88,6 +91,7 @@ int console_read(char *str, int cnt, int *newline)
                read_len++;
                if (read_len == cnt || str[read_len - 1] == '\n') {
                    stop = true;
                    break;
                }
            }
        }
@@ -122,6 +126,10 @@ int boot_console_init(void)
    uart_ll_set_stop_bits(serial_boot_uart_dev, 1u);
    uart_ll_set_parity(serial_boot_uart_dev, UART_PARITY_DISABLE);
    uart_ll_set_rx_tout(serial_boot_uart_dev, 16);
    uart_ll_set_data_bit_num(serial_boot_uart_dev, UART_DATA_8_BITS);
    uart_ll_set_tx_idle_num(serial_boot_uart_dev, 0);
    uart_ll_set_hw_flow_ctrl(serial_boot_uart_dev, UART_HW_FLOWCTRL_DISABLE, 100);
    periph_ll_enable_clk_clear_rst(PERIPH_UART0_MODULE + SERIAL_BOOT_UART_NUM);

    uart_ll_txfifo_rst(serial_boot_uart_dev);
    uart_ll_rxfifo_rst(serial_boot_uart_dev);