42 #define MIN(x,y) ((x) < (y) ? (x) : (y))
51 uint32_t bytes_to_read =
MIN(
sizeof(buf), length);
56 CRC_CalcBlockCRC((uint32_t *)buf, bytes_to_read >> 2);
58 partition_offset += bytes_to_read;
59 length -= bytes_to_read;
82 return (actual_crc == xfer->
crc);
94 switch (xfer_start->
label) {
164 if (bytes_this_xfer == 0) {
198 bool partition_needs_erase =
true;
204 switch (xfer_start->
label) {
222 partition_needs_erase =
false;
249 if (bytes_to_xfer > max_bytes_in_xfer) {
254 if (partition_needs_erase) {
284 if (bytes_this_xfer == 0) {
290 for (uint8_t
i = 0;
i < bytes_this_xfer /
sizeof(uint32_t);
i++) {
291 uint32_t *
data = &((uint32_t *)xfer_cont->
data)[
i];
318 switch (wipe_partition->
label) {
343 uintptr_t partition_id;
360 uintptr_t fw_partition_id;
366 .v.cap_rep_specific = {
369 .bl_version = bdinfo->
bl_rev,
377 #if defined(BL_INCLUDE_CAP_EXTENSIONS)
381 uintptr_t partition_id;
382 uint32_t partition_size;
bool bl_xfer_completed_p(const struct xfer_state *xfer)
int32_t PIOS_FLASH_find_partition_id(enum pios_flash_partition_labels label, uintptr_t *partition_id)
int32_t PIOS_COM_MSG_Send(uintptr_t com_id, const uint8_t *msg, uint16_t msg_len)
uint8_t data[XFER_BYTES_PER_PACKET]
int32_t PIOS_FLASH_erase_partition(uintptr_t partition_id)
enum dfu_partition_label label
Main PiOS header to include all the compiled in PiOS options.
bool bl_xfer_read_start(struct xfer_state *xfer, const struct msg_xfer_start *xfer_start)
struct msg_wipe_partition wipe_partition
uint32_t original_partition_offset
int32_t PIOS_FLASH_get_partition_size(uintptr_t partition_id, uint32_t *partition_size)
bool bl_xfer_wipe_partition(const struct msg_wipe_partition *wipe_partition)
bool bl_xfer_send_next_read_packet(struct xfer_state *xfer)
static uint32_t bl_compute_partition_crc(uintptr_t partition_id, uint32_t partition_offset, uint32_t length)
bool bl_xfer_crc_ok_p(const struct xfer_state *xfer)
#define PIOS_COM_TELEM_USB
#define XFER_BYTES_PER_PACKET
const struct pios_board_info pios_board_info_blob
uint8_t data[XFER_BYTES_PER_PACKET]
bool bl_xfer_write_start(struct xfer_state *xfer, const struct msg_xfer_start *xfer_start)
int32_t PIOS_FLASH_write_data(uintptr_t partition_id, uint32_t offset, const uint8_t *data, uint16_t len)
struct bl_messages::@23::msg_capabilities_rep_specific cap_rep_specific
uint32_t current_partition_offset
int32_t PIOS_FLASH_end_transaction(uintptr_t partition_id)
bool bl_xfer_write_cont(struct xfer_state *xfer, const struct msg_xfer_cont *xfer_cont)
DFU_PARTITION_LOADABLE_EXTENSION
struct msg_xfer_start xfer_start
COM MSG layer functions header.
uint32_t current_packet_number
struct bl_messages::@23::msg_xfer_cont xfer_cont
enum dfu_partition_label label
uint8_t words_in_last_packet
struct msg_xfer_cont xfer_cont
pios_flash_partition_labels
int32_t PIOS_FLASH_read_data(uintptr_t partition_id, uint32_t offset, uint8_t *data, uint16_t len)
int32_t PIOS_FLASH_start_transaction(uintptr_t partition_id)
uint32_t next_packet_number
uint32_t packets_in_transfer
bool bl_xfer_send_capabilities_self(void)
#define BL_CAP_EXTENSION_MAGIC