summaryrefslogtreecommitdiff
path: root/serial.c
diff options
context:
space:
mode:
authorhailfinger <hailfinger@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2010-09-16 22:34:25 +0000
committerhailfinger <hailfinger@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2010-09-16 22:34:25 +0000
commit08b279cd6412db864238776d445c3376ff4daf55 (patch)
treedd8ff0f4846f741f85d58af6b553ef690c453f87 /serial.c
parentfe34406ad660bdf26fdf41509bb238a8e4a2d6f3 (diff)
downloadflashrom-08b279cd6412db864238776d445c3376ff4daf55.tar.gz
Thanks to Johannes Sjölund for reporting that the Bus Pirate init could
not deal with a Bus Pirate which is already in binary Bitbang mode. This is caused by a combination of the slowness of the Bus Pirate, the slowness of USB and a fast serial port flush routine which just flushes the buffer contents and does not wait until data arrival stops. 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 <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Mattias Mattsson <vitplister@gmail.com> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@1178 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'serial.c')
-rw-r--r--serial.c8
1 files changed, 6 insertions, 2 deletions
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;