STM8SVL Discovery Board on Linux

The STM8SVL Discovery Board is an evaluation board for the STM8 value line controller. This article shows the basic steps for using the board on Linux (Ubuntu).

STM8SVL Discovery board

Compiler: SDCC

The STM8 microcontrollers are supported by the SDCC - Small Device C Compiler. Install it on Ubuntu:
sudo apt-get install sdcc

Test firmware: Blinky

Create "main.c":
#define PD_ODR *(unsigned char*)0x500F
#define PD_DDR *(unsigned char*)0x5011
#define PD_CR1 *(unsigned char*)0x5012

int main() {
	int d;

	// LED is connected to D0 on Discovery board STM8SVLDISCOVERY
	PD_DDR = 0x01;
	PD_CR1 = 0x01;

	do {
		PD_ODR ^= 0x01;
		for(d = 0; d < 29000; d++) { }
	} while(1);
}
            
Compile it (outputs "main.ihx"):
sdcc -lstm8 -mstm8 --out-fmt-ihx main.c

Flash tool: stm8flash

The discovery board contains an embedded STLink programmer. You can talk with it with stm8flash.
git clone https://github.com/vdudouyt/stm8flash.git
cd stm8flash
make
sudo make install
Note: The embedded debugger on the discovery board also implements a mass storage device. This doesn't work on my Linux/Ubuntu system: it fails with "FAILED Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK" kernel log messages. A firmware upgrade with the STSW-LINK007 tool under Windows doesn't solve this issue. Nevertheless stm8flash works without any problems with the onboard STLink programmer and we don't need the stuff on the usb drive on Linux.

Now flash our compiled blinky test to the board:
stm8flash -cstlink -pstm8s003?3 -w main.ihx

Links

en STM8SVLDISCOVERY