Skip to content

Commit e776462

Browse files
committed
add links to sdunio uno and MB, update tool compiling instructions
1 parent 146c946 commit e776462

4 files changed

Lines changed: 120 additions & 123 deletions

File tree

docs/developer/compiling-the-tools.md

Lines changed: 36 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
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

8047
Now 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

9260
Compiling 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+
205110
Required 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

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
diff --git a/Makefile b/Makefile
2+
index 7ed48d1..eef1710 100644
3+
--- a/Makefile
4+
+++ b/Makefile
5+
@@ -39,6 +39,7 @@ else
6+
LIBS = -lusb-1.0
7+
LIBUSB_CFLAGS =
8+
CC ?= GCC
9+
+ SKIP_ESP = yes
10+
BIN_SUFFIX =.exe
11+
endif
12+
13+
@@ -47,7 +48,12 @@ override CFLAGS := $(BASE_CFLAGS) $(LIBUSB_CFLAGS) $(CFLAGS)
14+
15+
16+
BIN =stm8flash
17+
-OBJECTS =stlink.o stlinkv2.o espstlink.o main.o byte_utils.o ihex.o srec.o stm8.o libespstlink.o
18+
+OBJECTS =stlink.o stlinkv2.o main.o byte_utils.o ihex.o srec.o stm8.o
19+
+ifeq ($(SKIP_ESP),yes)
20+
+ override CFLAGS += -DNO_ESP
21+
+else
22+
+ OBJECTS +=espstlink.o libespstlink.o
23+
+endif
24+
25+
26+
.PHONY: all clean install
27+
diff --git a/main.c b/main.c
28+
index 21c5133..7ab575b 100644
29+
--- a/main.c
30+
+++ b/main.c
31+
@@ -81,6 +81,7 @@ programmer_t pgms[] = {
32+
stlink2_swim_read_range,
33+
stlink2_swim_write_range,
34+
},
35+
+#ifndef NO_ESP
36+
{
37+
"espstlink",
38+
ESP_STLink,
39+
@@ -92,6 +93,7 @@ programmer_t pgms[] = {
40+
espstlink_swim_read_range,
41+
espstlink_swim_write_range,
42+
},
43+
+#endif
44+
{ NULL },
45+
};
46+

docs/img/no-spi.patch

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
diff --git a/Makefile b/Makefile
2+
index 24b0057..053d17b 100644
3+
--- a/Makefile
4+
+++ b/Makefile
5+
@@ -4,7 +4,7 @@ CC = gcc
6+
CFLAGS = -c -Wall -I./STM8_Routines
7+
#CFLAGS += -DDEBUG
8+
LDFLAGS = -g3 -lm
9+
-SOURCES = bootloader.c hexfile.c main.c misc.c serial_comm.c spi_spidev_comm.c spi_Arduino_comm.c
10+
+SOURCES = bootloader.c hexfile.c main.c misc.c serial_comm.c spi_Arduino_comm.c
11+
INCLUDES = globals.h misc.h bootloader.h hexfile.h serial_comm.h spi_spidev_comm.h spi_Arduino_comm.h main.h
12+
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
13+
STM8INCLUDES = $(STM8FLASH:.s19=.h)
14+
@@ -16,6 +16,7 @@ RM = rm -fr
15+
# add optional SPI support via spidev library (Windows not yet supported)
16+
ifeq (,$(findstring Win,$(OS)))
17+
CFLAGS += -DUSE_SPIDEV
18+
+ SOURCES += spi_spidev_comm.c
19+
endif
20+
21+
# add optional GPIO reset via wiringPi library (Raspberry only)
22+
diff --git a/misc.c b/misc.c
23+
index 9fe02a0..67b5c0d 100644
24+
--- a/misc.c
25+
+++ b/misc.c
26+
@@ -22,7 +22,7 @@
27+
// WIN32 specific
28+
#if defined(WIN32)
29+
30+
- #include "Windows.h"
31+
+ #include "windows.h"
32+
33+
// forground colours
34+
#define FG_BLACK 0

mkdocs.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ nav:
3030
- Flash tool: hardware/flashtool.md
3131
# - List of supported boards: hardware.md
3232
- 'Generic STM8S103 breakout board (stm8blue)': hardware/stm8blue.md
33-
- 'ESP14: Wifi board, STM8S003': hardware/esp14.md
33+
- 'ESP14 Wifi board (STM8S003F3P6)': hardware/esp14.md
34+
- 'W1209 thermostat board (STM8S003F3P6)': 'hardware/w1209-thermostat.md'
3435
- 'STM8S105Discovery: Evaluation board made my ST': hardware/stm8sdiscovery.md
35-
- W1209 thermostat board: 'hardware/w1209-thermostat.md'
36+
- 'sduino Uno (STM8S105K6)': https://github.com/roybaer/sduino_uno
37+
- 'sduino MB (STM8S208MB), inspired by Arduino Mega': https://github.com/roybaer/sduino_mb
3638
- Developer Guide:
3739
- IDE integration: 'developer/ide-integration.md'
3840
- Compiling the tools: 'developer/compiling-the-tools.md'

0 commit comments

Comments
 (0)