Skip to content

Commit 97ec097

Browse files
committed
first successful compilation and upload using the IDE (commit missing some files)
1 parent 295afc1 commit 97ec097

5 files changed

Lines changed: 310 additions & 2 deletions

File tree

sduino/hardware/sduino/stm8/boards.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44

55
stm8sblue.name=STM8S103F3 Breakout Board
66

7-
stm8sblue.upload.using=stm8flash
7+
stm8sblue.upload.tool=stm8flash
88
stm8sblue.upload.protocol=stlinkv2
99
stm8sblue.upload.mcu=stm8s103?3
1010
stm8sblue.upload.maximum_size=8192
11+
stm8sblue.upload.maximum_data_size=1024
1112

1213
stm8sblue.build.mcu=STM8S103
1314
stm8sblue.build.f_cpu=16000000L
15+
stm8sblue.build.board=STM8S_BLUE
1416
stm8sblue.build.core=sduino
1517
stm8sblue.build.variant=standard
1618

@@ -23,13 +25,15 @@ stm8sblue.upload.speed=1
2325

2426
stm8sdisco.name=STM8S105C6 Discovery Board
2527

26-
stm8sdisco.upload.using=stm8flash
28+
stm8sdisco.upload.tool=stm8flash
2729
stm8sdisco.upload.protocol=stlink
2830
stm8sdisco.upload.mcu=stm8s105?6
2931
stm8sdisco.upload.maximum_size=32768
32+
stm8sdisco.upload.maximum_data_size=2048
3033

3134
stm8sdisco.build.mcu=STM8S105
3235
stm8sdisco.build.f_cpu=16000000L
36+
stm8sdisco.build.board=STM8S_DISCOVERY
3337
stm8sdisco.build.core=sduino
3438
stm8sdisco.build.variant=stm8sdisco
3539

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
2+
# Arduino AVR Core and platform.
3+
# ------------------------------
4+
#
5+
# For more info:
6+
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification
7+
8+
name=STM8 Testboards
9+
version=1.6.15
10+
11+
# AVR compile variables
12+
# ---------------------
13+
14+
compiler.warning_flags=
15+
compiler.warning_flags.none=--less-pedantic
16+
compiler.warning_flags.default=
17+
compiler.warning_flags.more=-Wall
18+
compiler.warning_flags.all=-Wall -Wextra
19+
20+
# Default "compiler.path" is correct, change only if you want to override the initial value
21+
compiler.path={runtime.hardware.path}/tools/sdcc/bin/
22+
compiler.tools.path=/usr/bin/
23+
#compiler.tools.path={runtime.hardware.path}/tools/bin/
24+
compiler.path.emu={runtime.hardware.path}/tools/linux/
25+
compiler.path.emu.windows={runtime.hardware.path}/tools/win/
26+
compiler.path.emu.macos={runtime.hardware.path}/tools/macos/
27+
#/home/mmayer/stm8/abuild/
28+
29+
compiler.c.cmd=sdcc-pseudo-g++
30+
compiler.c.cmd.windows=sdcc-pseudo-g++.bat
31+
compiler.c.flags=-c -Ddouble=float -D__PROG_TYPES_COMPAT__ {compiler.warning_flags}
32+
compiler.c.elf.flags=--code-size {upload.maximum_size} --iram-size {upload.maximum_data_size}
33+
34+
compiler.c.elf.cmd=sdcc-link
35+
compiler.c.elf.cmd.windows=sdcc-link.bat
36+
compiler.S.flags=-c -g -x assembler-with-cpp -flto
37+
38+
compiler.cpp.cmd=sdcc-pseudo-g++
39+
compiler.cpp.cmd.windows=sdcc-pseudo-g++.bat
40+
compiler.cpp.flags=-c -Ddouble=float -D__PROG_TYPES_COMPAT__ {compiler.warning_flags}
41+
42+
compiler.ar.cmd=sdar
43+
compiler.ar.cmd.windows=sdar.exe
44+
compiler.ar.flags=rcs
45+
46+
compiler.objcopy.cmd=objcopy
47+
#compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0
48+
#compiler.objcopy.eep.flags=-O ihex -j EEPROM EEPROM=0
49+
50+
compiler.elf2hex.cmd=objcopy
51+
compiler.elf2hex.flags=-O ihex -R DATA -R INITIALIZED -R SSEG
52+
53+
compiler.syslibs.stdlib.path={runtime.hardware.path}/tools/sdcc/share/sdcc/
54+
compiler.syslibs.spl.path={runtime.platform.path}/STM8S_StdPeriph_Driver/
55+
56+
compiler.ldflags=
57+
#compiler.ld.stdlib=lib/stm8/
58+
59+
compiler.size.cmd=size
60+
compiler.size.cmd.windows=size.exe
61+
62+
# Meine Ergänzungen, müssen irgendwie automatisiert werden:
63+
#compiler.systemincludes=-I/home/mmayer/rsync/stm8/STM8S_StdPeriph_Driver/inc -I/opt/sdcc/share/sdcc/include
64+
#compiler.systemincludes=-I/home/mmayer/rsync/stm8/STM8S_StdPeriph_Driver/inc "-I{runtime.hardware.path}/tools/sdcc/share/sdcc/include"
65+
#compiler.systemincludes="-I{runtime.platform.path}/STM8S_StdPeriph_Driver/inc" "-I{runtime.hardware.path}/tools/sdcc/share/sdcc/include"
66+
compiler.systemincludes="-I{compiler.syslibs.spl.path}inc" "-I{compiler.syslibs.stdlib.path}include"
67+
68+
# This can be overridden in boards.txt
69+
build.extra_flags=
70+
71+
# These can be overridden in platform.local.txt
72+
compiler.c.extra_flags=
73+
compiler.c.elf.extra_flags=
74+
compiler.S.extra_flags=
75+
compiler.cpp.extra_flags=
76+
compiler.ar.extra_flags=
77+
compiler.objcopy.eep.extra_flags=
78+
compiler.elf2hex.extra_flags=
79+
80+
# AVR compile patterns
81+
# --------------------
82+
83+
## Compile c files (re1)
84+
#recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" re1 {compiler.c.flags} -mstm8 -D{build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
85+
recipe.c.o.pattern="{compiler.path.emu}{compiler.c.cmd}" "{source_file}" "{object_file}" re2 "-Wp-MMD {object_file}.d" {compiler.c.flags} -mstm8 -D{build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {includes} {compiler.systemincludes}
86+
87+
## Compile c++ files (re2)
88+
#recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" re2 {compiler.cpp.flags} -mstm8 -D{build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
89+
recipe.cpp.o.pattern="{compiler.path.emu}{compiler.cpp.cmd}" "{source_file}" "{object_file}" re2 "-Wp-MMD {object_file}.d" {compiler.cpp.flags} -mstm8 -D{build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} {compiler.systemincludes}
90+
91+
# Soll-Aufruf .c.o:
92+
#/opt/sdcc/bin/sdcc "-Wp-MMD build-stm8sblue/Blink.c.d" -c -Ddouble=float -I.
93+
#-I/home/mmayer/rsync/stm8/sduino/../STM8S_StdPeriph_Driver/inc
94+
#-I/opt/sdcc/share/sdcc/include/ -mstm8 -DSTM8S103 -DF_CPU=16000000L
95+
#-DARDUINO=160 -DARDUINO_ARCH_STM8 -D__PROG_TYPES_COMPAT__
96+
#-I/home/mmayer/rsync/stm8/sduino/hardware/sduino/stm8/cores/sduino
97+
#-I/home/mmayer/rsync/stm8/sduino/hardware/sduino/stm8/variants/standard
98+
#Blink.c -o build-stm8sblue/Blink.c.rel
99+
100+
##FIXME Compile S files
101+
recipe.S.o.pattern="{compiler.path}{compiler.c.cmd}" re3 {compiler.S.flags} -mstm8 -D{build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
102+
103+
## Create archives (re4)
104+
# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value
105+
archive_file_path={build.path}/{archive_file}
106+
#recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"
107+
recipe.ar.pattern="{compiler.path.emu}{compiler.ar.cmd}" "{archive_file_path}" "{object_file}" re4 {compiler.ar.flags} {compiler.ar.extra_flags}
108+
109+
## Combine gc-sections, archives, and objects (re5)
110+
#recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" re5 {compiler.c.elf.flags} -mstm8 -D{build.mcu} {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" "-L{build.path}" -lm
111+
# produziert ihx:
112+
#recipe.c.combine.pattern="{compiler.path.emu}{compiler.c.elf.cmd}" "-L{runtime.platform.path}/STM8S_StdPeriph_Driver/lib" "-L{build.path}" "-L{compiler.ld.stdlib}" {compiler.c.elf.flags} -mstm8 -D{build.mcu} {compiler.c.elf.extra_flags} {object_files} "{build.path}/{archive_file}" "{build.path}/core/main.c.rel" -l{build.mcu} -lstm8 -o "{build.path}/{build.project_name}.ihx"
113+
# produziert elf:
114+
#recipe.c.combine.pattern="{compiler.path.emu}{compiler.c.elf.cmd}" "-L{runtime.platform.path}/STM8S_StdPeriph_Driver/lib" "-L{build.path}" "-L{compiler.ld.stdlib}" {compiler.c.elf.flags} -mstm8 -D{build.mcu} {compiler.c.elf.extra_flags} {object_files} "{build.path}/{archive_file}" "{build.path}/core/main.c.rel" -l{build.mcu} -lstm8 --out-fmt-elf -o "{build.path}/{build.project_name}.elf"
115+
recipe.c.combine.pattern="{compiler.path.emu}{compiler.c.elf.cmd}" "-L{compiler.syslibs.spl.path}lib" "-L{build.path}" "-L{compiler.syslibs.stdlib.path}lib/stm8" {compiler.c.elf.flags} -mstm8 -D{build.mcu} {compiler.c.elf.extra_flags} {object_files} "{build.path}/{archive_file}" "{build.path}/core/main.c.rel" -l{build.mcu} -lstm8 --out-fmt-elf -o "{build.path}/{build.project_name}.elf"
116+
117+
# Soll-Wert:
118+
#/opt/sdcc/bin/sdcc
119+
# -L /home/mmayer/rsync/stm8/sduino/../STM8S_StdPeriph_Driver/lib
120+
# -L/opt/sdcc/share/sdcc/lib/stm8
121+
# -mstm8 -DSTM8S103
122+
# build-stm8sblue/Blink.c.rel build-stm8sblue/libcore.lib \
123+
# build-stm8sblue/core/main.c.rel \
124+
# -lSTM8S103 -lstm8 -o build-stm8sblue/Blink.ihx
125+
126+
127+
128+
## Create output files (.eep and .hex)
129+
#recipe.objcopy.eep.pattern="{compiler.path}{compiler.objcopy.cmd}" re6 {compiler.objcopy.eep.flags} {compiler.objcopy.eep.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.eep"
130+
#recipe.objcopy.eep.pattern="{compiler.tools.path}{compiler.objcopy.cmd}" {compiler.objcopy.eep.flags} {compiler.objcopy.eep.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.eep"
131+
#recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" re7 {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"
132+
recipe.objcopy.hex.pattern="{compiler.tools.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"
133+
134+
## Save hex
135+
recipe.output.tmp_file={build.project_name}.hex
136+
recipe.output.save_file={build.project_name}.{build.variant}.hex
137+
138+
## Compute size
139+
#recipe.size.pattern="{compiler.path}{compiler.size.cmd}" re10 -A "{build.path}/{build.project_name}.elf"
140+
recipe.size.pattern="{compiler.tools.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"
141+
#recipe.size.regex=^(?:\.text|\.data|\.bootloader)\s+([0-9]+).*
142+
#recipe.size.regex.data=^(?:\.data|\.bss|\.noinit)\s+([0-9]+).*
143+
#recipe.size.regex.eeprom=^(?:\.eeprom)\s+([0-9]+).*
144+
# flash usage = HOME + GSINIT + GSFINAL + CODE + INITIALIZER
145+
# RAM usage = DATA + INITIALIZED
146+
recipe.size.regex=^(?:HOME|GSINIT|GSFINAL|CODE|INITIALIZER)\s+([0-9]+).*
147+
recipe.size.regex.data=^(?:DATA|INITIALIZED)\s+([0-9]+).*
148+
recipe.size.regex.eeprom=^(?:EEPROM)\s+([0-9]+).*
149+
150+
## Preprocessor
151+
#preproc.includes.flags=-w -x c++ -M -MG -MP
152+
preproc.includes.flags=-M -MG -MP
153+
recipe.preproc.includes="{compiler.path.emu}{compiler.cpp.cmd}" re11 {compiler.cpp.flags} {preproc.includes.flags} -mstm8 -D{build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}"
154+
155+
#preproc.macros.flags=-w -x c++ -E -CC
156+
preproc.macros.flags=-E -MC
157+
#recipe.preproc.macros="{compiler.path}{compiler.cpp.cmd}" re12 {compiler.cpp.flags} {preproc.macros.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{preprocessed_file_path}"
158+
#recipe.preproc.macros="avr-g++" {compiler.cpp.flags} {preproc.macros.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{preprocessed_file_path}"
159+
#recipe.preproc.macros="{compiler.path}{compiler.cpp.cmd}" re12 {compiler.cpp.flags} {preproc.macros.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{preprocessed_file_path}"
160+
recipe.preproc.macros="{compiler.path.emu}{compiler.cpp.cmd}" "{source_file}" "{preprocessed_file_path}" re12 {compiler.cpp.flags} {preproc.macros.flags} -mstm8 -D{build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} {compiler.systemincludes}
161+
162+
163+
# STlink/v2 Uploader
164+
# ------------------
165+
166+
tools.stm8flash.cmd=stm8flash
167+
tools.stm8flash.cmd.windows=stm8flash.exe
168+
tools.stm8flash.path={runtime.hardware.path}/tools/win
169+
tools.stm8flash.path.macosx={runtime.hardware.path}/tools/macosx
170+
tools.stm8flash.path.linux={runtime.hardware.path}/tools/linux
171+
#tools.stm8flash.path.linux64={runtime.hardware.path}/tools/linux64
172+
173+
#tools.stm8flash.upload.params.verify=
174+
tools.stm8flash.upload.params.verbose=
175+
tools.stm8flash.upload.params.quiet=
176+
tools.stm8flash.upload.pattern="{path}/{cmd}" -c{upload.protocol} -p{upload.mcu} -s flash -w "{build.path}/{build.project_name}.hex"
177+
# -cstlinkv2 -pstm8s103?3 -s flash -w build-stm8sblue/Blink.ihx
178+
#"-C{config.path}" {upload.verbose} {upload.verify} -p{build.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} -D "-Uflash:w:{build.path}/{build.project_name}.hex:i"
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
# ANSI color codes to beautify the output:
4+
BLACK='\E[0;30m'
5+
RED='\E[0;31m'
6+
GREEN='\E[0;32m'
7+
ORANGE='\E[0;33m'
8+
BLUE='\E[0;34m'
9+
PURPLE='\E[0;35m'
10+
CYAN='\E[0;36m'
11+
LGRAY='\E[0;37m'
12+
DGRAY='\E[1;30m'
13+
LRED='\E[1;31m'
14+
LGREEN='\E[1;32m'
15+
YELLOW='\E[1;33m'
16+
LBLUE='\E[1;34m'
17+
LPURPLE='\E[1;35m'
18+
LCYAN='\E[1;36m'
19+
WHITE='\E[1;37m'
20+
OFF='\E[0m'
21+
22+
23+
# echo the full command line in cyan:
24+
>&2 echo -e "${CYAN}${@}${OFF}"
25+
26+
# echo the mark id in green and the compiler call in white:
27+
LIB=$1
28+
OBJ=${2%.o}.rel
29+
MARK=$3
30+
shift 3
31+
32+
>&2 echo -e "${GREEN}Mark $MARK:${OFF}" /opt/sdcc/bin/sdar "$@" "$LIB" "$OBJ"
33+
/opt/sdcc/bin/sdar "$@" "$LIB" "$OBJ"
34+
cp -a "$LIB" "${LIB%.a}.lib"
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
3+
# usage: sdcc-link [.lib and .rel files] re5 [other flags and files]
4+
5+
# ANSI color codes to beautify the output:
6+
BLACK='\E[0;30m'
7+
RED='\E[0;31m'
8+
GREEN='\E[0;32m'
9+
ORANGE='\E[0;33m'
10+
BLUE='\E[0;34m'
11+
PURPLE='\E[0;35m'
12+
CYAN='\E[0;36m'
13+
LGRAY='\E[0;37m'
14+
DGRAY='\E[1;30m'
15+
LRED='\E[1;31m'
16+
LGREEN='\E[1;32m'
17+
YELLOW='\E[1;33m'
18+
LBLUE='\E[1;34m'
19+
LPURPLE='\E[1;35m'
20+
LCYAN='\E[1;36m'
21+
WHITE='\E[1;37m'
22+
OFF='\E[0m'
23+
24+
25+
# echo the full command line in cyan:
26+
>&2 echo -e "${CYAN}${@}${OFF}"
27+
28+
declare -a OBJS
29+
while [ $# -gt 0 ]; do
30+
echo $1
31+
FILE=$1
32+
if [[ $FILE == *.a ]]; then
33+
FILE=${FILE%.a}.lib
34+
# OBJS+=(${1%.a}.lib)
35+
fi
36+
if [[ $FILE == *.o ]]; then
37+
FILE=${FILE%.o}.rel
38+
# OBJS+=(${1%.o}.rel)
39+
fi
40+
OBJS+=(${FILE})
41+
shift
42+
done
43+
echo /opt/sdcc/bin/sdcc "${OBJS[@]}"
44+
/opt/sdcc/bin/sdcc "${OBJS[@]}"
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
3+
# ANSI color codes to beautify the output:
4+
BLACK='\E[0;30m'
5+
RED='\E[0;31m'
6+
GREEN='\E[0;32m'
7+
ORANGE='\E[0;33m'
8+
BLUE='\E[0;34m'
9+
PURPLE='\E[0;35m'
10+
CYAN='\E[0;36m'
11+
LGRAY='\E[0;37m'
12+
DGRAY='\E[1;30m'
13+
LRED='\E[1;31m'
14+
LGREEN='\E[1;32m'
15+
YELLOW='\E[1;33m'
16+
LBLUE='\E[1;34m'
17+
LPURPLE='\E[1;35m'
18+
LCYAN='\E[1;36m'
19+
WHITE='\E[1;37m'
20+
OFF='\E[0m'
21+
22+
23+
# echo the full command line in cyan:
24+
>&2 echo -e "${CYAN}${@}${OFF}"
25+
26+
# echo the mark id in green and the compiler call in white:
27+
SRC=$1
28+
OBJ=$2
29+
REL=${OBJ%.o}.rel
30+
MARK=$3
31+
shift 3
32+
>&2 echo -e "${GREEN}Mark $MARK:${OFF}" /opt/sdcc/bin/sdcc "$@" "$SRC" -o "$OBJ"
33+
34+
if [[ $SRC == *.cpp ]]; then
35+
>&2 echo -e "${RED}cpp gefunden${OFF}";
36+
CSRC="${SRC%pp}"
37+
cp -av "$SRC" "$CSRC"
38+
/opt/sdcc/bin/sdcc "$@" "$CSRC" -o "$OBJ"
39+
rm -f "$CSRC"
40+
else
41+
/opt/sdcc/bin/sdcc "$@" "$SRC" -o "$OBJ"
42+
fi
43+
44+
# copy the generated .rel files as an .o file to avoid recompiling the next time
45+
if [ -e "${REL}" ]; then
46+
cp -a "${REL}" "${OBJ}"
47+
cp -a "${REL}" "${OBJ}.o"
48+
fi

0 commit comments

Comments
 (0)