From patchwork Fri Dec 2 15:41:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Zhilin X-Patchwork-Id: 702013 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail.coreboot.org (mail.coreboot.org [80.81.252.135]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tVdhG0pwpz9t9x for ; Sat, 3 Dec 2016 02:42:37 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="rdqfGwlE"; dkim-atps=neutral Received: from [127.0.0.1] (helo=ra.coresystems.de) by mail.coreboot.org with esmtp (Exim 4.86_2) (envelope-from ) id 1cCpxy-0006FR-Pt; Fri, 02 Dec 2016 16:41:38 +0100 Received: from mail-wj0-f196.google.com ([209.85.210.196]) by mail.coreboot.org with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.86_2) (envelope-from ) id 1cCpxo-0006Da-Jp for flashrom@flashrom.org; Fri, 02 Dec 2016 16:41:36 +0100 Received: by mail-wj0-f196.google.com with SMTP id kp2so30724066wjc.0 for ; Fri, 02 Dec 2016 07:41:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to; bh=EKT6wC5dKxLHLOpWg8IaGOzYoGDsAQs+wxJZ3Lr6g4k=; b=rdqfGwlEfBqP2u/tpH5a4NskKBTxGVn1m9jhzf75VNNBCYs6BqIshhD1YVwv/MePab AEkwTFR+CYoMpc0KactzfmAte+Yym8rXB/kBpnnfYCMCVgxDvEV7Ety6wgK1leE5d3td X5c15F11isA8say4lry0fbiazE3Utdxe9GGaW71enkZQqrmQiypPnA9v/G/uHtM+C2z0 nbDvR5dslPSjmifSj6VaXBPyHDQk7sHP7n2vStiyEeL4l7n+T+lq+SOJI3Ssi2q4L9Yn NgQHZOFhs5cnNfc6ku7rlqn98h1g23X0BAKs2Vm5n2fdqRKA9nzf/TE4cZLKJf3+z/nE 7JCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=EKT6wC5dKxLHLOpWg8IaGOzYoGDsAQs+wxJZ3Lr6g4k=; b=VSAg/mhHVW2Ss8CgZSSagvdrylTjB3awL2JbRzh70Zubq+3H9lxGwKMppJyRBplWZn eOv8lLeihLpPXs4nJJ5mYHQhtkfyYve5xii7rs06O46x2bbm6FfI25VoKkAuoCmHD5SW /aHfnkM1FEV10ZsGO5gDIVDXCtu5mZ6rhSJHfVQA2qPI17LsKrbz6ykwmbLm6n1ZUZnX Nkj6QhwbAl0ymjejAG14edTeoIsCTTzfngR1Txng4Pa76FWxCsq9XsSP+E+lFukFHCEj MOeJz3aDs/HSpt4eiBgVcuPB2iVTbyyR+pUvmUyKRT3YZK067kxS6x5AChx6pHRq3rVc xNOQ== X-Gm-Message-State: AKaTC01I3J6c4SJJrU39QFhvsrhIuj3fj1uVnBEP1K1Mrrin59Kmit9sSFlCQPC8pDsYtUdTRGqkASBZWTUp6g== X-Received: by 10.194.18.196 with SMTP id y4mr40359416wjd.73.1480693286836; Fri, 02 Dec 2016 07:41:26 -0800 (PST) MIME-Version: 1.0 Received: by 10.28.70.197 with HTTP; Fri, 2 Dec 2016 07:41:26 -0800 (PST) From: Michael Zhilin Date: Fri, 2 Dec 2016 18:41:26 +0300 Message-ID: To: flashrom@flashrom.org X-Spam-Score: -5.6 (-----) Subject: [flashrom] [patch] serprog hangs under FreeBSD X-BeenThere: flashrom@flashrom.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: flashrom discussion and development mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: flashrom-bounces@flashrom.org Sender: "flashrom" X-Duff: Orig. Duff, Duff Lite, Duff Dry, Duff Dark, Raspberry Duff, Lady Duff, Red Duff, Tartar Control Duff Hi, This is attached patch to avoid hang of serprog under FreeBSD. Patch is against trunk (r1955, 10 context lines). My use case is flashrom+serprog to read SPI flash (MX25L6406) via Arduino Nano V3. Actual command is: /usr/local/bin/flashrom -p serprog:dev=/dev/cuaU0:57600 -c MX25L6406E/MX25L6408E -r tcw770.dump Using flashrom 0.9.9 it hangs after 5 seconds on read from tty ("ttyin"). The problem is that kernel method "ttydisc_rint" ignore same bytes. It happens due to enabled IEXTEN local flag of termios. TTY cuts few bytes, Arduino reads 11264 bytes, but flashrom gets 11244 bytes (corrupted) and waits for remaining 20 bytes. The fix is simple: turn off IEXTEN local flag. Tested on Arduino Nano V3 + FreeBSD 12-CURRENT. But I didn't check compilation on other BSD / Linux distros. Could you please test it and let me know results? Signed-off-by: Michael Zhilin I've added signed-off-by here, because I don't know how to add it into svn patch. It's my first patch, so please let me know if i miss anything. Thanks, Michael! Index: serial.c =================================================================== --- serial.c (revision 1955) +++ serial.c (working copy) @@ -196,21 +196,21 @@ wanted = observed; if (baud >= 0) { const struct baudentry *entry = round_baud(baud); if (cfsetispeed(&wanted, entry->flag) != 0 || cfsetospeed(&wanted, entry->flag) != 0) { msg_perr_strerror("Could not set serial baud rate: "); return 1; } } wanted.c_cflag &= ~(PARENB | CSTOPB | CSIZE | CRTSCTS); wanted.c_cflag |= (CS8 | CLOCAL | CREAD); - wanted.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); + wanted.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG | IEXTEN); wanted.c_iflag &= ~(IXON | IXOFF | IXANY | ICRNL | IGNCR | INLCR); wanted.c_oflag &= ~OPOST; if (tcsetattr(fd, TCSANOW, &wanted) != 0) { msg_perr_strerror("Could not change serial port configuration: "); return 1; } if (tcgetattr(fd, &observed) != 0) { msg_perr_strerror("Could not fetch new serial port configuration: "); return 1; }