Skip to content

Commit

Permalink
Update abs_block
Browse files Browse the repository at this point in the history
Add RP2 ignored extension to errata E10 abs_block, to make it more identifiable
  • Loading branch information
will-v-pi committed Nov 12, 2024
1 parent ae9a188 commit 78c9bd1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions elf2uf2/elf2uf2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ uf2_block gen_abs_block(uint32_t abs_block_loc) {
uf2_block block;
block.magic_start0 = UF2_MAGIC_START0;
block.magic_start1 = UF2_MAGIC_START1;
block.flags = UF2_FLAG_FAMILY_ID_PRESENT;
block.flags = UF2_FLAG_FAMILY_ID_PRESENT | UF2_FLAG_EXTENSION_FLAGS_PRESENT;
block.payload_size = UF2_PAGE_SIZE;
block.num_blocks = 2;
block.file_size = ABSOLUTE_FAMILY_ID;
Expand All @@ -138,19 +138,21 @@ uf2_block gen_abs_block(uint32_t abs_block_loc) {
block.block_no = 0;
memset(block.data, 0, sizeof(block.data));
memset(block.data, 0xef, UF2_PAGE_SIZE);
*(uint32_t*)&(block.data[UF2_PAGE_SIZE]) = UF2_EXTENSION_RP2_IGNORE_BLOCK;
return block;
}

bool check_abs_block(uf2_block block) {
return std::all_of(block.data, block.data + UF2_PAGE_SIZE, [](uint8_t i) { return i == 0xef; }) &&
block.magic_start0 == UF2_MAGIC_START0 &&
block.magic_start1 == UF2_MAGIC_START1 &&
block.flags == UF2_FLAG_FAMILY_ID_PRESENT &&
(block.flags & ~UF2_FLAG_EXTENSION_FLAGS_PRESENT) == UF2_FLAG_FAMILY_ID_PRESENT &&
block.payload_size == UF2_PAGE_SIZE &&
block.num_blocks == 2 &&
block.file_size == ABSOLUTE_FAMILY_ID &&
block.magic_end == UF2_MAGIC_END &&
block.block_no == 0;
block.block_no == 0 &&
!(block.flags & UF2_FLAG_EXTENSION_FLAGS_PRESENT && *(uint32_t*)&(block.data[UF2_PAGE_SIZE]) != UF2_EXTENSION_RP2_IGNORE_BLOCK);
}

int pages2uf2(std::map<uint32_t, std::vector<page_fragment>>& pages, std::shared_ptr<std::iostream> in, std::shared_ptr<std::iostream> out, uint32_t family_id, uint32_t abs_block_loc=0) {
Expand Down

0 comments on commit 78c9bd1

Please sign in to comment.