Skip to content

Commit d673ce8

Browse files
committed
bootloader_flash: add custom version
BOOTLOADER_BUILD definition is present in source code to define whether flash access (read/write/erase) are done using ROM apis or not. In esp-idf, where 2nd stage bootloader does not run on top of FreeRTOS, all flash access are performed over ROM calls. In Zephyr, there are 2 possible scenarios for code initialization: Using Simple Boot or MCUBoot. MCUBoot is a Zephyr application that requires flash APIs (not ROM) to be available for all operations. Simple Boot bootloader is part of the application and requires flash access using ROM API, otherwise it can't read data properly. Instead of using BOOTLOADER_BUILD as a definition to allow both bootloaders to be used, we can create a custom bootloader_flash.c file and append "_rom" for flash calls used in Simple Boot. Signed-off-by: Sylvio Alves <[email protected]>
1 parent eed68e1 commit d673ce8

File tree

2 files changed

+833
-0
lines changed

2 files changed

+833
-0
lines changed

components/bootloader_support/bootloader_flash/include/bootloader_flash_priv.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ uint32_t bootloader_mmap_get_free_pages(void);
8989
*/
9090
const void *bootloader_mmap(uint32_t src_addr, uint32_t size);
9191

92+
/* use ROM functions to mmap */
93+
const void *bootloader_mmap_rom(uint32_t src_addr, uint32_t size);
9294

9395
/**
9496
* @brief Unmap a previously mapped region of flash
@@ -97,6 +99,9 @@ const void *bootloader_mmap(uint32_t src_addr, uint32_t size);
9799
*/
98100
void bootloader_munmap(const void *mapping);
99101

102+
/* use ROM functions to unmmap */
103+
void bootloader_munmap_rom(const void *mapping);
104+
100105
/**
101106
* @brief Read data from Flash.
102107
*
@@ -114,6 +119,8 @@ void bootloader_munmap(const void *mapping);
114119
*/
115120
esp_err_t bootloader_flash_read(size_t src_addr, void *dest, size_t size, bool allow_decrypt);
116121

122+
/* use ROM functions to flash read */
123+
esp_err_t bootloader_flash_read_rom(size_t src_addr, void *dest, size_t size, bool allow_decrypt);
117124

118125
/**
119126
* @brief Write data to Flash.
@@ -132,6 +139,9 @@ esp_err_t bootloader_flash_read(size_t src_addr, void *dest, size_t size, bool a
132139
*/
133140
esp_err_t bootloader_flash_write(size_t dest_addr, void *src, size_t size, bool write_encrypted);
134141

142+
/* use ROM functions to flash write */
143+
esp_err_t bootloader_flash_write_rom(size_t dest_addr, void *src, size_t size, bool write_encrypted);
144+
135145
/**
136146
* @brief Erase the Flash sector.
137147
*
@@ -141,6 +151,9 @@ esp_err_t bootloader_flash_write(size_t dest_addr, void *src, size_t size, bool
141151
*/
142152
esp_err_t bootloader_flash_erase_sector(size_t sector);
143153

154+
/* use ROM functions to flash erase */
155+
esp_err_t bootloader_flash_erase_sector_rom(size_t sector);
156+
144157
/**
145158
* @brief Erase the Flash range.
146159
*
@@ -151,6 +164,9 @@ esp_err_t bootloader_flash_erase_sector(size_t sector);
151164
*/
152165
esp_err_t bootloader_flash_erase_range(uint32_t start_addr, uint32_t size);
153166

167+
/* use ROM functions to flash range read */
168+
esp_err_t bootloader_flash_erase_range_rom(uint32_t start_addr, uint32_t size);
169+
154170
/**
155171
* @brief Execute a user command on the flash
156172
*

0 commit comments

Comments
 (0)