From owner-svn-ports-head@freebsd.org Wed Apr 19 20:19:34 2017 Return-Path: Delivered-To: svn-ports-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C8720D46A69; Wed, 19 Apr 2017 20:19:34 +0000 (UTC) (envelope-from bsam@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A588D1484; Wed, 19 Apr 2017 20:19:34 +0000 (UTC) (envelope-from bsam@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3JKJXlQ082686; Wed, 19 Apr 2017 20:19:33 GMT (envelope-from bsam@FreeBSD.org) Received: (from bsam@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3JKJXgO082679; Wed, 19 Apr 2017 20:19:33 GMT (envelope-from bsam@FreeBSD.org) Message-Id: <201704192019.v3JKJXgO082679@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bsam set sender to bsam@FreeBSD.org using -f From: Boris Samorodov Date: Wed, 19 Apr 2017 20:19:33 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r438912 - in head/devel/bossa: . files X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the ports tree for head List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Apr 2017 20:19:34 -0000 Author: bsam Date: Wed Apr 19 20:19:32 2017 New Revision: 438912 URL: https://svnweb.freebsd.org/changeset/ports/438912 Log: devel/bossa: Adding the 1200bps hack to devel/bossa should improve reliability of programming the Arduino Due. PR: 218241 Submitted by: Kyle Evans (maintainer) Added: head/devel/bossa/files/ head/devel/bossa/files/patch-src_PosixSerialPort.cpp (contents, props changed) head/devel/bossa/files/patch-src_PosixSerialPort.h (contents, props changed) head/devel/bossa/files/patch-src_SerialPort.h (contents, props changed) head/devel/bossa/files/patch-src_WinSerialPort.cpp (contents, props changed) head/devel/bossa/files/patch-src_WinSerialPort.h (contents, props changed) head/devel/bossa/files/patch-src_bossac.cpp (contents, props changed) Modified: head/devel/bossa/Makefile Modified: head/devel/bossa/Makefile ============================================================================== --- head/devel/bossa/Makefile Wed Apr 19 20:15:52 2017 (r438911) +++ head/devel/bossa/Makefile Wed Apr 19 20:19:32 2017 (r438912) @@ -2,7 +2,7 @@ PORTNAME= bossa PORTVERSION= 1.7.0 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= devel MAINTAINER= bsdports@kyle-evans.net Added: head/devel/bossa/files/patch-src_PosixSerialPort.cpp ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/devel/bossa/files/patch-src_PosixSerialPort.cpp Wed Apr 19 20:19:32 2017 (r438912) @@ -0,0 +1,47 @@ +--- src/PosixSerialPort.cpp.orig 2017-03-31 15:31:35 UTC ++++ src/PosixSerialPort.cpp +@@ -85,6 +85,9 @@ PosixSerialPort::open(int baud, + + switch (baud) + { ++ case 1200: ++ speed = B1200; ++ break; + case 9600: + speed = B9600; + break; +@@ -297,6 +300,34 @@ PosixSerialPort::timeout(int millisecs) + { + _timeout = millisecs; + return true; ++} ++ ++void ++PosixSerialPort::setDTR(bool dtr) ++{ ++ if (_devfd == -1) ++ return; ++ ++ int iFlags = TIOCM_DTR; ++ ++ if (dtr) ++ ioctl(_devfd, TIOCMBIS, &iFlags); ++ else ++ ioctl(_devfd, TIOCMBIC, &iFlags); ++} ++ ++void ++PosixSerialPort::setRTS(bool rts) ++{ ++ if (_devfd == -1) ++ return; ++ ++ int iFlags = TIOCM_RTS; ++ ++ if (rts) ++ ioctl(_devfd, TIOCMBIS, &iFlags); ++ else ++ ioctl(_devfd, TIOCMBIC, &iFlags); + } + + void Added: head/devel/bossa/files/patch-src_PosixSerialPort.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/devel/bossa/files/patch-src_PosixSerialPort.h Wed Apr 19 20:19:32 2017 (r438912) @@ -0,0 +1,11 @@ +--- src/PosixSerialPort.h.orig 2017-03-31 15:31:35 UTC ++++ src/PosixSerialPort.h +@@ -52,6 +52,8 @@ class PosixSerialPort : public SerialPort (public) + + bool timeout(int millisecs); + void flush(); ++ void setDTR(bool dtr); ++ void setRTS(bool rts); + void setAutoFlush(bool autoflush); + + private: Added: head/devel/bossa/files/patch-src_SerialPort.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/devel/bossa/files/patch-src_SerialPort.h Wed Apr 19 20:19:32 2017 (r438912) @@ -0,0 +1,11 @@ +--- src/SerialPort.h.orig 2017-03-31 15:31:35 UTC ++++ src/SerialPort.h +@@ -68,6 +68,8 @@ class SerialPort (public) + + virtual bool timeout(int millisecs) = 0; + virtual void flush() = 0; ++ virtual void setDTR(bool dtr) = 0; ++ virtual void setRTS(bool rts) = 0; + + virtual std::string name() const { return _name; } + Added: head/devel/bossa/files/patch-src_WinSerialPort.cpp ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/devel/bossa/files/patch-src_WinSerialPort.cpp Wed Apr 19 20:19:32 2017 (r438912) @@ -0,0 +1,18 @@ +--- src/WinSerialPort.cpp.orig 2017-03-31 15:31:35 UTC ++++ src/WinSerialPort.cpp +@@ -251,3 +251,15 @@ WinSerialPort::flush() + { + Sleep(1); + } ++ ++void ++WinSerialPort::setDTR(bool dtr) ++{ ++ Sleep(1); ++} ++ ++void ++WinSerialPort::setRTS(bool rts) ++{ ++ Sleep(1); ++} Added: head/devel/bossa/files/patch-src_WinSerialPort.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/devel/bossa/files/patch-src_WinSerialPort.h Wed Apr 19 20:19:32 2017 (r438912) @@ -0,0 +1,11 @@ +--- src/WinSerialPort.h.orig 2017-03-31 15:31:35 UTC ++++ src/WinSerialPort.h +@@ -55,6 +55,8 @@ class WinSerialPort : public SerialPort (public) + + bool timeout(int millisecs); + void flush(); ++ void setDTR(bool dtr); ++ void setRTS(bool rts); + + private: + HANDLE _handle; Added: head/devel/bossa/files/patch-src_bossac.cpp ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/devel/bossa/files/patch-src_bossac.cpp Wed Apr 19 20:19:32 2017 (r438912) @@ -0,0 +1,69 @@ +--- src/bossac.cpp.orig 2017-03-31 15:31:35 UTC ++++ src/bossac.cpp +@@ -64,6 +64,7 @@ class BossaConfig (public) + bool help; + bool forceUsb; + string forceUsbArg; ++ bool arduinoErase; + + int readArg; + string portArg; +@@ -89,6 +90,7 @@ BossaConfig::BossaConfig() + info = false; + help = false; + forceUsb = false; ++ arduinoErase = false; + + readArg = 0; + bootArg = 1; +@@ -189,6 +191,11 @@ static Option opts[] = + 'R', "reset", &config.reset, + { ArgNone }, + "reset CPU (if supported)" ++ }, ++ { ++ 'a', "arduino_erase", &config.arduinoErase, ++ { ArgNone }, ++ "erase and reset via Arduino 1200 baud hack (cannot be used with port autodetection)" + } + }; + +@@ -257,6 +264,12 @@ main(int argc, char* argv[]) + return help(argv[0]); + } + ++ if (config.arduinoErase && !config.port) ++ { ++ fprintf(stderr, "%s: port must be specified for Arduino 1200bps erase hack\n", argv[0]); ++ return help(argv[0]); ++ } ++ + if (config.read || config.write || config.verify) + { + if (args == argc) +@@ -311,6 +324,25 @@ main(int argc, char* argv[]) + fprintf(stderr, "Invalid USB value: %s\n", config.forceUsbArg.c_str()); + return 1; + } ++ } ++ ++ if (config.arduinoErase) ++ { ++ SerialPort::Ptr port; ++ if (config.forceUsb) ++ port = portFactory.create(config.portArg, isUsb); ++ else ++ port = portFactory.create(config.portArg); ++ ++ if(!port->open(1200)) ++ { ++ fprintf(stderr, "Failed to open port at 1200bps\n"); ++ return 1; ++ } ++ ++ port->setRTS(true); ++ port->setDTR(false); ++ port->close(); + } + + if (config.port)