|
@@ -421,14 +421,14 @@ struct image_header {
|
421
|
421
|
};
|
422
|
422
|
static_assert(sizeof(struct image_header) == FLASH_PAGE_SIZE, "image_header must be FLASH_PAGE_SIZE bytes");
|
423
|
423
|
|
424
|
|
-static bool image_header_ok(struct image_header *hdr)
|
|
424
|
+static bool image_header_ok(struct image_header *hdr, bool check_crc)
|
425
|
425
|
{
|
426
|
426
|
uint32_t *vtor = (uint32_t *)hdr->vtor;
|
427
|
427
|
|
428
|
428
|
uint32_t calc = calc_crc32((void *)hdr->vtor, hdr->size);
|
429
|
429
|
|
430
|
|
- // CRC has to match
|
431
|
|
- if (calc != hdr->crc) {
|
|
430
|
+ // CRC has to match after flashing
|
|
431
|
+ if (check_crc && (calc != hdr->crc)) {
|
432
|
432
|
return false;
|
433
|
433
|
}
|
434
|
434
|
|
|
@@ -465,7 +465,7 @@ static uint32_t handle_seal(uint32_t *args_in, uint8_t *data_in, uint32_t *resp_
|
465
|
465
|
return TCP_COMM_RSP_ERR;
|
466
|
466
|
}
|
467
|
467
|
|
468
|
|
- if (!image_header_ok(&hdr)) {
|
|
468
|
+ if (!image_header_ok(&hdr, true)) {
|
469
|
469
|
return TCP_COMM_RSP_ERR;
|
470
|
470
|
}
|
471
|
471
|
|
|
@@ -684,7 +684,7 @@ int main()
|
684
|
684
|
|
685
|
685
|
sleep_ms(10);
|
686
|
686
|
|
687
|
|
- if (!should_stay_in_bootloader() && image_header_ok(&app_image_header)) {
|
|
687
|
+ if (!should_stay_in_bootloader() && image_header_ok(&app_image_header, false)) {
|
688
|
688
|
uint32_t vtor = *(uint32_t *)IMAGE_HEADER_ADDR;
|
689
|
689
|
disable_interrupts();
|
690
|
690
|
reset_peripherals();
|