Skip to content

Commit 88d826b

Browse files
committed
Added some patches from pull requests
shumatech#88 shumatech#133 shumatech#140 shumatech#150
1 parent e63a3d9 commit 88d826b

File tree

4 files changed

+28
-8
lines changed

4 files changed

+28
-8
lines changed

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,15 @@ WXVERSION=2.8
153153

154154
endif
155155

156+
#
157+
# FreeBSD rules. Tested on 12.1.
158+
#
156159
ifeq (${OS},FreeBSD)
157160

161+
# Readline and Wxwidgets are installed under /usr/local on Freebsd
162+
COMMON_CXXFLAGS=-I/usr/local/include
163+
COMMON_LDFLAGS=-L/usr/local/lib
164+
158165
# This is only needed for bossash, but we can't add it to BOSSASH_LIBS here
159166
# because that one is redefined later.
160167
COMMON_SRCS+=PosixSerialPort.cpp BSDPortFactory.cpp

src/BossaWindow.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,12 @@ BossaWindow::OnSerial(wxCommandEvent& event)
279279
Samba& samba = wxGetApp().samba;
280280

281281
wxString port = _portComboBox->GetString(event.GetSelection());
282+
errno = 0;
283+
282284
if (!samba.connect(portFactory.create(std::string(port.mb_str()))))
283285
{
284286
Disconnected();
285-
Error(wxString::Format(_("Could not connect to device on %s"), port.c_str()));
287+
Error(wxString::Format(_("Could not connect to device on %s: %s"), port.c_str(), strerror(errno)));
286288
return;
287289
}
288290

src/EefcFlash.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,23 @@ EefcFlash::writePage(uint32_t page)
276276
_wordCopy.setDstAddr(_addr + page * _size);
277277
_wordCopy.setSrcAddr(_onBufferA ? _pageBufferA : _pageBufferB);
278278
_onBufferA = !_onBufferA;
279-
waitFSR();
279+
// Some chip families have page restrictions on calling EEFC_FCMD_EWP on all pages
280+
// e.g. 16K boundary on SAM4S
281+
// Print a warning indicating that the flash must be erased first
282+
try
283+
{
284+
waitFSR();
285+
}
286+
catch (FlashCmdError& exc)
287+
{
288+
if (page > 0)
289+
{
290+
printf("\nNOTE: Some chip families may not support auto-erase on all flash regions.\n");
291+
printf(" Try erasing the flash first (bossash), or erasing at the same time (bossac).");
292+
fflush(stdout);
293+
}
294+
throw;
295+
}
280296
_wordCopy.runv();
281297
if (_planes == 2 && page >= _pages / 2)
282298
writeFCR1(_eraseAuto ? EEFC_FCMD_EWP : EEFC_FCMD_WP, page - _pages / 2);

src/PosixSerialPort.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@
3232
#include <stdio.h>
3333
#include <unistd.h>
3434
#include <fcntl.h>
35-
#include <errno.h>
3635
#include <termios.h>
37-
#include <errno.h>
3836
#include <sys/ioctl.h>
3937

4038
#include <string>
@@ -290,10 +288,7 @@ PosixSerialPort::put(int c)
290288
void
291289
PosixSerialPort::flush()
292290
{
293-
// There isn't a reliable way to flush on a file descriptor
294-
// so we just wait it out. One millisecond is the USB poll
295-
// interval so that should cover it.
296-
usleep(1000);
291+
tcdrain(_devfd);
297292
}
298293

299294
bool

0 commit comments

Comments
 (0)