px-fwlib 0.10.0
Cross-platform embedded library and documentation for 8/16/32-bit microcontrollers generated with Doxygen 1.9.2
px_uf2_defs.h
1#ifndef __PX_UF2_DEFS_H__
2#define __PX_UF2_DEFS_H__
3/* =============================================================================
4 ____ ___ ____ ___ _ _ ___ __ __ ___ __ __ TM
5 | _ \ |_ _| / ___| / _ \ | \ | | / _ \ | \/ | |_ _| \ \/ /
6 | |_) | | | | | | | | | | \| | | | | | | |\/| | | | \ /
7 | __/ | | | |___ | |_| | | |\ | | |_| | | | | | | | / \
8 |_| |___| \____| \___/ |_| \_| \___/ |_| |_| |___| /_/\_\
9
10 Copyright (c) 2019 Pieter Conradie <https://piconomix.com>
11
12 License: MIT
13 https://github.com/piconomix/px-fwlib/blob/master/LICENSE.md
14
15 Title: px_uf2_defs.h : PX_UF2 related definitions
16 Author(s): Pieter Conradie
17 Creation Date: 2019-05-25
18
19============================================================================= */
20
21/* _____STANDARD INCLUDES____________________________________________________ */
22
23/* _____PROJECT INCLUDES_____________________________________________________ */
24#include "px_defs.h"
25
26#ifdef __cplusplus
27extern "C"
28{
29#endif
30/* _____DEFINITIONS__________________________________________________________ */
31
32/* _____TYPE DEFINITIONS_____________________________________________________ */
33#define PX_UF2_MAGIC_START0 0x0a324655 // "PX_UF2\n"
34#define PX_UF2_MAGIC_START1 0x9e5d5157 // Randomly selected
35#define PX_UF2_MAGIC_END 0x0ab16f30 // Ditto
36
37// If set, the block is "comment" and should not be flashed to the device
38#define PX_UF2_FLAG_NOFLASH 0x00000001
39#define PX_UF2_FLAG_FAMILYID_PRESENT 0x00002000
40
41typedef struct
42{
43 // 32 byte header
44 uint32_t magic_start0;
45 uint32_t magic_start1;
46 uint32_t flags;
47 uint32_t target_addr;
48 uint32_t payload_size;
49 uint32_t block_nr;
50 uint32_t nr_of_blocks;
51 uint32_t family_id;
52
53 // raw data;
54 uint8_t data[476];
55
56 // store magic also at the end to limit damage from partial block reads
57 uint32_t magic_end;
58} PX_ATTR_PACKED px_uf2_block_t;
59
60typedef struct
61{
62 uint8_t jmp_boot[3]; // Jump instruction to boot code
63 uint8_t oem_name[8]; // OEM Name Identifier
64 uint16_t bytes_per_sector; // Count of bytes per secto
65 uint8_t sectors_per_cluster; // Number of sectors per allocation unit
66 uint16_t res_sector_count; // Number of sectors in the reserved region of the volume
67 uint8_t num_fats; // The count of file allocation tables (FATs) on the volume
68 uint16_t root_dir_entry_count; // The count of directory entries in the root directory
69 uint16_t total_sectors_16; // Old 16-bit total count of sectors on the volume
70 uint8_t media; // Specify media type (fixed, removable, ...)
71 uint16_t fat_sectors_16; // 16-bit count of sectors occupied by one FAT
72 uint16_t sectors_per_track; // Sector per track
73 uint16_t num_of_heads; // Number of heads
74 uint32_t hidden_sectors; // Count of hidden sectors preceding the partition that contains this FAT volume
75 uint32_t total_sectors_32; // new 32-bit count of sectors on the volume
76 uint8_t drive_num; // Drive number
77 uint8_t reserved;
78 uint8_t boot_sig; // Extended boot signature
79 uint32_t volume_id; // Volume serial number
80 uint8_t volume_label[11]; // Volume label
81 uint8_t file_system_type[8]; // "FAT12 ", "FAT16 " or "FAT "
82} PX_ATTR_PACKED px_uf2_fat_boot_block_t;
83
84typedef struct
85{
86 char name[8];
87 char ext[3];
88 uint8_t attrs;
89 uint8_t reserved;
90 uint8_t create_time_fine;
91 uint16_t create_time;
92 uint16_t create_date;
93 uint16_t last_access_date;
94 uint16_t high_start_cluster;
95 uint16_t update_time;
96 uint16_t update_date;
97 uint16_t start_cluster;
98 uint32_t size;
99} PX_ATTR_PACKED px_uf2_fat_dir_entry_t;
100
101#define PX_UF2_FAT_DIR_ATTR_READ_ONLY 0x01
102#define PX_UF2_FAT_DIR_ATTR_HIDDEN 0x02
103#define PX_UF2_FAT_DIR_ATTR_SYSTEM 0x04
104#define PX_UF2_FAT_DIR_ATTR_VOLUME_ID 0x08
105#define PX_UF2_FAT_DIR_ATTR_DIRECTORY 0x10
106#define PX_UF2_FAT_DIR_ATTR_ARCHIVE 0x20
107
108typedef struct
109{
110 const char name[11];
111 const char * content;
113
114/* _____GLOBAL VARIABLES_____________________________________________________ */
115
116/* _____GLOBAL FUNCTION DECLARATIONS_________________________________________ */
117
118/* _____MACROS_______________________________________________________________ */
119
120#ifdef __cplusplus
121}
122#endif
123
124#endif
Definition: px_uf2_defs.h:85