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.h : Microsoft UF2 bootloader over USB MSC (Mass Storage Class)

Description

Microsoft UF2 bootloader over USB MSD (Mass Storage Device).

File(s):

References:

This module implements the Microsoft UF2 bootloader communication layer over USB MSD (Mass Storage Device). It emulates (fakes) a USB storage device with a FAT16 file system to provide info when reading files and writes a new app to FLASH if it is formatted using the UF2 tool.

Macros

#define PX_UF2_CFG_FLASH_START_ADR   0x00004000
 Start address of flash to write to (reserved space for bootloader) More...
 
#define PX_UF2_CFG_FLASH_SIZE   0x00020000
 Flash size. More...
 
#define PX_UF2_CFG_INFO_VERSION   "1.0.0 F"
 Info file version text. More...
 
#define PX_UF2_CFG_INFO_MODEL   "PX-HERO"
 Info file model text. More...
 
#define PX_UF2_CFG_INFO_BOARD_ID   "STM32L072RB"
 Info file board ID text. More...
 
#define PX_UF2_CFG_INDEX_URL   "https://piconomix.com/px-fwlib/index.html"
 index.htm file URL More...
 
#define PX_UF2_CFG_VOLUME_LABEL   "HERO-BOOT "
 FAT16 volume label. More...
 
#define PX_UF2_CFG_FAMILY_ID   0xe892273c
 Family ID. More...
 

Typedefs

typedef void(* px_uf2_on_wr_flash_block_t) (const uint8_t *data, uint32_t adr, size_t nr_of_bytes)
 Definition of a pointer to a function that will be called to write a block of data to flash. More...
 
typedef void(* px_uf2_on_wr_flash_done_t) (void)
 Definition of a pointer to a function that will be called when last block has been written. More...
 

Functions

void px_uf2_init (px_uf2_on_wr_flash_block_t on_wr_flash_block, px_uf2_on_wr_flash_done_t on_wr_flash_done)
 Initialise UF2 module. More...
 
void px_uf2_on_rd_sector (uint32_t sector_adr, uint8_t *buf)
 Function that must be called when a 512 byte sector is read over USB Mass Storage. More...
 
void px_uf2_on_wr_sector (uint32_t sector_adr, const uint8_t *buf)
 Function that must be called when a 512 byte sector is written over USB Mass Storage. More...
 

Macro Definition Documentation

◆ PX_UF2_CFG_FLASH_START_ADR

#define PX_UF2_CFG_FLASH_START_ADR   0x00004000

Start address of flash to write to (reserved space for bootloader)

Definition at line 33 of file px_uf2_cfg_template.h.

◆ PX_UF2_CFG_FLASH_SIZE

#define PX_UF2_CFG_FLASH_SIZE   0x00020000

Flash size.

Definition at line 36 of file px_uf2_cfg_template.h.

◆ PX_UF2_CFG_INFO_VERSION

#define PX_UF2_CFG_INFO_VERSION   "1.0.0 F"

Info file version text.

Definition at line 39 of file px_uf2_cfg_template.h.

◆ PX_UF2_CFG_INFO_MODEL

#define PX_UF2_CFG_INFO_MODEL   "PX-HERO"

Info file model text.

Definition at line 42 of file px_uf2_cfg_template.h.

◆ PX_UF2_CFG_INFO_BOARD_ID

#define PX_UF2_CFG_INFO_BOARD_ID   "STM32L072RB"

Info file board ID text.

Definition at line 45 of file px_uf2_cfg_template.h.

◆ PX_UF2_CFG_INDEX_URL

#define PX_UF2_CFG_INDEX_URL   "https://piconomix.com/px-fwlib/index.html"

index.htm file URL

Definition at line 48 of file px_uf2_cfg_template.h.

◆ PX_UF2_CFG_VOLUME_LABEL

#define PX_UF2_CFG_VOLUME_LABEL   "HERO-BOOT "

FAT16 volume label.

Definition at line 51 of file px_uf2_cfg_template.h.

◆ PX_UF2_CFG_FAMILY_ID

#define PX_UF2_CFG_FAMILY_ID   0xe892273c

Family ID.

Definition at line 54 of file px_uf2_cfg_template.h.

Typedef Documentation

◆ px_uf2_on_wr_flash_block_t

typedef void(* px_uf2_on_wr_flash_block_t) (const uint8_t *data, uint32_t adr, size_t nr_of_bytes)

Definition of a pointer to a function that will be called to write a block of data to flash.

Parameters
dataPointer to buffer containing data to write
adrStart address to write to
nr_of_bytesNumber of bytes to write

Definition at line 81 of file px_uf2.h.

◆ px_uf2_on_wr_flash_done_t

typedef void(* px_uf2_on_wr_flash_done_t) (void)

Definition of a pointer to a function that will be called when last block has been written.

Definition at line 89 of file px_uf2.h.

Function Documentation

◆ px_uf2_init()

void px_uf2_init ( px_uf2_on_wr_flash_block_t  on_wr_flash_block,
px_uf2_on_wr_flash_done_t  on_wr_flash_done 
)

Initialise UF2 module.

Parameters
on_wr_flash_blockPointer to function that will be called to write a block to FLASH.
on_wr_flash_donePointer to a function that will be called when the whole UF2 file has been written.

Definition at line 160 of file px_uf2.c.

◆ px_uf2_on_rd_sector()

void px_uf2_on_rd_sector ( uint32_t  sector_adr,
uint8_t *  buf 
)

Function that must be called when a 512 byte sector is read over USB Mass Storage.

Parameters
sector_adrSector address to read
bufPointer to buffer to copy sector data into

Definition at line 167 of file px_uf2.c.

◆ px_uf2_on_wr_sector()

void px_uf2_on_wr_sector ( uint32_t  sector_adr,
const uint8_t *  buf 
)

Function that must be called when a 512 byte sector is written over USB Mass Storage.

Parameters
sector_adrSector address to write to
bufPointer to buffer containing data to write

Definition at line 306 of file px_uf2.c.