Page 1 of 1

spi_flash in custom bootloader

Posted: Tue Jun 19, 2018 5:12 pm
by timredfern
I'm trying to customise the ESP32 bootloader in order to implement a rollback mechanism.

I'm a little confused as to how the bootloader build system works..

I see in components/bootloader/subproject/Makefile the list of COMPONENTS: :- includes bootloader_support, log, spi_flash etc.. and the functions in bootloader_support, log etc. are available in the bootloader.

However, I want to load the OTA data partition in order to read a flag in order to test a new OTA partition. When I try to use functions from the spi_flash component, I get linker errors:

......./components/bootloader/subproject/main/drop_ota_ops.c:32: undefined reference to `esp_partition_find_first'
......./components/bootloader/subproject/main/drop_ota_ops.c:36: undefined reference to `esp_partition_mmap'
......./components/bootloader/subproject/main/drop_ota_ops.c:42: undefined reference to `spi_flash_munmap'

I see the note in http://esp-idf.readthedocs.io/en/latest ... oader.html
"In the bootloader space, you can not use the drivers and functions from other components. If necessary, then the required functionality should be placed in the folder bootloader (note that this will increase its size)"

However, the functions from log, bootloader_support components etc. ARE being used in the bootloader.

How can I use the component spi_flash within the bootloader? Or, what's the best way to save some data to be used by the bootloader in determining which OTA partition to boot?

Re: spi_flash in custom bootloader

Posted: Tue Jun 19, 2018 6:57 pm
by WiFive

Re: spi_flash in custom bootloader

Posted: Wed Jun 20, 2018 8:26 am
by timredfern
Thanks!

Re: spi_flash in custom bootloader

Posted: Wed Jun 20, 2018 8:55 am
by timredfern
The headers for these functions are in include_priv rather than include - does anyone know the significance of this? I see the source code is included.

Re: spi_flash in custom bootloader

Posted: Tue Jul 03, 2018 1:59 am
by ESP_Angus
timredfern wrote:The headers for these functions are in include_priv rather than include - does anyone know the significance of this? I see the source code is included.
include_priv is included by the bootloader & bootloader_support components, but not from other components.

Originally the idea was that eventually all code calling include_priv functions would be part of bootloader_support. However, since then we decided to encourage users to customise the bootloader - so this will not happen. Probably a better name for this directory now is "include_bootloader".