Skip to content

Commit

Permalink
Merge pull request #2852 from kaspar030/refactor_board_makefiles
Browse files Browse the repository at this point in the history
make: boards: refactor board makefiles
  • Loading branch information
haukepetersen committed May 26, 2015
2 parents ec9d5ea + 302699e commit 9e273be
Show file tree
Hide file tree
Showing 56 changed files with 350 additions and 4,346 deletions.
1 change: 1 addition & 0 deletions Makefile.pseudomodules
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ PSEUDOMODULES += ng_ipv6_router
PSEUDOMODULES += ng_ipv6_router_default
PSEUDOMODULES += pktqueue
PSEUDOMODULES += ng_netbase
PSEUDOMODULES += newlib
PSEUDOMODULES += ng_sixlowpan_default
PSEUDOMODULES += log
PSEUDOMODULES += log_printfnoformat
Expand Down
32 changes: 32 additions & 0 deletions boards/Makefile.include.cortex_common
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# we build all cortex boards with the GNU toolchain
export PREFIX = arm-none-eabi-
include $(RIOTBOARD)/Makefile.include.gnu

# use cortex name of CPU folder, but enable board Makefile to override
export MCPU ?= $(CORTEX)

# define build specific options
export CFLAGS_CPU = -mcpu=$(MCPU) -mlittle-endian -mthumb -mno-thumb-interwork $(CFLAGS_FPU)
export CFLAGS_STYLE = -std=gnu99 -Wall -Wstrict-prototypes
export CFLAGS_LINK = -ffunction-sections -fdata-sections -fno-builtin
export CFLAGS_DBG = -ggdb -g3
export CFLAGS_OPT ?= -Os
export CFLAGS += $(CFLAGS_CPU) $(CFLAGS_STYLE) $(CFLAGS_LINK) $(CFLAGS_DBG) $(CFLAGS_OPT)

export ASFLAGS += $(CFLAGS_CPU) $(CFLAGS_DEBUG)
export LINKFLAGS += -L$(RIOTCPU)/$(CPU)
export LINKFLAGS += $(CFLAGS_DEBUG) $(CFLAGS_CPU) $(CFLAGS_STYLE) -static -lgcc -nostartfiles -T$(LINKERSCRIPT)

export OFLAGS ?= -O ihex
export FFLAGS ?= flash
export DEBUGGER_FLAGS ?= debug
export DEBUGSERVER_FLAGS ?= debug-server
export RESET_FLAGS ?= reset

# use the nano-specs of the NewLib when 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
8 changes: 8 additions & 0 deletions boards/Makefile.include.gnu
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
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 DBG = $(PREFIX)gdb
4 changes: 4 additions & 0 deletions boards/Makefile.include.openocd
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export FLASHER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export DEBUGGER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export DEBUGSERVER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export RESET = $(RIOTBASE)/dist/tools/openocd/openocd.sh
17 changes: 17 additions & 0 deletions boards/Makefile.include.serial
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# set default port depending on operating system
OS := $(shell uname)
ifeq ($(OS),Linux)
PORT ?= $(PORT_LINUX)
else ifeq ($(OS),Darwin)
PORT ?= $(PORT_DARWIN)
endif

ifeq ($(PORT),)
$(info Warning: no PORT set!)
endif

export BAUD ?= 115200
export TERMFLAGS += -p "$(PORT)" -b "$(BAUD)"
export TERMPROG = $(RIOTBASE)/dist/tools/pyterm/pyterm

export PORT
61 changes: 9 additions & 52 deletions boards/airfy-beacon/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,15 @@
export CPU = nrf51822
export CPU_MODEL = nrf51822qfaa

#define the default port depending on the host OS
OS := $(shell uname)
ifeq ($(OS),Linux)
PORT ?= /dev/ttyUSB0
else ifeq ($(OS),Darwin)
PORT ?= $(shell ls -1 /dev/tty.SLAB_USBtoUART* | head -n 1)
else
$(info CAUTION: No flash tool for your host system found!)
# TODO: add support for windows as host platform
endif
export PORT
# define the default port depending on the host OS
PORT_LINUX ?= /dev/ttyUSB0
PORT_DARWIN ?= $(shell ls -1 /dev/tty.SLAB_USBtoUART* | head -n 1)

# define tools used for building the project
export PREFIX = arm-none-eabi-
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 DBG = $(PREFIX)gdb
export TERMPROG = $(RIOTBASE)/dist/tools/pyterm/pyterm
export FLASHER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export DEBUGGER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export DEBUGSERVER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export RESET = $(RIOTBASE)/dist/tools/openocd/openocd.sh
# setup serial terminal
include $(RIOTBOARD)/Makefile.include.serial

# define build specific options
CPU_USAGE = -mcpu=cortex-m0
FPU_USAGE =
export CFLAGS += -ggdb -g3 -std=gnu99 -Os -Wall -Wstrict-prototypes $(CPU_USAGE) $(FPU_USAGE) -mlittle-endian -mthumb -mno-thumb-interwork -nostartfiles
export CFLAGS += -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 -lgcc -mthumb -mno-thumb-interwork -nostartfiles
# $(LINKERSCRIPT) is specified in cpu/Makefile.include
export LINKFLAGS += -T$(LINKERSCRIPT)
export OFLAGS = -O ihex
export TERMFLAGS += -p "$(PORT)"
export FFLAGS = flash
export DEBUGGER_FLAGS = debug
export DEBUGSERVER_FLAGS = debug-server
export RESET_FLAGS = reset
# this board uses openocd
include $(RIOTBOARD)/Makefile.include.openocd

# unwanted (CXXUWFLAGS) and extra (CXXEXFLAGS) flags for c++
export CXXUWFLAGS +=
export CXXEXFLAGS +=

# use the nano-specs of the NewLib when 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
# include cortex defaults
include $(RIOTBOARD)/Makefile.include.cortex_common
46 changes: 8 additions & 38 deletions boards/arduino-due/Makefile.include
Original file line number Diff line number Diff line change
@@ -1,45 +1,15 @@
# define the cpu used by the arduino due board
export CPU = sam3x8e

# define tools used for building the project
export PREFIX = arm-none-eabi-
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 = $(RIOTBOARD)/$(BOARD)/dist/flash.sh
export OFLAGS = -O binary

#define the flash-tool and default port depending on the host operating system
OS := $(shell uname)
ifeq ($(OS),Linux)
PORT ?= /dev/ttyACM0
else ifeq ($(OS),Darwin)
PORT ?= $(shell ls -1 /dev/tty.usbmodem* | head -n 1)
else
$(info CAUTION: No flash tool for your host system found!)
# TODO: add support for windows as host platform
endif
export PORT
# define the default port depending on the host OS
PORT_LINUX ?= /dev/ttyACM0
PORT_DARWIN ?= $(shell ls -1 /dev/tty.usbmodem* | head -n 1)

# define build specific options
export CPU_USAGE = -mcpu=cortex-m3
export CFLAGS += -ggdb -g3 -std=gnu99 -Os -Wall -Wstrict-prototypes $(CPU_USAGE) $(FPU_USAGE) -mlittle-endian -mthumb -mno-thumb-interwork -nostartfiles
export CFLAGS += -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 -lgcc -mthumb -mno-thumb-interwork -nostartfiles
# linkerscript specified in cpu/Makefile.include
export LINKFLAGS += -T$(LINKERSCRIPT)
export OFLAGS += -O binary
export TERMFLAGS += -p "$(PORT)"
# setup serial terminal
include $(RIOTBOARD)/Makefile.include.serial

# use the nano-specs of the NewLib when 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
# include cortex defaults
include $(RIOTBOARD)/Makefile.include.cortex_common
42 changes: 8 additions & 34 deletions boards/cc2538dk/Makefile.include
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
# Define the cpu used by the CC2538DK board:
export CPU = cc2538

export CPU_MODEL ?= cc2538nf53

# Define tools used for building the project:
export PREFIX ?= arm-none-eabi-

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 OBJDUMP = $(PREFIX)objdump
# setup serial terminal
export PORT ?= /dev/ttyUSB1
include $(RIOTBOARD)/Makefile.include.serial

export TERMPROG ?= $(RIOTBASE)/dist/tools/pyterm/pyterm
# debugger config
export DEBUGGER = $(RIOTBOARD)/$(BOARD)/dist/debug.sh
export DEBUGSERVER = JLinkGDBServer -device CC2538SF53
export RESET = $(RIOTBOARD)/$(BOARD)/dist/reset.sh
Expand All @@ -31,30 +22,13 @@ else ifeq ($(PROGRAMMER),jlink)
export FFLAGS = $(BINDIR) $(HEXFILE)
endif

export PORT ?= /dev/ttyUSB1

# Define build specific options:
export CPU_USAGE = -mcpu=cortex-m3

export ASFLAGS += -ggdb -g3 $(CPU_USAGE) $(FPU_USAGE) -mlittle-endian
export CFLAGS += $(ASFLAGS) -std=gnu99 -mthumb -mno-thumb-interwork -nostartfiles -Os -Wall -Wstrict-prototypes -ffunction-sections -fdata-sections -fno-builtin
export LINKFLAGS += $(CFLAGS) -static -lgcc -T$(LINKERSCRIPT) -L$(RIOTCPU)/$(CPU)
export OFLAGS += -O binary --gap-fill 0xff
export LINKFLAGS += -L$(RIOTCPU)/$(CPU)
export OFLAGS = -O binary --gap-fill 0xff
export HEXFILE = $(ELFFILE:.elf=.bin)
export TERMFLAGS += -p "$(PORT)"
export DEBUGGER_FLAGS = $(BINDIR) $(ELFFILE)
export RESET_FLAGS = $(BINDIR)

export OBJDUMPFLAGS += --disassemble --source --disassembler-options=force-thumb

# unwanted (CXXUWFLAGS) and extra (CXXEXFLAGS) flags for c++
export CXXUWFLAGS +=
export CXXEXFLAGS +=

# Use the nano-specs of the NewLib when 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
# include cortex defaults
include $(RIOTBOARD)/Makefile.include.cortex_common
51 changes: 10 additions & 41 deletions boards/f4vi1/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,22 @@
export CPU = stm32f4
export CPU_MODEL = stm32f415rg

#define the default port depending on the host OS
OS := $(shell uname)
ifeq ($(OS),Linux)
PORT ?= /dev/ttyUSB0
else ifeq ($(OS),Darwin)
PORT ?= $(shell ls -1 /dev/tty.SLAB_USBtoUART* | head -n 1)
else
$(info CAUTION: No flash tool for your host system found!)
# TODO: add support for windows as host platform
endif
export PORT
# define the default port depending on the host OS
PORT_LINUX ?= /dev/ttyUSB0
PORT_DARWIN ?= $(shell ls -1 /dev/tty.SLAB_USBtoUART* | head -n 1)

# define tools used for building the project
export PREFIX = arm-none-eabi-
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
# setup serial terminal
include $(RIOTBOARD)/Makefile.include.serial

# st-flash
export FLASHER = st-flash
export DEBUGGER = $(RIOTBOARD)/$(BOARD)/dist/debug.sh
export DEBUGSERVER = st-util

# define build specific options
CPU_USAGE = -mcpu=cortex-m4
FPU_USAGE = -mfloat-abi=hard -mfpu=fpv4-sp-d16
export CFLAGS += -ggdb -g3 -std=gnu99 -Os -Wall -Wstrict-prototypes $(CPU_USAGE) $(FPU_USAGE) -mlittle-endian -mthumb -mno-thumb-interwork -nostartfiles
export CFLAGS += -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 -lgcc -mthumb -mno-thumb-interwork -nostartfiles
export LINKFLAGS += -T$(LINKERSCRIPT)
#
export OFLAGS = -O binary
export FFLAGS = write bin/$(BOARD)/$(APPLICATION).hex 0x8000000
export DEBUGGER_FLAGS = $(RIOTBOARD)/$(BOARD)/dist/gdb.conf $(BINDIR)/$(APPLICATION).elf
export TERMFLAGS += -p "$(PORT)"

# unwanted (CXXUWFLAGS) and extra (CXXEXFLAGS) flags for c++
export CXXUWFLAGS +=
export CXXEXFLAGS +=

# 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
# include cortex defaults
include $(RIOTBOARD)/Makefile.include.cortex_common
63 changes: 10 additions & 53 deletions boards/fox/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -3,60 +3,17 @@ export CPU = stm32f1
export CPU_MODEL = stm32f103re

# set default port depending on operating system
OS := $(shell uname)
ifeq ($(OS),Linux)
PORT ?= /dev/ttyUSB1
else ifeq ($(OS),Darwin)
PORT ?= $(shell ls -1 /dev/tty.usbserial* | head -n 1)
else
$(info CAUTION: No PORT was defined for your host platform!)
# TODO: add support for windows as host platform
endif
export PORT
PORT_LINUX ?= /dev/ttyUSB1
PORT_DARWIN ?= $(shell ls -1 /dev/tty.usbserial* | head -n 1)

# define tools used for building the project
export PREFIX = arm-none-eabi-
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 DBG = $(PREFIX)gdb
export TERMPROG = $(RIOTBASE)/dist/tools/pyterm/pyterm
export FLASHER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export DEBUGGER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export DEBUGSERVER = $(RIOTBASE)/dist/tools/openocd/openocd.sh
export RESET = $(RIOTBASE)/dist/tools/openocd/openocd.sh
# setup serial terminal
include $(RIOTBOARD)/Makefile.include.serial

# define build specific options
export CPU_USAGE = -mcpu=cortex-m3
export FPU_USAGE =
export CFLAGS += -ggdb -g3 -std=gnu99 -Os -Wall -Wstrict-prototypes $(CPU_USAGE) $(FPU_USAGE) -mlittle-endian -mthumb -mno-thumb-interwork -nostartfiles
export CFLAGS += -ffunction-sections -fdata-sections -fno-builtin

# unwanted (CXXUWFLAGS) and extra (CXXEXFLAGS) flags for c++
export CXXUWFLAGS +=
export CXXEXFLAGS +=

export ASFLAGS += -ggdb -g3 $(CPU_USAGE) $(FPU_USAGE) -mlittle-endian
export LINKFLAGS += -ggdb -g3 -std=gnu99 $(CPU_USAGE) $(FPU_USAGE) -mlittle-endian -static -lgcc -mthumb -mno-thumb-interwork -nostartfiles
# $(LINKERSCRIPT) is specified in cpu/Makefile.include
export LINKFLAGS += -T$(LINKERSCRIPT)
export OFLAGS = -O ihex
export TERMFLAGS += -p "$(PORT)"
export FFLAGS = flash
export DEBUGGER_FLAGS = debug
export DEBUGSERVER_FLAGS = debug-server
export RESET_FLAGS = reset

# use the nano-specs of the NewLib when 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/ -I$(RIOTBASE)/drivers/at86rf231/include -I$(RIOTBASE)/sys/net/include
# this board uses openocd
include $(RIOTBOARD)/Makefile.include.openocd

# include board dependencies
include $(RIOTBOARD)/$(BOARD)/Makefile.dep

# include cortex defaults
include $(RIOTBOARD)/Makefile.include.cortex_common
Loading

0 comments on commit 9e273be

Please sign in to comment.