11# Installing the needed tools
22
3- All tools are available for Linux, Windows and MacOS , most of them even for
3+ All tools are available for Linux, MacOS and Windows , most of them even for
44Raspbian on a RaspberryPi.
55
6- D
6+ SDCC support for the STM8 is still quite fresh and not very mature. It
7+ improves significantly from version to version. Be sure to use
8+ [ the latest snapshot build] ( http://sdcc.sourceforge.net/snap.php ) from the
9+ [ project site on sourceforge] ( http://sdcc.sourceforge.net/ ) , not the older
10+ version that might be included in your distribution.
11+
12+
713
814## Linux
915
16+ Download the lastest snapshot build for SDCC from
17+ http://sdcc.sourceforge.net/snap.php and extract it under ` /opt ` .
18+
19+ mkdir /opt
20+ tar xvjf ~/Downloads/sdcc-snapshot* -C /opt
21+
22+ ` make ` is part of the standard repository for any Linux distribution.
23+ Example for Debian-type systems (like Ubuntu, Mint, Elementary etc.):
24+
25+ apt-get install make
26+
27+ ` stm8flash ` is included in the tools directory of this repository. Copy it
28+ to a convient place in your path, e.g. ` /usr/local/bin ` . To use it you might
29+ need to add a udev rule in order to access the USB port. Save this as root
30+ in in ` /etc/udev/rules.d/99-stlink.rules ` :
31+
32+ # ST-Link/V2 programming adapter
33+
34+ # ST-Link V1, if using a STM8S discovery board
35+ # important: It needs a special entry in /etc/modprob/blacklist
36+ ATTR{idVendor}=="0483", ATTR{idProduct}=="3744", MODE="0666", GROUP="plugdev"
37+
38+ # ST-Link/V2, the china adapter with the green plastic housing
39+ ATTR{idVendor}=="0483", ATTR{idProduct}=="3748", MODE="0666", GROUP="plugdev"
40+
1041
11- easy.
1242
13- apt-get install build-essentials
43+ ## MacOS
44+
45+ Quite similar. [ Install Homebrew] ( https://brew.sh/ ) if you haven't done it
46+ yet, than:
47+
48+ brew make
1449 mkdir /opt
1550 tar xvjf sdcc-snapshot* -C /opt
1651
17- done.
52+ Not sure about stm8flash, I didn't try it. Have a look at the
53+ [ stm8flash repository] ( https://github.com/vdudouyt/stm8flash ) .
54+
1855
1956
2057
2158## Windows
2259
23- Harder, as we need to install some package management first.
60+ Harder, but still possible. It is lacking all the tools, a package system to
61+ install them and even a file system concept where to store them. For
62+ convinience, I collected the bare minimum of needed tools in a
63+ [ separate repository] ( https://github.com/tenbaht/sduino-windowstools ) .
64+ Download it and copy the directory tree into the sduino
65+ directory. Add the sduino/tools/bin directory to your path or move the files
66+ in there to a directory that is already in your path.
67+
68+ You are not bound to ` stm8flash ` , you can use the regular flash tool by ST
69+ as well.
70+
71+
72+
73+ ### The individual pieces
74+
75+ All the tools in the convinience package are 32 bit. If you need the 64 bit
76+ versions you might have to collect them yourself.
77+
78+ You need SDCC, ` make ` with some basic tools and maybe ` stm8flash ` . Get SDCC
79+ from the project website. ` make ` is a standard tool included in either
80+ MinGW/Msys or cygwin. Both are fine, MinGW/Msys is smaller. ` stm8flash ` from
81+ the [ stm8flash repository] ( https://github.com/vdudouyt/stm8flash ) .
82+
2483
25- You need SDCC,
26- make and git. SDCC from the project website, make and git are standard tools
27- included in either MinGW or cygwin. Both are fine, MinGW is smaller.
2884
29- SDCC:
85+ #### SDCC
3086
31- 1 . Download the lastes snapshot build from http://sdcc.sourceforge.net/snap.php
32- 2 . unzip into c:\\ sduino
87+ 1 . Download the lastest snapshot build from http://sdcc.sourceforge.net/snap.php
88+ 2 . unzip into c:\sdcc (use a path name without whitespace)
3389
34- [ MinGW] ( http://www.mingw.org/wiki/MSYS )
90+ You only need support for the stm8. You can safely delete all the files
91+ related to the pic1x CPUs (that safes more than 90% of the used disk space
92+ and leaves only 20MB out of 240MB)
93+
94+
95+ #### MinGW
96+
97+ [ MinGW/MSys] ( http://www.mingw.org/wiki/MSYS ) and
98+ [ cygwin] ( https://www.cygwin.com/ ) are both fine. cygwin aims to be an almost
99+ complete POSIX environment (which is nice, but we don't need it here). MinGW
100+ wants to be more compact and works with the native Windows API. That is good
101+ enough for this purpose.
35102
361031 . Check the
37104 [ MinGW Installation Notes] ( http://www.mingw.org/wiki/Getting_Started )
@@ -46,8 +113,70 @@ SDCC:
46113 command: ` mingw-get install msys-base `
471146 . Now ` ls ` or ` make ` should work.
48115
116+ For efficiency, the Makefile is configured to use dash instead of bash as a
117+ shell. ` egrep ` is replaced by ` grep -E ` . The bare minimum of tools you will
118+ need to run the Arduino.mk makefile:
119+
120+ dash make
121+ awk cat cut expr grep head ls mkdir sed tr uname which
122+
123+
124+
125+
126+ #### stm8flash
127+
128+ A precompiled windows binary was in the stm8flash repository for a while but
129+ got removed at one point. I used an
130+ [ old version] ( https://github.com/vdudouyt/stm8flash/raw/39b1a9ec1dd26030065c3e476fc3b7b89626e21d/stm8flash.exe )
131+ of the file. You might prefer to compile your own version from the
132+ [ stm8flash repository] ( https://github.com/vdudouyt/stm8flash ) using either
133+ MinGW or cygwin. For compiling, you will need the libusb windows binary:
134+ http://libusb.info/ (I used the MinGW32 dll)
135+
136+
137+
138+
139+ ### General problems using Windows
140+
141+ It works, but using the Arduino.mk makefile with Windows is slow. ** Very**
142+ slow. Painfully slow. Compiling-the-Blink-example-takes-about-40-seconds
143+ kind of slow. Yes, seriously. No kidding. 40 seconds. Measured on a 3GHz
144+ machine with 4GB RAM.
145+
146+ There is no easy fix, the underlying problem is a fundamental one. It is not
147+ about the compilation itself, it is the way Makefiles are written and
148+ executed. The whole concept relies on forking subprocesses for all the shell
149+ calls. Unfortunately, there is nothing like a fork in Windows and to work
150+ around that is painfully slow.
151+
152+ It would be great if somebody could manage to modify the original Arduino
153+ build system to support non-C++-builds. Or to integrate it somehow into the
154+ STVD IDE. Or replace the painfully slow parameter checking part of the
155+ makefile (that causes the majority of forking) by a single shell script that
156+ gets called by the makefile and delivers the results in no time. Or use
157+ [ cmake] ( www.cmake.org ) . Or whatever.
158+
159+ Until than the least annoying way out might be using a virtual machine
160+ running a simple Linux system. Ubuntu Mate or a basic Debian install for
161+ example. Virtual Box is great for this purpose and freely available.
162+
163+
164+
165+ ## Possible improvements
166+
167+ ### All-inclusive packages
49168
50- git:
51- https://git-for-windows.github.io/
169+ One of the big convinience points of the Arduino project are the
170+ easy-to-install all-inclusive packages without any external dependencies.
171+ They don't require any prior knowledge to set up a full cross-compiler tool
172+ chain.
52173
174+ Something like that would be very nice for the STM8 as well, but I didn't go
175+ that far. You still have to do some work yourself. You definitly need the
176+ compiler SDCC. ` stm8flash ` is a simple tool to transfer the compiled program
177+ to the CPU, but any other flash tool supporting the SWIM protocol will do.
178+ The build process is controlled by ` make ` . It is a standard tool with any
179+ UNIX system but available for windows as well.
53180
181+ Alternative ways of controlling the build process exist, but then you are
182+ on your own to set it up.
0 commit comments