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
This commit is contained in:
Omar Chebib
2021-04-15 10:31:33 +08:00
parent 82a5f9c4b7
commit a79acb413e
27 changed files with 435 additions and 5 deletions

View File

@@ -16,6 +16,7 @@
#include "bootloader_init.h"
#include "bootloader_utility.h"
#include "bootloader_common.h"
#include "bootloader_hooks.h"
static const char *TAG = "boot";
@@ -29,11 +30,21 @@ static int selected_boot_partition(const bootloader_state_t *bs);
*/
void __attribute__((noreturn)) call_start_cpu0(void)
{
// (0. Call the before-init hook, if available)
if (bootloader_before_init) {
bootloader_before_init();
}
// 1. Hardware initialization
if (bootloader_init() != ESP_OK) {
bootloader_reset();
}
// (1.1 Call the after-init hook, if available)
if (bootloader_after_init) {
bootloader_after_init();
}
#ifdef CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP
// If this boot is a wake up from the deep sleep then go to the short way,
// try to load the application which worked before deep sleep.