Skip to content

Commit

Permalink
fixes #272 Deliver forth.asm and other source files in release archive
Browse files Browse the repository at this point in the history
  • Loading branch information
TG9541 committed Oct 19, 2019
1 parent 8fa0841 commit bb61a1c
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 67 deletions.
65 changes: 5 additions & 60 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ ifeq ($(BOARD),)
all: zip tgz

zip: build
find out/ -name "*.ihx" -print | zip -r out/stm8ef-bin docs/words.md mcu/* lib/* -@
find out/ -name "forth.rst" -print | zip -r out/stm8ef-bin tools/* -@
find out/ -name "*.ihx" -print | zip -r out/stm8ef-bin forth.asm forth.h forth.mk main.c LICENSE.md docs/words.md inc/* mcu/* lib/* -@
find out/ -name "simbreak.txt" -print | zip -r out/stm8ef-bin tools/* -@
find out/ -name "target" -print | zip -r out/stm8ef-bin -@

tgz: build
( find out/ -path "*target/*" -print0 ; find out/ -name "*.ihx" -type f -print0 ; find out/ -name "forth.rst" -type f -print0 ) | tar -czvf out/stm8ef-bin.tgz docs/words.md mcu lib tools --null -T -
( find out/ -path "*target/*" -print0 ; find out/ -name "*.ihx" -type f -print0 ; find out/ -name "simbreak.txt" -type f -print0 ) | tar -czvf out/stm8ef-bin.tgz forth.asm forth.h forth.mk main.c LICENSE.md docs/words.md mcu lib tools --null -T -
( find out/ -name "forth.rst" -type f -print0 ) | tar -czvf out/stm8ef-rst.tgz --null -T -

build: words
make BOARD=CORE
Expand Down Expand Up @@ -49,63 +50,7 @@ defaults105:
stm8flash -c stlinkv2 -p stm8s105k4 -s opt -w tools/stm8s105FactoryDefaults.bin

else

MDEPS = forth.rel forth.h
MKDIR_P = mkdir -p out
BTARGET = $(BOARD)/target.inc
OUT = out/$(BOARD)

TARGET := $(shell echo `[ -f $(BTARGET) ] && awk '/TARGET/ {print tolower($$3)}' $(BTARGET) || echo "stm8s103f3"`)
OPTFILE := $(shell echo $(TARGET) | awk '{print "tools/" substr($$0,1,8) "FactoryDefaults.bin"}')
all: directories main.ihx
main.ihx: main.c $(MDEPS)
sdcc -mstm8 -I./$(BOARD) -I./inc -o$(OUT)/$(BOARD).ihx main.c $(OUT)/forth.rel
mkdir -p $(OUT)/target
rm -f $(OUT)/target/*
rm -f target
ln -s $(OUT)/target/ target
awk -f tools/genalias.awk -v target="$(OUT)/target/" $(OUT)/forth.rst
awk -f tools/genconst.awk -v target="$(OUT)/target/" $(OUT)/forth.rst
forth.rel: forth.asm
mkdir -p $(OUT)
sdasstm8 -I. -I./$(BOARD) -I./inc -plosgffw $(OUT)/forth.rel forth.asm
flash: main.ihx
stm8flash -c stlinkv2 -p $(TARGET) -w $(OUT)/$(BOARD).ihx
forth: main.ihx
tools/simload.sh $(BOARD)
forthflash: forth
stm8flash -c stlinkv2 -p $(TARGET) -w $(OUT)/$(BOARD)-forth.ihx
readflash:
stm8flash -c stlinkv2 -p $(TARGET) -s flash -r $(OUT)/$(BOARD)-readflash.ihx
readeeprom:
stm8flash -c stlinkv2 -p $(TARGET) -s eeprom -r $(OUT)/$(BOARD)-readeeprom.ihx
readopt:
stm8flash -c stlinkv2 -p $(TARGET) -s opt -r $(OUT)/$(BOARD)-readopt.ihx
defaults:
stm8flash -c stlinkv2 -p $(TARGET) -s opt -w $(OPTFILE)
# Usage:
# make term BOARD=<board dir> [TERM_PORT=ttyXXXX] [TERM_BAUD=nnnn] [TERM_FLAGS="--half-duplex --idm"]
term:
cd $(BOARD) && $(E4THCOM) -t stm8ef -p .:../lib $(TERM_FLAGS) -d $(TERM_PORT) -b B$(TERM_BAUD)
directories: out
out:
${MKDIR_P}
.PHONY: directories
include forth.mk
endif


Expand Down
67 changes: 67 additions & 0 deletions forth.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@

MDEPS = forth.rel forth.h
MKDIR_P = mkdir -p out
BTARGET = $(BOARD)/target.inc
OUT = out/$(BOARD)

TARGET := $(shell echo `[ -f $(BTARGET) ] && awk '/TARGET/ {print tolower($$3)}' $(BTARGET) || echo "stm8s103f3"`)
OPTFILE := $(shell echo $(TARGET) | awk '{print "tools/" substr($$0,1,8) "FactoryDefaults.bin"}')
all: directories main.ihx
main.ihx: main.c $(MDEPS)
sdcc -mstm8 -I./$(BOARD) -I./inc -o$(OUT)/$(BOARD).ihx main.c $(OUT)/forth.rel
mkdir -p $(OUT)/target
rm -f $(OUT)/target/*
rm -f target
ln -s $(OUT)/target/ target
awk '/^ +([0-9A-F]){6}.* HI:/ {print "break 0x" $$1}' $(OUT)/forth.rst > $(OUT)/simbreak.txt
awk -f tools/genalias.awk -v target="$(OUT)/target/" $(OUT)/forth.rst
awk -f tools/genconst.awk -v target="$(OUT)/target/" $(OUT)/forth.rst
forth.rel: forth.asm
mkdir -p $(OUT)
sdasstm8 -I. -I./$(BOARD) -I./inc -plosgffw $(OUT)/forth.rel forth.asm
flash: main.ihx
stm8flash -c stlinkv2 -p $(TARGET) -w $(OUT)/$(BOARD).ihx
forth: main.ihx
tools/simload.sh $(BOARD)
forthflash: forth
stm8flash -c stlinkv2 -p $(TARGET) -w $(OUT)/$(BOARD)-forth.ihx
readflash:
stm8flash -c stlinkv2 -p $(TARGET) -s flash -r $(OUT)/$(BOARD)-readflash.ihx
readeeprom:
stm8flash -c stlinkv2 -p $(TARGET) -s eeprom -r $(OUT)/$(BOARD)-readeeprom.ihx
readopt:
stm8flash -c stlinkv2 -p $(TARGET) -s opt -r $(OUT)/$(BOARD)-readopt.ihx
defaults:
stm8flash -c stlinkv2 -p $(TARGET) -s opt -w $(OPTFILE)
# Usage:
# make term BOARD=<board dir> [TERM_PORT=ttyXXXX] [TERM_BAUD=nnnn] [TERM_FLAGS="--half-duplex --idm"]
term:
cd $(BOARD) && $(E4THCOM) -t stm8ef -p .:../lib $(TERM_FLAGS) -d $(TERM_PORT) -b B$(TERM_BAUD)
directories: out
out:
${MKDIR_P}
.PHONY: directories
#directories: out
#out:
# ${MKDIR_P}
.PHONY: all zip build defaults term
8 changes: 1 addition & 7 deletions tools/simload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,7 @@ export object="$1"
export ucsimstart=`mktemp`
echo "load \"out/$object/$object.ihx\"" > "$ucsimstart"

# awk: set breakpoint at binary code address of HI
read -d '' setbreak << 'EOF'
/^ +([0-9A-F]){6}.* HI:/ {
print "break 0x" $1
}
EOF
awk "$setbreak" out/$object/forth.rst >> "$ucsimstart"
cat out/$object/simbreak.txt >> "$ucsimstart"

echo "simload.sh: run STM8EF in uCsim with breakpoint at HI"

Expand Down

0 comments on commit bb61a1c

Please sign in to comment.