Add flashing support for AVR.
author(no author) <(no author)@38d2e660-2303-0410-9eaa-f027e97ec537>
Wed, 26 Aug 2009 17:16:28 +0000 (17:16 +0000)
committer(no author) <(no author)@38d2e660-2303-0410-9eaa-f027e97ec537>
Wed, 26 Aug 2009 17:16:28 +0000 (17:16 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2786 38d2e660-2303-0410-9eaa-f027e97ec537

13 files changed:
bertos/config.mk
bertos/cpu/avr/info/ATmega103.cdef
bertos/cpu/avr/info/ATmega128.cdef
bertos/cpu/avr/info/ATmega1281.cdef
bertos/cpu/avr/info/ATmega168.cdef
bertos/cpu/avr/info/ATmega32.cdef
bertos/cpu/avr/info/ATmega64.cdef
bertos/cpu/avr/info/ATmega8.cdef
bertos/cpu/avr/info/avr.common
bertos/cpu/avr/info/avr_post.common [new file with mode: 0644]
bertos/cpu/avr/scripts/flash.sh [new file with mode: 0755]
bertos/rules.mk
examples/triface/triface.mk

index 9a62e2fd40f1079b00adc03dd86839e98f0b20f1..845083f9f90a9d2dcba9baa834ad11961eff0c32 100644 (file)
@@ -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
index 21598a3833e2fe30217a4e4cfe44f01d223b0a3c..2d1cd9122cc62a634ec520520d4cbcf6c1c3babf 100644 (file)
@@ -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")
index 8665004095ebdaea304e985fdd28861a019e7593..88eb826cd78e31c7a22581fc56bc43e6911e1a44 100644 (file)
@@ -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")
index e03338fdefa73aabffcf1522778f047ad8c0ab71..7b0486607b907d242d2c59d8a66074a30131c17d 100644 (file)
@@ -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")
index 27771d1825194f696dd20301cc350dce9e4e85e0..a373e754dc3aab66031e4cc34add373e9ee9b190 100644 (file)
@@ -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")
index e3c50e955d28e3744e06aec029b7aced8c53da81..9a73ebaf8c425ac53b9ce01147747d8857a0b583 100644 (file)
@@ -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")
index 3bb4193f9c8cf6bc4a754d983427b7a7aa5a37b9..77b04434224179c542209e7247cd843cdd230d41 100644 (file)
@@ -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")
index 87d43426a6f247ca3de4049488fe36fe4bc05f50..2cfbaa5ef66c523f679d6e891e4392bc5c9fc07b 100644 (file)
@@ -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")
index 140c207627b107a42839b8f747fdb070dec6d587..924eea9a02dec02b77eb38fd05c93969cd91322a 100644 (file)
@@ -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 (file)
index 0000000..e123743
--- /dev/null
@@ -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 (executable)
index 0000000..21b6ab8
--- /dev/null
@@ -0,0 +1,3 @@
+#!/usr/bin/env bash
+
+avrdude -p ${PROGRAMMER_CPU} -c ${PROGRAMMER_TYPE} -P ${PROGRAMMER_PORT} -U ${IMAGE_FILE}
index 6096accf67c2ad26f4506dd1673527166a1c5e13..cce8ccba9dc3d01b3bea6eede3648343dea6cc86 100644 (file)
@@ -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:
index e9861a064c324e0fcfcd16af88d59ef0eb65b671..6061be8ce1d2460b3d0a1a27b9761b1e4b1095b1 100644 (file)
@@ -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