|
#define | FOTA_MAX_DATAGRAM_SIZE (8U * 256U) |
| Maximum supported datagram size (2KB)
|
|
#define | FOTA_MAX_PACKETS_PER_DATAGRAM ((FOTA_MAX_DATAGRAM_SIZE / FOTA_PACKET_PAYLOAD_SIZE) + 1U) |
| Maximum number of packets that can make up a datagram (8 data + 1 Header)
|
|
#define | NUM_FLASH_PAGES 128U |
| 256KB of memory / 2KB per page
|
|
#define | FOTA_PAGE_BYTES ((uint32_t)0x800U) |
| 2KB per flash page as per datasheet
|
|
#define | FOTA_PING_BYTES ((uint32_t)0x1000U) |
| 4KB max per ping
|
|
#define | FOTA_FLASH_WORD_SIZE 4U |
| ARM32 Word size is 4 bytes.
|
|
#define | FOTA_ADDR_TO_PAGE(addr) (((uintptr_t)(addr) - (uintptr_t)APPLICATION_START_ADDRESS) / FOTA_PAGE_BYTES) |
| Convert memory address to page number. More...
|
|
#define | FOTA_PAGE_TO_ADDR(page) ((uintptr_t)(page) * (uintptr_t)FOTA_PAGE_BYTES + (uintptr_t)APPLICATION_START_ADDRESS) |
| Convert page number to memory address. More...
|
|
#define | LOG_FOTA_DEBUG(msg) printf("[FOTA DEBUG]: %s\n"); |
| Debug log.
|
|
#define | LOG_FOTA_WARNING(msg) printf("[FOTA WARNING]: %s\n"); |
| Warning log.
|
|
#define | LOG_FOTA_ERROR(msg) printf("[FOTA ERROR]: %s\n"); |
| Error log.
|
|
#define | FLASH_START_ADDRESS_LINKERSCRIPT ((uint32_t) & _flash_start) |
| Flash start address as defined in the linkerscripts.
|
|
#define | FLASH_SIZE_LINKERSCRIPT ((size_t) & _flash_size) |
| Flash size as defined in the linkerscripts.
|
|
#define | FLASH_PAGE_SIZE_LINKERSCRIPT ((size_t) & _flash_page_size) |
| Flash page size as defined in the linkerscripts.
|
|
#define | APPLICATION_START_ADDRESS ((uint32_t) & _application_start) |
| Application start address as defined in the linkerscripts.
|
|
#define | APPLICATION_SIZE ((size_t) & _application_size) |
| Application size as defined in the linkerscripts.
|
|
#define | BOOTLOADER_START_ADDRESS ((uint32_t) & _bootloader_start) |
| Bootloader start address as defined in the linkerscripts.
|
|
#define | BOOTLOADER_SIZE ((size_t) & _bootloader_size) |
| Bootloader size as defined in the linkerscripts.
|
|
#define | SRAM_START_ADDRESS ((uint32_t) & _sram_start) |
| SRAM start address as defined in the linkerscripts.
|
|
#define | SRAM_SIZE ((size_t) & _sram_size) |
| SRAM size as defined in the linkerscripts.
|
|
#define | FOTA_PACKET_PAYLOAD_SIZE 256U |
| FOTA packet payload size. More...
|
|
#define | FOTA_PACKET_SOF 0xAAU |
| FOTA packet start of frame.
|
|
#define | FOTA_PACKET_EOF 0xBBU |
| FOTA packet end of frame.
|
|
#define | FOTA_PACKET_MINIMUM_SIZE 14U |
| FOTA packet minimum size.
|
|
#define | FOTA_TIMEOUT_MS 15000U |
|
#define | UART_MAX_BUFFER_LEN 256U |
| Maximum size permitted for a UART transaction.
|
|
#define | UART_TIMEOUT_MS 1U |
| Maximum time permitted for a UART transaction.
|
|
#define | FOTA_UART_TIMEOUT_MS 10U |
| Maximum time permitted for a FOTA UART transaction.
|
|
#define | NETWORK_BUFFER_SIZE 1024U |
|
#define | FOTA_MAX_ACTIVE_DATAGRAMS 2U |
|
|
enum | FotaDatagramType {
FOTA_DATAGRAM_TYPE_FIRMWARE_METADATA
, FOTA_DATAGRAM_TYPE_FIRMWARE_CHUNK
, FOTA_DATAGRAM_TYPE_UPDATE_REQUEST
, FOTA_DATAGRAM_TYPE_UPDATE_RESPONSE
,
FOTA_DATAGRAM_TYPE_VERIFICATION
} |
| Datagram types corresponding to different FOTA operations. More...
|
|
enum | FotaError {
FOTA_ERROR_SUCCESS
, FOTA_ERROR_RESOURCE_EXHAUSTED
, FOTA_ERROR_INVALID_ARGS
, FOTA_ERROR_INTERNAL_ERROR
,
FOTA_ERROR_CRC32_MISMATCH
, FOTA_ERROR_CRC32_DATA_NOT_ALIGNED
, FOTA_ERROR_FLASH_WRITE_FAILED
, FOTA_ERROR_FLASH_WRITE_OUT_OF_BOUNDS
,
FOTA_ERROR_FLASH_WRITE_NOT_ALIGNED
, FOTA_ERROR_FLASH_READ_FAILED
, FOTA_ERROR_FLASH_ERASE
, FOTA_ERROR_FLASH_VERIFICATION_FAILED
,
FOTA_ERROR_INVALID_PACKET
, FOTA_ERROR_NO_MEMORY
, FOTA_ERROR_NO_DATAGRAM_FOUND
, FOTA_ERROR_JUMP_FAILED
} |
| FOTA Error code definitions. More...
|
|
enum | FotaJumpRequest { FOTA_JUMP_APPLICATION
, FOTA_JUMP_BOOTLOADER
, FOTA_JUMP_MIDSUN_BIOS
} |
|
enum | FotaPacketType {
FOTA_PACKET_TYPE_DATA
, FOTA_PACKET_TYPE_HEADER
, FOTA_PACKET_TYPE_ACK
, FOTA_PACKET_TYPE_NACK
,
FOTA_PACKET_TYPE_ERROR
} |
| FOTA Packet Type. More...
|
|
enum | UartPort {
UART_PORT_1 = 0
, UART_PORT_2
, NUM_UART_PORTS
, UART_PORT_1 = 0
,
UART_PORT_2
, NUM_UART_PORTS
} |
| UART Port selection.
|
|
enum | UartFlowControl {
UART_FLOW_CONTROL_NONE
, UART_FLOW_CONTROL_RTS
, UART_FLOW_CONTROL_CTS
, UART_FLOW_CONTROL_RTS_CTS
,
UART_FLOW_CONTROL_NONE
, UART_FLOW_CONTROL_RTS
, UART_FLOW_CONTROL_CTS
, UART_FLOW_CONTROL_RTS_CTS
} |
| UART Flow control selection. More...
|
|
enum | GpioPort {
GPIO_PORT_A = 0
, GPIO_PORT_B
, NUM_GPIO_PORTS
, GPIO_PORT_A = 0
,
GPIO_PORT_B
, GPIO_PORT_C
, GPIO_PORT_D
, GPIO_PORT_E
,
GPIO_PORT_H
, NUM_GPIO_PORTS
} |
| UART Settings. More...
|
|
enum | PacketReceiverState {
PKT_STATE_WAITING_SOF
, PKT_STATE_READING_HEADER
, PKT_STATE_READING_PAYLOAD
, PKT_STATE_READING_CRC
,
PKT_STATE_READING_EOF
} |
| State machine states for packet receiving. More...
|
|
|
FotaError | fota_init () |
|
void | fota_process (void) |
|
FotaError | fota_datagram_init (FotaDatagram *datagram, FotaDatagramType type, uint32_t datagram_id, uint8_t *data, uint32_t length) |
| Initialize a datagram structure. More...
|
|
FotaError | fota_datagram_to_packets (FotaDatagram *datagram, FotaPacket *packets, uint16_t *num_packets, uint16_t max_packets) |
| Fragment a datagram into packets for transmission. More...
|
|
FotaError | fota_datagram_process_data_packet (FotaDatagram *datagram, FotaPacket *packet) |
| Process a received packet and incorporate it into a datagram. More...
|
|
FotaError | fota_datagram_process_header_packet (FotaDatagram *datagram, FotaPacket *packet) |
| Process a received header packet and incorporate it into a datagram. More...
|
|
bool | fota_datagram_is_complete (FotaDatagram *datagram) |
| Check if a datagram has been completely received. More...
|
|
FotaError | fota_datagram_verify (FotaDatagram *datagram) |
| Verify the integrity of a complete datagram. More...
|
|
FotaError | fota_encryption_init () |
| Initialize the encryption unit. More...
|
|
uint32_t | fota_calculate_crc32 (uint8_t *data, uint32_t length_words) |
| Calculate the CRC32 for a given buffer of 4-byte aligned data. More...
|
|
FotaError | fota_verify_packet_encryption (FotaPacket *packet) |
| Verify a FOTA packets encryption. More...
|
|
FotaError | fota_verify_datagram_encryption (FotaDatagram *datagram) |
| Verify a FOTA datagrams encryption. More...
|
|
FotaError | fota_flash_write (uintptr_t address, uint8_t *buffer, uint32_t buffer_len) |
| Write to flash memory. More...
|
|
FotaError | fota_flash_erase (uint8_t start_page, uint8_t num_pages) |
| Erase some number of flash pages. More...
|
|
FotaError | fota_flash_read (uintptr_t address, uint8_t *buffer, uint32_t buffer_len) |
| Read from flash memory. More...
|
|
FotaError | fota_verify_flash_memory (void) |
| Verify that the flash memory is not erased. More...
|
|
FotaError | fota_jump (FotaJumpRequest jump_request) |
|
FotaError | fota_packet_init (FotaPacket *packet, FotaPacketType type, uint8_t sequence, uint16_t length) |
| Initialize a packet structure. More...
|
|
FotaError | fota_packet_set_crc (FotaPacket *packet) |
| Calculate and set the CRC for a packet. More...
|
|
FotaError | fota_packet_serialize (FotaPacket *packet, uint8_t *buffer, uint32_t buf_size, uint32_t *bytes_written) |
| Serialize packet into a buffer for transmission. More...
|
|
FotaError | fota_packet_deserialize (FotaPacket *packet, uint8_t *buffer, uint32_t buf_size) |
| Deserialize packet from received data. More...
|
|
bool | fota_is_timed_out (void) |
| Checks if FOTA has timed out, meaning no requests have been received. More...
|
|
FotaError | network_init (UartPort uart, UartSettings *settings, NetworkBuffer *network_buffer) |
| Initialize UART instance, assuming standard 8 bits 1 stop bit. More...
|
|
FotaError | network_read (UartPort uart, uint8_t *data, size_t len) |
| Read data from the network buffer. More...
|
|
FotaError | network_tx (UartPort uart, uint8_t *data, size_t len) |
| Transmit data from the UART port. More...
|
|
bool | isTimeout (bool is_tx) |
| Checks if tx or rx command has timed out. More...
|
|
FotaError | network_buffer_init (NetworkBuffer *network_buffer) |
| Initalizes circular buffer for use, by initalizing assocated structs. More...
|
|
uint16_t | network_buffer_num_items (NetworkBuffer *network_buffer) |
| Fetches the number of items in the network buffer. More...
|
|
uint16_t | network_buffer_num_empty_slots (NetworkBuffer *network_buffer) |
| Fetches the number of empty slots in the network buffer. More...
|
|
bool | network_buffer_empty (NetworkBuffer *network_buffer) |
| Checks if the network buffer is empty. More...
|
|
bool | network_buffer_full (NetworkBuffer *network_buffer) |
| Checks if the network buffer is full. More...
|
|
FotaError | network_buffer_write (NetworkBuffer *network_buffer, uint8_t *data) |
| Write data bytes. More...
|
|
FotaError | network_buffer_read (NetworkBuffer *network_buffer, uint8_t *data) |
| Read data bytes. More...
|
|
FotaError | packet_manager_init (PacketManager *manager, UartSettings *uart2_settings, void(*callback)(FotaDatagram *datagram)) |
| Initialize the packet manager. More...
|
|
FotaError | packet_manager_process (PacketManager *manager) |
| Process received data from the network buffer. More...
|
|
FotaError | packet_manager_send_datagram (PacketManager *manager, FotaDatagram *datagram, FotaError(*send_func)(int8_t *data, uint32_t length)) |
| Send a datagram by fragmenting it into packets. More...
|
|
FotaError | packet_manager_create_datagram (PacketManager *manager, FotaDatagramType type, uint8_t *data, uint32_t length, FotaDatagram *datagram) |
| Create a new datagram for sending. More...
|
|
FotaError | packet_manager_get_datagram (PacketManager *manager, uint32_t datagram_id, FotaDatagram **datagram) |
| Get a pointer to a completed datagram. More...
|
|
FotaError | packet_manager_free_datagram (PacketManager *manager, uint32_t datagram_id) |
| Free a datagram slot. More...
|
|
Firmware Over the Air (FOTA) Update system.