summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTravis Geiselbrecht <travisg@google.com>2012-06-27 22:48:01 -0700
committerTravis Geiselbrecht <travisg@google.com>2012-06-27 22:48:01 -0700
commitf60a73c0f4b646eb54892db4670080f8b54edc46 (patch)
treec88001efd90b94f61823fb493fabf2dd7c6ab14f
parent6e02e1ceb49f6f7e03f7917a763e3cb4d0a88b1d (diff)
downloadadk2012_demo-f60a73c0f4b646eb54892db4670080f8b54edc46.tar.gz
[bossac] add README and patch to build the bossac tool
Change-Id: Ib12f6102e1628cbcb969eff55b806d69b50f5ccb
-rw-r--r--tools/bossac/README.txt18
-rw-r--r--tools/bossac/bossac.patch88
2 files changed, 106 insertions, 0 deletions
diff --git a/tools/bossac/README.txt b/tools/bossac/README.txt
new file mode 100644
index 0000000..7d95b3c
--- /dev/null
+++ b/tools/bossac/README.txt
@@ -0,0 +1,18 @@
+In order to build the bossac tool, check out the BOSSA repository at Sourceforge
+as follows:
+
+git clone git://git.code.sf.net/p/b-o-s-s-a/code b-o-s-s-a-code
+
+Apply the patch with the following command
+
+patch -d b-o-s-s-a-code -p1 < bossac.patch
+
+To build bossac, change to the bossac source directory and run
+
+make bin/bossac
+
+The resulting binary will be at bin/bossac.
+
+NOTE: the patch will cleanly apply to change 05bfcc39bc0453c3028b1161175b95a81af7a901.
+Subsequent commits on the bossa repository may implement the patch, and render
+it obsolete.
diff --git a/tools/bossac/bossac.patch b/tools/bossac/bossac.patch
new file mode 100644
index 0000000..d423bda
--- /dev/null
+++ b/tools/bossac/bossac.patch
@@ -0,0 +1,88 @@
+diff --git a/Makefile b/Makefile
+index 821f579..687d2be 100644
+--- a/Makefile
++++ b/Makefile
+@@ -67,6 +67,8 @@ ifeq ($(OS),Linux)
+ COMMON_SRCS+=PosixSerialPort.cpp LinuxPortFactory.cpp
+ COMMON_LIBS=-Wl,--as-needed
+ WX_LIBS+=-lX11
++COMMON_CXXFLAGS+=-m32
++COMMON_LDFLAGS+=-m32
+
+ MACHINE:=$(shell uname -m)
+
+@@ -151,7 +153,7 @@ BOSSASH_CXXFLAGS=$(COMMON_CXXFLAGS) -Isrc/arm-dis
+ #
+ # LD Flags
+ #
+-COMMON_LDFLAGS+=-g
++COMMON_LDFLAGS+=-g -m32
+ BOSSA_LDFLAGS=$(COMMON_LDFLAGS)
+ BOSSAC_LDFLAGS=$(COMMON_LDFLAGS)
+ BOSSASH_LDFLAGS=$(COMMON_LDFLAGS)
+diff --git a/src/EefcFlash.cpp b/src/EefcFlash.cpp
+index 890dd76..b8af491 100644
+--- a/src/EefcFlash.cpp
++++ b/src/EefcFlash.cpp
+@@ -62,7 +62,7 @@ EefcFlash::EefcFlash(Samba& samba,
+ _regs(regs), _canBrownout(canBrownout), _eraseAuto(true)
+ {
+ assert(planes == 1 || planes == 2);
+- assert(pages <= 1024);
++ assert(pages <= 2048);
+ assert(lockRegions <= 32);
+
+ // SAM3 Errata (FWS must be 6)
+@@ -236,6 +236,7 @@ EefcFlash::setBootFlash(bool enable)
+ {
+ waitFSR();
+ writeFCR0(enable ? EEFC_FCMD_SGPB : EEFC_FCMD_CGPB, (_canBrownout ? 3 : 1));
++ waitFSR();
+ }
+
+ void
+@@ -292,7 +293,7 @@ EefcFlash::waitFSR()
+ }
+ if (fsr0 & fsr1 & 0x1)
+ break;
+- usleep(100);
++ usleep(5000);
+ }
+ if (tries > 500)
+ throw FlashCmdError();
+diff --git a/src/PosixSerialPort.cpp b/src/PosixSerialPort.cpp
+index 9da2fbd..dd06ad2 100644
+--- a/src/PosixSerialPort.cpp
++++ b/src/PosixSerialPort.cpp
+@@ -237,6 +237,7 @@ PosixSerialPort::write(const uint8_t* buffer, int len)
+ if (_devfd == -1)
+ return -1;
+
++ flush();
+ return ::write(_devfd, buffer, len);
+ }
+
+diff --git a/src/Samba.cpp b/src/Samba.cpp
+index bc3abf7..49f5ae1 100644
+--- a/src/Samba.cpp
++++ b/src/Samba.cpp
+@@ -480,13 +480,16 @@ Samba::go(uint32_t addr)
+ if (_debug)
+ printf("%s(addr=%#x)\n", __FUNCTION__, addr);
+
++ // The SAM firmware can get confused if another command is
++ // received in the same USB data packet as the go command
++ // so we flush before and after writing the command over USB.
++ if (_isUsb)
++ _port->flush();
++
+ snprintf((char*) cmd, sizeof(cmd), "G%08X#", addr);
+ if (_port->write(cmd, sizeof(cmd) - 1) != sizeof(cmd) - 1)
+ throw SambaError();
+
+- // The SAM firmware can get confused if another command is
+- // received in the same USB data packet as the go command
+- // so we flush after writing the command over USB.
+ if (_isUsb)
+ _port->flush();
+ }