So this is a pretty cringe project with a cringe name by someone who does not know anything about embedded development and is pretty shit at software development. But it may against all odds help someone get started with the STM8 development on a POSIX system for people who don't want to write everything by hand or entertain the notion of using an eclipse based IDE.
I have no understanding of any of this and it is all just things that I managed to get working somehow.
Pull requests are not expected but would be very welcome.
Major thanks goes out to the dude who wrote this blog post. The bulk of all the installation steps in the requirements sections are pretty much copied verbatim and a lotr of what was written here was used as the base for this.
Just run forge.py --cube-file my-poject.txt
And you can then flash your device by running ninja flash
Forge will hopefully complain if it can't find the stuff it needs.
- Generate a ninja build file to build a project using SDCC
- Automatically resolves the used peripherals from the STM8CubeMx report file (the .txt ones) and include the appropriate files from the
STM8S_StdPeriph
library (not included) - Setup a build target for flashing a device using stm8flash matching the MCU used
- Support building for debugging
- Will create a file (
serve_openocd
) to start an openocd instance matching the MCU used - Has cringy colors in the output like some fancy kind of thing
- Pretends to be robust and do some error checking
- Has lofty plans to add code generation
- Lose interest, move on to something else and never touch this again
- Add a way to manually specify things besides CubeMx
- Add code generation for peripherals
- Better cli interface
- Dockerfile for dependencies
- Generalize and add support for completely different MCUs
These are the things that you pretty much have to have.
Version 3.something, probably at least 10. Can be found wherever you get your python installations from
Used for the actuall building
3.5 or higher i guess. This is how i got mine, your mileage may vary:
# download the latest version
$ wget https://sourceforge.net/projects/sdcc/files/sdcc-linux-amd64/4.3.0/sdcc-4.3.0-amd64-unknown-linux2.5.tar.bz2
$ tar -xjf ./sdcc-4.3.0-amd64-unknown-linux2.5.tar.bz2
$ cd sdcc
$ sudo cp -r * /usr/local
Whatever version is avaliable, have fun.
Download the STM8S standard peripheral library which is hidden away behind some moronic license.
You will need to patch the libs to make it compatible with SDCC.
Your mileage may vary here as well. I had some issues getting rid of a bunch of warnings so i needed to
add void _assert_failed(void);
to my main file to get SDCC to shut up.
What forge will use to flash your thing
$ git clone https://github.com/vdudouyt/stm8flash.git
$ cd stm8flash
$ make
$ sudo make install
This is kinda fun if you are into debugging. But also a bit of a hassle and takes a while.
$ wget https://sourceforge.net/projects/stm8-binutils-gdb/files/stm8-binutils-gdb-sources-2018-03-04.tar.gz/download -O stm8-binutils-gdb-sources-2018-03-04.tar.gz
$ tar -xf stm8-binutils-gdb-sources-2018-03-04.tar.gz
$ cd stm8-binutils-gdb-sources
$ ./patch_binutils.sh
$ ./configure_binutils.sh
$ cd binutils-2.30
$ make
$ sudo make install
Note: To get the TUI working, which is fun, you will have to install the development files for ncursesw. If you don*t do this you will get no indication that TUI is disabled.
This is neat and sets creates a connection between the MCU and your computer that gdb (or other debuggers i guess) can use.