2016-04-22 17:51:59 +02:00
|
|
|
CONTIKI_TARGET_DIRS = . dev apps net loader dev/arduino
|
2013-02-19 10:22:48 +01:00
|
|
|
|
|
|
|
CONTIKI_CORE=contiki-main
|
|
|
|
CONTIKI_TARGET_MAIN = ${CONTIKI_CORE}.o
|
|
|
|
CONTIKI_TARGET_SOURCEFILES += contiki-main.c params.c node-id.c
|
|
|
|
#Needed for slip
|
2016-04-22 17:51:59 +02:00
|
|
|
CONTIKI_TARGET_SOURCEFILES += led.c sensors.c slip_uart0.c slip.c leds-arch.c
|
|
|
|
CONTIKI_TARGET_SOURCEFILES += temperature-sensor.c adc.c
|
2013-02-19 10:22:48 +01:00
|
|
|
#Needed for Button
|
|
|
|
CONTIKI_TARGET_SOURCEFILES += button-sensor.c
|
2014-06-21 21:30:48 +02:00
|
|
|
# i2c Master
|
2016-02-27 22:13:12 +01:00
|
|
|
#CONTIKI_TARGET_SOURCEFILES += i2c.c
|
2013-02-19 10:22:48 +01:00
|
|
|
#Needed for DHT11 humidity sensor
|
|
|
|
CONTIKI_TARGET_SOURCEFILES += dht11.c
|
|
|
|
#Needed for DS18S20 temperature sensor
|
|
|
|
CONTIKI_TARGET_SOURCEFILES += ds1820.c
|
|
|
|
#Needed for Battery test
|
2013-08-20 13:34:01 +02:00
|
|
|
CONTIKI_TARGET_SOURCEFILES += battery-sensor.c batmon.c
|
2013-02-19 10:22:48 +01:00
|
|
|
#Needed for PIR
|
|
|
|
CONTIKI_TARGET_SOURCEFILES += pir-sensor.c
|
2013-03-13 16:02:30 +01:00
|
|
|
#Needed for OPTRIAC
|
2014-07-14 20:31:04 +02:00
|
|
|
CONTIKI_TARGET_SOURCEFILES += optriac-sensor.c
|
2013-03-13 16:02:30 +01:00
|
|
|
#Needed for SERVO
|
2013-02-22 17:04:19 +01:00
|
|
|
CONTIKI_TARGET_SOURCEFILES += servo.c servo-sensor.c
|
2013-04-04 13:03:18 +02:00
|
|
|
#Needed for Timer4 Servo
|
2014-04-04 11:03:53 +02:00
|
|
|
#CONTIKI_TARGET_SOURCEFILES += t4-servo.c t4-servo-sensor.c
|
2013-11-22 16:34:13 +01:00
|
|
|
#Needed for Relay 1 to 4
|
|
|
|
CONTIKI_TARGET_SOURCEFILES += relay.c relay-sensor.c
|
2014-05-22 16:25:15 +02:00
|
|
|
# Arduino
|
2014-06-29 17:26:15 +02:00
|
|
|
CONTIKI_TARGET_SOURCEFILES += wiring_digital.c
|
2016-02-27 22:13:12 +01:00
|
|
|
CONTIKI_TARGET_SOURCEFILES += new.cpp twi.c Wire.cpp WMath.cpp
|
|
|
|
CONTIKI_TARGET_SOURCEFILES += Print.cpp Stream.cpp WString.cpp
|
2016-11-15 09:36:30 +01:00
|
|
|
CONTIKI_TARGET_SOURCEFILES += SPI.cpp
|
2016-11-09 15:14:45 +01:00
|
|
|
CONTIKI_TARGET_SOURCEFILES += HardwareSerial.cpp HardwareSerial1.cpp
|
2016-04-22 17:51:59 +02:00
|
|
|
# guh Source Files
|
|
|
|
# Smart Grid Ready Interface
|
|
|
|
CONTIKI_TARGET_SOURCEFILES += sg-ready.c
|
2015-01-25 18:31:17 +01:00
|
|
|
|
2016-04-22 17:51:59 +02:00
|
|
|
CONTIKIAVR=$(CONTIKI)/cpu/avr
|
2017-08-22 10:13:36 +02:00
|
|
|
THISPLATFORM=$(CONTIKI)/platform/osd-merkur-256
|
2013-02-22 17:04:19 +01:00
|
|
|
|
2013-02-19 10:22:48 +01:00
|
|
|
CONTIKIBOARD=.
|
2016-04-22 17:51:59 +02:00
|
|
|
BOOTLOADER_START = 0x3E000
|
2014-05-31 16:17:07 +02:00
|
|
|
CONTIKI_PLAT_DEFS = -DF_CPU=16000000UL -DAUTO_CRC_PADDING=2 -DPLAT_TIMER=5
|
2013-02-19 10:22:48 +01:00
|
|
|
|
2016-04-22 17:51:59 +02:00
|
|
|
MCU=atmega256rfr2
|
2013-02-19 10:22:48 +01:00
|
|
|
|
2016-04-22 17:51:59 +02:00
|
|
|
#AVRDUDE_PROGRAMMER=jtag2
|
|
|
|
AVRDUDE_PROGRAMMER=stk500v2
|
2013-02-19 10:22:48 +01:00
|
|
|
|
2016-04-22 17:51:59 +02:00
|
|
|
# For usb devices, you may either use PORT=usb, or (e.g. if you have
|
|
|
|
# more than one programmer connected) you can use the following trick to
|
|
|
|
# find out the serial number:
|
2013-02-19 10:22:48 +01:00
|
|
|
#
|
2016-04-22 17:51:59 +02:00
|
|
|
# The example is for an JTAGICE mkII used to program an atmega256:
|
|
|
|
# avrdude -v -P usb:xxxx -c jtag2 -p atmega256
|
|
|
|
# AVRDUDE_PORT=usb:00B000000D79
|
|
|
|
# For serial devices with bootloader we also use the AVRDUDE_PORT setting:
|
|
|
|
AVRDUDE_PORT=/dev/ttyUSB0
|
|
|
|
# Only needed for serial devices, use empty setting for other
|
|
|
|
# programmers
|
|
|
|
AVRDUDE_BAUD_OPTION=-b 57600
|
2013-02-19 10:22:48 +01:00
|
|
|
|
|
|
|
# Additional avrdude options
|
2016-04-22 17:51:59 +02:00
|
|
|
# First some flash options:
|
|
|
|
# Verify off is -V
|
|
|
|
# Erase is -e
|
|
|
|
# No-Erase (needed by our stk500 variant) is -D
|
|
|
|
# Note that it really doesn't turn off erase: It doesn't issue an
|
|
|
|
# explicit erase command (which is not implemented) but the bootloader
|
|
|
|
# *always* does an implicit erase when programming.
|
|
|
|
AVRDUDE_FLASH_OPTIONS=-D
|
|
|
|
AVRDUDE_OPTIONS=$(AVRDUDE_BAUD_OPTION) $(AVRDUDE_FLASH_OPTIONS)
|
|
|
|
AVRDUDE_MCU=m256rfr2
|
2013-02-19 10:22:48 +01:00
|
|
|
|
2013-06-04 11:28:42 +02:00
|
|
|
#debug
|
|
|
|
# CFLAGS += -save-temps
|
|
|
|
# Bootloader bonsai
|
|
|
|
# LDFLAGS += -save-temps
|
2016-04-22 17:51:59 +02:00
|
|
|
# For newer bootloaders we have a jump table at the end of the bootloader
|
|
|
|
# section: guhRF Bootloader MAC Address
|
|
|
|
BOOTLOADER_GET_MAC=0x0003ff80
|
2017-07-30 00:20:04 +02:00
|
|
|
BOOTLOADER_WRITE_PAGE_TO_FLASH=0x0003ff84
|
2017-08-19 19:25:38 +02:00
|
|
|
BOOTLOADER_GET_PART_COUNT=0x0003ff88
|
|
|
|
BOOTLOADER_GET_PART_SIZE=0x0003ff8c
|
|
|
|
BOOTLOADER_GET_PART_START=0x0003ff90
|
|
|
|
BOOTLOADER_SET_PART_OK=0x0003ff94
|
|
|
|
BOOTLOADER_CLR_PART_OK=0x0003ff98
|
|
|
|
BOOTLOADER_SET_BOOT_DEFAULT=0x0003ff9c
|
|
|
|
BOOTLOADER_SET_BOOT_NEXT=0x0003ffa0
|
|
|
|
BOOTLOADER_BACKUP_IRQ_TABLE=0x0003ffa4
|
|
|
|
BOOTLOADER_GET_BOOT_DEFAULT=0x0003ffa8
|
|
|
|
BOOTLOADER_GET_BOOT_NEXT=0x0003ffac
|
2017-08-22 20:20:07 +02:00
|
|
|
BOOTLOADER_GET_ACTIVE_PART=0x0003ffb0
|
2017-08-19 19:25:38 +02:00
|
|
|
BOOTLOADER_PARTITION=0
|
|
|
|
|
2017-08-22 10:13:36 +02:00
|
|
|
TEXT_SECTION_LENGTH=0x1ef00
|
|
|
|
PART_IRQVEC_SIZE=$(shell echo $$((0x800)))
|
|
|
|
|
2017-08-19 19:25:38 +02:00
|
|
|
ifeq ($(BOOTLOADER_PARTITION),0)
|
|
|
|
TEXT_SECTION_START=0x0
|
2017-08-22 10:13:36 +02:00
|
|
|
LOW_PARTITIONS=--only-section=.customlowtext --only-section=.text
|
2017-08-19 19:25:38 +02:00
|
|
|
else
|
2017-08-22 10:13:36 +02:00
|
|
|
TEXT_SECTION_START=$(TEXT_SECTION_LENGTH)
|
|
|
|
LOW_PARTITIONS=--only-section=.customlowtext
|
2017-08-19 19:25:38 +02:00
|
|
|
endif
|
2014-05-13 16:56:59 +02:00
|
|
|
|
2017-08-22 10:13:36 +02:00
|
|
|
PART_IRQVEC_BACKUP_START:=$(shell printf "0x%x" \
|
|
|
|
$$(($(TEXT_SECTION_START) + $(TEXT_SECTION_LENGTH) - $(PART_IRQVEC_SIZE))))
|
|
|
|
|
2017-08-20 20:57:17 +02:00
|
|
|
CUSTOM_SUFFIX=.$(BOOTLOADER_PARTITION)
|
|
|
|
|
2017-07-30 00:20:04 +02:00
|
|
|
LDFLAGS += -Wl,--defsym,bootloader_get_mac=$(BOOTLOADER_GET_MAC) \
|
2017-08-20 11:47:13 +02:00
|
|
|
-Wl,--defsym,_bootloader_write_page_to_flash=$(BOOTLOADER_WRITE_PAGE_TO_FLASH) \
|
2017-08-19 19:25:38 +02:00
|
|
|
-Wl,--defsym,bootloader_get_part_count=$(BOOTLOADER_GET_PART_COUNT) \
|
|
|
|
-Wl,--defsym,bootloader_get_part_size=$(BOOTLOADER_GET_PART_SIZE) \
|
|
|
|
-Wl,--defsym,bootloader_get_part_start=$(BOOTLOADER_GET_PART_START) \
|
2017-08-20 11:47:13 +02:00
|
|
|
-Wl,--defsym,_bootloader_set_part_ok=$(BOOTLOADER_SET_PART_OK) \
|
|
|
|
-Wl,--defsym,_bootloader_clr_part_ok=$(BOOTLOADER_CLR_PART_OK) \
|
|
|
|
-Wl,--defsym,_bootloader_set_boot_default=$(BOOTLOADER_SET_BOOT_DEFAULT) \
|
|
|
|
-Wl,--defsym,_bootloader_set_boot_next=$(BOOTLOADER_SET_BOOT_NEXT) \
|
|
|
|
-Wl,--defsym,_bootloader_backup_irq_table=$(BOOTLOADER_BACKUP_IRQ_TABLE) \
|
2017-08-19 19:25:38 +02:00
|
|
|
-Wl,--defsym,bootloader_get_boot_default=$(BOOTLOADER_GET_BOOT_DEFAULT) \
|
|
|
|
-Wl,--defsym,bootloader_get_boot_next=$(BOOTLOADER_GET_BOOT_NEXT) \
|
2017-08-22 20:20:07 +02:00
|
|
|
-Wl,--defsym,bootloader_get_active_part=$(BOOTLOADER_GET_ACTIVE_PART) \
|
2017-08-22 10:13:36 +02:00
|
|
|
-Wl,--defsym,__TEXT_SECTION_OFFSET__=$(TEXT_SECTION_START) \
|
|
|
|
-T $(THISPLATFORM)/custom-avr6.xm
|
2013-06-04 11:28:42 +02:00
|
|
|
|
2013-02-19 10:22:48 +01:00
|
|
|
|
|
|
|
include $(CONTIKIAVR)/Makefile.avr
|
|
|
|
include $(CONTIKIAVR)/radio/Makefile.radio
|
2014-04-14 13:27:01 +02:00
|
|
|
|
2015-01-25 18:31:17 +01:00
|
|
|
MODULES += core/net/mac core/net core/net/mac/sicslowmac \
|
2016-08-20 14:32:26 +02:00
|
|
|
core/net/mac/contikimac core/net/llsec core/net/llsec/noncoresec \
|
2014-12-29 11:02:51 +01:00
|
|
|
# core/net/ipv6 core/net/ipv4 core/net/ip \
|
|
|
|
# core/net/rime \
|
|
|
|
# core/net/rpl \
|
2017-08-20 20:57:17 +02:00
|
|
|
|
|
|
|
|
|
|
|
CUSTOM_RULE_LINK=1
|
|
|
|
|
|
|
|
%.$(TARGET)$(CUSTOM_SUFFIX): %.co $(PROJECT_OBJECTFILES) \
|
|
|
|
$(PROJECT_LIBRARIES) contiki-$(TARGET).a
|
|
|
|
$(TRACE_LD)
|
|
|
|
$(Q)$(LD) $(LDFLAGS) $(TARGET_STARTFILES) ${filter-out %.a,$^} \
|
|
|
|
${filter %.a,$^} $(TARGET_LIBFILES) -o $@
|
|
|
|
|
|
|
|
%: %.$(TARGET)
|
|
|
|
|
|
|
|
%: %.$(TARGET)$(CUSTOM_SUFFIX)
|
|
|
|
@
|
|
|
|
|
2017-08-22 10:13:36 +02:00
|
|
|
# Generic rules for .hex, .eep and .sz (size) file:
|
|
|
|
%.$(TARGET)$(CUSTOM_SUFFIX).hex: %.$(TARGET)$(CUSTOM_SUFFIX)
|
|
|
|
$(OBJCOPY) -j .customlowtext -j .text -j .data -O ihex $< $@
|
|
|
|
|
|
|
|
%.$(TARGET)$(CUSTOM_SUFFIX).eep: %.$(TARGET)$(CUSTOM_SUFFIX)
|
|
|
|
$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
|
|
|
|
--change-section-lma .eeprom=0 -O ihex $< $@
|
|
|
|
|
|
|
|
%.$(TARGET)$(CUSTOM_SUFFIX).sz: %.$(TARGET)$(CUSTOM_SUFFIX)
|
|
|
|
$(ELF_SIZE) $<
|
|
|
|
|
|
|
|
%.$(TARGET)$(CUSTOM_SUFFIX)-combined: %.$(TARGET)$(CUSTOM_SUFFIX)
|
|
|
|
cp $< $@.tmp
|
|
|
|
$(OBJCOPY) -O binary $(LOW_PARTITIONS) $< tmp.bin
|
|
|
|
truncate -s $(PART_IRQVEC_SIZE) tmp.bin
|
|
|
|
$(OBJCOPY) --add-section .upperlowtext=tmp.bin \
|
|
|
|
--change-section-address .upperlowtext=$(PART_IRQVEC_BACKUP_START) \
|
|
|
|
--set-section-flags .upperlowtext=alloc,load,contents,readonly \
|
|
|
|
$@.tmp
|
|
|
|
mv $@.tmp $@
|
|
|
|
rm -f tmp.bin
|
|
|
|
|
|
|
|
%.$(TARGET)$(CUSTOM_SUFFIX)-combined.hex: %.$(TARGET)$(CUSTOM_SUFFIX)-combined
|
|
|
|
$(OBJCOPY) -j .upperlowtext -j .customlowtext -j .text -j .data \
|
|
|
|
-O ihex $< $@
|
2017-08-20 20:57:17 +02:00
|
|
|
|
|
|
|
flash: $(EXE).$(TARGET)$(CUSTOM_SUFFIX)-combined.u
|
|
|
|
|
|
|
|
avr-size: $(EXE).$(TARGET)$(CUSTOM_SUFFIX).sz
|
|
|
|
|
|
|
|
.PHONY: flash avr-size
|
|
|
|
|
|
|
|
.PRECIOUS: %.$(TARGET)$(CUSTOM_SUFFIX) \
|
|
|
|
$(EXE).$(TARGET)$(CUSTOM_SUFFIX).hex \
|
|
|
|
$(EXE).$(TARGET)$(CUSTOM_SUFFIX).eep \
|
2017-08-22 10:13:36 +02:00
|
|
|
$(EXE).$(TARGET)$(CUSTOM_SUFFIX)-combined \
|
2017-08-20 20:57:17 +02:00
|
|
|
$(EXE).$(TARGET)$(CUSTOM_SUFFIX)-combined.hex
|