2015-01-12 14:42:48 +01:00
|
|
|
# define the cpu used by the Mulle board
|
2017-10-27 01:26:26 +02:00
|
|
|
export CPU = kinetis
|
2015-01-12 14:42:48 +01:00
|
|
|
|
|
|
|
# Default GDB port
|
|
|
|
export GDBPORT ?= 3333
|
|
|
|
|
|
|
|
# MULLE_SERIAL is used to select which specific Mulle board we are compiling for.
|
|
|
|
ifdef MULLE_SERIAL
|
|
|
|
CFLAGS += -DMULLE_SERIAL=$(MULLE_SERIAL)
|
|
|
|
endif
|
|
|
|
|
|
|
|
### CPU part number (must have a specific linker script for each part)
|
|
|
|
# Note that MK60DN256ZVLL10 (version 1.x) and MK60DN256VLL10 (version 2.x, no Z)
|
|
|
|
# only differ in some register locations etc, not in the actual memory layout,
|
|
|
|
# so it is safe to use the same linker script for both version 1.x and version
|
|
|
|
# 2.x silicon.
|
|
|
|
# The linker script needs to know the flash and RAM sizes of the device.
|
|
|
|
|
|
|
|
ifeq ($(CPU_MODEL),)
|
2017-03-25 18:24:22 +01:00
|
|
|
CPU_MODEL = mk60dn512vll10
|
2015-01-12 14:42:48 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
export CPU_MODEL
|
|
|
|
|
|
|
|
# OpenOCD settings for Mulle board.
|
|
|
|
# Try to determine which version of the OpenOCD config file we should use.
|
|
|
|
# Specify PROGRAMMER_VERSION or PROGRAMMER_SERIAL to choose a specific programmer board.
|
|
|
|
ifeq ($(PROGRAMMER_VERSION),)
|
|
|
|
ifneq ($(PROGRAMMER_SERIAL),)
|
|
|
|
# Makefile-way of comparing numbers, using lexicographical sorting since we don't have any arithmetic comparisons.
|
|
|
|
# Programmers with serial 100 -- 148 are version 0.60
|
|
|
|
# Programmers with serial 301 -- 330 are version 0.70
|
|
|
|
ifeq "100" "$(word 1, $(sort 100 $(PROGRAMMER_SERIAL)))"
|
|
|
|
# >= 100
|
|
|
|
ifneq "149" "$(word 1, $(sort 149 $(PROGRAMMER_SERIAL)))"
|
|
|
|
# < 149
|
|
|
|
PROGRAMMER_VERSION = 0.60
|
|
|
|
else
|
|
|
|
# >= 149
|
|
|
|
PROGRAMMER_VERSION = 0.70
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
2016-03-02 13:06:32 +01:00
|
|
|
# Default to version 0.70 programmer
|
|
|
|
PROGRAMMER_VERSION ?= 0.70
|
2015-01-12 14:42:48 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
export OPENOCD_CONFIG = $(RIOTBOARD)/$(BOARD)/dist/openocd/mulle-programmer-$(PROGRAMMER_VERSION).conf
|
|
|
|
|
|
|
|
# Add serial matching command
|
|
|
|
ifneq ($(PROGRAMMER_SERIAL),)
|
|
|
|
OPENOCD_EXTRA_INIT += -c 'ftdi_serial $(PROGRAMMER_SERIAL)'
|
|
|
|
endif
|
|
|
|
|
|
|
|
OPENOCD_EXTRA_INIT += $(CPU_OOCD_FLAGS)
|
|
|
|
|
2015-05-30 12:10:56 +02:00
|
|
|
# Host OS name
|
|
|
|
OS := $(shell uname)
|
|
|
|
|
2015-01-12 14:42:48 +01:00
|
|
|
ifeq ($(PORT),)
|
|
|
|
# try to find tty name by serial number, only works on Linux currently.
|
|
|
|
ifeq ($(OS),Linux)
|
|
|
|
ifneq ($(PROGRAMMER_SERIAL),)
|
2016-05-18 21:07:24 +02:00
|
|
|
PORT := $(firstword $(shell $(RIOTBASE)/dist/tools/usb-serial/find-tty.sh '^$(PROGRAMMER_SERIAL)$$'))
|
2015-01-12 14:42:48 +01:00
|
|
|
else
|
|
|
|
# find-tty.sh will return the first USB tty if no serial is given.
|
2016-05-18 21:07:24 +02:00
|
|
|
PORT := $(firstword $(shell $(RIOTBASE)/dist/tools/usb-serial/find-tty.sh))
|
2015-01-12 14:42:48 +01:00
|
|
|
endif
|
|
|
|
else ifeq ($(OS),Darwin)
|
2015-12-08 11:07:11 +01:00
|
|
|
ifneq ($(PROGRAMMER_SERIAL),)
|
|
|
|
PORT := /dev/tty.usbserial-$(PROGRAMMER_SERIAL)B
|
|
|
|
else
|
|
|
|
PORT := $(firstword $(sort $(wildcard /dev/tty.usbserial*)))
|
|
|
|
endif
|
2015-01-12 14:42:48 +01:00
|
|
|
endif
|
|
|
|
endif
|
2015-07-10 10:58:22 +02:00
|
|
|
ifeq ($(PORT),)
|
|
|
|
# fall back to a sensible default
|
|
|
|
PORT := /dev/ttyUSB0
|
|
|
|
endif
|
2015-01-12 14:42:48 +01:00
|
|
|
|
2015-05-23 11:05:57 +02:00
|
|
|
# We need special handling of the watchdog if we want to speed up the flash
|
|
|
|
# verification by using the MCU to compute the image checksum after flashing.
|
|
|
|
# wdog-disable.bin is a precompiled binary which will disable the watchdog and
|
|
|
|
# return control to the debugger (OpenOCD)
|
|
|
|
export OPENOCD_PRE_VERIFY_CMDS += \
|
2017-10-27 01:26:26 +02:00
|
|
|
-c 'load_image $(RIOTCPU)/$(CPU)/dist/wdog-disable.bin 0x20000000 bin' \
|
2015-05-23 11:05:57 +02:00
|
|
|
-c 'resume 0x20000000'
|
|
|
|
export OPENOCD_EXTRA_INIT
|
2017-10-27 01:26:26 +02:00
|
|
|
export PRE_FLASH_CHECK_SCRIPT = $(RIOTCPU)/$(CPU)/dist/check-fcfield-elf.sh
|
2015-05-23 11:05:57 +02:00
|
|
|
|
|
|
|
.PHONY: flash
|
2017-10-27 01:26:26 +02:00
|
|
|
flash: $(RIOTCPU)/$(CPU)/dist/wdog-disable.bin
|
2015-05-23 11:05:57 +02:00
|
|
|
|
|
|
|
# Reset the default goal.
|
|
|
|
.DEFAULT_GOAL :=
|
2015-01-12 14:42:48 +01:00
|
|
|
|
2015-05-30 12:10:56 +02:00
|
|
|
# this board uses openocd
|
2016-01-27 10:47:12 +01:00
|
|
|
include $(RIOTMAKE)/tools/openocd.inc.mk
|
2015-01-12 14:42:48 +01:00
|
|
|
|
2015-05-30 12:10:56 +02:00
|
|
|
# setup serial terminal
|
2016-01-27 10:47:12 +01:00
|
|
|
include $(RIOTMAKE)/tools/serial.inc.mk
|