MCPcopy Create free account
hub / github.com/OpenEPaperLink/OpenEPaperLink / writeFlash

Method writeFlash

ESP32_AP-Flasher/src/flasher.cpp:323–349  ·  view source on GitHub ↗

erase flash and program from flash buffer

Source from the content-addressed store, hash-verified

321
322// erase flash and program from flash buffer
323bool flasher::writeFlash(uint8_t *flashbuffer, uint16_t size) {
324 if (!zbs->select_flash(0)) return false;
325 zbs->erase_flash();
326 if (!zbs->select_flash(0)) return false;
327 Seriallog.printf("Starting flash, size=%d\r\n", size);
328 for (uint16_t c = 0; c < size; c++) {
329 if (flashbuffer[c] == 0xFF) goto flashWriteSuccess;
330 for (uint8_t i = 0; i < MAX_WRITE_ATTEMPTS; i++) {
331 zbs->write_flash(c, flashbuffer[c]);
332 if (zbs->read_flash(c) == flashbuffer[c]) {
333 goto flashWriteSuccess;
334 }
335 }
336 return false;
337 flashWriteSuccess:
338 if (c % 256 == 0) {
339#ifdef HAS_RGB_LED
340 shortBlink(CRGB::White);
341#else
342 quickBlink(2);
343#endif
344 Seriallog.printf("\rNow flashing, %d/%d ", c, size);
345 vTaskDelay(1 / portTICK_PERIOD_MS);
346 }
347 }
348 return true;
349}
350
351bool flasher::writeBlock256(uint16_t offset, uint8_t *flashbuffer) {
352 for (uint16_t c = 0; c < 256; c++) {

Callers

nothing calls this directly

Calls 7

printfMethod · 0.80
shortBlinkFunction · 0.70
quickBlinkFunction · 0.70
select_flashMethod · 0.45
erase_flashMethod · 0.45
write_flashMethod · 0.45
read_flashMethod · 0.45

Tested by

no test coverage detected