From cbc3015878e547042b5ded7625ac3a1a45d6b7f0 Mon Sep 17 00:00:00 2001
From: Georg Lukas <georg@op-co.de>
Date: Sat, 31 Jan 2009 02:08:31 +0100
Subject: [PATCH] added soft-reset command to ramtool and lpctool

When no RTS/DTR lines are available (cell phone cable), a soft reset can
be performed after a successful flash instead of an external reset.

You have to open the EINT1 jumper during the flash process if you want
to boot into the newly loaded firmware!
---
 lpctool.c |    3 +++
 ramtool.c |    6 ++++++
 toolcmd.h |    1 +
 3 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/lpctool.c b/lpctool.c
index 8a23a4a..1ed0b90 100644
--- a/lpctool.c
+++ b/lpctool.c
@@ -1,6 +1,7 @@
 #include "infohelper.h"
 #include "lpctool_serial.h"
 #include "bootcom.h"
+#include "toolcmd.h"
 #include "toolcom.h"
 
 #define VERSION_MAJOR 0
@@ -154,7 +155,9 @@ void enterBootLD(void)
 
 void resetFB(void)
 {
+	char reset_cmd = RESET_CMD;
 	setDTR(1);
+	sendBuf(1, &reset_cmd);
 	usleep(100);
 	setDTR(0);
 }
diff --git a/ramtool.c b/ramtool.c
index e87ed45..d4a44f5 100644
--- a/ramtool.c
+++ b/ramtool.c
@@ -13,6 +13,8 @@ typedef volatile unsigned int *reg32_t;
 #include "toolcmd.h"
 #include "fonty.h"
 
+void (*resetBL)(void) = (void (*)(void))0x7FFFE000;
+
 union
 {
 	unsigned long wbuf[128];
@@ -331,6 +333,10 @@ fail_f:
 				serial_putc('\n');
 			}
 		}
+		else if(i==RESET_CMD)
+		{
+			resetBL();
+		}
 	}
 	return 0;
 }
diff --git a/toolcmd.h b/toolcmd.h
index 065ddd9..b25dccf 100644
--- a/toolcmd.h
+++ b/toolcmd.h
@@ -13,6 +13,7 @@
 #define SETNUMBYTES_CMD	'S'
 #define READ_CMD	'R'
 #define SKIP_CMD	'>'
+#define RESET_CMD	'*'
 #define HELOTOKEN	"HELO"
 #define ACKTOKEN	"ACK!"
 #define NACKTOKEN	"NACK"
-- 
1.5.6.5

