Skip to content

Commit 472b1b4

Browse files
committed
Added requested comment and missing comment for UMM_CRITICAL_PERIOD_ANALYZE.
1 parent 40c6e95 commit 472b1b4

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

cores/esp8266/umm_malloc/umm_malloc.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ extern int umm_last_fail_alloc_size;
585585
#if defined(DEBUG_ESP_PORT) || defined(DEBUG_ESP_ISR)
586586
#define DEBUG_IRAM_ATTR ICACHE_RAM_ATTR
587587
/*
588-
Printing from the malloc routines is tricky. Since a lot of library calls
588+
Printing from the malloc routines is tricky. Since a lot of library calls
589589
will want to do malloc.
590590
591591
Objective: To be able to print "last gasp" diagnostic messages
@@ -610,6 +610,13 @@ int DEBUG_IRAM_ATTR _isr_safe_printf_P(const char *fmt, ...) {
610610
#else
611611
uart_buff_switch(0U); // Side effect, clears RX FIFO
612612
#endif
613+
/*
614+
To use ets_strlen() and ets_memcpy() safely with PROGMEM, flash storage,
615+
the PROGMEM address must be word (4 bytes) aligned. The destination
616+
address for ets_memcpy must also be word-aligned. We also round the
617+
buf_len up to the nearest word boundary. So that all transfers will be
618+
whole words.
619+
*/
613620
size_t str_len = ets_strlen(fmt);
614621
size_t buf_len = (str_len + 1 + 3) & ~0x03U;
615622
char ram_buf[buf_len] __attribute__ ((aligned(4)));

cores/esp8266/umm_malloc/umm_malloc_cfg.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,16 @@ extern char _heap_start;
122122
#define DEFAULT_CRITICAL_SECTION_INTLEVEL 15
123123
#endif
124124

125-
#define UMM_CRITICAL_PERIOD_ANALYZE
125+
/*
126+
* -D UMM_CRITICAL_PERIOD_ANALYZE :
127+
*
128+
* Build option to collect timing usage data on critical section usage in
129+
* functions: info, malloc, realloc. Collects MIN, MAX, and number of time
130+
* IRQs were disabled at request time. Note, IRQs disabled value can be
131+
* inflated by calls to realloc. realloc may call malloc and/or free.
132+
* Examine code for specifics on what info is available and how to access.
133+
*/
134+
// #define UMM_CRITICAL_PERIOD_ANALYZE
126135

127136
#ifndef __STRINGIFY
128137
#define __STRINGIFY(a) #a
@@ -175,7 +184,6 @@ static inline void _critical_entry(time_stat_t *p, uint32_t *saved_ps) {
175184
*saved_ps = xt_rsil(DEFAULT_CRITICAL_SECTION_INTLEVEL);
176185
if (0U != (*saved_ps & 0x0FU)) {
177186
p->intlevel += 1U;
178-
// inflight_stack_trace(*saved_ps);
179187
}
180188

181189
p->start = _umm_get_cycle_count();

0 commit comments

Comments
 (0)