From d36034e554d6190a4745a145e25f7bb5cb13f1f0 Mon Sep 17 00:00:00 2001 From: Dong Heng Date: Wed, 11 Mar 2020 16:07:09 +0800 Subject: [PATCH] feat(bootloader): add option to disable JTAG I/O when boot --- components/bootloader/Kconfig.projbuild | 9 +++++++++ components/bootloader_support/src/bootloader_init.c | 11 +++++++++++ docs/en/general-notes/index.rst | 11 +++++++++++ 3 files changed, 31 insertions(+) diff --git a/components/bootloader/Kconfig.projbuild b/components/bootloader/Kconfig.projbuild index 9953b77b..51d060b1 100644 --- a/components/bootloader/Kconfig.projbuild +++ b/components/bootloader/Kconfig.projbuild @@ -10,6 +10,15 @@ config BOOTLOADER_INIT_SPI_FLASH If your system bootloader is based on v3.0, the option must not be enable, because the v3.0 bootloader don't support this function. +config BOOTLOADER_DISABLE_JTAG_IO + bool "Bootloader disable JTAG I/O" + default n + help + Enable this option, when SoC brings up and bootloader initializes hardware, it will + disable JTAG's I/O and set these GPIOs to be normal I/O with inputting mode. + + If users use JTAG to help develop, please disable this option. + choice LOG_BOOTLOADER_LEVEL bool "Bootloader log verbosity" default LOG_BOOTLOADER_LEVEL_INFO diff --git a/components/bootloader_support/src/bootloader_init.c b/components/bootloader_support/src/bootloader_init.c index 3035b10b..f10d75e6 100644 --- a/components/bootloader_support/src/bootloader_init.c +++ b/components/bootloader_support/src/bootloader_init.c @@ -613,6 +613,17 @@ esp_err_t bootloader_init() static esp_err_t bootloader_main() { +#ifdef CONFIG_BOOTLOADER_DISABLE_JTAG_IO + /* Set GPIO 12-15 to be normal GPIO */ + PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDI_U, FUNC_GPIO12); + PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, FUNC_GPIO13); + PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTMS_U, FUNC_GPIO14); + PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U, FUNC_GPIO15); + + /* Set GPIO 12-15 to be input mode */ + GPIO_REG_WRITE(GPIO_ENABLE_W1TC_ADDRESS, BIT12 | BIT13 | BIT14 | BIT15); +#endif + uart_console_configure(); esp_image_header_t fhdr; diff --git a/docs/en/general-notes/index.rst b/docs/en/general-notes/index.rst index 46cd69bf..77bbc5a8 100755 --- a/docs/en/general-notes/index.rst +++ b/docs/en/general-notes/index.rst @@ -24,3 +24,14 @@ We split the native OTA example into several sub-examples to let custemors to ch ^^^^^^^^^^^^^^^^^^ For better compatibility, the SDK is in bg mode by default. And application can set it to be bgn mode for reconnecting when it fails to connect some 11n only APs, refer to the `examples/wifi/simple_wifi `_. + +4. JTAG I/O +^^^^^^^^^^^ + +In some cases, if enable JTAG I/O (default options), it will cost some more current so that the hardware will cost more power. +So if users don't use Jtag or these GPIOs directly and want to save more power, please enable this option in the menuconfig: + +:: + + "Bootloader config ---> + [ ] Bootloader disable JTAG I/O"