Skip to content

Commit ad736e9

Browse files
author
Deepika
committed
Add RAM/ROM memory statistics to system stats structure
Internal RAM / ROM memory size and start address of target can be fetched using `mbed_stats_sys_get()` API.
1 parent 1627968 commit ad736e9

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

platform/mbed_stats.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,35 @@ void mbed_stats_sys_get(mbed_stats_sys_t *stats)
131131

132132
#if defined(MBED_SYS_STATS_ENABLED)
133133
stats->os_version = MBED_VERSION;
134+
stats->ram_start[0] = MBED_RAM_START;
135+
stats->ram_size[0] = MBED_RAM_SIZE;
136+
stats->rom_start[0] = MBED_ROM_START;
137+
stats->rom_size[0] = MBED_ROM_SIZE;
138+
#if defined(MBED_RAM1_START) && defined(MBED_RAM1_SIZE)
139+
stats->ram_start[1] = MBED_RAM1_START;
140+
stats->ram_size[1] = MBED_RAM1_SIZE;
141+
#endif
142+
#if defined(MBED_RAM2_START) && defined(MBED_RAM2_SIZE)
143+
stats->ram_start[2] = MBED_RAM2_START;
144+
stats->ram_size[2] = MBED_RAM2_SIZE;
145+
#endif
146+
#if defined(MBED_RAM3_START) && defined(MBED_RAM3_SIZE)
147+
stats->ram_start[3] = MBED_RAM3_START;
148+
stats->ram_size[3] = MBED_RAM3_SIZE;
149+
#endif
150+
#if defined(MBED_ROM1_START) && defined(MBED_ROM1_SIZE)
151+
stats->rom_start[1] = MBED_ROM1_START;
152+
stats->rom_size[1] = MBED_ROM1_SIZE;
153+
#endif
154+
#if defined(MBED_ROM2_START) && defined(MBED_ROM2_SIZE)
155+
stats->rom_start[2] = MBED_ROM2_START;
156+
stats->rom_size[2] = MBED_ROM2_SIZE;
157+
#endif
158+
#if defined(MBED_ROM3_START) && defined(MBED_ROM3_SIZE)
159+
stats->rom_start[3] = MBED_ROM3_START;
160+
stats->rom_size[3] = MBED_ROM3_SIZE;
161+
#endif
162+
134163
#if defined(__CORTEX_M)
135164
stats->cpu_id = SCB->CPUID;
136165
#endif

platform/mbed_stats.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ extern "C" {
3838
#define MBED_THREAD_STATS_ENABLED 1
3939
#endif
4040

41+
/** Maximum memory regions reported by mbed-os memory statistics */
42+
#define MBED_MAX_MEM_REGIONS 4
43+
4144
/**
4245
* struct mbed_stats_heap_t definition
4346
*/
@@ -144,6 +147,10 @@ typedef struct {
144147
uint32_t cpu_id; /**< CPUID register data (Cortex-M only supported) */
145148
mbed_compiler_id_t compiler_id; /**< Compiler ID \ref mbed_compiler_id_t */
146149
uint32_t compiler_version; /**< Compiler version */
150+
uint32_t ram_start[MBED_MAX_MEM_REGIONS];/**< Start addresses of all internal RAM memories */
151+
uint32_t ram_size[MBED_MAX_MEM_REGIONS];/**< Size of all internal RAM memories in target */
152+
uint32_t rom_start[MBED_MAX_MEM_REGIONS];/**< Start addresses of all internal ROM memories */
153+
uint32_t rom_size[MBED_MAX_MEM_REGIONS];/**< Size of all internal ROM memories in target */
147154
} mbed_stats_sys_t;
148155

149156
/**

0 commit comments

Comments
 (0)