| 413 | } |
| 414 | |
| 415 | bool 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 | |
| 450 | bool flasher::writeFlashFromPack(String filename, uint8_t type) { |
| 451 | JsonDocument doc; |
no test coverage detected