|
|
|
@ -267,7 +267,19 @@ void PX4Storage::_flash_write(uint16_t line)
@@ -267,7 +267,19 @@ void PX4Storage::_flash_write(uint16_t line)
|
|
|
|
|
bool PX4Storage::_flash_write_data(uint8_t sector, uint32_t offset, const uint8_t *data, uint16_t length) |
|
|
|
|
{ |
|
|
|
|
size_t base_address = up_progmem_getaddress(_flash_page+sector); |
|
|
|
|
return up_progmem_write(base_address+offset, data, length) == length; |
|
|
|
|
bool ret = up_progmem_write(base_address+offset, data, length) == length; |
|
|
|
|
if (!ret && _flash_erase_ok()) { |
|
|
|
|
// we are getting flash write errors while disarmed. Try
|
|
|
|
|
// re-writing all of flash
|
|
|
|
|
uint32_t now = AP_HAL::millis(); |
|
|
|
|
if (now - _last_re_init_ms > 5000) { |
|
|
|
|
_last_re_init_ms = now; |
|
|
|
|
bool ok = _flash.re_initialise(); |
|
|
|
|
printf("Storage: failed at %u:%u for %u - re-init %u\n", |
|
|
|
|
sector, offset, length, (unsigned)ok); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|