spi_flash in custom bootloader

timredfern
Posts: 31
Joined: Sun Feb 25, 2018 10:59 am

spi_flash in custom bootloader

Postby timredfern » Tue Jun 19, 2018 5:12 pm

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?

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: spi_flash in custom bootloader

Postby WiFive » Tue Jun 19, 2018 6:57 pm


timredfern
Posts: 31
Joined: Sun Feb 25, 2018 10:59 am

Re: spi_flash in custom bootloader

Postby timredfern » Wed Jun 20, 2018 8:26 am

Thanks!

timredfern
Posts: 31
Joined: Sun Feb 25, 2018 10:59 am

Re: spi_flash in custom bootloader

Postby timredfern » Wed Jun 20, 2018 8:55 am

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.

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: spi_flash in custom bootloader

Postby ESP_Angus » Tue Jul 03, 2018 1:59 am

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".

Who is online

Users browsing this forum: No registered users and 123 guests