36 Commits

Author SHA1 Message Date
Frantisek Hrbata 6416f75581 feat(bootloader): build bootloader using cmakev2
Add CMakeLists_v2.txt to the bootloader subproject, implementing the
bootloader build using the new cmakev2 IDF build framework.

The file covers the full bootloader build pipeline:
- Sets PROJECT_COMPONENTS_SOURCE to "idf_components" so that the
  subproject's built-in components (main/, components/) are treated as
  IDF components (priority 0) rather than project components (priority
  3).  This preserves the cmakev1 behaviour where user-supplied
  components in bootloader_components/ can override the built-in ones.
- Registers optional user-supplied bootloader components from the
  application project's bootloader_components/ directory, with support
  for selectively excluding individual components via
  IGNORE_EXTRA_COMPONENT.
- Bootstraps the cmakev2 framework (idf.cmake) and initialises the
  project with BOOTLOADER_BUILD and NON_OS_BUILD properties, which are
  also exposed as C preprocessor definitions.
- Sets GENERATE_SDKCONFIG to 0 to prevent the bootloader subproject
  from regenerating the main project's sdkconfig, as the bootloader
  has a different set of components and hence different Kconfig files.
- Sets the common implicit component dependencies shared by every
  bootloader component (log, esp_rom, esp_common, esp_hw_support,
  esp_libc, arch-specific component).
- Applies the compiler options specific for bootloader
- Selects the correct target-specific linker script, including a
  separate script for ESP32-P4 silicon revisions < v3.
- Links the bootloader ELF via idf_build_executable and then converts it
  to a flat binary via one of three paths depending on the secure boot
  configuration:
    * No secure boot: plain binary + size check + metadata.
    * Secure Boot V1 one-time-flash: plain binary with post-build
      instructions showing the esptool.py flash command.
    * Secure Boot V1 reflashable: derives the symmetric eFuse key from
      the ECDSA signing key, produces the reflash-digest image, and
      prints burn/flash instructions.
    * Secure Boot V2: produces an unsigned binary, optionally signs it
      with the configured signing key (RSA-PSS 3072, ECDSA P-256, or
      ECDSA P-384) via idf_sign_binary, and prints flash/multi-key
      signing instructions.
- Adds comprehensive inline documentation explaining each section's
  purpose, the rationale behind individual flags, and the relationships
  between Kconfig symbols and generated artefacts.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2026-03-27 19:18:11 +08:00
Frantisek Hrbata 413a0615bf fix(bootloader): remove CMAKE_CURRENT_LIST_DIR from bootloader_extra_component_dirs
`CMAKE_CURRENT_LIST_DIR` is actually `components/bootloader`, so it
doesn’t need to be passed via `EXTRA_COMPONENT_DIRS`: the build already
recognizes it as an esp-idf component.

In **cmakev1**, this is silently ignored: if a component with the same
name already exists, its directory is updated and the previous directory
is stored in the `COMPONENT_OVERRIDEN_DIR` component property.

In **cmakev2**, this is correctly detected and reported.

CMake Warning at /home/fhrbata/work/esp-idf/tools/cmakev2/utilities.cmake:63 (message):
   IDF: Component 'bootloader' directory '/home/fhrbata/work/esp-idf/components/bootloader'
   with higher priority 'project_extra_components' will be used instead of component directory
   '/home/fhrbata/work/esp-idf/components/bootloader' with lower priority 'idf_components'
Call Stack (most recent call first):
  /home/fhrbata/work/esp-idf/tools/cmakev2/component.cmake:625 (idf_warn)
  /home/fhrbata/work/esp-idf/tools/cmakev2/idf.cmake:411 (__init_component)
  /home/fhrbata/work/esp-idf/tools/cmakev2/project.cmake:580 (__init_components)
  CMakeLists_v2.txt:28 (idf_project_init)
  CMakeLists.txt:19 (include)

Since it doesn’t make sense to explicitly add the bootloader as an extra
component, remove it.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2026-03-27 19:18:11 +08:00
harshal.patil 130e72f82b feat(bootloader_support): Support Secure Boot using ECDSA-P384 curve 2025-07-21 09:19:42 +05:30
Laukik Hase 66f880fc1c feat(esp_tee): Support for ESP-TEE - bootloader component 2024-12-02 10:09:53 +05:30
Omar Chebib e33bcaa6d3 feat(bootloader): use idf property to specify extra components directories 2024-11-01 13:52:01 +08:00
Omar Chebib 775c65a6b7 feat(bootloader): add the possibility to specify extra components directories 2024-11-01 13:52:01 +08:00
Jan Beran a7141f75d7 fix: Fix condition checking if secure boot signing key exists 2024-08-09 08:38:38 +02:00
Jan Beran 981062d54f feat(tools): add often used espsecure subcommands to idf.py 2024-05-20 15:13:35 +02:00
Omar Chebib c98d1f1619 feat(bootloader): add the possibility to ignore extra components 2023-07-28 15:04:21 +08:00
Marius Vikhammer d17248ecdf build-system: replace ADDITIONAL_MAKE_CLEAN_FILES with ADDITIONAL_CLEAN_FILES
ADDITIONAL_MAKE_CLEAN_FILES is deprecated and only worked with make.
Replaced with the new ADDITIONAL_CLEAN_FILES (CMake 3.15) which also works with ninja.
2023-05-08 15:51:48 +08:00
Alexey Lapshin 29655fe22a tools: fixed elf symbols load if gdbinit specified
ROM and bootloader symbols add to use in GDB (via 'idf.py gdb')
2022-09-21 22:39:03 +04:00
Sachin Parekh 2c725264f7 esp32c2: Support Secure Boot V2 based on ECDSA scheme 2022-05-11 18:00:03 +05:30
morris 869bed1bb5 soc: don't expose unstable soc header files in public api 2022-01-06 23:10:22 +08:00
Omar Chebib a79acb413e bootloader: override the 2nd stage bootloader
Add the possibility to have user bootloader components. This is performed
from an application/project, by creating bootloader components. To do so,
it is required to create a `bootloader_component` directory containing
the custom modules to be compiled with the bootloader.

Thanks to this, two solutions are available to override the bootloader now:
- Using hooks within a user bootloader component
- Using a user defined `main` bootloader component to totally override the
  old implementation

Please check the two new examples in `examples/custom_bootloader`

* Closes https://github.com/espressif/esp-idf/issues/7043
2021-07-05 10:25:32 +08:00
Angus Gratton 6f6b4c3983 cmake partition_table: Check binaries fit in partition spaces at build time
- Bootloader is checked not to overlap partition table
- Apps are checked not to overlap any app partition regions

Supported for CMake build system only.

Closes https://github.com/espressif/esp-idf/pull/612
Closes https://github.com/espressif/esp-idf/issues/5043
Probable fix for https://github.com/espressif/esp-idf/issues/5456
2021-04-16 16:40:47 +10:00
morris b587428e5d bootloader: make bootloader offset address in flash configurable 2020-07-20 10:51:05 +08:00
Supreet Deshpande a9ccc5e5c8 feat/secure_boot_v2: Adding secure boot v2 support for ESP32-ECO3 2020-02-25 01:28:22 +05:30
Angus Gratton 6f761dd62d cmake: Fix some uninitialized variable warnings 2019-11-08 12:50:28 +08:00
Angus Gratton 4352265fa0 cmake: Fix case error passing extra CMake args to sub-projects
Bug in commit f4ea7c5a where the wrong variable case was used when passing
through to sub-projects
2019-11-08 11:56:13 +08:00
Angus Gratton f4ea7c5a46 cmake: Set uninitialized variable warnings in ULP & bootloader subprojects
Fixes issue where PYTHON was not being expanded when running ulp_mapgen.py,
causing Windows launch setting to be used - reported here:
https://esp32.com/viewtopic.php?f=13&t=12640&p=50283#p50283
2019-10-29 05:38:39 +00:00
Roland Dobai 5a916ce126 Support ELF files loadable with gdb 2019-09-24 07:19:50 +00:00
Angus Gratton e3e21b7954 build system: Pass Python executable through to bootloader build
Fixes failures if the PYTHON cache setting doesn't match the
default of "python" on the PATH.
2019-08-29 18:53:18 +10:00
Renz Christian Bagaporo 9edc867c62 bootloader: fix secure boot issues
Do not include bootloader in flash target when secure boot is enabled.
Emit signing warning on all cases where signed apps are enabled (secure
boot and signed images)
Follow convention of capital letters for SECURE_BOOT_SIGNING_KEY variable, since it is
relevant to other components, not just bootloader.
Pass signing key and verification key via config, not requiring
bootloader to know parent app dir.
Misc. variables name corrections
2019-06-28 10:54:21 +08:00
Renz Christian Bagaporo e1db12993b bootloader: pass legacy header config variable to subproject 2019-05-21 17:03:45 +08:00
Renz Christian Bagaporo 927007fdd2 cmake: fix custom bootloader issue
Issue is that when users creates a custom bootloader from
$IDF_PATH/components/bootloader. Parent project build uses the copy but
bootloader subproject build uses the original still. The issue is solved
by passing the custom bootloader as extra component directory so
bootloader build knows to use the new copy (itself) in the build.
2019-05-17 15:17:32 +08:00
Renz Christian Bagaporo ffec9d4947 components: update with build system changes 2019-05-13 19:59:17 +08:00
suda-morris 63e4677c55 pass IDF_TARGET variable to bootloader build process 2019-05-09 14:19:02 +08:00
Renz Christian Bagaporo 234de8de55 cmake: Allow components to present their own images to flash 2019-03-18 03:45:22 +08:00
Renz Christian Bagaporo 37d30c7a6e cmake: separate app from idf lib project
mbedtls: import mbedtls using unmodified cmake file
2018-11-27 13:59:24 +08:00
Renz Christian Bagaporo 3a02a12aa4 cmake: remove unecessary info passed to bootloader build 2018-11-23 16:08:47 +08:00
Anurag Kar 1f6622b2d1 CMake : Secure Boot support added 2018-11-06 17:09:55 +05:30
Renz Bagaporo cc774111bf cmake: Add support for test build 2018-10-20 12:07:24 +08:00
Angus Gratton bf10447b82 cmake: Fix issues when IDF_PATH is not set in environment
Support cases where IDF_PATH may be passed in on the cmake command line,
or inferred from a (hardcoded absolute or relative) path to project.cmake
2018-06-18 14:48:03 +10:00
Angus Gratton 88df8fd293 cmake: Use cmake_lint project, tidy up all CMake source files 2018-04-30 09:59:20 +10:00
Angus Gratton abef220b13 cmake: Allow selecting toolchain file based on config
Refactor IDF "project" functionality under a wrapping of the default
"project" command, so we can tweak it a bit...

Will need more testing in other environments.
2018-04-30 09:59:20 +10:00
Angus Gratton 3fac2b2ddc cmake: Refactor bootloader_subproject into the bootloader component itself 2018-04-30 09:59:20 +10:00