Skip to content

Commit

Permalink
Merge pull request stlink-org#77 from WinterMute/mingw
Browse files Browse the repository at this point in the history
Changes to allow compiling for windows using mingw toolchains
  • Loading branch information
texane committed May 14, 2012
2 parents 5cb053d + 620a63c commit d2c78b9
Show file tree
Hide file tree
Showing 18 changed files with 679 additions and 106 deletions.
45 changes: 28 additions & 17 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
nbproject
.project
COPYING
INSTALL
Makefile.in
aclocal.m4
autom4te.cache
config.guess
config.sub
configure
depcomp
install-sh
ltmain.sh
missing
*.bz2
*.lo
*.o
*.elf
doc/tutorial/*.log
doc/tutorial/*.aux
libstlink.a
test_usb
test_sg
gdbserver/st-util
flash/flash
*.log
example/*/*.bin
example/*/*.elf
example/*/*/*.bin
example/*/*/*/*.bin
example/*/*/*.a
example/*/*/*/*.a
.libs
libtool
*.la
config.log
config.status
compile
st-flash
st-util
*.deps*
*.dirstamp
*.a
Makefile
*.exe
example/blink/*.elf
Empty file added ChangeLog
Empty file.
58 changes: 0 additions & 58 deletions Makefile

This file was deleted.

37 changes: 37 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Makefile.am -- Process this file with automake to produce Makefile.in

AUTOMAKE_OPTIONS = subdir-objects

bin_PROGRAMS = st-flash st-util

noinst_LIBRARIES = libstlink.a

st_flash_SOURCES = flash/main.c
st_util_SOURCES = gdbserver/gdb-remote.c gdbserver/gdb-remote.h gdbserver/gdb-server.c mingw/mingw.c mingw/mingw.h

CFILES = \
src/stlink-common.c \
src/stlink-usb.c \
src/stlink-sg.c \
src/uglylogging.c

HFILES = \
src/stlink-common.h \
src/stlink-usb.h \
src/stlink-sg.h \
src/uglylogging.h \
src/mmap.h

libstlink_a_SOURCES = $(CFILES) $(HFILES)

libstlink_a_CPPFLAGS = -std=gnu99 -Wall -Wextra -O2
libstlink_a_LIBADD = $(LIBOBJS)

st_flash_LDADD = libstlink.a
st_flash_CPPFLAGS = -std=gnu99 -Wall -Wextra -O2 -I$(top_srcdir)/src -I$(top_srcdir)/mingw

st_util_LDADD = libstlink.a
st_util_CPPFLAGS = -std=gnu99 -Wall -Wextra -O2 -I$(top_srcdir)/src -I$(top_srcdir)/mingw

EXTRA_DIST = autogen.sh

Empty file added NEWS
Empty file.
2 changes: 2 additions & 0 deletions autogen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
autoreconf --install --force --verbose
40 changes: 40 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.61)
AC_INIT([stlink],[0.5.2],[[email protected]])
AC_CONFIG_SRCDIR([src/stlink-common.c])
AC_CONFIG_LIBOBJ_DIR([src])
AM_INIT_AUTOMAKE([1.10])


# Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL
AC_CANONICAL_HOST
AC_CANONICAL_BUILD
AC_PROG_RANLIB
AM_PROG_CC_C_O

AC_CHECK_HEADERS(sys/mman.h)
AC_CHECK_HEADERS(sys/poll.h)
AC_CHECK_FUNCS(mmap)
AC_REPLACE_FUNCS(mmap pread)

# Checks for libraries.
PKG_CHECK_MODULES(USB, libusb-1.0 >= 1.0.0,,
AC_MSG_ERROR([*** Required libusb-1.0 >= 1.0.0 not installed ***]))
AC_CHECK_LIB([usbpath],[usb_path2devnum],,,-lusb)

LIBS="$LIBS $USB_LIBS"
CFLAGS="$CFLAGS $USB_CFLAGS"

case "${host}" in
*-mingw32*)
LIBS="$LIBS -lws2_32"
CPPFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $CPPFLAGS"
;;
esac
AC_CONFIG_FILES([Makefile])
AC_OUTPUT

2 changes: 1 addition & 1 deletion example/blink/main.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* missing type */

typedef unsigned int uint32_t;

void main(void);

/* hardware configuration */

Expand Down
8 changes: 6 additions & 2 deletions gdbserver/gdb-remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,24 @@
#include <stdlib.h>
#include <unistd.h>
#include <stdint.h>
#ifdef __MINGW32__
#include "mingw.h"
#else
#include <sys/poll.h>
#endif

static const char hex[] = "0123456789abcdef";

int gdb_send_packet(int fd, char* data) {
unsigned length = strlen(data) + 5;
int length = strlen(data) + 5;
char* packet = malloc(length); /* '$' data (hex) '#' cksum (hex) */

memset(packet, 0, length);

packet[0] = '$';

uint8_t cksum = 0;
for(int i = 0; i < strlen(data); i++) {
for(unsigned int i = 0; i < strlen(data); i++) {
packet[i + 1] = data[i];
cksum += data[i];
}
Expand Down
Loading

0 comments on commit d2c78b9

Please sign in to comment.