callback to write data to flash */
| 331 | callback to write data to flash |
| 332 | */ |
| 333 | bool Storage::_flash_write_data(uint8_t sector, uint32_t offset, const uint8_t *data, uint16_t length) |
| 334 | { |
| 335 | size_t base_address = sitl_flash_getpageaddr(sector); |
| 336 | bool ret = sitl_flash_write(base_address+offset, data, length); |
| 337 | if (!ret && _flash_erase_ok()) { |
| 338 | // we are getting flash write errors while disarmed. Try |
| 339 | // re-writing all of flash |
| 340 | uint32_t now = AP_HAL::millis(); |
| 341 | if (now - _last_re_init_ms > 5000) { |
| 342 | _last_re_init_ms = now; |
| 343 | bool ok = _flash.re_initialise(); |
| 344 | hal.console->printf("Storage: failed at %u:%u for %u - re-init %u\n", |
| 345 | (unsigned)sector, (unsigned)offset, (unsigned)length, (unsigned)ok); |
| 346 | } |
| 347 | } |
| 348 | return ret; |
| 349 | } |
| 350 | |
| 351 | /* |
| 352 | callback to read data from flash |
nothing calls this directly
no test coverage detected