1 /* 2 * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef _BOOT_UF2_H 8 #define _BOOT_UF2_H 9 10 #include <stdint.h> 11 #include <assert.h> 12 13 /** \file uf2.h 14 * \defgroup boot_uf2 boot_uf2 15 * 16 * Header file for the UF2 format supported by an RP2040 in BOOTSEL mode. 17 */ 18 19 #define UF2_MAGIC_START0 0x0A324655u 20 #define UF2_MAGIC_START1 0x9E5D5157u 21 #define UF2_MAGIC_END 0x0AB16F30u 22 23 #define UF2_FLAG_NOT_MAIN_FLASH 0x00000001u 24 #define UF2_FLAG_FILE_CONTAINER 0x00001000u 25 #define UF2_FLAG_FAMILY_ID_PRESENT 0x00002000u 26 #define UF2_FLAG_MD5_PRESENT 0x00004000u 27 28 #define RP2040_FAMILY_ID 0xe48bff56 29 30 struct uf2_block { 31 // 32 byte header 32 uint32_t magic_start0; 33 uint32_t magic_start1; 34 uint32_t flags; 35 uint32_t target_addr; 36 uint32_t payload_size; 37 uint32_t block_no; 38 uint32_t num_blocks; 39 uint32_t file_size; // or familyID; 40 uint8_t data[476]; 41 uint32_t magic_end; 42 }; 43 44 static_assert(sizeof(struct uf2_block) == 512, "uf2_block not sector sized"); 45 46 #endif 47