Makefile.include
3.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# define the cpu used by the Mulle board
export CPU = k60
# 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),)
CPU_MODEL = mk60dn512vll10
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
# Default to version 0.70 programmer
PROGRAMMER_VERSION ?= 0.70
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)
# Host OS name
OS := $(shell uname)
ifeq ($(PORT),)
# try to find tty name by serial number, only works on Linux currently.
ifeq ($(OS),Linux)
ifneq ($(PROGRAMMER_SERIAL),)
PORT := $(firstword $(shell $(RIOTBASE)/dist/tools/usb-serial/find-tty.sh '^$(PROGRAMMER_SERIAL)$$'))
else
# find-tty.sh will return the first USB tty if no serial is given.
PORT := $(firstword $(shell $(RIOTBASE)/dist/tools/usb-serial/find-tty.sh))
endif
else ifeq ($(OS),Darwin)
ifneq ($(PROGRAMMER_SERIAL),)
PORT := /dev/tty.usbserial-$(PROGRAMMER_SERIAL)B
else
PORT := $(firstword $(sort $(wildcard /dev/tty.usbserial*)))
endif
endif
endif
ifeq ($(PORT),)
# fall back to a sensible default
PORT := /dev/ttyUSB0
endif
# 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 += \
-c 'load_image $(RIOTCPU)/kinetis_common/dist/wdog-disable.bin 0x20000000 bin' \
-c 'resume 0x20000000'
export OPENOCD_EXTRA_INIT
export PRE_FLASH_CHECK_SCRIPT = $(RIOTCPU)/kinetis_common/dist/check-fcfield-elf.sh
.PHONY: flash
flash: $(RIOTCPU)/kinetis_common/dist/wdog-disable.bin
# Reset the default goal.
.DEFAULT_GOAL :=
# this board uses openocd
include $(RIOTMAKE)/tools/openocd.inc.mk
# setup serial terminal
include $(RIOTMAKE)/tools/serial.inc.mk