mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-27 20:48:29 +00:00
Add MG_OTA_{ROLLBACK,STATE_SET,STATE_GET}
This commit is contained in:
1 parent
a6452f5311
commit
67f249c58a
16 files changed
+345
-131
No files matched your search
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#include "hal.h"
|
||||
|
||||
// See https://mongoose.ws/documentation/#build-options
|
||||
#define MG_ARCH MG_ARCH_ARMGCC
|
||||
@@ -12,16 +13,34 @@
|
||||
#define MG_ENABLE_PACKED_FS 1
|
||||
#define MG_ENABLE_DRIVER_STM32H 1
|
||||
|
||||
#define MG_OTA_PUBLIC_KEY { \
|
||||
0x19, 0x7f, 0xed, 0x81, 0x8b, 0xb7, 0xb2, 0xa5, \
|
||||
0xde, 0xe0, 0xde, 0x04, 0x83, 0x60, 0xc8, 0x69, \
|
||||
0x61, 0x39, 0x30, 0x1f, 0xc1, 0x52, 0x11, 0x4b, \
|
||||
0xb7, 0xa4, 0xd7, 0x52, 0x03, 0x36, 0xc6, 0xc1, \
|
||||
0xbf, 0x22, 0x75, 0x04, 0x49, 0xf8, 0x46, 0x47, \
|
||||
0xec, 0x20, 0xd6, 0x8d, 0x48, 0x29, 0x7d, 0x63, \
|
||||
0xb3, 0xf7, 0x1f, 0x58, 0x44, 0x82, 0xcc, 0x7a, \
|
||||
0x4b, 0x5e, 0x68, 0x98, 0x24, 0x1f, 0x86, 0xf4, \
|
||||
}
|
||||
#define MG_OTA_PUBLIC_KEY \
|
||||
{ \
|
||||
0x19, 0x7f, 0xed, 0x81, 0x8b, 0xb7, 0xb2, 0xa5, 0xde, 0xe0, 0xde, \
|
||||
0x04, 0x83, 0x60, 0xc8, 0x69, 0x61, 0x39, 0x30, 0x1f, 0xc1, 0x52, \
|
||||
0x11, 0x4b, 0xb7, 0xa4, 0xd7, 0x52, 0x03, 0x36, 0xc6, 0xc1, 0xbf, \
|
||||
0x22, 0x75, 0x04, 0x49, 0xf8, 0x46, 0x47, 0xec, 0x20, 0xd6, 0x8d, \
|
||||
0x48, 0x29, 0x7d, 0x63, 0xb3, 0xf7, 0x1f, 0x58, 0x44, 0x82, 0xcc, \
|
||||
0x7a, 0x4b, 0x5e, 0x68, 0x98, 0x24, 0x1f, 0x86, 0xf4, \
|
||||
}
|
||||
|
||||
// OTA rollback timer via IWDG. PR=8 → /1024 on H563 (RM0481 §52.4.2).
|
||||
// Max timeout: 4095 * 1024 / 32000 = 131 s. PVU/RVU must clear before
|
||||
// writing RLR/starting, otherwise the write is ignored (RM0481 §52.4.3).
|
||||
#define MG_OTA_ROLLBACK_TIMER_START(seconds) \
|
||||
do { \
|
||||
IWDG->KR = 0x5555U; /* unlock */ \
|
||||
IWDG->PR = 8U; /* /1024 */ \
|
||||
while (IWDG->SR & IWDG_SR_PVU) (void) 0; /* wait PVU */ \
|
||||
IWDG->RLR = (uint32_t) ((seconds) * 32000 / 1024); \
|
||||
while (IWDG->SR & IWDG_SR_RVU) (void) 0; /* wait RVU */ \
|
||||
IWDG->KR = 0xCCCCU; /* start */ \
|
||||
IWDG->KR = 0xAAAAU; /* reload RLR */ \
|
||||
} while (0)
|
||||
|
||||
// OTA state in TAMP backup register 0 (survives all resets, clears on POR).
|
||||
// Requires hal_backup_domain_init() (called from hal_clock_init) to have run.
|
||||
#define MG_OTA_STATE_GET() (TAMP->BKP0R)
|
||||
#define MG_OTA_STATE_SET(v) (TAMP->BKP0R = (uint32_t) (v))
|
||||
|
||||
// #define MG_DRIVER_MDC_CR 4 // RMII MDC clock divider, from 0 to 4
|
||||
// #define MG_TCPIP_PHY_ADDR 0 // PHY address
|
||||
@@ -33,17 +52,8 @@
|
||||
// #define MG_TCPIP_GW MG_IPV4(192, 168, 0, 1)
|
||||
// #define MG_TCPIP_MASK MG_IPV4(255, 255, 255, 0)
|
||||
|
||||
// Set custom MAC address. By default, it is randomly generated
|
||||
// Using a build-time constant:
|
||||
// #define MG_SET_MAC_ADDRESS(mac) do { mac[0] = 2; mac[1] = 3; mac[2] = 4; mac[3] = 5; mac[4] = 6; mac[5] = 7; } while (0)
|
||||
//
|
||||
// Using custom function:
|
||||
// extern void my_function(unsigned char *mac);
|
||||
// #define MG_SET_MAC_ADDRESS(mac) my_function(mac)
|
||||
|
||||
// Construct MAC address from the MCU unique ID. It is defined in the
|
||||
// ST CMSIS header as UID_BASE
|
||||
#define MGUID ((uint32_t *) 0x08fff800) // Unique 96-bit chip ID
|
||||
// Construct MAC address from the MCU unique ID
|
||||
#define MGUID ((uint32_t *) UID_BASE)
|
||||
#define MG_SET_MAC_ADDRESS(mac) \
|
||||
do { \
|
||||
mac[0] = 2; \
|
||||
|
||||
Reference in new issue
Block a user