Skip to content

Commit

Permalink
Added some patches from pull requests
Browse files Browse the repository at this point in the history
  • Loading branch information
LumitoLuma committed Jun 25, 2021
1 parent e63a3d9 commit 88d826b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/BossaWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
18 changes: 17 additions & 1 deletion src/EefcFlash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 1 addition & 6 deletions src/PosixSerialPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <termios.h>
#include <errno.h>
#include <sys/ioctl.h>

#include <string>
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 88d826b

Please sign in to comment.