22
33## stm8gal
44
5- Project page: https://github.com/gicking/stm8gal
5+ Project repository:
6+ [ https://github.com/gicking/stm8gal ] ( https://github.com/gicking/stm8gal )
67
78 git clone [email protected] :gicking/stm8gal.git 89
@@ -37,45 +38,11 @@ Now start the compiler:
3738
3839### For Windows
3940
40- Windows does not support an SPI device. Apply this patch to disable
41- compilation of spi_spidev_comm.c for Windows:
42-
43- ``` diff
44- diff --git a/Makefile b/Makefile
45- index 24b0057..053d17b 100644
46- --- a/Makefile
47- +++ b/Makefile
48- @@ -4,7 +4,7 @@ CC = gcc
49- CFLAGS = -c -Wall -I./STM8_Routines
50- #CFLAGS += -DDEBUG
51- LDFLAGS = -g3 -lm
52- - SOURCES = bootloader.c hexfile.c main.c misc.c serial_comm.c spi_spidev_comm.c spi_Arduino_comm.c
53- + SOURCES = bootloader.c hexfile.c main.c misc.c serial_comm.c spi_Arduino_comm.c
54- INCLUDES = globals.h misc.h bootloader.h hexfile.h serial_comm.h spi_spidev_comm.h spi_Arduino_comm.h main.h
55- STM8FLASH = STM8_Routines/E_W_ROUTINEs_128K_ver_2.1.s19 STM8_Routines/E_W_ROUTINEs_128K_ver_2.0.s19 STM8_Routines/E_W_ROUTINEs_256K_ver_1.0.s19 STM8_Routines/E_W_ROUTINEs_32K_ver_1.3.s19 STM8_Routines/E_W_ROUTINEs_32K_ver_1.4.s19 STM8_Routines/E_W_ROUTINEs_128K_ver_2.2.s19 STM8_Routines/E_W_ROUTINEs_32K_ver_1.0.s19 STM8_Routines/E_W_ROUTINEs_128K_ver_2.4.s19 STM8_Routines/E_W_ROUTINEs_32K_ver_1.2.s19 STM8_Routines/E_W_ROUTINEs_32K_verL_1.0.s19 STM8_Routines/E_W_ROUTINEs_8K_verL_1.0.s19
56- STM8INCLUDES = $(STM8FLASH:.s19=.h)
57- @@ -16,6 +16,7 @@ RM = rm -fr
58- # add optional SPI support via spidev library (Windows not yet supported)
59- ifeq (,$(findstring Win,$(OS)))
60- CFLAGS += -DUSE_SPIDEV
61- + SOURCES += spi_spidev_comm.c
62- endif
63-
64- # add optional GPIO reset via wiringPi library (Raspberry only)
65- diff --git a/misc.c b/misc.c
66- index 9fe02a0..67b5c0d 100644
67- --- a/misc.c
68- +++ b/misc.c
69- @@ -22,7 +22,7 @@
70- // WIN32 specific
71- #if defined(WIN32)
72-
73- - #include "Windows.h"
74- + #include "windows.h"
75-
76- // forground colours
77- #define FG_BLACK 0
78- ```
41+ Windows does not support an SPI device. Apply [ this
42+ patch] ( ../img/no-spi.patch ) to disable the compilation of spi_spidev_comm.c
43+ for Windows:
44+
45+ patch -p1 < no-spi.patch
7946
8047Now compile:
8148
@@ -87,87 +54,11 @@ Now compile:
8754
8855## stm8flash
8956
90- Project page: https://github.com/vdudouyt/stm8flash
57+ Project repository:
58+ [ https://github.com/vdudouyt/stm8flash ] ( https://github.com/vdudouyt/stm8flash )
9159
9260Compiling for Linux and OSX is straight forward, Windows is more
93- complicated. Current versions of stm8flash support the espstlink programmer.
94- The programmer is conneced via USB and a virtual serial port, not over Wifi
95- and for serial access the termios library is used. Being a POSIX function,
96- this is not supported by mingw, only by cygwin. As a workaround I use this
97- patch to disable the espstlink functionality on Windows systems:
98-
99- ``` diff
100- diff --git a/Makefile b/Makefile
101- index 7ed48d1..e76a69f 100644
102- --- a/Makefile
103- +++ b/Makefile
104- @@ -39,6 +39,7 @@ else
105- LIBS = -lusb-1.0
106- LIBUSB_CFLAGS =
107- CC ?= GCC
108- + SKIP_ESP = yes
109- BIN_SUFFIX =.exe
110- endif
111-
112- @@ -47,8 +48,12 @@ override CFLAGS := $(BASE_CFLAGS) $(LIBUSB_CFLAGS) $(CFLAGS)
113-
114-
115- BIN =stm8flash
116- - OBJECTS =stlink.o stlinkv2.o espstlink.o main.o byte_utils.o ihex.o srec.o stm8.o libespstlink.o
117- -
118- + OBJECTS =stlink.o stlinkv2.o main.o byte_utils.o ihex.o srec.o stm8.o
119- + ifeq ($(SKIP_ESP),yes)
120- + override CFLAGS += -DNO_ESP
121- + else
122- + OBJECTS +=espstlink.o libespstlink.o
123- + endif
124-
125- .PHONY: all clean install
126-
127- diff --git a/main.c b/main.c
128- index ce19e47..29a25d2 100644
129- --- a/main.c
130- +++ b/main.c
131- @@ -54,6 +54,7 @@ programmer_t pgms[] = {
132- stlink2_swim_read_range,
133- stlink2_swim_write_range,
134- },
135- + #ifndef NO_ESP
136- {
137- "espstlink",
138- 0,
139- @@ -64,6 +65,7 @@ programmer_t pgms[] = {
140- espstlink_swim_read_range,
141- espstlink_swim_write_range,
142- },
143- + #endif
144- { NULL },
145- };
146-
147- @@ -72,9 +74,15 @@ void print_help_and_exit(const char *name, bool err) {
148- fprintf(stream, "Usage: %s [-c programmer] [-S serialno] [-p partno] [-s memtype] [-b bytes] [-r|-w|-v] <filename>\n", name);
149- fprintf(stream, "Options:\n");
150- fprintf(stream, "\t-? Display this help\n");
151- - fprintf(stream, "\t-c programmer Specify programmer used (stlink, stlinkv2 or espstlink)\n");
152- + fprintf(stream, "\t-c programmer Specify programmer used (stlink, stlinkv2"
153- + #ifndef NO_ESP
154- + " or espstlink"
155- + #endif
156- + ")\n");
157- fprintf(stream, "\t-S serialno Specify programmer's serial number. If not given and more than one programmer is available, they'll be listed.\n");
158- + #ifndef NO_ESP
159- fprintf(stream, "\t-d port Specify the serial device for espstlink (default: /dev/ttyUSB0)\n");
160- + #endif
161- fprintf(stream, "\t-p partno Specify STM8 device\n");
162- fprintf(stream, "\t-l List supported STM8 devices\n");
163- fprintf(stream, "\t-s memtype Specify memory type (flash, eeprom, ram, opt or explicit address)\n");
164- ```
165-
166- Obviously, a better approach would be the use of a simple intermediate
167- cross-platform layer like
168- [ libserialport] ( https://sigrok.org/wiki/Libserialport ) .
169-
170-
61+ complicated.
17162
17263
17364### For Linux
@@ -202,15 +93,39 @@ Compiling stm8flash:
20293
20394### Cross-Compiling for windows on a Linux system
20495
96+ Current versions of stm8flash support the espstlink programmer.
97+ The programmer is conneced via USB and a virtual serial port, not over Wifi
98+ and for serial access the termios library is used. Being a POSIX function,
99+ this is not supported by mingw, only by cygwin. As a workaround apply [ this
100+ patch] ( ../img/no-espstlink-10810e88.patch ) to disable the espstlink
101+ functionality on Windows systems:
102+
103+ patch -p1 < no-espstlink-10810e88.patch
104+
105+ Obviously, a better approach would be the use of a simple intermediate
106+ cross-platform layer like
107+ [ libserialport] ( https://sigrok.org/wiki/Libserialport ) .
108+
109+
205110Required packages:
206111
207112 apt install mingw-w64 mingw-w64-tools
208113
209- Compiling stm8flash:
114+ Get stm8flash and patch the sources to cut out espstlink code :
210115
211116 git clone [email protected] :vdudouyt/stm8flash.git 212117 cd stm8flash
213- make CC=i686-w64-mingw32-gcc RELEASE=yes CFLAGS=-I. PLATFORM=w7
118+ wget https://tenbaht.github.io/sduino/img/no-espstlink-10810e88.patch
119+
120+ Download the 7z file containing the latest [ libusb dll
121+ binary] ( https://github.com/libusb/libusb/releases ) . Unpack the archive into
122+ a new directory inside the stm8flash directory:
123+
124+ 7z -owindows x <libusb-xxx.7z>
125+
126+ Compiling stm8flash (as 32 bit binary for XP compatibility):
127+
128+ make CC=i686-w64-mingw32-gcc RELEASE=yes CFLAGS="-Iwindows/include -Lwindows/MinGW32/dll" PLATFORM=w7
214129
215130
216131
0 commit comments