Introducing Sduino for the STM8

Arduino on the STM8 (8 bit processor)
tenbaht
Posts: 6
Joined: Wed Oct 11, 2017 3:10 pm

Introducing Sduino for the STM8

Post by tenbaht » Wed Oct 11, 2017 4:06 pm

Hi,

last year I adopted the Arduino environment as closely as possible for the STM8. Now user Kenjutsu suggested to link the STM8 board of this forum from my project website as a place for general discussions about my project. I hope that is ok? So far I didn't post any links.

Michael
https://github.com/tenbaht/sduino - Programming the STM8 the Arduino way

User avatar
RogerClark
Posts: 7187
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Introducing Sduino for the STM8

Post by RogerClark » Wed Oct 11, 2017 8:49 pm

Hi...

I know several other people were investigating how Arduino could be run on the STM8.

AFIK no one has written a complete core that is C++ compatible for the STM8, but I think work is still ongoing

Or perhaps the best that is achievable is a C based system, with workarounds for classes

tenbaht
Posts: 6
Joined: Wed Oct 11, 2017 3:10 pm

Re: Introducing Sduino for the STM8

Post by tenbaht » Wed Oct 11, 2017 9:20 pm

Hi Roger!
Yes, that's what I did. Use pure C, but thanks to some preprocessor magic it almost looks like C++. In many cases you get away with a simple search-and-replace to exchange all class-dots with underscores. Converting an existing Arduino library is harder, though.
It would be great if somebody would find a way to use SDCC for real C++ input. There are some ideas around, but AFAIK none is working so far.
https://github.com/tenbaht/sduino - Programming the STM8 the Arduino way

User avatar
RogerClark
Posts: 7187
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Introducing Sduino for the STM8

Post by RogerClark » Wed Oct 11, 2017 9:37 pm

Cool

Is you system integrated into the IDE ?

I looked at the github link, and it looks like its standalone.

We are a bit luckly with the SM32 because the ARM compiler gets installed if you install the Arduino Due or Zero, but I know that other compilers can be used with the IDE because the ESP8266 uses a completely different compiler.

So I presume it would be possible to integrate into the IDE

User avatar
RogerClark
Posts: 7187
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Introducing Sduino for the STM8

Post by RogerClark » Thu Oct 12, 2017 1:11 am

Where do you get the compiler ?

Is it from here

http://sdcc.sourceforge.net/

tenbaht
Posts: 6
Joined: Wed Oct 11, 2017 3:10 pm

Re: Introducing Sduino for the STM8

Post by tenbaht » Thu Oct 12, 2017 7:15 am

Yes, it's the SDCC.
I would love to integrate it into the IDE. I tried that at the beginning, but I never got it to work without having at least one C++ input file. I don't remember the full details anymore, but it was something about a hardwired assumption about filename extentions in this build program, that is distributed as an exe only.
If somebody would find a way to make it work with C only would be great! Right now I am using a Makefile based on the Arduino.mk makefile https://github.com/sudar/Arduino-Makefile.
That works great on Linux and MacOS and is my favorite working style, but unfortunately, windows is not suited very well for this and things get slow there. Really slow. This happens because make heavenly relies on forking the current process which is not supported on Windows and is internally emulated by starting new processes from scratch. And that takes time. A lot of time. Compiling-the-blink-example-takes-40-seconds kind of time. Time wasted just to needlessly starting and killing subprocesses. I guess this is why the Arduino guys came up with their proprietary build system in the first place.
Somebody came up with a python implementation of a simple build system. That might be an improvement, but using the stock Arduino one would be the best.
https://github.com/tenbaht/sduino - Programming the STM8 the Arduino way

User avatar
RogerClark
Posts: 7187
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Introducing Sduino for the STM8

Post by RogerClark » Thu Oct 12, 2017 8:58 am

@tenbaht

No worries

I have looked at the directory structure and its similar to Arduino STM32 but not quite the same

I'm also not sure how the Arduino IDE creates the list of files it needs to send to the compiler.

dannyf
Posts: 150
Joined: Wed May 11, 2016 4:29 pm

Re: Introducing Sduino for the STM8

Post by dannyf » Sun Oct 15, 2017 7:55 pm

tenbaht: welcome. your sduino port is a valuable option for users of STM8.

On the use of SPL: when I ported STM8Sduino, I actually used a middle layer (of mine) that is built on SPL. The overhead is about 2kb (using IAR). As my target was small STM8s (STM8S003F), I thought that was too costly and went to a middle layer that doesn't rely on the SPL and then completely wrote out the middle layer - the overhead now is about 0.5 - 0.75kb.

It may be helpful if you look into your code and see which functions are taking up the most space and gradually replace them with your own code to save space.

Just my 2cents.

tenbaht
Posts: 6
Joined: Wed Oct 11, 2017 3:10 pm

Re: Introducing Sduino for the STM8

Post by tenbaht » Mon Oct 16, 2017 8:27 am

Hi danny,

Yes, the SPL is a memory hog and quite complicated to use. The only advantage I can see in using it would be to be prepared for an easier migration to the STM32.

That's why I don't use it for Sduino anymore. It is still part of the source code, but the only function still used is the serial initialization code - and this is on it's way out as well. But so far I am still planning to keep the SPL related to Sduino to allow for easy integration of SPL-based example programs by the user.

To avoid the 2kB penalty of linking dead code I wrote a Makefile that breaks up the SPL source files into single-function source files and compiles them separately. This way only the functions that are actually used get linked into the project and no dead code is left. So it is possible to use SPL, but it doesn't cost anything if you don't.
https://github.com/tenbaht/sduino - Programming the STM8 the Arduino way

ag123
Posts: 777
Joined: Thu Jul 21, 2016 4:24 pm

Re: Introducing Sduino for the STM8

Post by ag123 » Sat Oct 21, 2017 4:49 pm

it seemed that a google search for sdcc and stm8 turns up quite a number of articles, are there any 'known' limitations / issues / problems of sdcc say vs the more 'commercial' compilers?

it seemed with stm8s one of the main problem seem to be debug as stm8s don't do swd
https://www.cnx-software.com/2015/04/13 ... -in-linux/

any one figured out more than the above? which seem to suggest debug for stm8s is probably hitting a wall with open sourced tools.

Post Reply