From: Leo C Date: Fri, 6 Apr 2018 22:35:51 +0000 (+0200) Subject: Set __malloc_margin, Print free heap command X-Git-Url: http://cloudbase.mooo.com/gitweb/z180-stamp.git/commitdiff_plain/c6a1984b8079fe67c45388517baa2588028c0183 Set __malloc_margin, Print free heap command --- diff --git a/avr/command_tbl.c b/avr/command_tbl.c index 95b6a59..ce99134 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 89f829d..31ee7dc 100644 --- a/include/config.h +++ b/include/config.h @@ -65,6 +65,7 @@ #define CONFIG_SYS_HIST_MAX 20 #define CONFIG_SYS_MAXARGS 20 #define CONFIG_SYS_ENV_NAMELEN 16 +#define CONFIG_SYS_MALLOC_MARGIN 256 #define CONFIG_SYS_PROMPT "-> " #define CONFIG_SYS_PROMPT_REPEAT "=> "