From: (no author) <(no author)@38d2e660-2303-0410-9eaa-f027e97ec537> Date: Wed, 26 Aug 2009 17:16:28 +0000 (+0000) Subject: Add flashing support for AVR. X-Git-Tag: 2.2.0~182 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=388f7931a07e3bf406978bdf788d34e86f33bf53;p=bertos.git Add flashing support for AVR. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2786 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/config.mk b/bertos/config.mk index 9a62e2fd..845083f9 100644 --- a/bertos/config.mk +++ b/bertos/config.mk @@ -11,7 +11,6 @@ # Programmer type # see local pgm_config.mk for programmer customization. -include pgm_config.mk -DPROG ?= -V -c stk500 -P /dev/ttyS0 OPTCFLAGS = -ffunction-sections -fdata-sections #OPTCFLAGS = -funsafe-loop-optimizations diff --git a/bertos/cpu/avr/info/ATmega103.cdef b/bertos/cpu/avr/info/ATmega103.cdef index 21598a38..2d1cd912 100644 --- a/bertos/cpu/avr/info/ATmega103.cdef +++ b/bertos/cpu/avr/info/ATmega103.cdef @@ -51,3 +51,4 @@ CPU_DESC += [ "128 Kbyte in-System Programmable Flash", # If we use the GCC compiler we should pass some flags. CORE_CPU = "atmega103" +include("avr_post.common") diff --git a/bertos/cpu/avr/info/ATmega128.cdef b/bertos/cpu/avr/info/ATmega128.cdef index 86650040..88eb826c 100644 --- a/bertos/cpu/avr/info/ATmega128.cdef +++ b/bertos/cpu/avr/info/ATmega128.cdef @@ -51,3 +51,4 @@ CPU_DESC += [ "128 Kbyte in-System Programmable Flash", # If we use the GCC compiler we should pass some flags. CORE_CPU = "atmega128" +include("avr_post.common") diff --git a/bertos/cpu/avr/info/ATmega1281.cdef b/bertos/cpu/avr/info/ATmega1281.cdef index e03338fd..7b048660 100644 --- a/bertos/cpu/avr/info/ATmega1281.cdef +++ b/bertos/cpu/avr/info/ATmega1281.cdef @@ -52,3 +52,4 @@ CPU_DESC += [ "128 Kbyte in-System Programmable Flash", # If we use the GCC compiler we should pass some flags. CORE_CPU = "atmega1281" +include("avr_post.common") diff --git a/bertos/cpu/avr/info/ATmega168.cdef b/bertos/cpu/avr/info/ATmega168.cdef index 27771d18..a373e754 100644 --- a/bertos/cpu/avr/info/ATmega168.cdef +++ b/bertos/cpu/avr/info/ATmega168.cdef @@ -51,3 +51,4 @@ CPU_DESC += [ "16 Kbyte in-System Programmable Flash", # If we use the GCC compiler we should pass some flags. CORE_CPU = "atmega168" +include("avr_post.common") diff --git a/bertos/cpu/avr/info/ATmega32.cdef b/bertos/cpu/avr/info/ATmega32.cdef index e3c50e95..9a73ebaf 100644 --- a/bertos/cpu/avr/info/ATmega32.cdef +++ b/bertos/cpu/avr/info/ATmega32.cdef @@ -51,3 +51,4 @@ CPU_DESC += [ "32 Kbyte in-System Programmable Flash", # If we use the GCC compiler we should pass some flags. CORE_CPU = "atmega32" +include("avr_post.common") diff --git a/bertos/cpu/avr/info/ATmega64.cdef b/bertos/cpu/avr/info/ATmega64.cdef index 3bb4193f..77b04434 100644 --- a/bertos/cpu/avr/info/ATmega64.cdef +++ b/bertos/cpu/avr/info/ATmega64.cdef @@ -51,3 +51,4 @@ CPU_DESC += [ "64 Kbyte in-System Programmable Flash", # If we use the GCC compiler we should pass some flags. CORE_CPU = "atmega64" +include("avr_post.common") diff --git a/bertos/cpu/avr/info/ATmega8.cdef b/bertos/cpu/avr/info/ATmega8.cdef index 87d43426..2cfbaa5e 100644 --- a/bertos/cpu/avr/info/ATmega8.cdef +++ b/bertos/cpu/avr/info/ATmega8.cdef @@ -51,3 +51,4 @@ CPU_DESC += [ "8 Kbyte in-System Programmable Flash", # If we use the GCC compiler we should pass some flags. CORE_CPU = "atmega8" +include("avr_post.common") diff --git a/bertos/cpu/avr/info/avr.common b/bertos/cpu/avr/info/avr.common index 140c2076..924eea9a 100644 --- a/bertos/cpu/avr/info/avr.common +++ b/bertos/cpu/avr/info/avr.common @@ -64,6 +64,8 @@ SCRIPT_DIR = CPU_DIR + "avr/scripts/" HW_DIR = CPU_DIR + "avr/hw/" DRV_DIR = CPU_DIR + "avr/drv/" +FLASH_SCRIPT = SCRIPT_DIR + "flash.sh" +DEBUG_SCRIPT = SCRIPT_DIR + "debug.sh" # Common GCC flags. CPP_FLAGS = [ "-Os", "-fno-strict-aliasing", "-I" + CPU_DIR + "avr/"] diff --git a/bertos/cpu/avr/info/avr_post.common b/bertos/cpu/avr/info/avr_post.common new file mode 100644 index 00000000..e1237433 --- /dev/null +++ b/bertos/cpu/avr/info/avr_post.common @@ -0,0 +1,4 @@ + +# CPU type used for flashing +PROGRAMMER_CPU = CORE_CPU + diff --git a/bertos/cpu/avr/scripts/flash.sh b/bertos/cpu/avr/scripts/flash.sh new file mode 100755 index 00000000..21b6ab86 --- /dev/null +++ b/bertos/cpu/avr/scripts/flash.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +avrdude -p ${PROGRAMMER_CPU} -c ${PROGRAMMER_TYPE} -P ${PROGRAMMER_PORT} -U ${IMAGE_FILE} diff --git a/bertos/rules.mk b/bertos/rules.mk index 6096accf..cce8ccba 100644 --- a/bertos/rules.mk +++ b/bertos/rules.mk @@ -244,11 +244,10 @@ $$(OUTDIR)/$(1)_whole.elf: bumprev $$($(1)_SRC) $$($(1)_LDSCRIPT) # Flash target # NOTE: we retry in case of failure because the STK500 programmer is crappy .PHONY: flash_$(1) -flash_$(1): $(OUTDIR)/$(1).s19 flash_$(1)_local - if ! $(AVRDUDE) $(DPROG) -p $$($(1)_MCU) -U flash:w:$$< ; then \ - $(AVRDUDE) $(DPROG) -p $$($(1)_MCU) -U flash:w:$$< ; \ - fi - #avarice --mkII -j usb --erase --program --verify --file images/triface.elf +flash_$(1): $(OUTDIR)/$(1).hex flash_$(1)_local + PROGRAMMER_CPU=$$($(1)_PROGRAMMER_CPU) PROGRAMMER_TYPE=$(PROGRAMMER_TYPE) \ + PROGRAMMER_PORT=$(PROGRAMMER_PORT) IMAGE_FILE=$$< \ + $$($(1)_FLASH_SCRIPT) .PHONY: flash_$(1)_local flash_$(1)_local: diff --git a/examples/triface/triface.mk b/examples/triface/triface.mk index e9861a06..6061be8c 100644 --- a/examples/triface/triface.mk +++ b/examples/triface/triface.mk @@ -55,10 +55,11 @@ triface_CSRC = \ triface_PCSRC += bertos/mware/formatwr.c - triface_CFLAGS = -O2 -D'ARCH=(ARCH_TRIFACE)' -D'CPU_FREQ=(14745600UL)' -D'WIZ_AUTOGEN' -fno-strict-aliasing -Iexamples/triface -Ibertos/cpu/avr triface_LDFLAGS = -Wl +triface_PROGRAMMER_CPU = atmega1281 +triface_FLASH_SCRIPT = bertos/cpu/avr/scripts/flash.sh # Set to 1 for debug builds boot_DEBUG = 0 @@ -87,3 +88,5 @@ boot_CFLAGS = -Os -mcall-prologues boot_LDFLAGS = -Wl,--relax -Wl,--section-start=.text=$(BOOT_ADDR_START) +boot_PROGRAMMER_CPU = atmega1281 +boot_FLASH_SCRIPT = bertos/cpu/avr/scripts/flash.sh