Midnight Sun Firmware
Loading...
Searching...
No Matches
bootloader.h
1#pragma once
2
3/************************************************************************************************
4 * @file bootloader.h
5 *
6 * @brief Header file for bootloader
7 *
8 * @date 2025-01-08
9 * @author Midnight Sun Team #24 - MSXVI
10 ************************************************************************************************/
11
12/* Standard library Headers */
13#include <stdint.h>
14
15/* Inter-component Headers */
16
17/* Intra-component Headers */
18#include "bootloader_can.h"
19#include "bootloader_error.h"
20
27extern uint32_t _application_start;
28extern uint32_t _application_size;
29extern uint32_t _bootloader_start;
30extern uint32_t _bootloader_size;
31extern uint32_t _sram_start;
32extern uint32_t _sram_size;
33
35#define APPLICATION_START_ADDRESS ((uint32_t)&_application_start)
36
38#define APPLICATION_SIZE ((size_t)&_application_size)
39
41#define BOOTLOADER_START_ADDRESS ((uint32_t)&_bootloader_start)
42
44#define BOOTLOADER_SIZE ((size_t)&_bootloader_size)
45
47#define SRAM_START_ADDRESS ((uint32_t)&_sram_start)
48
50#define SRAM_SIZE ((size_t)&_sram_size)
51
55typedef enum {
64
68typedef struct {
71 uint32_t bytes_written;
72 uint32_t data_size;
73 uint32_t packet_crc32;
75 uint16_t buffer_index;
79 uint16_t target_nodes;
82
88
95
102
BootloaderError bootloader_run(Boot_CanMessage *msg)
Run the bootloader.
Definition: bootloader.c:259
BootloaderStates
Bootloader State Machine.
Definition: bootloader.h:55
BootloaderError bootloader_init(void)
Initialize the bootloader.
Definition: bootloader.c:27
BootloaderError bootloader_jump_app(void)
Jump application.
Definition: bootloader.c:142
BootloaderError
Bootloader error definitions.
Definition: bootloader_error.h:28
@ BOOTLOADER_JUMP_APP
Definition: bootloader.h:61
@ BOOTLOADER_WAIT_SEQUENCING
Definition: bootloader.h:59
@ BOOTLOADER_DATA_RECEIVE
Definition: bootloader.h:60
@ BOOTLOADER_START
Definition: bootloader.h:58
@ BOOTLOADER_FAULT
Definition: bootloader.h:62
@ BOOTLOADER_UNINITIALIZED
Definition: bootloader.h:56
@ BOOTLOADER_IDLE
Definition: bootloader.h:57
CAN message structure.
Definition: bootloader_can.h:72
Private Bootloader State Storage.
Definition: bootloader.h:68
uint16_t buffer_index
Definition: bootloader.h:75
uintptr_t application_start
Definition: bootloader.h:69
uintptr_t current_write_address
Definition: bootloader.h:70
uint32_t bytes_written
Definition: bootloader.h:71
bool first_byte_received
Definition: bootloader.h:80
uint16_t target_nodes
Definition: bootloader.h:79
uint32_t packet_crc32
Definition: bootloader.h:73
BootloaderError error
Definition: bootloader.h:78
BootloaderStates state
Definition: bootloader.h:77
uint32_t data_size
Definition: bootloader.h:72
uint16_t expected_sequence_number
Definition: bootloader.h:74