26
The free toolchain for the STM8 Getting into first place when non-free tools had years of head start Philipp Klaus Krause February 3, 2018

The free toolchain for the STM8 - FOSDEMThe free toolchain for the STM8 Getting into first place when non-free tools had years of head start Philipp Klaus Krause February 3, 2018

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: The free toolchain for the STM8 - FOSDEMThe free toolchain for the STM8 Getting into first place when non-free tools had years of head start Philipp Klaus Krause February 3, 2018

The free toolchain for the STM8Getting into first place when non-free tools had years of head

start

Philipp Klaus Krause

February 3, 2018

Page 2: The free toolchain for the STM8 - FOSDEMThe free toolchain for the STM8 Getting into first place when non-free tools had years of head start Philipp Klaus Krause February 3, 2018

Table of Contents

STM8

ST-Link

stm8flashstm8gal

SDCC

LLVMEclipse

Code::Blocks

OpenOCDGDB

Page 3: The free toolchain for the STM8 - FOSDEMThe free toolchain for the STM8 Getting into first place when non-free tools had years of head start Philipp Klaus Krause February 3, 2018

Table of Contents

STM8

ST-Link

stm8flashstm8gal

SDCC

LLVMEclipse

Code::Blocks

OpenOCDGDB

Page 4: The free toolchain for the STM8 - FOSDEMThe free toolchain for the STM8 Getting into first place when non-free tools had years of head start Philipp Klaus Krause February 3, 2018

STM8 microcontrollers

High-performance 8-bit coreRich set of peripherals similar to STM32C-friendly architectureUp to 6 KB of RAM, 128 KB of flashCheapBillions made

Page 5: The free toolchain for the STM8 - FOSDEMThe free toolchain for the STM8 Getting into first place when non-free tools had years of head start Philipp Klaus Krause February 3, 2018

Table of Contents

STM8

ST-Link

stm8flashstm8gal

SDCC

LLVMEclipse

Code::Blocks

OpenOCDGDB

Page 6: The free toolchain for the STM8 - FOSDEMThe free toolchain for the STM8 Getting into first place when non-free tools had years of head start Philipp Klaus Krause February 3, 2018

What is SDCC?

Standard C compiler (ANSI C89, ISO C90, ISO C99, ISO C11)Freestanding implementation or part of a hostedimplementationSupporting tools (assembler, linker, simulator, ...)Works on many host systems (GNU/Linux, Windows, MacOS, NetBSD, FreeBSD, OpenBSD, Hurd, ...)Targets various 8-bit architectures (MCS-51, DS80C390, Z80,Z180, Rabbit 2000, Rabbit 3000A, GBZ80, TLCS-90, HC08,S08, STM8, PIC)Has some unusual optimizations that make sense for thesetargets (in particular in register allocation)

Page 7: The free toolchain for the STM8 - FOSDEMThe free toolchain for the STM8 Getting into first place when non-free tools had years of head start Philipp Klaus Krause February 3, 2018

Optimal Register Allocation in Polynomial Time

Register allocator based on graph-structure theoryOptimal register allocation in polynomial timeFlexible through use of cost functionProvides substantial improvements in code qualityBut slow for architectures with many registersCompilation speed / code quality trade-off:–max-allocs-per-node

Page 8: The free toolchain for the STM8 - FOSDEMThe free toolchain for the STM8 Getting into first place when non-free tools had years of head start Philipp Klaus Krause February 3, 2018

Bytewise Register Allocation and Spilling

Decide on the storage of variables bytewiseDecide for each individual byte in a variable whether to storeit in memory or a registerConsider any byte of any register as a possible storage location

Page 9: The free toolchain for the STM8 - FOSDEMThe free toolchain for the STM8 Getting into first place when non-free tools had years of head start Philipp Klaus Krause February 3, 2018

Regression testing

Regression testing of nightly snapshots≈ 10000 tests compiled and executed on simulatorTests mostly from fixed bugs and from GCCTargets architectures: MCS-51, DS390, Z80, Z180, GBZ80,Rabbit 2000, Rabbit 3000A, TLCS-90, HC08, S08, STM8Host OS: GNU/Linux, Windows, MacOSHost architectures: i386, x86_64, ppc, arm

Page 10: The free toolchain for the STM8 - FOSDEMThe free toolchain for the STM8 Getting into first place when non-free tools had years of head start Philipp Klaus Krause February 3, 2018

SDCC vs. non-free compilers: Benchmark scores

Page 11: The free toolchain for the STM8 - FOSDEMThe free toolchain for the STM8 Getting into first place when non-free tools had years of head start Philipp Klaus Krause February 3, 2018

SDCC vs. non-free compilers: Code size

Page 12: The free toolchain for the STM8 - FOSDEMThe free toolchain for the STM8 Getting into first place when non-free tools had years of head start Philipp Klaus Krause February 3, 2018

SDCC vs. non-free compilers: Summary

Standard compl. Code speed Code size OS support LicenseSDCC 3.5.0 + - - + +Cosmic ◦ ◦ ◦ ◦ -Raisonance - - + - -IAR + ◦ - - -SDCC 3.7.0 + + ◦ + +

Page 13: The free toolchain for the STM8 - FOSDEMThe free toolchain for the STM8 Getting into first place when non-free tools had years of head start Philipp Klaus Krause February 3, 2018

Table of Contents

STM8

ST-Link

stm8flashstm8gal

SDCC

LLVMEclipse

Code::Blocks

OpenOCDGDB

Page 14: The free toolchain for the STM8 - FOSDEMThe free toolchain for the STM8 Getting into first place when non-free tools had years of head start Philipp Klaus Krause February 3, 2018

LLVM+SDCC

Uses LLVM C front- and backend to produce C code to becompiled with SDCCCode compiled with LLVM+SDCC can be mixed with C codecompiled with SDCCAllows languages other than CEnables high-level optimizationsExperimental, many issues remaining

Page 15: The free toolchain for the STM8 - FOSDEMThe free toolchain for the STM8 Getting into first place when non-free tools had years of head start Philipp Klaus Krause February 3, 2018

Table of Contents

STM8

ST-Link

stm8flashstm8gal

SDCC

LLVMEclipse

Code::Blocks

OpenOCDGDB

Page 16: The free toolchain for the STM8 - FOSDEMThe free toolchain for the STM8 Getting into first place when non-free tools had years of head start Philipp Klaus Krause February 3, 2018

stm8flash

Allows reading and writing of flash, eeprom, option bytesSupports all known STM8 variantsUses ST-Link and ESP-STLINK

Page 17: The free toolchain for the STM8 - FOSDEMThe free toolchain for the STM8 Getting into first place when non-free tools had years of head start Philipp Klaus Krause February 3, 2018

Table of Contents

STM8

ST-Link

stm8flashstm8gal

SDCC

LLVMEclipse

Code::Blocks

OpenOCDGDB

Page 18: The free toolchain for the STM8 - FOSDEMThe free toolchain for the STM8 Getting into first place when non-free tools had years of head start Philipp Klaus Krause February 3, 2018

stm8gal

Allows reading and writing of flashDoes not need ST-Link, directly uses STM8 on-chip UARTUses bootloader (not available on all STM8)Needs non-free blob for some STM8

Page 19: The free toolchain for the STM8 - FOSDEMThe free toolchain for the STM8 Getting into first place when non-free tools had years of head start Philipp Klaus Krause February 3, 2018

Table of Contents

STM8

ST-Link

stm8flashstm8gal

SDCC

LLVMEclipse

Code::Blocks

OpenOCDGDB

Page 20: The free toolchain for the STM8 - FOSDEMThe free toolchain for the STM8 Getting into first place when non-free tools had years of head start Philipp Klaus Krause February 3, 2018

OpenOCD and GDB

Patches to OpenOCD and GDB for STM8 and ST-LinksupportAllows on-target debugging

Page 21: The free toolchain for the STM8 - FOSDEMThe free toolchain for the STM8 Getting into first place when non-free tools had years of head start Philipp Klaus Krause February 3, 2018

Table of Contents

STM8

ST-Link

stm8flashstm8gal

SDCC

LLVMEclipse

Code::Blocks

OpenOCDGDB

Page 22: The free toolchain for the STM8 - FOSDEMThe free toolchain for the STM8 Getting into first place when non-free tools had years of head start Philipp Klaus Krause February 3, 2018

Eclipse

eclipseSDCC plugin from 2006Plugin needs updating for current SDCC and EclipseNeeds work from someone familiar with Java and EclipseDebugging support works with Eclipse without plugin

Page 23: The free toolchain for the STM8 - FOSDEMThe free toolchain for the STM8 Getting into first place when non-free tools had years of head start Philipp Klaus Krause February 3, 2018

Code::Blocks

Has support for current SDCCNeeds testing and improvementNeeds debugging support

Page 24: The free toolchain for the STM8 - FOSDEMThe free toolchain for the STM8 Getting into first place when non-free tools had years of head start Philipp Klaus Krause February 3, 2018

Table of Contents

STM8

ST-Link

stm8flashstm8gal OpenOCDGDB

SDCC

EclipseCode::Blocks

LLVM

Page 25: The free toolchain for the STM8 - FOSDEMThe free toolchain for the STM8 Getting into first place when non-free tools had years of head start Philipp Klaus Krause February 3, 2018

ST-Link

Originals by ST, many cheap clones availableAll variants use non-free firmwareFree alternatives: ESP-STLINK, UPROG2 support memoryread / write, but not debugging

Page 26: The free toolchain for the STM8 - FOSDEMThe free toolchain for the STM8 Getting into first place when non-free tools had years of head start Philipp Klaus Krause February 3, 2018

TODO

SDCC needs developersFix SDCC bugsImprove SDCC further in standard compliance, optimizations,debug info, etcMake LLVM+SDCC useableGet GDB changes integrated upstreamImprove IDE integrationPort RTOSesReplace non-free ST-Link firmware and bootloader, supportfree replacements in tools