mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-08 16:11:18 +00:00
Single bank OTA
This commit is contained in:
1 parent
d6d2d7575a
commit
376e5ccaae
26 files changed
+2065
-1808
No files matched your search
+40
-25
@@ -27,21 +27,21 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#define MG_ARCH_CUSTOM 0 // User creates its own mongoose_custom.h
|
||||
#define MG_ARCH_UNIX 1 // Linux, BSD, Mac, ...
|
||||
#define MG_ARCH_WIN32 2 // Windows
|
||||
#define MG_ARCH_ESP32 3 // ESP32
|
||||
#define MG_ARCH_ESP8266 4 // ESP8266
|
||||
#define MG_ARCH_FREERTOS 5 // FreeRTOS
|
||||
#define MG_ARCH_AZURERTOS 6 // MS Azure RTOS
|
||||
#define MG_ARCH_ZEPHYR 7 // Zephyr RTOS
|
||||
#define MG_ARCH_NEWLIB 8 // Bare metal ARM
|
||||
#define MG_ARCH_CMSIS_RTOS1 9 // CMSIS-RTOS API v1 (Keil RTX)
|
||||
#define MG_ARCH_TIRTOS 10 // Texas Semi TI-RTOS
|
||||
#define MG_ARCH_RP2040 11 // Raspberry Pi RP2040
|
||||
#define MG_ARCH_ARMCC 12 // Keil MDK-Core with Configuration Wizard
|
||||
#define MG_ARCH_CMSIS_RTOS2 13 // CMSIS-RTOS API v2 (Keil RTX5, FreeRTOS)
|
||||
#define MG_ARCH_RTTHREAD 14 // RT-Thread RTOS
|
||||
#define MG_ARCH_CUSTOM 0 // User creates its own mongoose_custom.h
|
||||
#define MG_ARCH_UNIX 1 // Linux, BSD, Mac, ...
|
||||
#define MG_ARCH_WIN32 2 // Windows
|
||||
#define MG_ARCH_ESP32 3 // ESP32
|
||||
#define MG_ARCH_ESP8266 4 // ESP8266
|
||||
#define MG_ARCH_FREERTOS 5 // FreeRTOS
|
||||
#define MG_ARCH_AZURERTOS 6 // MS Azure RTOS
|
||||
#define MG_ARCH_ZEPHYR 7 // Zephyr RTOS
|
||||
#define MG_ARCH_NEWLIB 8 // Bare metal ARM
|
||||
#define MG_ARCH_CMSIS_RTOS1 9 // CMSIS-RTOS API v1 (Keil RTX)
|
||||
#define MG_ARCH_TIRTOS 10 // Texas Semi TI-RTOS
|
||||
#define MG_ARCH_RP2040 11 // Raspberry Pi RP2040
|
||||
#define MG_ARCH_ARMCC 12 // Keil MDK-Core with Configuration Wizard
|
||||
#define MG_ARCH_CMSIS_RTOS2 13 // CMSIS-RTOS API v2 (Keil RTX5, FreeRTOS)
|
||||
#define MG_ARCH_RTTHREAD 14 // RT-Thread RTOS
|
||||
|
||||
#if !defined(MG_ARCH)
|
||||
#if defined(__unix__) || defined(__APPLE__)
|
||||
@@ -497,6 +497,7 @@ typedef int socklen_t;
|
||||
#define realpath(a, b) _fullpath((b), (a), MG_PATH_MAX)
|
||||
#define sleep(x) Sleep((x) *1000)
|
||||
#define mkdir(a, b) _mkdir(a)
|
||||
#define timegm(x) _mkgmtime(x)
|
||||
|
||||
#ifndef S_ISDIR
|
||||
#define S_ISDIR(x) (((x) &_S_IFMT) == _S_IFDIR)
|
||||
@@ -919,16 +920,23 @@ void mg_pfn_stdout(char c, void *param); // param: ignored
|
||||
|
||||
|
||||
enum { MG_LL_NONE, MG_LL_ERROR, MG_LL_INFO, MG_LL_DEBUG, MG_LL_VERBOSE };
|
||||
extern int mg_log_level; // Current log level, one of MG_LL_*
|
||||
|
||||
void mg_log(const char *fmt, ...);
|
||||
bool mg_log_prefix(int ll, const char *file, int line, const char *fname);
|
||||
void mg_log_set(int log_level);
|
||||
void mg_log_prefix(int ll, const char *file, int line, const char *fname);
|
||||
// bool mg_log2(int ll, const char *file, int line, const char *fmt, ...);
|
||||
void mg_hexdump(const void *buf, size_t len);
|
||||
void mg_log_set_fn(mg_pfn_t fn, void *param);
|
||||
|
||||
#define mg_log_set(level_) mg_log_level = (level_)
|
||||
|
||||
#if MG_ENABLE_LOG
|
||||
#define MG_LOG(level, args) \
|
||||
do { \
|
||||
if (mg_log_prefix((level), __FILE__, __LINE__, __func__)) mg_log args; \
|
||||
#define MG_LOG(level, args) \
|
||||
do { \
|
||||
if ((level) <= mg_log_level) { \
|
||||
mg_log_prefix((level), __FILE__, __LINE__, __func__); \
|
||||
mg_log args; \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
#define MG_LOG(level, args) \
|
||||
@@ -1053,8 +1061,8 @@ uint64_t mg_now(void); // Return milliseconds since Epoch
|
||||
#define MG_ROUND_DOWN(x, a) ((a) == 0 ? (x) : (((x) / (a)) * (a)))
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define MG_ARM_DISABLE_IRQ() asm volatile ("cpsid i" : : : "memory")
|
||||
#define MG_ARM_ENABLE_IRQ() asm volatile ("cpsie i" : : : "memory")
|
||||
#define MG_ARM_DISABLE_IRQ() asm volatile("cpsid i" : : : "memory")
|
||||
#define MG_ARM_ENABLE_IRQ() asm volatile("cpsie i" : : : "memory")
|
||||
#else
|
||||
#define MG_ARM_DISABLE_IRQ()
|
||||
#define MG_ARM_ENABLE_IRQ()
|
||||
@@ -1678,6 +1686,12 @@ void mg_rpc_list(struct mg_rpc_req *r);
|
||||
#define MG_OTA MG_OTA_NONE
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && !defined(__APPLE__)
|
||||
#define MG_IRAM __attribute__((section(".iram")))
|
||||
#else
|
||||
#define MG_IRAM
|
||||
#endif
|
||||
|
||||
// Firmware update API
|
||||
bool mg_ota_begin(size_t new_firmware_size); // Start writing
|
||||
bool mg_ota_write(const void *buf, size_t len); // Write chunk, aligned to 1k
|
||||
@@ -1696,8 +1710,9 @@ uint32_t mg_ota_crc32(int firmware); // Return firmware checksum
|
||||
uint32_t mg_ota_timestamp(int firmware); // Firmware timestamp, UNIX UTC epoch
|
||||
size_t mg_ota_size(int firmware); // Firmware size
|
||||
|
||||
bool mg_ota_commit(void); // Commit current firmware
|
||||
bool mg_ota_rollback(void); // Rollback to the previous firmware
|
||||
bool mg_ota_commit(void); // Commit current firmware
|
||||
bool mg_ota_rollback(void); // Rollback to the previous firmware
|
||||
MG_IRAM void mg_ota_boot(void); // Bootloader function
|
||||
// Copyright (c) 2023 Cesanta Software Limited
|
||||
// All rights reserved
|
||||
|
||||
@@ -1723,7 +1738,7 @@ int mg_flash_bank(void); // 0: not dual bank, 1: bank1, 2: bank2
|
||||
|
||||
// Write, erase, swap bank
|
||||
bool mg_flash_write(void *addr, const void *buf, size_t len);
|
||||
bool mg_flash_erase(void *addr); // Must be at sector boundary
|
||||
bool mg_flash_erase(void *sector);
|
||||
bool mg_flash_swap_bank(void);
|
||||
|
||||
// Convenience functions to store data on a flash sector with wear levelling
|
||||
|
||||
Reference in new issue
Block a user