Add H5 and H7 to health monitor

This commit is contained in:
cpq committed 2026-10-08 15:15:11 +01:00
1 parent 16a5a7d9fb
commit eda9a5726c
6 files changed
+19 -11

No files matched your search

+1 -1
View File
@@ -6,7 +6,7 @@
struct mg_health mg_health_record MG_HEALTH_RAM;
// STM32 H723 support. Needs the _estack symbol from the linker script
#if MG_ENABLE_HEALTH && defined(STM32H723xx_H)
#if MG_ENABLE_HEALTH && (defined(STM32H7_DEV_ID) || defined(STM32H5))
// Fault handler body. Runs in exception context: no printf, no malloc, no
// blocking calls. Copies the unwind registers and raw stack into the health
// record, then resets.
+5 -1
View File
@@ -9,6 +9,10 @@
#define MG_HEALTH_MAGIC {'M', 'G', 'H', '3'} // '3' is the layout version
#endif
#if !defined(MG_HEALTH_RAM) && (defined(STM32H7_DEV_ID) || defined(STM32H5))
#define MG_HEALTH_RAM __attribute__((section(".mg_health")))
#endif
// Places the record in RAM that survives a reset. Define in mongoose_config.h
// to match the linker script, e.g. __attribute__((section(".mg_health")))
#ifndef MG_HEALTH_RAM
@@ -30,7 +34,7 @@ enum mg_health_reason {
};
#ifndef MG_HEALTH_DATA_SIZE
#define MG_HEALTH_DATA_SIZE 20
#define MG_HEALTH_DATA_SIZE 250
#endif
struct mg_health {
+3 -2
View File
@@ -43,11 +43,12 @@ bool mg_random(void *buf, size_t len) {
success = true;
#elif MG_ARCH == MG_ARCH_CUBE && defined(HAL_RNG_MODULE_ENABLED)
extern RNG_HandleTypeDef hrng;
success = true;
for (size_t n = 0; n < len; n += sizeof(uint32_t)) {
uint32_t r = HAL_RNG_ReadLastRandomNumber(&hrng);
uint32_t r = 0;
if (HAL_RNG_GenerateRandomNumber(&hrng, &r) != HAL_OK) success = false;
memcpy((char *) buf + n, &r, n + sizeof(r) > len ? len - n : sizeof(r));
}
success = true;
#elif MG_ARCH == MG_ARCH_PICOSDK
while (len--) *p++ = (unsigned char) (get_rand_32() & 255);
success = true;