Files
bootloader/include/bootloader.h
T
rovinaandClaude Opus 4.6 d2b8bd7940 Initial commit: STM32 Bootloader extension module
Add a production-ready, educational bootloader extension for STM32 MCUs.

Core features:
- Custom binary protocol with CRC16/CRC32 verification
- AES-256 encryption for firmware security
- Dual-bank firmware management with rollback support
- Version management and firmware validation
- Modular architecture with BSP abstraction layer

Project structure:
- include/: Header files (bootloader.h, bsp_flash.h, bsp_uart.h)
- src/: Core implementation (bootloader, protocol, crypto, firmware manager)
- port/: MCU-specific adaptation layer (STM32F4xx)
- docs/: Documentation (integration guide, porting guide)

Supported platforms:
- STM32F4xx (primary)
- STM32F1xx (via porting)

Quick start:
1. Copy extension module to project
2. Configure bootloader_config.h
3. Modify linker script for APP_BASE_ADDR
4. Build and flash bootloader to 0x08000000

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-02 15:03:51 +08:00

54 lines
1.1 KiB
C

#ifndef BOOTLOADER_H
#define BOOTLOADER_H
#include <stdint.h>
#include <stdbool.h>
#include "bootloader_config.h"
typedef enum {
BOOT_STATE_IDLE = 0,
BOOT_STATE_HANDSHAKE,
BOOT_STATE_RECEIVING,
BOOT_STATE_VERIFYING,
BOOT_STATE_WRITING,
BOOT_STATE_UPDATING,
BOOT_STATE_JUMP_APP,
BOOT_STATE_ERROR,
} bootloader_state_t;
typedef enum {
BOOT_OK = 0,
BOOT_ERR_FLASH_WRITE,
BOOT_ERR_FLASH_VERIFY,
BOOT_ERR_UART_TIMEOUT,
BOOT_ERR_CRC_MISMATCH,
BOOT_ERR_AES_DECRYPT,
BOOT_ERR_PROTOCOL,
BOOT_ERR_APP_INVALID,
} bootloader_error_t;
void bootloader_init(void);
void bootloader_process(void);
bool bootloader_check_entry(void);
bootloader_state_t bootloader_get_state(void);
bootloader_error_t bootloader_get_error(void);
void bootloader_jump_to_app(uint32_t app_addr);
bool bootloader_check_app_valid(uint32_t app_addr);
typedef struct {
uint32_t magic;
uint32_t version;
uint32_t checksum;
uint32_t bank_id;
uint32_t timestamp;
uint32_t size;
} firmware_version_t;
firmware_version_t *bootloader_get_version(void);
#endif