]> cloudbase.mooo.com Git - z180-stamp.git/commitdiff
Support for Peter Danneggers fboot.
authorLeo C <erbl259-lmu@yahoo.de>
Wed, 21 Jan 2015 03:07:19 +0000 (04:07 +0100)
committerLeo C <erbl259-lmu@yahoo.de>
Wed, 21 Jan 2015 03:07:19 +0000 (04:07 +0100)
avr/command_tbl.c
avr/con-utils.c
avr/debug.c
avr/main.c
avr/print-utils.c
include/config.h
include/print-utils.h

index d4ff6f2258bb0364150978fda0feccbf35ee91bf..cbd23821bfbfb33ca63f88d74a970b7655f95088 100644 (file)
@@ -60,6 +60,11 @@ CMD_TBL_ITEM(
        "EEPROM dump",
        "address [count]"
 ),
+CMD_TBL_ITEM(
+       !mdf,   3,      1,      do_dump_mem,
+       "FLASH dump",
+       "address [count]"
+),
 CMD_TBL_ITEM(
        !cpe,   4,      0,      do_eep_cp,
        "EEPROM copy",
index f20dbfed214258bf77eb18e85d3f10f93a3b610c..5ee1ff1585fbbdd10c50973ebec374c97ac69db2 100644 (file)
@@ -4,9 +4,11 @@
  * SPDX-License-Identifier:    GPL-2.0+
  */
 
-#include <string.h>
 #include "common.h"
+#include <string.h>
+#include <avr/wdt.h>
 
+#include "config.h"
 #include "serial.h"
 #include "background.h"
 #include "con-utils.h"
@@ -26,6 +28,31 @@ int my_getchar(uint_fast8_t waitforchar)
                c = serial_getc();
        } while ((c < 0) && waitforchar);
 
+#ifdef CONFIG_SYS_FBOOTSIG
+       if (c < 0)
+               return c;
+
+       static const FLASH unsigned char bootsig[] = {CONFIG_SYS_FBOOTSIG};
+       static uint8_t pb;
+       unsigned char uc = c;
+
+
+       if (bootsig[pb] == 0) {
+               if (uc == 0xff) {
+                       wdt_enable(WDTO_15MS);
+                       for(;;)
+                               ;
+               } else
+                       pb = 0;
+
+       } else {
+               if (bootsig[pb] == uc)
+                       pb++;
+               else
+                       pb = 0;
+       }
+#endif
+
        return c;
 }
 
index 251ef269a6e1d4d1d43b0d8fde692c3c1356ae08..d4ae1f4aa7c09c68835f0a80d5597bc00c933449 100644 (file)
@@ -49,12 +49,19 @@ command_ret_t do_dump_mem(cmd_tbl_t *cmdtp, int flag, int argc, char * const arg
        uint32_t addr;
        uint32_t length = 128;
 
-       if (strchr(argv[0],'r') != NULL)
+       switch (argv[0][3]) {
+       case 'r':
                readhow = ram_read_buf;
-       else if (strchr(argv[0],'e') != NULL)
+               break;
+       case 'e':
                readhow = eeprom_read_buf;
-       else
+               break;
+       case 'f':
+               readhow = flash_read_buf;
+               break;
+       default:
                return CMD_RET_USAGE;
+       }
 
        /* Address is specified since argc > 1 */
        addr =  strtoul(argv[1], NULL, 16);
index 8bffef991971c64c9b443773016b19f984e2203d..f4d4c6ff0b6b2d484b03b23f4e47cc7517f8139a 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "common.h"
 #include <avr/interrupt.h>
+#include <avr/wdt.h>
 #include <stdlib.h>
 #include <stdio.h>
 
 #include "time.h"
 #include "rtc.h"
 
-static uint8_t mcusr;
+uint8_t mcusr __attribute__ ((section (".noinit")));
 
-/*--------------------------------------------------------------------------*/
 #if DEBUG
-
 __attribute__ ((naked)) __attribute__ ((section (".init3")))
 void preset_ram (void)
 {
@@ -36,6 +35,21 @@ void preset_ram (void)
                *p = 0xdd;
 
 }
+#endif
+
+__attribute__ ((naked)) __attribute__ ((section (".init3")))
+void get_mcusr (void)
+{
+       /* save and clear reset reason(s) */
+       /* TODO: move to init section? */
+       mcusr = MCUSR;
+       MCUSR = 0;
+
+       wdt_disable();
+}
+
+/*--------------------------------------------------------------------------*/
+#if DEBUG
 
 static const FLASH char * const FLASH rreasons[] = {
                        FSTR("Power on"),
@@ -77,13 +91,6 @@ ISR(INT6_vect)
 static
 void setup_avr(void)
 {
-       /* save and clear reset reason(s) */
-       /* TODO: move to init section? */
-       mcusr = MCUSR;
-       MCUSR = 0;
-
-       /* WD */
-
        /* CPU */
 
        /* Disable JTAG Interface regardless of the JTAGEN fuse setting. */
index 3f48620ff358a174c2b90d61ef40d4e94e0f06cb..9ce3e5044f9547e71ef131fe2bf8ad9cbe5f7733 100644 (file)
@@ -5,6 +5,7 @@
  */
 
 #include "common.h"
+#include <stdint.h>
 #include <stdio.h>
 #include <ctype.h>
 #include "con-utils.h"
@@ -28,6 +29,12 @@ void ram_read_buf(uint8_t *buf, uint32_t addr, uint8_t count)
                        *buf++ = *(uint8_t *) (size_t) addr++;
 }
 
+void flash_read_buf(uint8_t *buf, uint32_t addr, uint8_t count)
+{
+               while (count--)
+                       *buf++ = *(const __memx uint8_t *) (__uint24) addr++;
+}
+
 int dump_mem(uint32_t address, uint32_t offset, uint32_t len,
                void (*readfkt)(uint8_t *, uint32_t, uint8_t), char *title)
 {
index f51ebe926d2db8e7fcb082f163656cd39817111a..e40d016b017f5adf5bfc6f6b629fbb8c0e3cdc18 100644 (file)
@@ -40,6 +40,8 @@
 #define CONFIG_SYS_PROMPT      "=> "
 #define CONFIG_ESC_CHAR                ('^'-0x40)
 
+#define CONFIG_SYS_FBOOTSIG "Peda"
+
 
 /* TODO: */
 //#define CONFIG_CMDLINE_EDITING       1
index 8acf975f4acaa6a6bd3928d00096440f534ec7a5..7d48287c4dbc6f2c5a64f9d771ad392f31d4ee2f 100644 (file)
@@ -19,5 +19,6 @@ void dump_ram(uint8_t *addr, size_t offset, unsigned int len, char *title);
 
 void eeprom_read_buf(uint8_t *buf, uint32_t addr, uint8_t count);
 void ram_read_buf(uint8_t *buf, uint32_t addr, uint8_t count);
+void flash_read_buf(uint8_t *buf, uint32_t addr, uint8_t count);
 
 #endif /* PRINT_UTILS_H */