]> cloudbase.mooo.com Git - z180-stamp.git/commitdiff
Set __malloc_margin, Print free heap command
authorLeo C <erbl259-lmu@yahoo.de>
Fri, 6 Apr 2018 22:35:51 +0000 (00:35 +0200)
committerLeo C <erbl259-lmu@yahoo.de>
Fri, 6 Apr 2018 22:35:51 +0000 (00:35 +0200)
avr/command_tbl.c
avr/debug.c
avr/main.c
include/config.h

index 95b6a5919084f004822e10fe68230c7c4abab20a..ce991343c0ffd9a73643ff62064d74e3ce48b67e 100644 (file)
@@ -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,
index 1b4ecc2a60bb7930fffabdaa8c3a1323d576f235..46e2ef668a0970ffe90882c9eb40e647826d125b 100644 (file)
@@ -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 */
index 1e5a6f97f94df4eb1610f8a8b3e0e2839904356f..450e2bad324b08161c55e47baed790ee4d706bca 100644 (file)
@@ -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);
index 89f829d84efde37b3fa3da3901afc910ed7423d9..31ee7dc250a5dccbec94fd1cc2c9a4565f039871 100644 (file)
@@ -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       "=> "