|
PER Firmware
|
#include "bootloader/bootloader.h"#include <string.h>#include "can_library/generated/can_version.h"#include "bootloader/bootloader_common.h"#include "phal_G4/crc/crc.h"#include "phal_G4/fdcan/fdcan.h"#include "phal_G4/flash/flash.h"#include "phal_G4/gpio/gpio.h"#include "phal_G4/rcc/rcc.h"#include "node_defs.h"Macros | |
| #define | BL_RX_QUEUE_LENGTH 16U |
| #define | BL_RAM_START 0x20000000U |
| #define | BL_RAM_END 0x2001FFFFU |
Enumerations | |
| enum | BLState_t { BL_STATE_STARTUP , BL_STATE_READY , BL_STATE_UPDATING , BL_STATE_CHECKING , BL_STATE_RECOVERY } |
Functions | |
| static bool | bl_size_is_valid (uint32_t size_bytes) |
| static bool | bl_range_is_valid (uint32_t address, uint32_t size_bytes) |
| static uint32_t | bl_message_id (const CanMsgTypeDef_t *message) |
| static bool | bl_message_is_bootloader_traffic (const CanMsgTypeDef_t *message) |
| static void | bl_send_status (bootloader_status_t status, uint32_t detail) |
| static void | bl_send_info (void) |
| static bool | bl_flush_pending_word (void) |
| static bool | bl_write_word (uint32_t index, uint32_t word) |
| static uint32_t | bl_physical_size (uint32_t size_bytes) |
| static bool | bl_invalidate_metadata (void) |
| static bool | bl_begin_update (uint32_t size_bytes) |
| static bool | bl_write_metadata (uint32_t crc32, uint32_t size_bytes) |
| static bool | bl_application_crc_is_valid (uint32_t address, uint32_t size_bytes, uint32_t expected_crc) |
| static bool | bl_vector_is_valid (uint32_t app_address, uint32_t size_bytes) |
| static bool | bl_commit_update (uint32_t expected_crc) |
| bool | BL_checkAndBoot (void) |
| Validate the committed image and transfer control to it. | |
| static uint32_t | bl_uint32_data (const CanMsgTypeDef_t *message) |
| static void | bl_process_message (const CanMsgTypeDef_t *message) |
| void | SysTick_Handler (void) |
| static void | bl_process_queued_messages (void) |
| void | BL_poll (void) |
| Process every frame currently queued by the FDCAN receive interrupt. | |
| static void | bl_enable_irq (FDCAN_GlobalTypeDef *peripheral) |
| void | BL_init (void) |
| Configure the node-specific transport and announce readiness. | |
| void | PHAL_FDCAN_rxCallback (CanMsgTypeDef_t *message) |
| Weak callback fired once per received frame. | |
Variables | |
| static volatile CanMsgTypeDef_t | bl_rx_queue [BL_RX_QUEUE_LENGTH] |
| static volatile uint8_t | bl_rx_head |
| static volatile uint8_t | bl_rx_tail |
| static BLState_t | current_state = BL_STATE_STARTUP |
| static BLState_t | next_state = BL_STATE_STARTUP |
| static bool | bl_boot_status_requested |
| static bool | bl_update_active |
| static volatile uint32_t | bl_millis |
| static uint32_t | bl_startup_start_ms |
| static uint32_t | bl_last_info_ms |
| static bool | bl_info_sent |
| static uint32_t | bl_firmware_size |
| static uint32_t | bl_total_words |
| static uint32_t | bl_next_word |
| static uint32_t | bl_pending_word |
| static bool | bl_pending_word_valid |
| #define BL_RAM_END 0x2001FFFFU |
| #define BL_RAM_START 0x20000000U |
| #define BL_RX_QUEUE_LENGTH 16U |
| enum BLState_t |
|
static |
|
static |
| bool BL_checkAndBoot | ( | void | ) |
Validate the committed image and transfer control to it.
Metadata, vector-table values, and application CRC are checked before VTOR and MSP are changed.
|
static |
|
static |
|
static |
| void BL_init | ( | void | ) |
Configure the node-specific transport and announce readiness.
The system clock must be configured before this function is called.
|
static |
|
static |
|
static |
|
static |
| void BL_poll | ( | void | ) |
Process every frame currently queued by the FDCAN receive interrupt.
Call repeatedly from main context. This function is the sole queue consumer and owns all flash and CRC work; the receive ISR only copies matching frames into the bounded software queue.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
| void PHAL_FDCAN_rxCallback | ( | CanMsgTypeDef_t * | msg | ) |
Weak callback fired once per received frame.
Called from FDCANx_IT0_IRQHandler (interrupt context) for every frame popped from RX FIFO0.
Default implementation does nothing.
| msg | the received frame (valid only for the duration of the call) |
| void SysTick_Handler | ( | void | ) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |