Add h723 baremetal cubemx stack/heap reporting

This commit is contained in:
robert committed 2026-10-23 11:44:09 +03:00
1 parent 10ecb604a0
commit 76a9853b12
4 files changed
+34 -4

No files matched your search

@@ -84,6 +84,17 @@ static void MX_USART3_UART_Init(void);
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
size_t hal_get_heap(void) {
extern void *_sbrk(ptrdiff_t incr);
extern unsigned char _end; // Start of heap, see linker script
return (size_t) ((uintptr_t) _sbrk(0) - (uintptr_t) &_end);
}
size_t hal_get_stack(void) {
extern unsigned char _estack; // Initial stack pointer, see linker script
return (size_t) ((uintptr_t) &_estack - (uintptr_t) __get_MSP());
}
static void log_fn(char ch, void *param) {
HAL_UART_Transmit(param, (unsigned char *) &ch, 1, HAL_MAX_DELAY);
}
@@ -1,6 +1,21 @@
#pragma once
#include <stddef.h>
#include <stdint.h>
#define MG_ARCH MG_ARCH_CUBE
// Current memory usage in bytes
size_t hal_get_heap(void);
size_t hal_get_stack(void);
#define MG_HEALTH_HEAP_USED hal_get_heap()
#define MG_HEALTH_STACK_USED hal_get_stack()
extern uint32_t _Min_Stack_Size;
extern unsigned char _end, _sstack;
#define MG_HEALTH_STACK_TOTAL ((size_t) (uintptr_t) &_Min_Stack_Size)
#define MG_HEALTH_HEAP_TOTAL \
((size_t) ((uintptr_t) &_sstack - (uintptr_t) &_end))
// Ethernet driver tunables:
// #define MG_DRIVER_MDC_CR 4 // RMII MDC clock divider, from 0 to 5
// #define MG_TCPIP_PHY_ADDR 0 // PHY address