├── boot_hooks ├── CMakeLists.txt └── boot_hooks.c └── README.md /boot_hooks/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if("$ENV{IDF_TARGET}" STREQUAL "esp32s3") 2 | idf_component_register(SRCS "boot_hooks.c") 3 | endif() 4 | 5 | # We need to force GCC to integrate this static library into the 6 | # bootloader link. Indeed, by default, as the hooks in the bootloader are weak, 7 | # the linker would just ignore the symbols in the extra. (i.e. not strictly 8 | # required) 9 | # To do so, we need to define the symbol (function) `bootloader_hooks_include` 10 | # within hooks.c source file. 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # bootloader_components 2 | 3 | bootloader hooks to avoid papers3 power issues 4 | 5 | **Please clone this repository into your IDF project, at the same level as components.** 6 | 7 | ## For example 8 | 9 | ```bash 10 | . 11 | ├── bootloader_components # <===== Here 12 | ├── components 13 | ├── main 14 | ├── managed_components 15 | ├── CMakeLists.txt 16 | ├── sdkconfig 17 | ├── sdkconfig.old 18 | └── version.txt 19 | ``` 20 | 21 | ## How to use 22 | 23 | ```bash 24 | cd /path/to/your/project 25 | git clone https://github.com/m5stack/bootloader_components.git 26 | ``` 27 | -------------------------------------------------------------------------------- /boot_hooks/boot_hooks.c: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #include "esp_log.h" 7 | #include "soc/rtc_cntl_struct.h" 8 | #include "soc/usb_serial_jtag_reg.h" 9 | 10 | /* Function used to tell the linker to include this file 11 | * with all its symbols. 12 | */ 13 | void bootloader_hooks_include(void) 14 | { 15 | } 16 | 17 | void bootloader_before_init(void) 18 | { 19 | // Disable D+ pullup, to prevent the USB host from retrieving USB-Serial-JTAG's descriptor. 20 | SET_PERI_REG_MASK(USB_SERIAL_JTAG_CONF0_REG, USB_SERIAL_JTAG_PAD_PULL_OVERRIDE); 21 | CLEAR_PERI_REG_MASK(USB_SERIAL_JTAG_CONF0_REG, USB_SERIAL_JTAG_DP_PULLUP); 22 | CLEAR_PERI_REG_MASK(USB_SERIAL_JTAG_CONF0_REG, USB_SERIAL_JTAG_USB_PAD_ENABLE); 23 | } 24 | --------------------------------------------------------------------------------