fix(bootloader): handle extra component dirs in v1 subproject

Closes https://github.com/espressif/esp-idf/issues/18651
This commit is contained in:
Konstantin Kondrashov
2026-07-16 10:37:12 +08:00
committed by BOT
parent 1918bb2b10
commit 5bc1dfc166
16 changed files with 141 additions and 16 deletions
@@ -5,9 +5,11 @@
(See the README.md file in the upper level for more information about bootloader examples.)
The purpose of this example is to show how to add a custom directory that contains a component to the bootloader build.
The purpose of this example is to show how to add bootloader components that are not placed in the conventional `bootloader_components` directory.
Registering extra components for the bootloader can be done thanks to the IDF property `BOOTLOADER_EXTRA_COMPONENT_DIRS`. It can either refer to a directory that contains several components, either refer to a single component.
The bootloader always uses the `bootloader_components` folder name as the project-local search path for bootloader components. Use this folder for bootloader-specific code that belongs to the project, such as hooks or overrides.
Use the `BOOTLOADER_EXTRA_COMPONENT_DIRS` property when bootloader components already live somewhere else, for example in a shared components directory or in a component reused by several projects. Each path can point either to a directory containing multiple components or directly to a single component. If the extra location contains components that are not needed in a particular bootloader build, list them by component name in `BOOTLOADER_IGNORE_EXTRA_COMPONENT`.
## Usage of this example:
@@ -33,9 +35,11 @@ User application is loaded and running.
## Organization of this example
This project contains a `main` directory that represents an application. It also has a `bootloader_components` directory that contains a component that will be compiled and linked with the bootloader. This `bootloader_components` can contain several components, each of them would be in a different directory.
This project contains a `main` directory that represents an application. It also has a `bootloader_components` directory with `my_boot_hooks`, a bootloader-specific hook component that belongs to this project.
The directory `extra_bootloader_components/extra_component/` contains a component that is meant to be included in the bootloader build. To do so, the CMake property `BOOTLOADER_EXTRA_COMPONENT_DIRS` is set from the `CMakeLists.txt` file.
The `extra_bootloader_components/` directory demonstrates an extra path that contains several components. `extra_component1` is required by `my_boot_hooks`, while `extra_component2` is included directly from `BOOTLOADER_EXTRA_COMPONENT_DIRS` without being required by another component. `extra_component3` is present in the same directory but is excluded from this bootloader build with `BOOTLOADER_IGNORE_EXTRA_COMPONENT`.
The `extra_component4/` and `extra_component5/` directories demonstrate extra paths that point directly to individual components. `extra_component4` is included directly, while `extra_component5` is excluded with `BOOTLOADER_IGNORE_EXTRA_COMPONENT`.
Below is a short explanation of files in the project folder.
@@ -49,8 +53,20 @@ Below is a short explanation of files in the project folder.
│   ├── CMakeLists.txt
│   └── hooks.c Implementation of the hooks to execute on boot
├── extra_bootloader_components
│   └── extra_component
│   ├── extra_component1
│   │   ├── CMakeLists.txt
│   │   └── extra_component1.c Implementation of the extra component
│   ├── extra_component2
│   │   ├── CMakeLists.txt
│   │   └── extra_component2.c Implementation of the 2nd extra component
│   └── extra_component3
│   ├── CMakeLists.txt
│   └── extra_component.c Implementation of the extra component
│   └── extra_component3.c Extra component excluded from this bootloader build
├── extra_component4
│   ├── CMakeLists.txt
│   └── extra_component4.c Extra component included directly
├── extra_component5
│   ├── CMakeLists.txt
│   └── extra_component5.c Extra component excluded directly
└── README.md This is the file you are currently reading
```