Midnight Sun Firmware
Loading...
Searching...
No Matches
bootloader_flash.h
1#pragma once
2
3/************************************************************************************************
4 * @file bootloader_can_flash.h
5 *
6 * @brief Header file for the flash API in the bootloader
7 *
8 * @date 2025-01-08
9 * @author Midnight Sun Team #24 - MSXVI
10 ************************************************************************************************/
11
12/* Standard library Headers */
13#include <stddef.h>
14#include <stdint.h>
15
16/* Inter-component Headers */
17
18/* Intra-component Headers */
19#include "bootloader.h"
20#include "bootloader_error.h"
21
29#define NUM_FLASH_PAGES 128U
30
32#define BOOTLOADER_PAGE_BYTES ((size_t)0x800)
33
35#define BOOTLOADER_FLASH_WORD_SIZE 4U
36
42#define BOOTLOADER_ADDR_TO_PAGE(addr) (((uintptr_t)(addr) - (uintptr_t)APPLICATION_START_ADDRESS) / BOOTLOADER_PAGE_BYTES)
43
49#define BOOTLOADER_PAGE_TO_ADDR(page) ((uintptr_t)(page) * (uintptr_t)BOOTLOADER_PAGE_BYTES + (uintptr_t)APPLICATION_START_ADDRESS)
50
60BootloaderError boot_flash_write(uintptr_t address, uint8_t *buffer, size_t buffer_len);
61
69BootloaderError boot_flash_erase(uint8_t start_page, uint8_t num_pages);
70
79BootloaderError boot_flash_read(uintptr_t address, uint8_t *buffer, size_t buffer_len);
80
88
BootloaderError boot_flash_read(uintptr_t address, uint8_t *buffer, size_t buffer_len)
Read from flash memory.
Definition: bootloader_flash.c:25
BootloaderError boot_flash_erase(uint8_t start_page, uint8_t num_pages)
Erase some number of flash pages.
Definition: bootloader_flash.c:21
BootloaderError boot_verify_flash_memory(void)
Verify that the flash memory is not erased.
Definition: bootloader_flash.c:29
BootloaderError boot_flash_write(uintptr_t address, uint8_t *buffer, size_t buffer_len)
Write to flash memory.
Definition: bootloader_flash.c:17
BootloaderError
Bootloader error definitions.
Definition: bootloader_error.h:28