OTA API refactoring: renamed files and defines

This commit is contained in:
robert committed 2023-09-26 08:33:39 -04:00
1 parent 822b0c011a
commit fa54a22aed
13 files changed
+536 -536

No files matched your search

+7 -7
View File
@@ -5,13 +5,13 @@
#include "arch.h"
#define MG_SYS_NONE 0 // Dummy system
#define MG_SYS_STM32H5 1 // STM32 H5
#define MG_SYS_STM32H7 2 // STM32 H7
#define MG_SYS_CUSTOM 100 // Custom implementation
#define MG_DEVICE_NONE 0 // Dummy system
#define MG_DEVICE_STM32H5 1 // STM32 H5
#define MG_DEVICE_STM32H7 2 // STM32 H7
#define MG_DEVICE_CUSTOM 100 // Custom implementation
#ifndef MG_SYS
#define MG_SYS MG_SYS_NONE
#ifndef MG_DEVICE
#define MG_DEVICE MG_DEVICE_NONE
#endif
// Flash information
@@ -31,4 +31,4 @@ bool mg_flash_swap_bank(void);
bool mg_flash_load(void *sector, uint32_t key, void *buf, size_t len);
bool mg_flash_save(void *sector, uint32_t key, const void *buf, size_t len);
void mg_sys_reset(void); // Reboot device immediately
void mg_device_reset(void); // Reboot device immediately
+3 -3
View File
@@ -1,6 +1,6 @@
#include "sys.h"
#include "device.h"
#if MG_SYS == MG_SYS_NONE
#if MG_DEVICE == MG_DEVICE_NONE
void *mg_flash_start(void) {
return NULL;
}
@@ -27,6 +27,6 @@ bool mg_flash_write(void *addr, const void *buf, size_t len) {
(void) addr, (void) buf, (void) len;
return false;
}
void mg_sys_reset(void) {
void mg_device_reset(void) {
}
#endif
+2 -2
View File
@@ -1,6 +1,6 @@
#include "sys.h"
#include "device.h"
#if MG_SYS == MG_SYS_STM32H7 || MG_SYS == MG_SYS_STM32H5
#if MG_DEVICE == MG_DEVICE_STM32H7 || MG_DEVICE == MG_DEVICE_STM32H5
// Flash can be written only if it is erased. Erased flash is 0xff (all bits 1)
// Writes must be mg_flash_write_align() - aligned. Thus if we want to save an
// object, we pad it at the end for alignment.
+3 -3
View File
@@ -1,7 +1,7 @@
#include "log.h"
#include "sys.h"
#include "device.h"
#if MG_SYS == MG_SYS_STM32H5
#if MG_DEVICE == MG_DEVICE_STM32H5
#define FLASH_BASE 0x40022000 // Base address of the flash controller
#define FLASH_KEYR (FLASH_BASE + 0x4) // See RM0481 7.11
@@ -135,7 +135,7 @@ bool mg_flash_write(void *addr, const void *buf, size_t len) {
return ok;
}
void mg_sys_reset(void) {
void mg_device_reset(void) {
// SCB->AIRCR = ((0x5fa << SCB_AIRCR_VECTKEY_Pos)|SCB_AIRCR_SYSRESETREQ_Msk);
*(volatile unsigned long *) 0xe000ed0c = 0x5fa0004;
}
+3 -3
View File
@@ -1,7 +1,7 @@
#include "log.h"
#include "sys.h"
#include "device.h"
#if MG_SYS == MG_SYS_STM32H7
#if MG_DEVICE == MG_DEVICE_STM32H7
#define FLASH_BASE1 0x52002000 // Base address for bank1
#define FLASH_BASE2 0x52002100 // Base address for bank2
@@ -141,7 +141,7 @@ bool mg_flash_write(void *addr, const void *buf, size_t len) {
return ok;
}
void mg_sys_reset(void) {
void mg_device_reset(void) {
// SCB->AIRCR = ((0x5fa << SCB_AIRCR_VECTKEY_Pos)|SCB_AIRCR_SYSRESETREQ_Msk);
*(volatile unsigned long *) 0xe000ed0c = 0x5fa0004;
}
+2 -2
View File
@@ -1,9 +1,9 @@
#include "arch.h"
#include "log.h"
#include "ota.h"
#include "sys.h"
#include "device.h"
// This OTA implementation uses the internal flash API outlined in sys.h
// This OTA implementation uses the internal flash API outlined in device.h
// It splits flash into 2 equal partitions, and stores OTA status in the
// last sector of the partition.