File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -224,7 +224,21 @@ void hal_prepare_boot(void)
224224
225225int RAMFUNCTION hal_flash_write (uint32_t address , const uint8_t * data , int len )
226226{
227- flash_range_program (address - XIP_BASE , data , len );
227+ uint8_t cache [WOLFBOOT_SECTOR_SIZE ];
228+ uint32_t written = 0 ;
229+ uint32_t sz ;
230+ if (((uintptr_t )data & 0x20000000UL ) == 0 ) {
231+ /* Not in RAM: copy to cache before writing */
232+ while (written < len ) {
233+ sz = WOLFBOOT_SECTOR_SIZE ;
234+ if (sz > (len - written ))
235+ sz = len - written ;
236+ memcpy (cache , data + written , sz );
237+ flash_range_program (address - XIP_BASE + written , cache , sz );
238+ written += sz ;
239+ }
240+ } else
241+ flash_range_program (address - XIP_BASE , data , len );
228242 return 0 ;
229243}
230244
You can’t perform that action at this time.
0 commit comments