summaryrefslogtreecommitdiff
path: root/avr/con-utils.c
diff options
context:
space:
mode:
authorLeo C2015-01-21 04:07:19 +0100
committerLeo C2015-01-21 04:07:19 +0100
commitc748023ede9e7d8bdbf81ce8c8be2a437607a9e4 (patch)
treeafb7994e11bf67ff8f370c6da67892acd2d8df4d /avr/con-utils.c
parentce47d431da8ca00d52caffebaafd7ddb817d7b26 (diff)
downloadz180-stamp-c748023ede9e7d8bdbf81ce8c8be2a437607a9e4.zip
Support for Peter Danneggers fboot.
Diffstat (limited to 'avr/con-utils.c')
-rw-r--r--avr/con-utils.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/avr/con-utils.c b/avr/con-utils.c
index f20dbfe..5ee1ff1 100644
--- a/avr/con-utils.c
+++ b/avr/con-utils.c
@@ -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;
}