Skip to content

Commit

Permalink
mulle: Initial import of Eistec Mulle board.
Browse files Browse the repository at this point in the history
Initially supports only Mulles with serial number > 220 (due to missing
MK60DN256ZVLL10 support in k60).

See also: https://github.com/RIOT-OS/RIOT/wiki/Board%3A-Mulle

Signed-off-by: Joakim Gebart <joakim.gebart@eistec.se>
  • Loading branch information
Joakim Gebart committed Jan 12, 2015
1 parent 6d01372 commit 304422b
Show file tree
Hide file tree
Showing 15 changed files with 1,724 additions and 0 deletions.
4 changes: 4 additions & 0 deletions boards/mulle/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# tell the Makefile.base which module to build
MODULE = $(BOARD)_base

include $(RIOTBASE)/Makefile.base
1 change: 1 addition & 0 deletions boards/mulle/Makefile.features
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FEATURES_PROVIDED = periph_gpio periph_uart periph_spi periph_i2c periph_pwm periph_adc periph_rtc periph_random periph_cpuid
174 changes: 174 additions & 0 deletions boards/mulle/Makefile.include
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
# define the cpu used by the Mulle board
export CPU = k60

### 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.

export GDBPORT ?= 3333

# MULLE_SERIAL is used to select which specific Mulle board we are compiling for.
# This was called MULLE_BOARD_SERIAL_NUMBER previously, renamed because
# MULLE_BOARD_SERIAL_NUMBER is too long to type.
ifdef MULLE_SERIAL
ifeq "200" "$(word 1, $(sort 200 $(MULLE_SERIAL)))"
# >= 100
ifneq "220" "$(word 1, $(sort 220 $(MULLE_SERIAL)))"
# < 220
CPU_MODEL = K60DN256ZVLL10
else
# >= 220
CPU_MODEL = K60DN512VLL10
endif
endif
CFLAGS += -DMULLE_SERIAL=$(MULLE_SERIAL)
endif

ifeq ($(CPU_MODEL),)
CPU_MODEL = K60DN512VLL10
endif

export CPU_MODEL

# Host OS name
OS := $(shell uname)

# 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.60 programmer for now.
PROGRAMMER_VERSION ?= 0.60
endif

OOCD_BOARD_FLAGS = -f '$(RIOTBOARD)/$(BOARD)/dist/openocd/mulle-programmer-$(PROGRAMMER_VERSION).conf'

# Add serial matching command
ifneq ($(PROGRAMMER_SERIAL),)
OOCD_BOARD_FLAGS += -c 'ftdi_serial $(PROGRAMMER_SERIAL)'

ifeq ($(PORT),)
# try to find tty name by serial number, only works on Linux currently.
ifeq ($(OS),Linux)
PORT :=$(shell $(RIOTBOARD)/dist/tools/ftdi/find-tty.sh $(PROGRAMMER_SERIAL))
endif
endif
endif

ifeq ($(PORT),)
ifeq ($(OS),Linux)
PORT := /dev/ttyUSB0
else ifeq ($(OS),Darwin)
PORT := $(shell ls -1 /dev/tty.SLAB_USBtoUART* | head -n 1)
endif
endif

# TODO: add support for windows as host platform
ifeq ($(PORT),)
$(info CAUTION: No terminal port for your host system found!)
endif
export PORT

# Default optimization level, possible to override from command line.
OPTIMIZATION ?= -Os

# define tools used for building the project
export PREFIX ?= arm-none-eabi-
export GDBPREFIX ?= $(PREFIX)
export OPENOCD ?= openocd
export GDB ?= $(GDBPREFIX)gdb
export CC = $(PREFIX)gcc
export CXX = $(PREFIX)g++
export AR = $(PREFIX)ar
export AS = $(PREFIX)as
export LINK = $(PREFIX)gcc
export SIZE = $(PREFIX)size
export OBJCOPY = $(PREFIX)objcopy
export TERMPROG ?= $(RIOTBASE)/dist/tools/pyterm/pyterm
export FLASHER ?= $(OPENOCD)
export DEBUGGER ?= $(GDB)
export DEBUGSERVER ?= $(OPENOCD)
export RESET ?= $(OPENOCD)

# define build specific options
CPU_USAGE = -mcpu=cortex-m4
FPU_USAGE = -mfloat-abi=soft -msoft-float
export CFLAGS += -ggdb -g3 -std=gnu99 $(OPTIMIZATION) -Wall -Wstrict-prototypes -Werror=implicit-function-declaration $(CPU_USAGE) $(FPU_USAGE) -mlittle-endian -mthumb -mno-thumb-interwork -nostartfiles
export CFLAGS += -ffunction-sections -fdata-sections -fno-builtin
export CXXFLAGS += -ffunction-sections -fdata-sections -fno-builtin
export ASFLAGS += -ggdb -g3 $(CPU_USAGE) $(FPU_USAGE) -mlittle-endian
export LINKFLAGS += -g3 -ggdb -std=gnu99 $(CPU_USAGE) $(FPU_USAGE) -mlittle-endian -static -mthumb -nostartfiles -Wl,--fatal-warnings
export LINKFLAGS += -L$(LINKERSCRIPTPATH) -T$(LINKERSCRIPT)
export OFLAGS ?= -O binary

FFLAGS ?= $(OOCD_BOARD_FLAGS)
FFLAGS += \
-c 'tcl_port 0' \
-c 'gdb_port 0' \
-c 'telnet_port 0' \
-c 'init' \
-c 'targets' \
-c 'reset halt' \
-c 'flash write_image erase bin/$(BOARD)/$(APPLICATION).elf 0x00000000 elf' \
-c 'verify_image bin/$(BOARD)/$(APPLICATION).elf' \
-c 'reset run' \
-c 'shutdown'

export FFLAGS

DEBUGSERVER_FLAGS ?= $(OOCD_BOARD_FLAGS)
DEBUGSERVER_FLAGS += \
-c 'tcl_port 0' \
-c 'gdb_port $(GDBPORT)' \
-c 'telnet_port 0' \
-c 'init' \
-c 'targets' \
-c 'reset halt'

export DEBUGSERVER_FLAGS

RESET_FLAGS ?= $(OOCD_BOARD_FLAGS)
RESET_FLAGS += \
-c 'tcl_port 0' \
-c 'gdb_port 0' \
-c 'telnet_port 0' \
-c 'init' \
-c 'reset run' \
-c 'shutdown'

export RESET_FLAGS

DEBUGGER_FLAGS ?= -x $(RIOTBOARD)/$(BOARD)/dist/gdb.conf
DEBUGGER_FLAGS += \
-ex 'tar ext :$(GDBPORT)' \
$(BINDIR)/$(APPLICATION).elf

export DEBUGGER_FLAGS

export TERMFLAGS += -p "$(PORT)"

# use newLib nano-specs if available
ifeq ($(shell $(LINK) -specs=nano.specs -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0)
export LINKFLAGS += -specs=nano.specs -lc -lnosys
endif

# export board specific includes to the global includes-listing
export INCLUDES += -I$(RIOTBOARD)/$(BOARD)/include
65 changes: 65 additions & 0 deletions boards/mulle/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright (C) 2014 Eistec AB
*
* This file is subject to the terms and conditions of the GNU Lesser General
* Public License v2.1. See the file LICENSE in the top level directory for more
* details.
*/

/**
* @ingroup board_k60
* @{
*
* @file
* @brief Board specific implementations for the Mulle board
*
* @author Joakim Gebart <joakim.gebart@eistec.se>
*
* @}
*/

#include <stddef.h> /* for NULL */
#include <stdio.h>
#include "board.h"
#include "cpu.h"
#include "periph/gpio.h"
#include "periph/uart.h"
#include "devicemap.h"

static void leds_init(void);

void board_init(void)
{
/* initialize the boards LEDs, this is done first for debugging purposes */
leds_init();

LED_RED_ON;

/* Set up clocks */
SystemInit();

/* Update SystemCoreClock global var */
SystemCoreClockUpdate();

/* initialize the CPU */
cpu_init();

LED_YELLOW_ON;

devicemap_init();
}

/**
* @brief Initialize the boards on-board LEDs
*
* The LEDs are initialized here in order to be able to use them in the early
* boot for diagnostics.
*
*/
static void leds_init(void)
{
/* The pin configuration can be found in board.h and periph_conf.h */
gpio_init_out(LED_RED_GPIO, GPIO_NOPULL);
gpio_init_out(LED_YELLOW_GPIO, GPIO_NOPULL);
gpio_init_out(LED_GREEN_GPIO, GPIO_NOPULL);
}
Loading

0 comments on commit 304422b

Please sign in to comment.