diff --git a/Makefile b/Makefile index 70c8a89..9c128de 100644 --- a/Makefile +++ b/Makefile @@ -153,8 +153,15 @@ WXVERSION=2.8 endif +# +# FreeBSD rules. Tested on 12.1. +# ifeq (${OS},FreeBSD) +# Readline and Wxwidgets are installed under /usr/local on Freebsd +COMMON_CXXFLAGS=-I/usr/local/include +COMMON_LDFLAGS=-L/usr/local/lib + # This is only needed for bossash, but we can't add it to BOSSASH_LIBS here # because that one is redefined later. COMMON_SRCS+=PosixSerialPort.cpp BSDPortFactory.cpp diff --git a/src/BossaWindow.cpp b/src/BossaWindow.cpp index 9b453e6..81a46ce 100644 --- a/src/BossaWindow.cpp +++ b/src/BossaWindow.cpp @@ -279,10 +279,12 @@ BossaWindow::OnSerial(wxCommandEvent& event) Samba& samba = wxGetApp().samba; wxString port = _portComboBox->GetString(event.GetSelection()); + errno = 0; + if (!samba.connect(portFactory.create(std::string(port.mb_str())))) { Disconnected(); - Error(wxString::Format(_("Could not connect to device on %s"), port.c_str())); + Error(wxString::Format(_("Could not connect to device on %s: %s"), port.c_str(), strerror(errno))); return; } diff --git a/src/EefcFlash.cpp b/src/EefcFlash.cpp index cf44724..c8d62c1 100644 --- a/src/EefcFlash.cpp +++ b/src/EefcFlash.cpp @@ -276,7 +276,23 @@ EefcFlash::writePage(uint32_t page) _wordCopy.setDstAddr(_addr + page * _size); _wordCopy.setSrcAddr(_onBufferA ? _pageBufferA : _pageBufferB); _onBufferA = !_onBufferA; - waitFSR(); + // Some chip families have page restrictions on calling EEFC_FCMD_EWP on all pages + // e.g. 16K boundary on SAM4S + // Print a warning indicating that the flash must be erased first + try + { + waitFSR(); + } + catch (FlashCmdError& exc) + { + if (page > 0) + { + printf("\nNOTE: Some chip families may not support auto-erase on all flash regions.\n"); + printf(" Try erasing the flash first (bossash), or erasing at the same time (bossac)."); + fflush(stdout); + } + throw; + } _wordCopy.runv(); if (_planes == 2 && page >= _pages / 2) writeFCR1(_eraseAuto ? EEFC_FCMD_EWP : EEFC_FCMD_WP, page - _pages / 2); diff --git a/src/PosixSerialPort.cpp b/src/PosixSerialPort.cpp index 45eaca9..ccd9848 100644 --- a/src/PosixSerialPort.cpp +++ b/src/PosixSerialPort.cpp @@ -32,9 +32,7 @@ #include #include #include -#include #include -#include #include #include @@ -290,10 +288,7 @@ PosixSerialPort::put(int c) void PosixSerialPort::flush() { - // There isn't a reliable way to flush on a file descriptor - // so we just wait it out. One millisecond is the USB poll - // interval so that should cover it. - usleep(1000); + tcdrain(_devfd); } bool