ESP32 bootloader hooks

Hello, I’m trying to add some code to be executed when entering the 2nd stage bootloader. I’m following the idea presented in this example from esp-idf github.

PlatformIO normally does some magic with components directory but since there is no #include to perform from my application, the folder is not compiled at all, thanks to platformIO’s optimization to avoid compiling unneeded source files.

So I added the folder explicitly to my root’s CMakeLists.txt by adding this line:

list(APPEND EXTRA_COMPONENT_DIRS bootloader_components)

Now, I see the hooks.c file getting compiled and I can see my custom bootloader component in my output .pio/build folder.

But the resulting library does not get linked to my final bootloader.elf (bootloder.bin)

How should I implement bootloader hooks through platformio for an esp-idf based project?