diff options
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/loaders/Makefile | 5 | ||||
-rw-r--r-- | contrib/loaders/erase_check/Makefile | 17 | ||||
-rw-r--r-- | contrib/loaders/erase_check/stm8_erase_check.inc | 5 | ||||
-rw-r--r-- | contrib/loaders/erase_check/stm8_erase_check.s | 69 |
4 files changed, 95 insertions, 1 deletions
diff --git a/contrib/loaders/Makefile b/contrib/loaders/Makefile index 31cccb5..a9a2770 100644 --- a/contrib/loaders/Makefile +++ b/contrib/loaders/Makefile @@ -1,6 +1,6 @@ .PHONY: arm clean-arm -all: arm +all: arm stm8 common_dirs = \ checksum \ @@ -32,3 +32,6 @@ clean: clean-arm for d in $(common_dirs); do \ $(MAKE) -C $$d clean; \ done + +stm8: + $(MAKE) -C erase_check stm8 diff --git a/contrib/loaders/erase_check/Makefile b/contrib/loaders/erase_check/Makefile index 01e62de..427fa0c 100644 --- a/contrib/loaders/erase_check/Makefile +++ b/contrib/loaders/erase_check/Makefile @@ -6,6 +6,12 @@ ARM_OBJCOPY ?= $(ARM_CROSS_COMPILE)objcopy ARM_AFLAGS = -EL +STM8_CROSS_COMPILE ?= stm8- +STM8_AS ?= $(STM8_CROSS_COMPILE)as +STM8_OBJCOPY ?= $(STM8_CROSS_COMPILE)objcopy + +STM8_AFLAGS = + arm: armv4_5_erase_check.inc armv7m_erase_check.inc armv7m_0_erase_check.inc armv4_5_%.elf: armv4_5_%.s @@ -26,5 +32,16 @@ armv7m_%.bin: armv7m_%.elf armv7m_%.inc: armv7m_%.bin $(BIN2C) < $< > $@ +stm8: stm8_erase_check.inc + +stm8_%.elf: stm8_%.s + $(STM8_AS) $(STM8_AFLAGS) $< -o $@ + +stm8_%.bin: stm8_%.elf + $(STM8_OBJCOPY) -Obinary $< $@ + +stm8_%.inc: stm8_%.bin + $(BIN2C) < $< > $@ + clean: -rm -f *.elf *.bin *.inc diff --git a/contrib/loaders/erase_check/stm8_erase_check.inc b/contrib/loaders/erase_check/stm8_erase_check.inc new file mode 100644 index 0000000..66b4ec7 --- /dev/null +++ b/contrib/loaders/erase_check/stm8_erase_check.inc @@ -0,0 +1,5 @@ +/* Autogenerated with ../../../src/helper/bin2char.sh */ +0x00,0x80,0x00,0x00,0x80,0x00,0x96,0xcf,0x00,0x22,0x1e,0x01,0x16,0x04,0xa6,0xff, +0x90,0x5d,0x26,0x04,0x0d,0x03,0x27,0x17,0x90,0x5d,0x26,0x02,0x0a,0x03,0x90,0x5a, +0x92,0xbc,0x00,0x00,0xa1,0xff,0x26,0x07,0x5c,0x26,0xe5,0x0c,0x00,0x20,0xe1,0x1f, +0x01,0x17,0x04,0x8b, diff --git a/contrib/loaders/erase_check/stm8_erase_check.s b/contrib/loaders/erase_check/stm8_erase_check.s new file mode 100644 index 0000000..6269400 --- /dev/null +++ b/contrib/loaders/erase_check/stm8_erase_check.s @@ -0,0 +1,69 @@ +/* + Copyright (C) 2017 Ake Rehnman + ake.rehnman(at)gmail.com + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ +;; +;; erase check memory code +;; + .org 0x0 +;; start address + start_addr: .byte 0x00 + .word 0x8000 +;; byte count + byte_cnt: .byte 0x00 + .word 0x8000 +; +; SP must point to start_addr on entry +; first relocate start_addr to the location +; we are running at +start: + ldw X,SP + ldw .cont+2,X + ldw X,(start_addr+1,SP) ;start addr + ldw Y,(byte_cnt+1,SP) ;count + ld A,#0xff +; +; if count == 0 return +.L1: + tnzw Y + jrne .decrcnt ;continue if low word != 0 + tnz (byte_cnt,SP) ;high byte + jreq .exit ;goto exit +; +; decrement count (byte_cnt) +.decrcnt: + tnzw Y ;low word count + jrne .decr1 + dec (byte_cnt,SP) ;high byte +.decr1: + decw Y; decr low word +; +; first check if [start_addr] is 0xff +.cont: + ldf A, [start_addr.e] + cp A,#0xff + jrne .exit ;exit if not 0xff +; +; increment start_addr (addr) + incw X + jrne .L1 + inc (start_addr,SP) ;increment high byte + jra .L1 +; +.exit: + ldw (start_addr+1,SP),X ;start addr + ldw (byte_cnt+1,SP),Y ;count + break |