Page 1 of 1

How to implement custom bootloader

Posted: Tue Jul 28, 2020 3:57 pm
by ukrsms
I'd like to override the original bootloader to extend its functions.
Guided by the description from https://docs.espressif.com/projects/esp ... oader.html I copied the folder /esp-idf/components/bootloader to /my_project/components/bootloader.
The page said one should edit the file called bootloader_main.c, however, there is the only file named bootloader_start.c in the directory (it looks like a mistake in the description).
Nevertheless, when trying to build my project I got the following:

Code: Select all

Executing "ninja all"...
[1/98] Performing configure step for 'bootloader'
FAILED: bootloader-prefix/src/bootloader-stamp/bootloader-configure
cmd.exe /C "cd /D C:\firmware\esp32\test\build\bootloader && C:\Users\PC\.espressif\tools\cmake\3.13.4\bin\cmake.exe -DSDKCONFIG=C:/firmware/esp32/test/sdkconfig -DIDF_PATH=C:/esp-idf -DIDF_TARGET=esp32 -DPYTHON_DEPS_CHECKED=1 -DPYTHON=C:\Users\PC\.espressif\python_env\idf4.1_py3.7_env\Scripts\python.exe -DEXTRA_COMPONENT_DIRS=C:/firmware/esp32/components/bootloader -DLEGACY_INCLUDE_COMMON_HEADERS= -GNinja C:/firmware/esp32/components/bootloader/subproject && C:\Users\PC\.espressif\tools\cmake\3.13.4\bin\cmake.exe -E touch C:/firmware/esp32/test/build/bootloader-prefix/src/bootloader-stamp/bootloader-configure"
CMake Error: The source "C:/firmware/esp32/components/bootloader/subproject/CMakeLists.txt" does not match the source "C:/esp-idf/components/bootloader/subproject/CMakeLists.txt" used to generate cache.  Re-run cmake with a different source directory.
[2/98] Building CXX object esp-idf/battery/CMakeFiles/__idf_battery.dir/battery.cpp.obj
I do not know how to manage this issue. I even tried to remove the original bootloader directory from esp-idf folder but the same error occurred even after clean and reconfigure command.

Does someone have experience in building the custom bootloader?

Re: How to implement custom bootloader

Posted: Wed Jul 29, 2020 8:43 am
by ESP_Angus
Hi ukrsms,

Sorry for the hassle, this is a limitation in CMake trying to track the state of the build. "idf.py fullclean" (which deletes the entire build directory including CMake metadata), followed by a build, should fix it.

Will add this to the documentation, and also update the source file name to match the current code.

Angus

Re: How to implement custom bootloader

Posted: Thu Jul 30, 2020 10:12 am
by ukrsms
Thank you, it really helped to solve the issue!