Skip to content

Commit 1959098

Browse files
committed
added stm8flash to makefile
1 parent 449f50d commit 1959098

6 files changed

Lines changed: 100 additions & 48 deletions

File tree

sduino/hardware/sduino/stm8/boards.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
stm8sblue.name=STM8S103F3 Breakout Board
66

7+
stm8sblue.upload.using=stm8flash
78
stm8sblue.upload.protocol=stlinkv2
9+
stm8sblue.upload.mcu=stm8s103?3
810
stm8sblue.upload.maximum_size=8192
9-
stm8sblue.upload.using=stm8flash
1011

1112
stm8sblue.build.mcu=stm8
1213
stm8sblue.build.f_cpu=16000000L

test/libmake/Arduino.mk

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,13 @@ ifeq ($(strip $(NO_CORE)),)
654654
endif
655655
endif
656656

657+
ifndef AVRDUDE_MCU
658+
AVRDUDE_MCU := $(call PARSE_BOARD,$(BOARD_TAG),upload.mcu)
659+
ifndef AVRDUDE_MCU
660+
AVRDUDE_MCU = $(MCU)
661+
endif
662+
endif
663+
657664
ifndef AVRDUDE_ARD_BAUDRATE
658665
AVRDUDE_ARD_BAUDRATE := $(call PARSE_BOARD,$(BOARD_TAG),menu.(chip|cpu).$(BOARD_SUB).upload.speed)
659666
ifndef AVRDUDE_ARD_BAUDRATE
@@ -895,8 +902,9 @@ endif
895902
# Rules for making stuff
896903

897904
# The name of the main targets
898-
TARGET_IHX = $(OBJDIR)/$(TARGET).ihx
899-
TARGET_HEX = $(OBJDIR)/$(TARGET).hex
905+
#TARGET_IHX = $(OBJDIR)/$(TARGET).ihx
906+
#TARGET_HEX = $(OBJDIR)/$(TARGET).hex
907+
TARGET_HEX = $(OBJDIR)/$(TARGET).ihx
900908
TARGET_ELF = $(OBJDIR)/$(TARGET).elf
901909
TARGET_EEP = $(OBJDIR)/$(TARGET).eep
902910
CORE_LIB = $(OBJDIR)/libcore.lib
@@ -1032,7 +1040,8 @@ CPPFLAGS += -$(MCU_FLAG_NAME)$(MCU) -DF_CPU=$(F_CPU) -DARDUINO=$(ARDUINO_VE
10321040
ifdef DEBUG
10331041
OPTIMIZATION_FLAGS= $(DEBUG_FLAGS)
10341042
else
1035-
OPTIMIZATION_FLAGS = -O$(OPTIMIZATION_LEVEL)
1043+
#OPTIMIZATION_FLAGS = -O$(OPTIMIZATION_LEVEL)
1044+
OPTIMIZATION_FLAGS =
10361045
endif
10371046

10381047
CPPFLAGS += $(OPTIMIZATION_FLAGS)
@@ -1084,7 +1093,7 @@ ifeq ($(shell expr $(CC_VERNUM) '>' 490), 1)
10841093
ASFLAGS += -flto
10851094
endif
10861095
#LDFLAGS += -$(MCU_FLAG_NAME)=$(MCU) -Wl,--gc-sections -O$(OPTIMIZATION_LEVEL)
1087-
LDFLAGS += -$(MCU_FLAG_NAME)$(MCU) -O$(OPTIMIZATION_LEVEL)
1096+
LDFLAGS += -$(MCU_FLAG_NAME)$(MCU)
10881097
ifeq ($(shell expr $(CC_VERNUM) '>' 490), 1)
10891098
LDFLAGS += -flto -fuse-linker-plugin
10901099
endif
@@ -1350,9 +1359,9 @@ endif
13501359
# This is needed to be able to compile for attiny84a but specify the upload mcu as attiny84.
13511360
# We default to picking the -mmcu flag, but you can override this by setting
13521361
# AVRDUDE_MCU in your makefile.
1353-
ifndef AVRDUDE_MCU
1354-
AVRDUDE_MCU = $(MCU)
1355-
endif
1362+
#ifndef AVRDUDE_MCU
1363+
# AVRDUDE_MCU = $(MCU)
1364+
#endif
13561365

13571366
AVRDUDE_COM_OPTS = $(AVRDUDE_OPTS) -p $(AVRDUDE_MCU)
13581367
ifdef AVRDUDE_CONF
@@ -1453,7 +1462,8 @@ endif
14531462
# Explicit targets start here
14541463

14551464
#all: $(TARGET_EEP) $(TARGET_HEX)
1456-
all: $(TARGET_HEX)
1465+
all: size
1466+
#$(TARGET_HEX) $(SIZE)
14571467

14581468
# Rule to create $(OBJDIR) automatically. All rules with recipes that
14591469
# create a file within it, but do not already depend on a file within it
@@ -1467,15 +1477,14 @@ $(OBJDIR): pre-build
14671477
pre-build:
14681478
$(call runscript_if_exists,$(PRE_BUILD_HOOK))
14691479

1470-
$(TARGET_IHX): $(LOCAL_OBJS) $(CORE_LIB) $(OTHER_OBJS)
1471-
$(CC) $(LDFLAGS) $(LOCAL_OBJS) $(CORE_LIB) $(OTHER_OBJS) $(OTHER_LIBS) -lstm8s103 -lm $(LINKER_SCRIPTS) -o $@
1480+
$(TARGET_HEX): $(LOCAL_OBJS) $(CORE_LIB) $(OTHER_OBJS)
1481+
$(CC) $(LDFLAGS) $(LOCAL_OBJS) $(CORE_LIB) $(OTHER_OBJS) $(OTHER_LIBS) -lstm8s103 -lstm8 $(LINKER_SCRIPTS) -o $@
14721482
# $(CC) $(LDFLAGS) -o $@ $(LOCAL_OBJS) $(CORE_LIB) $(OTHER_OBJS) $(OTHER_LIBS) -lc -lm $(LINKER_SCRIPTS)
14731483

14741484
$(TARGET_ELF): $(LOCAL_OBJS) $(CORE_LIB) $(OTHER_OBJS)
14751485
$(CC) $(LDFLAGS) -o $@ $(LOCAL_OBJS) $(CORE_LIB) $(OTHER_OBJS) $(OTHER_LIBS) -lc -lm $(LINKER_SCRIPTS)
14761486

14771487
$(CORE_LIB): $(CORE_OBJS) $(LIB_OBJS) $(PLATFORM_LIB_OBJS) $(USER_LIB_OBJS)
1478-
# $(AR) rcs $@ $(patsubst %.o,%.rel, $(CORE_OBJS) $(LIB_OBJS) $(PLATFORM_LIB_OBJS) $(USER_LIB_OBJS))
14791488
$(AR) rcs $@ $(CORE_OBJS) $(LIB_OBJS) $(PLATFORM_LIB_OBJS) $(USER_LIB_OBJS)
14801489

14811490
error_on_caterina:

test/libmake/Makefile

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,3 @@
11
BOARD_TAG = stm8sblue
2-
ARDUINO_DIR = ../../sduino
3-
ARDMK_VENDOR = sduino
4-
ARCHITECTURE = stm8
5-
CPPFLAGS = -DSTM8S103 -I ../../STM8S_StdPeriph_Driver/inc
6-
#CFLAGS = -I ../../STM8S_StdPeriph_Driver/inc
7-
#LDFLAGS = --out-fmt-elf
8-
LDFLAGS = -L ../../STM8S_StdPeriph_Driver/src
9-
10-
MCU_FLAG_NAME = m
11-
#MMD = "-Wp-MMD abc"
12-
13-
OVERRIDE_EXECUTABLES=yes
14-
SDCC_PATH=/opt/sdcc/bin
15-
CC = $(SDCC_PATH)/sdcc
16-
AS = $(SDCC_PATH)/sdasstm8
17-
AR = $(SDCC_PATH)/sdar
18-
SIZE = /usr/bin/size
19-
20-
#ALTERNATE_CORE = sduino
21-
#ARDUINO_VAR_PATH = ../../sduino
22-
#ARDUINO_CORE_PATH = ../../sduino
23-
24-
25-
all:
26-
27-
include Arduino.mk
28-
29-
TARGET_HEX = $(OBJDIR)/$(TARGET).ihx
30-
31-
all: $(TARGET_HEX)
32-
33-
upload: $(TARGET_HEX) verify_size
34-
$(MAKE) reset
35-
$(MAKE) do_upload
362

3+
include sduino.mk

test/libmake/README.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
# Problems with SDCC and Arduino.mk
1+
## Defined new parameters in boards.txt
22

3-
## missing/non-supported compiler flags
3+
`BOARD.upload.mcu` cpu specifier for avrdude/stm8flash. Defines AVRDUDE_MCU
4+
5+
6+
## Problems with SDCC and Arduino.mk
7+
8+
### missing/non-supported compiler flags
49

510
`-dumpversion`
611

@@ -20,3 +25,13 @@ erwartet wird:
2025
dieser Aufruf erzeugt aber nur die dep. in der rel-Datei und kein Object file
2126

2227
Der Assembler erzeugt immer .rel-Files, es werden aber .o-Files erwartet.
28+
29+
30+
31+
### general suggestions for Arduino.mk:
32+
33+
- rename the programmer specific variables from AVRDUDE_xxxx to a more
34+
generic PROGRAMMER_xxxx
35+
- allow predefined AVRDUDE_xxxx definitions from the Makefile to override
36+
the PROGRAMMER_xxxx definitions
37+

test/libmake/sduino.mk

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
ARDUINO_DIR = ../../sduino
2+
ARDUINO_SKETCHBOOK = /tmp # temporarly, to prevent usage of the real libs
3+
ARDMK_VENDOR = sduino
4+
ARCHITECTURE = stm8
5+
CPPFLAGS = -DSTM8S103 -I../../STM8S_StdPeriph_Driver/inc -I/opt/sdcc/share/sdcc/include/
6+
#CFLAGS = -I ../../STM8S_StdPeriph_Driver/inc
7+
#LDFLAGS = --out-fmt-elf
8+
LDFLAGS = -L ../../STM8S_StdPeriph_Driver/src -L/opt/sdcc/share/sdcc/lib/stm8
9+
10+
11+
MCU_FLAG_NAME = m
12+
13+
OVERRIDE_EXECUTABLES=yes
14+
SDCC_PATH=/opt/sdcc/bin
15+
CC = $(SDCC_PATH)/sdcc
16+
AS = $(SDCC_PATH)/sdasstm8
17+
AR = $(SDCC_PATH)/sdar
18+
SIZE = /usr/bin/size
19+
20+
#ALTERNATE_CORE = sduino
21+
#ARDUINO_VAR_PATH = ../../sduino
22+
#ARDUINO_CORE_PATH = ../../sduino
23+
24+
25+
all:
26+
27+
include Arduino.mk
28+
29+
30+
STM8FLASH = stm8flash
31+
STM8FLASH_COM_OPTS =
32+
STM8FLASH_ARD_OPTS = -c$(AVRDUDE_ARD_PROGRAMMER) -p$(AVRDUDE_MCU)
33+
STM8FLASH_UPLOAD_HEX = -s flash -w $(TARGET_HEX)
34+
STM8FLASH_UPLOAD_EEP = -s eeprom -w $(TARGET_EEP)
35+
36+
upload: $(TARGET_HEX) verify_size
37+
$(STM8FLASH) $(STM8FLASH_COM_OPTS) $(STM8FLASH_ARD_OPTS) \
38+
$(STM8FLASH_UPLOAD_HEX)

test/libmake/stat.awk

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/gawk -f
2+
3+
/ [ls]_/ {
4+
v=strtonum("0x"$1);
5+
type=substr($2,1,1);
6+
name=substr($2,3);
7+
arr[name][type]=v;
8+
# print v,type,name,$0
9+
}
10+
11+
END {
12+
for (n in arr)
13+
print arr[n]["l"] "\t" n;
14+
# print n, arr[n]["s"],arr[n]["l"];
15+
print "memory usage statics"
16+
print "--------------------"
17+
print "RAM:\t\t" arr["DATA"]["l"]+arr["INITIALIZED"]["l"];
18+
print "Flash:\t\t" arr["CODE"]["l"]+arr["INITIALIZER"]["l"];
19+
for (n in arr) printf("%s\t",n);
20+
for (n in arr) print arr[n]["l"] "\t";
21+
22+
}

0 commit comments

Comments
 (0)