write info to infoblock
| 379 | |
| 380 | // write info to infoblock |
| 381 | bool flasher::writeInfoBlock() { |
| 382 | if (infoblock == nullptr) return false; |
| 383 | if (!zbs->select_flash(1)) return false; |
| 384 | zbs->erase_infoblock(); |
| 385 | if (!zbs->select_flash(1)) return false; |
| 386 | // select info page |
| 387 | |
| 388 | for (uint16_t c = 0; c < 1024; c++) { |
| 389 | if (infoblock[c] == 0xFF) goto ifBlockWriteSuccess; |
| 390 | for (uint8_t i = 0; i < MAX_WRITE_ATTEMPTS; i++) { |
| 391 | zbs->write_flash(c, infoblock[c]); |
| 392 | if (zbs->read_flash(c) == infoblock[c]) { |
| 393 | goto ifBlockWriteSuccess; |
| 394 | } |
| 395 | } |
| 396 | return false; |
| 397 | ifBlockWriteSuccess: |
| 398 | continue; |
| 399 | } |
| 400 | return true; |
| 401 | } |
| 402 | |
| 403 | bool flasher::prepareInfoBlock() { |
| 404 | if (infoblock == nullptr) return false; |
no test coverage detected