@@ -68,4 +68,51 @@ This function is called by the bootloader at a very late stage, before chain-loa
6868in the next stage. This can be used to revert all the changes made to the clock settings, to ensure
6969that the state of the microcontroller is restored to its original settings.
7070
71+ ### Optional support for external flash memory
72+
73+ WolfBoot can be compiled with the makefile option ` EXT_FLASH=1 ` . When the external flash support is
74+ enabled, update and swap partitions can be associated to an external memory, and will use alternative
75+ HAL function for read/write/erase access.
76+ To associate the update or the swap partition to an external memory, define ` PART_UPDATE_EXT ` and/or
77+ ` PART_SWAP_EXT ` , respectively.
78+
79+ The following functions are used to access the external memory, and must be defined when ` EXT\_FLASH `
80+ is on:
81+
82+ ` int ext_flash_write(uint32_t address, const uint8_t *data, int len) `
83+
84+ This function provides an implementation of the flash write function, using the
85+ external memory's specific interface. ` address ` is the offset from the beginning of the
86+ addressable space in the device, ` data ` is the payload to be stored,
87+ and ` len ` is the size of the payload. ` ext_flash_write ` should return 0 upon success,
88+ or a negative value in case of failure.
89+
90+ ` int ext_flash_read(uint32_t address, uint8_t *data, int len) `
91+
92+ This function provides an indirect read of the external memory, using the
93+ driver's specific interface. ` address ` is the offset from the beginning of the
94+ addressable space in the device, ` data ` is a pointer where payload is stored upon a successful
95+ call, and ` len ` is the maximum size allowed for the payload. ` ext_flash_read ` should return 0
96+ upon success, or a negative value in case of failure.
97+
98+ ` int ext_flash_erase(uint32_t address, int len) `
99+
100+ Called by the bootloader to erase part of the external memory.
101+ Erase operations must be performed via the specific interface of the target driver (e.g. SPI flash).
102+ ` address ` marks the start of the area relative to the device, that the bootloader wants to erase,
103+ and ` len ` specifies the size of the area to be erased. This function must take into account the
104+ geometry of the sectors, and erase all the sectors in between.
105+
106+ ` void ext_flash_lock(void) `
107+
108+ If the interface of the external flash memory requires locking/unlocking, this function
109+ may be used to restore the flash write protection or exclude write accesses. This function is called
110+ by the bootloader at the end of every write and erase operations on the external device.
111+
112+
113+ ` void ext_flash_unlock(void) `
114+
115+ If the IAP interface of the external memory requires it, this function
116+ is called before every write and erase operations to unlock write access to the
117+ device. On some drivers, this function may be empty.
71118
0 commit comments