README.md
1# Custom bootloader examples
2
3The following directory contains two examples presenting the different ways
4we provide in order to override the second stage bootloader or complete it
5with few hooks.
6
7## Extending the bootloader
8
9In both cases, a project can define custom bootloader components by creating
10them within a directory called `bootloader_components`.
11
12Naming one of them `main` would let the compiler entirely override the
132nd stage bootloader with the implementation provided.
14
15The bootloader components containing the hooks can have any name, as long
16as it is part of `bootloader_components`, it will be taken into account
17in the build.
18
19## Hooks vs overriding the bootloader
20
21In brief, using hooks will let the application add code to the bootloader.
22They cannot replace the code that is already executed within bootloader.
23
24Two hooks are available at the moment, the first one is called before the
25initialization, and the second one is performed after the bootloader
26initialization, before choosing and loading any partition. The
27signature for these hooks can be found in `bootloader_hooks.h` file in
28`components/bootloader/subproject/main/`.
29
30
31On the other hand, overriding the bootloader offers the possibility to
32totally or partially re-write it, in order to include, remove or modify
33parts of it. Thanks to this, it will be fully customizable.
34This shall only be used if heavy changes are required and they cannot
35be done with hooks or within an application.
36