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

Method writeFlashFromPackOffset

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

Source from the content-addressed store, hash-verified

413}
414
415bool flasher::writeFlashFromPackOffset(fs::File *file, uint16_t length) {
416 if (!zbs->select_flash(0)) return false;
417 zbs->erase_flash();
418 if (!zbs->select_flash(0)) return false;
419 Seriallog.printf("Starting flash, size=%d\r\n", length);
420
421 uint8_t *buf = (uint8_t *)malloc(256);
422 uint16_t offset = 0;
423 while (length) {
424 if (length > 256) {
425 file->read(buf, 256);
426 length -= 256;
427 } else {
428 file->read(buf, length);
429 length = 0;
430 }
431#ifdef HAS_RGB_LED
432 shortBlink(CRGB::White);
433#else
434 quickBlink(2);
435#endif
436 Seriallog.printf("\r[Flashing %d bytes] ", length);
437
438 bool res = writeBlock256(offset, buf);
439 offset += 256;
440 if (!res) {
441 Seriallog.printf("Failed writing block to tag, probably a hardware failure\r\n");
442 return false;
443 }
444 vTaskDelay(1 / portTICK_PERIOD_MS);
445 }
446 Seriallog.printf("\r\nFlashing done\r\n");
447 return true;
448}
449
450bool flasher::writeFlashFromPack(String filename, uint8_t type) {
451 JsonDocument doc;

Callers 1

doForcedAPFlashFunction · 0.45

Calls 6

printfMethod · 0.80
shortBlinkFunction · 0.70
quickBlinkFunction · 0.70
select_flashMethod · 0.45
erase_flashMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected