Midnight Sun Firmware
Loading...
Searching...
No Matches
fota_flash.h
1#pragma once
2
3/************************************************************************************************
4 * @file fota_flash.h
5 *
6 * @brief Fota Flash Header File
7 *
8 * @date 2025-04-30
9 * @author Midnight Sun Team #24 - MSXVI
10 ************************************************************************************************/
11
12/* Standard library Headers */
13#include <stdbool.h>
14#include <stddef.h>
15#include <stdint.h>
16
17/* Inter-component Headers */
18
19/* Intra-component Headers */
20#include "fota_error.h"
21
29#define NUM_FLASH_PAGES 128U
30
32#define FOTA_PAGE_BYTES ((uint32_t)0x800U)
33
35#define FOTA_PING_BYTES ((uint32_t)0x1000U)
36
42#define FOTA_ADDR_TO_PAGE(addr) (((uintptr_t)(addr) - (uintptr_t)APP_ACTIVE_START_ADDRESS) / FOTA_PAGE_BYTES)
43
49#define FOTA_PAGE_TO_ADDR(page) ((uintptr_t)(page) * (uintptr_t)FOTA_PAGE_BYTES + (uintptr_t)APP_ACTIVE_START_ADDRESS)
50
61FotaError fota_flash_write(uint32_t address, uint8_t *buffer, size_t buffer_len);
62
70FotaError fota_flash_erase(uint32_t start_page, uint8_t num_pages);
71
80FotaError fota_flash_read(uint32_t address, uint8_t *buffer, size_t buffer_len);
81
90FotaError fota_verify_flash_memory(uintptr_t start_addr, size_t size_bytes);
91
FotaError fota_flash_read(uint32_t address, uint8_t *buffer, size_t buffer_len)
Read from flash memory.
Definition: fota_flash.c:87
FotaError fota_flash_write(uint32_t address, uint8_t *buffer, size_t buffer_len)
Write to flash memory.
Definition: fota_flash.c:40
FotaError
FOTA Error code definitions.
Definition: fota_error.h:27
FotaError fota_flash_erase(uint32_t start_page, uint8_t num_pages)
Erase some number of flash pages.
Definition: fota_flash.c:65
FotaError fota_verify_flash_memory(uintptr_t start_addr, size_t size_bytes)
Verify that the flash memory is not erased.
Definition: fota_flash.c:100