From 08b279cd6412db864238776d445c3376ff4daf55 Mon Sep 17 00:00:00 2001 From: hailfinger Date: Thu, 16 Sep 2010 22:34:25 +0000 Subject: =?UTF-8?q?Thanks=20to=20Johannes=20Sj=C3=B6lund=20for=20reporting?= =?UTF-8?q?=20that=20the=20Bus=20Pirate=20init=20could=20not=20deal=20with?= =?UTF-8?q?=20a=20Bus=20Pirate=20which=20is=20already=20in=20binary=20Bitb?= =?UTF-8?q?ang=20mode.=20This=20is=20caused=20by=20a=20combination=20of=20?= =?UTF-8?q?the=20slowness=20of=20the=20Bus=20Pirate,=20the=20slowness=20of?= =?UTF-8?q?=20USB=20and=20a=20fast=20serial=20port=20flush=20routine=20whi?= =?UTF-8?q?ch=20just=20flushes=20the=20buffer=20contents=20and=20does=20no?= =?UTF-8?q?t=20wait=20until=20data=20arrival=20stops.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make the Bus Pirate init more robust by running the flush command 10 times with 1.5 ms delay in between. This code development was sponsored by Mattias Mattsson. Thanks! Tested a few dozen times, should work reliably. Signed-off-by: Carl-Daniel Hailfinger Acked-by: Mattias Mattsson git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@1178 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1 --- serial.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'serial.c') diff --git a/serial.c b/serial.c index caf9389..9957fb4 100644 --- a/serial.c +++ b/serial.c @@ -200,8 +200,10 @@ int serialport_write(unsigned char *buf, unsigned int writecnt) #else tmp = write(sp_fd, buf, writecnt); #endif - if (tmp == -1) + if (tmp == -1) { + msg_perr("Serial port write error!\n"); return 1; + } if (!tmp) msg_pdbg("Empty write\n"); writecnt -= tmp; @@ -221,8 +223,10 @@ int serialport_read(unsigned char *buf, unsigned int readcnt) #else tmp = read(sp_fd, buf, readcnt); #endif - if (tmp == -1) + if (tmp == -1) { + msg_perr("Serial port read error!\n"); return 1; + } if (!tmp) msg_pdbg("Empty read\n"); readcnt -= tmp; -- cgit v1.2.1