Skip to content

Commit 8b3002a

Browse files
committed
getting ready for release of 0.3.0: halbfertig.
1 parent 31bd06c commit 8b3002a

6 files changed

Lines changed: 179 additions & 169 deletions

File tree

README.md

Lines changed: 59 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
Getting started on the STM8 CPU the easy way by using an Arduino-like
44
programming API.
55

6-
This project makes the most important features of the Arduino API available
7-
for the STM8S. It is based on free tools that are available for Linux,
8-
MacOS, and Windows: SDCC, make, and stm8flash.
6+
This project is based on free tools that are available for Linux, MacOS, and
7+
Windows: SDCC, make, and stm8flash. Since it's based on the SDCC Small
8+
Devices compiler, I called it "Small Devices -uino" or "Small-duino".
99

10-
Since it's based on the SDCC Small Devices compiler, I called it "Small
11-
Devices -uino" or "Small-duino".
10+
It fully integrates with the Arduino IDE or can be used
11+
independently (GUI-less) with very easy Makefiles based on the amazing
12+
[Arduino.mk makefile](https://github.com/sudar/Arduino-Makefile) by
13+
[Sudar](http://sudarmuthu.com>).
1214

1315
This project is not supposed to be “better than Arduino”. It’s purpose
1416
is to give you a head start into a different CPU architecture if you happen
@@ -29,147 +31,85 @@ forum. It will help to catch my attention to prefix your topic with
2931
"[sduino]".
3032

3133

32-
## Table of Contents
33-
34-
* [Project Website](https://tenbaht.github.io/sduino/)
35-
* [Usage example](#usage)
36-
* [Supported hardware](#supported-hardware)
37-
* [Why use a STM8 instead of an ATmega?](#why-use-a-stm8-instead-of-an-atmega)
38-
* [Library support](#library-support)
39-
* [Compatibility with the Arduino world](#compatibility-with-the-arduino-world)
40-
41-
42-
43-
44-
## Usage example
45-
46-
*Preview: IDE integration is on the way now! It already works for Linux (and
47-
probably MacOS), Windows is to follow soon*
48-
49-
If you have ever used the Arduino environment before you will feel at home
50-
right away, despite this project beeing based on a makefile rather than the
51-
full Arduino IDE. But don't be afraid, it is based on the amazing
52-
[Arduino.mk makefile](https://github.com/sudar/Arduino-Makefile) by
53-
[Sudar](http://sudarmuthu.com>) to control the build process, that makes
54-
everything very easy.
55-
56-
First, let's make an LED blink using the Blink example from Arduino:
57-
58-
```c
59-
/*
60-
Blink
61-
Turns on an LED on for one second, then off for one second, repeatedly.
34+
## Installation
6235

63-
This example code is in the public domain.
64-
*/
36+
Starting with version 0.3.0 automatic IDE integration is supported via the
37+
Arduino Boards Manager. This is the recommanded way of installation now. For
38+
a manual non-IDE installation please check the full [installation
39+
instructions](https://tenbaht.github.io/sduino/install/).
6540

66-
#include <Arduino.h>
41+
Arduino IDE versions 1.8.5 and 1.6.13 are tested, but any version >=1.6.6
42+
should work.
6743

68-
// Pin 13 has an LED connected on most Arduino boards.
69-
// Pin 3 for the STM8S103 break out board
70-
// give it a name:
71-
int led = LED_BUILTIN;
44+
Supported Systems:
45+
* Linux 64 bit: Tested on Ubuntu 16.04
46+
* Linux 32 bit: Tested on Ubuntu 16.04
47+
* Windows: Tested on Windows 7. Sduino might work on XP (not tested), but
48+
the ST-Link/V2 driver is not available anymore for XP.
49+
* MacOS: Not tested, but should be very close to working. Will need a manual
50+
install, but IDE integration should be easy now. Any volunteers?
7251

73-
// the setup routine runs once when you press reset:
74-
void setup() {
75-
// initialize the digital pin as an output.
76-
pinMode(led, OUTPUT);
77-
}
52+
Start the Arduino-IDE. In File->Preferences, Settings tab, enter
53+
https://github.com/tenbaht/sduino/raw/master/package_sduino_stm8_index.json
54+
as an Additional Boards Manager URL.
7855

79-
// the loop routine runs over and over again forever:
80-
void loop() {
81-
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
82-
delay(1000); // wait for a second
83-
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
84-
delay(1000); // wait for a second
85-
}
86-
```
56+
Open Tools->Board:...->Boards Manager. Find Sduino by typing 'sd' into
57+
the search line. Click on the list entry, Click on Install.
8758

88-
All we need for a full build is this very basic `Makefile`:
59+
Now you should find a new entry "STM8S Boards" in the list at
60+
Tools->Board:... Choose *STM8S103F3 Breakout Board* from the list, open the
61+
standard Blink example from File->Examples->01. Basics->Blink and compile it
62+
by hitting 'Verify'.
8963

90-
```make
91-
BOARD_TAG = stm8sblue
9264

93-
include ../../sduino/sduino.mk
94-
```
9565

96-
Compile and upload it:
66+
### Uploading to the board
9767

98-
make upload
68+
To upload the compiled sketch to the hardware you need an ST-Link/V2
69+
compatible flash programmer. They are very cheap, starting at $2.50 on
70+
Aliexpress or eBay.
9971

100-
Done! Your first STM8 based project is up and running!
72+
#### ST-Link/V2 for Linux
10173

74+
Required lines in /etc/udev/rules.d/99-stlink.rules:
10275

103-
## Supported hardware
76+
# ST-Link/V2 programming adapter
10477

105-
Anything with an STM8S103 or STM8S003 should work. For example, the
106-
70-cent-[STM8S103 breakout boards](https://tenbaht.github.io/sduino/hardware/stm8blue),
107-
[ESP14 Wifi boards](https://tenbaht.github.io/sduino/hardware/esp14),
108-
or even the [W1209 thermostat boards](https://www.aliexpress.com/wholesale?SearchText=w1209)
109-
that are abundant on aliexpress and Amazon. All you need to get started is a
110-
simple ST-Link/V2 compatible flash programmer, available for less then $3
111-
from China.
78+
# ST-Link V1, ST-Discovery boards
79+
ATTR{idVendor}=="0483", ATTR{idProduct}=="3744", MODE="0666", GROUP="pl
11280

113-
The STM8 series by ST might be the cheapest CPUs on the market while still
114-
being as powerful as the ATmega series. That makes them every Chinese
115-
engineer's darling and chances are pretty good that you will find an '003 if
116-
you crack open any cheap appliance like an irrigation, temperature, or
117-
charging controller.
81+
# ST-Link/V2, the china adapter with the green plastic housing
82+
ATTR{idVendor}=="0483", ATTR{idProduct}=="3748", MODE="0666", GROUP="pl
11883

119-
The '003 or '103 CPUs feature a 16MHz internal oscillator, 8kB flash, 1kB
120-
RAM and 128 or 640 byte EEPROM. They both include a UART, SPI, I2C, PWM,
121-
five 10 bit ADC inputs, 3 timers, and up to 14 I/O pins - quite similar to
122-
an Atmel ATmega8 as it was used on the first Arduino boards.
12384

124-
Support for the more powerful
125-
[STM8S105 Discovery board](https://tenbaht.github.io/sduino/hardware/stm8sdiscovery)
126-
is very fresh, but should work now. At least Blink.c works already. These
127-
amazing $9 boards offer even more resources, come with a build-in flash
128-
programmer and are very similar to an Arduino Uno with an ATmega328 CPU.
12985

130-
Find more information here: [Supported Boards](https://tenbaht.github.io/sduino/hardware)
86+
#### ST-Link/V2 for Windows
13187

88+
Download and install the ST-Link/v2 driver **before you plug in the flash
89+
tool**: [STSW-LINK009 driver download]
90+
(http://www.st.com/en/development-tools/stsw-link009.html) (Registration
91+
required, but very easy)
13292

13393

134-
## Why use a STM8 instead of an ATmega?
94+
#### Serial upload
13595

136-
The fairly new ESP-14 module includes a STM8S003F3P6. Wifi and a
137-
programmable I/O-CPU for just over two dollars - that might be the most
138-
compelling reason to get started on the STM8S series. Apart from pure
139-
curiosity and eagerness to learn something new, of course.
96+
Most larger STM8 CPUs (unfortunately not the popular STM8S103) even come
97+
with a builtin bootloader. Support for programming via a simple serial
98+
adapter for these devices is planned, but not implemented yet.
14099

141-
The simple STM8S103F breakout boards are powerful and dirt cheap. They cost
142-
well under one dollar. You can get three boards and one flash programmer
143-
together for well under five dollars on http://www.aliexpress.com/ ,
144-
including shipping from China.
145100

146-
The major downside is the lack of information and community support for the
147-
STM8. The community support and the sheer number of existing libraries for
148-
all kinds of sensors and hardware is outstanding in the Arduino world. If
149-
you just want to get something done, go for an Arduino board. Nothing will
150-
give you faster and easier results.
151101

152-
For commercial use the STM8S offers some interesting advantages:
153-
154-
**Motor control**: The STM8 has a strong focus on motor and position control
155-
systems. Things you need to handle yourself on an ATmega are implemented in
156-
hardware and work independently of the state of the software. There is even
157-
hardware support for quadrature encoders as used in position sensors and
158-
rotary encoders.
159-
160-
**Low power modes**: The numbers in the datasheets don't look that different,
161-
but in real life the STM8 can be powered two or three times longer using the
162-
same battery capacity due to the finer control on the power modes (very,
163-
very careful programming required).
102+
## Compatibility with the Arduino world
164103

165-
**Value for the money**: 40 to 60 cents for a STM8 with 14 I/O pins compared to
166-
$1.60-$3.00 for an ATmega8.
104+
Unfortunatly there is no free C++ compiler for the STM8. This makes it
105+
impossible to do a full 1:1 port of the whole enviroment as is has been done
106+
for the STM32 and the ESP8266.
167107

168-
**Upgrade path**: The peripheral units of the STM8 are identical or at least
169-
very, very similar to the ones used with the STM32 family of 32 bit
170-
ARM-Cortex CPUs. This makes it is relatively easy to migrate existing
171-
software between the 8- and the 32-bit world. This is quite unique among the
172-
other CPUs.
108+
This is not a drop-in replacement for an AVR, but thanks to some C
109+
preprocessor magic the programming API is still very, very similar and it is
110+
often enough to just move over the opening bracket of the class
111+
instanciation statement and to replace the dot in a method call for an
112+
underscore.
173113

174114

175115

@@ -185,24 +125,3 @@ HD44780 controller.
185125

186126
For more sophisticated output there are libraries for Nokia-5110-type
187127
graphical LCDs and SSD1306-based graphical OLED displays.
188-
189-
190-
191-
## Compatibility with the Arduino world
192-
193-
I adopted the Arduino core functionality for the STM8S to set up a simple
194-
programming environment. But unfortunatly there is no free C++ compiler
195-
for these CPUs. This makes it impossible to do a full port of the whole
196-
enviroment and integrate it with the Arduino IDE and build system as it
197-
has been done for the STM32 and the ESP8266.
198-
199-
This is not a drop-in replacement for an AVR, but the programming API is
200-
still very, very similar. Thanks to some C preprocessor magic it is often
201-
enough to just move over the opening bracket of the class instanciation
202-
statement and to replace the dot in a method call for an underscore.
203-
204-
The whole Arduino build system is deeply based on the assumption of
205-
processing C++ source files. I am not sure if it would be even possible to
206-
configure a build process based only on C files without modifing the IDE
207-
sources. This makes a full IDE integration very unlikely.
208-

board-manager/gen_platform_entry.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ list_boards()
6565

6666
cat << EOF
6767
{
68-
"name": "Sduino test core",
68+
"name": "Sduino STM8 plain C core (non-C++)",
6969
"architecture": "stm8",
7070
"version": "$COREVERSION",
7171
"category": "Contributed",

board-manager/gen_tools_entry.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,20 @@ VERSION=$2
3232
### helper functions #####################################################
3333

3434
# format ID information for a file
35+
#
36+
# usage: print_filedata filename
37+
#
3538
print_filedata()
3639
{
3740
URL=file://$(realpath $1)
3841
FILENAME=$(basename "$1")
3942
SIZE=$(stat --printf="%s" $1)
4043
CHKSUM=$(shasum -a 256 $1|cut "-d " -f1)
41-
cat << EOF
42-
"url": "$URL",
43-
"archiveFileName": "$FILENAME",
44-
"checksum": "SHA-256:$CHKSUM",
45-
"size": "$SIZE"
44+
cat << EOF
45+
"url": "$URL",
46+
"archiveFileName": "$FILENAME",
47+
"checksum": "SHA-256:$CHKSUM",
48+
"size": "$SIZE"
4649
EOF
4750
}
4851

docs/hardware/flashtool.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ SWD):
4848

4949
## Installation for Linux
5050

51-
For Linux: required lines in /etc/udev/rules.d/99-stlink.rules:
51+
Required lines in /etc/udev/rules.d/99-stlink.rules:
5252

5353
# ST-Link/V2 programming adapter
5454

@@ -59,6 +59,16 @@ For Linux: required lines in /etc/udev/rules.d/99-stlink.rules:
5959
ATTR{idVendor}=="0483", ATTR{idProduct}=="3748", MODE="0666", GROUP="plugdev"
6060

6161

62+
63+
## Installation for Windows
64+
65+
Download and install the ST-Link/v2 driver **before you plug in the flash
66+
tool**:
67+
[STSW-LINK009 driver download](http://www.st.com/en/development-tools/stsw-link009.html)
68+
(Registration required, but very easy)
69+
70+
71+
6272
## Connection to the CPU board
6373

6474
The pinout of the SWIM connector P3 on my STM8S103 breakout board fits the

package_sduino_stm8_index.json

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
{
2+
"packages": [
3+
{
4+
"name": "sduino",
5+
"maintainer": "Tenbaht",
6+
"websiteURL": "https://tenbaht.github.io/sduino/",
7+
"email": "[email protected]",
8+
"help": {
9+
"online": "http://www.stm32duino.com/viewforum.php?f=52"
10+
},
11+
"platforms" : [
12+
{
13+
"name": "Sduino STM8 plain C core (non-C++)",
14+
"architecture": "stm8",
15+
"version": "0.3.0-pre.1",
16+
"category": "Contributed",
17+
"boards": [
18+
{"name": "STM8S103F3 Breakout Board"},
19+
{"name": "STM8S105C6 Discovery Board"}
20+
],
21+
"toolsDependencies": [
22+
{
23+
"name": "STM8Tools",
24+
"version": "2017.10.21",
25+
"packager": "sduino"
26+
},
27+
{
28+
"name": "sdcc",
29+
"version": "build.10088",
30+
"packager": "sduino"
31+
}
32+
],
33+
"url": "https://github.com/tenbaht/just_a_test/releases/download/v0.1/sduino-core-0.3.0-pre.1.tar.bz2",
34+
"archiveFileName": "sduino-core-0.3.0-pre.1.tar.bz2",
35+
"checksum": "SHA-256:5e3b2b950954e1004ef78084063374c59b37f682ba43f1789bc40d66d88e9994",
36+
"size": "4261038"
37+
}
38+
],
39+
"tools" : [
40+
{
41+
"name": "STM8Tools",
42+
"version": "2017.10.21",
43+
"systems": [
44+
{
45+
"host": "i686-pc-linux-gnu",
46+
"url": "https://github.com/tenbaht/just_a_test/releases/download/v0.1/sduino-tools_linux32-2017.10.21.tar.bz2",
47+
"archiveFileName": "sduino-tools_linux32-2017.10.21.tar.bz2",
48+
"checksum": "SHA-256:5f10d3de3e044e03160e63252ed818754c177afe5e9b5ce73a656f779193cffe",
49+
"size": "44516"
50+
},{
51+
"host": "x86_64-pc-linux-gnu",
52+
"url": "https://github.com/tenbaht/just_a_test/releases/download/v0.1/sduino-tools_linux64-2017.10.21.tar.bz2",
53+
"archiveFileName": "sduino-tools_linux64-2017.10.21.tar.bz2",
54+
"checksum": "SHA-256:0943f76ad2a7eef325e1ab858212c2413123521768ea9a06f946a2b238e0a100",
55+
"size": "49065"
56+
},{
57+
"host": "i686-mingw32",
58+
"url": "https://github.com/tenbaht/just_a_test/releases/download/v0.1/sduino-tools_mingw32-2017.10.21.tar.bz2",
59+
"archiveFileName": "sduino-tools_mingw32-2017.10.21.tar.bz2",
60+
"checksum": "SHA-256:dfdc7364a0d6749d3d1693ce5b5311ace4d80425225c98a90c5c527e375d1ecd",
61+
"size": "5541472"
62+
}
63+
]
64+
},
65+
{
66+
"name": "sdcc",
67+
"version": "build.10088",
68+
"systems": [
69+
{
70+
"host": "x86_64-pc-linux-gnu",
71+
"url": "https://github.com/tenbaht/just_a_test/releases/download/v0.1/sdcc-stm8-amd64-unknown-linux2.5-20171020-10088.tar.bz2",
72+
"archiveFileName": "sdcc-stm8-amd64-unknown-linux2.5-20171020-10088.tar.bz2",
73+
"checksum": "SHA-256:dce37df6f57f6264e6b705cf7ce394d9b4407dba53c4071e77bfa34f746599a6",
74+
"size": "2486676"
75+
},{
76+
"host": "i686-pc-linux-gnu",
77+
"url": "https://github.com/tenbaht/just_a_test/releases/download/v0.1/sdcc-stm8-i386-unknown-linux2.5-20171020-10088.tar.bz2",
78+
"archiveFileName": "sdcc-stm8-i386-unknown-linux2.5-20171020-10088.tar.bz2",
79+
"checksum": "SHA-256:5237465f22f62beb69c62a14adf1e1140fe12fc29060329c61516c11fe4bacf2",
80+
"size": "2606938"
81+
},{
82+
"host": "i686-mingw32",
83+
"url": "https://github.com/tenbaht/just_a_test/releases/download/v0.1/sdcc-stm8-i586-mingw32msvc-20171020-10088.tar.bz2",
84+
"archiveFileName": "sdcc-stm8-i586-mingw32msvc-20171020-10088.tar.bz2",
85+
"checksum": "SHA-256:2c9db6ff4d2f7b7b608f956adbc06e24ac8ec4dd4f41f26c79c48f9ddecb22a5",
86+
"size": "2973875"
87+
}
88+
]
89+
}
90+
]
91+
}
92+
]
93+
}

0 commit comments

Comments
 (0)