From fb9b17a9518501c3de8eb6858e887b40328364c6 Mon Sep 17 00:00:00 2001 From: Leo C Date: Sat, 21 Jul 2018 12:15:44 +0200 Subject: Set __malloc_margin, Print free heap command # Conflicts: # include/config.h --- avr/command_tbl.c | 6 ++++++ avr/debug.c | 12 +++++++----- avr/main.c | 1 + include/config.h | 1 + 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/avr/command_tbl.c b/avr/command_tbl.c index 7e7ccee..7f75397 100644 --- a/avr/command_tbl.c +++ b/avr/command_tbl.c @@ -37,6 +37,7 @@ extern command_ret_t do_fat(cmd_tbl_t *, int, int, char * const []); extern command_ret_t do_run(cmd_tbl_t *, int, int, char * const []); extern command_ret_t do_source(cmd_tbl_t *, int, int, char * const []); extern command_ret_t do_attach(cmd_tbl_t *, int, int, char * const []); +extern command_ret_t do_pr_free_avr(cmd_tbl_t *, int, int, char * const []); #ifdef CONFIG_SYS_LONGHELP const FLASH char sd_help_text[] = @@ -87,6 +88,11 @@ CMD_TBL_ITEM( "avr memory modify (constant address)", "address" ), +CMD_TBL_ITEM( + !prfree, 2, 1, do_pr_free_avr, + "print avr heap free list", + "address" +), #endif CMD_TBL_ITEM( mstep, 2, 1, do_busreq_pulse, diff --git a/avr/debug.c b/avr/debug.c index 1b4ecc2..46e2ef6 100644 --- a/avr/debug.c +++ b/avr/debug.c @@ -142,7 +142,6 @@ static command_ret_t mod_mem_avr(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[]) { uint8_t *addr; - uint8_t data; int nbytes; (void) cmdtp; @@ -168,7 +167,7 @@ mod_mem_avr(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const arg * the next value. A non-converted value exits. */ do { - data = *addr; + uint8_t data = *addr; printf_P(PSTR("%04x: %02x"), addr, data); nbytes = cli_readline(PSTR(" ? "), 0); @@ -208,8 +207,6 @@ command_ret_t do_mem_nm_avr(cmd_tbl_t *cmdtp, int flag, int argc, char * const a /*------------------------------------------------------------------------------*/ -#if 1 - struct __freelist { size_t sz; struct __freelist *nx; @@ -250,6 +247,11 @@ printfreelist(const char * title) (size_t) STACK_POINTER(), (size_t) __brkval, freesum); } -#endif +command_ret_t do_pr_free_avr(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + printfreelist(NULL); + + return CMD_RET_SUCCESS; +} #endif /* DEBUG */ diff --git a/avr/main.c b/avr/main.c index 1e5a6f9..450e2ba 100644 --- a/avr/main.c +++ b/avr/main.c @@ -246,6 +246,7 @@ int main(void) { extern void setup_mmc(void); + __malloc_margin = CONFIG_SYS_MALLOC_MARGIN; setup_avr(); for (int i = 0; i < GPIO_MAX; i++) gpio_config(i, INPUT_PULLUP); diff --git a/include/config.h b/include/config.h index 54cbc98..f5bccb9 100644 --- a/include/config.h +++ b/include/config.h @@ -66,6 +66,7 @@ #define CONFIG_SYS_MAXARGS 20 #define CONFIG_SYS_ENV_NAMELEN 16 #define CONFIG_SYS_HISTSIZE (CONFIG_SYS_CBSIZE*2) +#define CONFIG_SYS_MALLOC_MARGIN 256 #define CONFIG_SYS_PROMPT "-> " #define CONFIG_SYS_PROMPT_REPEAT "=> " -- cgit v1.2.3