Skip to content

Commit

Permalink
Make stm32flash work in Linux as well. Fixes to Makefile and serial f…
Browse files Browse the repository at this point in the history
…lushing.
  • Loading branch information
nakedible committed Jan 22, 2014
1 parent 7048e90 commit 8fee92f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@ AR = $(CROSS_COMPILE)ar
export CC
export AR

CCFLAGS = -Wall
ifeq ($(UNAME_S),Darwin)
CCFLAGS += -mmacosx-version-min=10.6
endif

all:
$(MAKE) -C parsers
$(CC) -g -o stm32flash -I./ \
$(CC) $(CCFLAGS) -g -o stm32flash -I./ \
main.c \
utils.c \
stm32.c \
serial_common.c \
serial_platform.c \
parsers/parsers.a \
stm32/stmreset_binary.c \
-Wall \
-mmacosx-version-min=10.6 \
-DUSE_SERIAL_RESET

clean:
Expand Down
6 changes: 6 additions & 0 deletions serial_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,9 @@ const char* serial_get_setup_str(const serial_t *h) {

serial_err_t serial_reset(const serial_t *serial, int dtr) {
int state;
#ifdef __APPLE__
int flush = FREAD | FWRITE;
#endif

int err = ioctl(serial->fd, TIOCMGET, &state);
if (err)
Expand All @@ -249,7 +251,11 @@ serial_err_t serial_reset(const serial_t *serial, int dtr) {
usleep(10000);

// Flush any pending I/O
#ifdef __APPLE__
err = ioctl(serial->fd, TIOCFLUSH, &flush);
#else
err = ioctl(serial->fd, TCFLSH, TCIOFLUSH);
#endif
if (err)
return SERIAL_ERR_SYSTEM;

Expand Down

0 comments on commit 8fee92f

Please sign in to comment.