From 64a6fef8230b9958f3442929ee0e29c0e0216d5e Mon Sep 17 00:00:00 2001 From: "Sergio R. Caprile" Date: Fri, 1 Nov 2024 16:21:18 -0300 Subject: [PATCH] MG_IRAM -> noinline --- mongoose.c | 9 +++++---- mongoose.h | 2 +- src/ota.h | 2 +- src/ota_stm32f.c | 6 +++--- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/mongoose.c b/mongoose.c index 1d492a4f..33a5231e 100644 --- a/mongoose.c +++ b/mongoose.c @@ -6118,8 +6118,9 @@ MG_IRAM static bool flash_page_start(volatile uint32_t *dst) { if ((p - base) % (16 * 1024 * flash_config) == 0) return true; } else if (p == base + 16 * 1024 * 4 * flash_config) { return true; - } else if ((p - base) % (128 * 1024 * flash_config) == 0) + } else if ((p - base) % (128 * 1024 * flash_config) == 0) { return true; + } } return false; } @@ -6166,7 +6167,7 @@ MG_IRAM static void flash_clear_err(void) { MG_REG(MG_FLASH_BASE + MG_FLASH_SR) = 0xf2; // Clear all errors } -__attribute__((noinline)) MG_IRAM static bool mg_stm32f_erase(void *addr) { +MG_IRAM static bool mg_stm32f_erase(void *addr) { bool ok = false; if (flash_page_start(addr) == false) { MG_ERROR(("%p is not on a sector boundary", addr)); @@ -6207,7 +6208,7 @@ MG_IRAM static bool mg_stm32f_swap(void) { static bool s_flash_irq_disabled; -__attribute__((noinline)) MG_IRAM static bool mg_stm32f_write(void *addr, +MG_IRAM static bool mg_stm32f_write(void *addr, const void *buf, size_t len) { if ((len % s_mg_flash_stm32f.align) != 0) { @@ -6240,7 +6241,7 @@ __attribute__((noinline)) MG_IRAM static bool mg_stm32f_write(void *addr, } // just overwrite instead of swap -__attribute__((noinline)) MG_IRAM void single_bank_swap(char *p1, char *p2, +MG_IRAM void single_bank_swap(char *p1, char *p2, size_t size) { // no stdlib calls here mg_stm32f_write(p1, p2, size); diff --git a/mongoose.h b/mongoose.h index 8b8f55e7..3e86e15d 100644 --- a/mongoose.h +++ b/mongoose.h @@ -2657,7 +2657,7 @@ void mg_rpc_list(struct mg_rpc_req *r); #else #ifndef MG_IRAM #if defined(__GNUC__) -#define MG_IRAM __attribute__((section(".iram"))) +#define MG_IRAM __attribute__((noinline, section(".iram"))) #else #define MG_IRAM #endif // compiler diff --git a/src/ota.h b/src/ota.h index c6f3dd39..a5a837f6 100644 --- a/src/ota.h +++ b/src/ota.h @@ -23,7 +23,7 @@ #else #ifndef MG_IRAM #if defined(__GNUC__) -#define MG_IRAM __attribute__((section(".iram"))) +#define MG_IRAM __attribute__((noinline, section(".iram"))) #else #define MG_IRAM #endif // compiler diff --git a/src/ota_stm32f.c b/src/ota_stm32f.c index 135ad909..edb40c42 100644 --- a/src/ota_stm32f.c +++ b/src/ota_stm32f.c @@ -120,7 +120,7 @@ MG_IRAM static void flash_clear_err(void) { MG_REG(MG_FLASH_BASE + MG_FLASH_SR) = 0xf2; // Clear all errors } -__attribute__((noinline)) MG_IRAM static bool mg_stm32f_erase(void *addr) { +MG_IRAM static bool mg_stm32f_erase(void *addr) { bool ok = false; if (flash_page_start(addr) == false) { MG_ERROR(("%p is not on a sector boundary", addr)); @@ -161,7 +161,7 @@ MG_IRAM static bool mg_stm32f_swap(void) { static bool s_flash_irq_disabled; -__attribute__((noinline)) MG_IRAM static bool mg_stm32f_write(void *addr, +MG_IRAM static bool mg_stm32f_write(void *addr, const void *buf, size_t len) { if ((len % s_mg_flash_stm32f.align) != 0) { @@ -194,7 +194,7 @@ __attribute__((noinline)) MG_IRAM static bool mg_stm32f_write(void *addr, } // just overwrite instead of swap -__attribute__((noinline)) MG_IRAM void single_bank_swap(char *p1, char *p2, +MG_IRAM void single_bank_swap(char *p1, char *p2, size_t size) { // no stdlib calls here mg_stm32f_write(p1, p2, size);