flash_internal: probe_write only tests over advertized flash (works also with linker info)
This commit is contained in:
parent
60279d0a52
commit
5a028c23c4
|
@ -324,10 +324,11 @@ uint32_t flash_internal_probe_write_size(void)
|
|||
// prepare for writing the flash
|
||||
flash_unlock(); // unlock flash to be able to write it
|
||||
// try reading and writing the flash, page per page
|
||||
uint32_t address = FLASH_BASE + DESIG_FLASH_SIZE * 1024; // start with the end of the advertised flash
|
||||
if ((uint32_t)&__flash_end >= FLASH_BASE) {
|
||||
address = (uint32_t)&__flash_end;
|
||||
uint32_t start = FLASH_BASE + DESIG_FLASH_SIZE * 1024; // start with the end of the advertised flash
|
||||
if ((uint32_t)&__flash_end >= FLASH_BASE) { // use linker flash size if provided
|
||||
start = (uint32_t)&__flash_end;
|
||||
}
|
||||
uint32_t address = start; // address to test
|
||||
const uint16_t test_data = 0x2342; // the data we will write and read to test page
|
||||
while (address < 0x1FFFEFFF) { // this is where the system memory starts
|
||||
// try reading the flash
|
||||
|
@ -359,5 +360,5 @@ uint32_t flash_internal_probe_write_size(void)
|
|||
SCB_CCR &= ~SCB_CCR_BFHFNMIGN; // re-enable bus fault
|
||||
cm_enable_faults(); // re-enable faults
|
||||
|
||||
return address - FLASH_BASE;
|
||||
return address - start;
|
||||
}
|
||||
|
|
|
@ -44,13 +44,11 @@ bool flash_internal_eeprom_read(uint8_t *eeprom, uint16_t size);
|
|||
* @return number of bytes written (including preserved data), or negative in case of error
|
||||
*/
|
||||
int32_t flash_internal_eeprom_write(const uint8_t *eeprom, uint16_t size);
|
||||
/** probe the real size of the internal flash
|
||||
/** probe the readable size of the internal flash
|
||||
* @return tested size (in bytes)
|
||||
* @note it only test if the flash is readable (not writable)
|
||||
*/
|
||||
uint32_t flash_internal_probe_read_size(void);
|
||||
/** probe the real size of the internal flash
|
||||
/** probe the additional writable size of the internal flash, after the advertised size (and linker provided)
|
||||
* @return tested size (in bytes)
|
||||
* @warning it will write to the pages over the advertised size (it will not test the MCU advertised or linker provided size and assumes this is writable)
|
||||
*/
|
||||
uint32_t flash_internal_probe_write_size(void);
|
||||
|
|
Loading…
Reference in New Issue