🇨🇿 Česká verze | 🇬🇧 English
- This is a starter source code tree and
Makefilefor teaching Microprocessor Technology with STM8S. - The tree is designed for the SDCC compiler (or SDCC-gas).
- The Standard Peripheral Library SPL
should (for licensing reasons) be downloaded separately from the manufacturer's website and use the
patch. But I think if you run
make split won't be a sin. - Competition and inspiration:
There are three Makefile variants available in the .make directory. This is because the
SDCC compiler cannot remove dead code. There are three solutions. The first one is
the most optimal, the other two solutions are kept just in case. When you run make
for the first time, the toolchain will switch to the most optimal solution called sdcc.
To select a Makefile, run:
make
# or
make sdcc
# or
make sdcc-gas
# or
make sdccrmYou can switch between Makefile variants later:
make switch-sdcc
make switch-sdcc-gas
make switch-sdccrm
Switching only means creating a symlink to the root directory of the project. On systems that don't support symlinks (like Windows), the file is copied instead, so this operation may be lossy. On normal systems (pretty much all except Windows), this operation is lossless.
For more details, see https://chytrosti.marrek.cz/stm8oss.html
First, you need to select a Makefile. If you haven't done so yet, run:
make
Then you need to configure the microprocessor and its frequency in the Makefile;
optionally the path to SDCC installation, or
STVP.
#DEVICE_FLASH=stm8s103f3
DEVICE_FLASH=stm8s208rb
### STlink version for flash2 target (stm8flash program)
#STLINK=stlinkv2
#STLINK=stlink
STLINK=stlinkv21
F_CPU=16000000
ifeq ($(OS),Windows_NT)
CC_ROOT = "/c/Program Files/SDCC"
STVP_ROOT = "/c/Program Files (x86)/STMicroelectronics/st_toolset/stvp"
else
CC_ROOT = /usr
endif... and then just tinker, program and run make.
| Command | |
|---|---|
make spl |
downloads and prepares libraries |
make |
compiles the project (alias for make ihx) |
make ihx |
compiles to Intel HEX format |
make elf |
compiles to ELF format (with debug info) |
make all |
compiles both (ihx and elf) |
make flash |
uploads the program to the chip. On Linux it uses OpenOCD. On Windows it uses STVP command line version. |
make flash2 |
alternative method (uses stm8flash). |
make reflash |
cleans everything and uploads again |
make clean |
deletes everything that was compiled |
make cleanall |
deletes everything including SPL libraries |
make rebuild |
cleans everything and recompiles |
make openocd |
runs openocd for debugging |
make gdb |
runs STM8-gdb |
make gdbgui |
runs gdbgui (if installed) |
make tree |
displays the project tree |
make spl-renew |
re-downloads SPL libraries |
make switch-sdcc |
switches to pure SDCC Makefile |
make switch-sdcc-gas |
switches to SDCC-gas Makefile |
make switch-sdccrm |
switches to SDCCRM Makefile |
- GNU Make
- GNU Bash -- on Windows it can be installed together with Git.
- SDCC or SDCC-gas
- STM8 binutils (
stm8-gdb,stm8-ld) - OpenOCD for
flashanddebugor STVP forflashon Windows. - (stm8flash for
flash2)
choco install git make vscode mingw