Skip to content

Commit

Permalink
Adding WINC1500-XSTK bootloader binaries
Browse files Browse the repository at this point in the history
Signed-off-by: Thibaut VIARD <[email protected]>
  • Loading branch information
aethaniel committed Mar 21, 2017
1 parent 1465fa0 commit 7e91610
Show file tree
Hide file tree
Showing 3 changed files with 558 additions and 0 deletions.
182 changes: 182 additions & 0 deletions module/bootloaders/atmel_winc1500_xstk/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
# Copyright (c) 2015 Atmel Corp./Thibaut VIARD. All right reserved.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

# -----------------------------------------------------------------------------
# Paths
ifeq ($(OS),Windows_NT)

# Are we using mingw/msys/msys2/cygwin?
ifeq ($(TERM),xterm)
T=$(shell cygpath -u $(LOCALAPPDATA))
# T=$(shell cygpath -u $(APPDATA))
MODULE_PATH?=$(T)/Arduino15/packages/arduino
ARM_GCC_PATH?=$(MODULE_PATH)/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-
RM=rm
SEP=/
else
MODULE_PATH?=$(LOCALAPPDATA)/Arduino15/packages/arduino
# MODULE_PATH?=$(APPDATA)/Arduino15/packages/arduino
ARM_GCC_PATH?=$(MODULE_PATH)/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-
RM=rm
SEP=\\
endif
else
UNAME_S := $(shell uname -s)

ifeq ($(UNAME_S),Linux)
MODULE_PATH?=$HOME/.arduino15/packages/arduino
ARM_GCC_PATH?=$(MODULE_PATH)/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-
RM=rm
SEP=/
endif

ifeq ($(UNAME_S),Darwin)
MODULE_PATH?=$HOME/Library/Arduino15/packages/arduino/
ARM_GCC_PATH?=$(MODULE_PATH)/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-
RM=rm
SEP=/
endif
endif

BUILD_PATH=build

# -----------------------------------------------------------------------------
# Tools
CC=$(ARM_GCC_PATH)gcc
OBJCOPY=$(ARM_GCC_PATH)objcopy
NM=$(ARM_GCC_PATH)nm
SIZE=$(ARM_GCC_PATH)size

# -----------------------------------------------------------------------------
# Compiler options
#-w
CFLAGS=-mthumb -mcpu=cortex-m0plus -Wall -c -std=gnu99 -ffunction-sections -fdata-sections -nostdlib -nostartfiles --param max-inline-insns-single=500
ifdef DEBUG
CFLAGS+=-g3 -O1 -DDEBUG=1
else
CFLAGS+=-Os -DDEBUG=0
endif
# we put here the Atmel SAM-BA USB VID/PID and remove the support of Serial, because Serial pins are different than Zero ones
CFLAGS_EXTRA?=-D__SAMD21J18A__ -DUSB_PID_LOW=0x24 -DUSB_PID_HIGH=0x61 -DUSB_VID_LOW=0xEB -DUSB_VID_HIGH=0x03 -DSAM_BA_INTERFACE=2
INCLUDES=-I"$(MODULE_PATH)/tools/CMSIS/4.0.0-atmel/CMSIS/Include/" -I"$(MODULE_PATH)/tools/CMSIS/4.0.0-atmel/Device/ATMEL/"

# -----------------------------------------------------------------------------
# Linker options
LDFLAGS=-mthumb -mcpu=cortex-m0plus -Wall -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all
LDFLAGS+=-Wl,--warn-common -Wl,--warn-section-align -Wl,--warn-unresolved-symbols --specs=nano.specs --specs=nosys.specs

# -----------------------------------------------------------------------------
# Source files and objects
# this path has to be updated if Arduino delivers any samd-core update!
PROJECT_PATH=$(MODULE_PATH)/hardware/samd/1.6.2/bootloaders/zero
SOURCES_ORIG= \
board_driver_led.c \
board_driver_serial.c \
board_driver_usb.c \
board_init.c \
board_startup.c \
main.c \
sam_ba_usb.c \
sam_ba_cdc.c \
sam_ba_monitor.c \
sam_ba_serial.c

#VPATH=$(PROJECT_PATH)
SOURCES=$(addprefix $(PROJECT_PATH)/,$(SOURCES_ORIG))
OBJECTS=$(addprefix $(BUILD_PATH)/,$(SOURCES_ORIG:.c=.o))
#DEPS=$(addprefix $(BUILD_PATH)/, $(SOURCES:.c=.d))

NAME=samd21_sam_ba
ELF=$(NAME).elf
BIN=$(NAME).bin
HEX=$(NAME).hex

ifneq "test$(AVRSTUDIO_EXE_PATH)" "test"
AS_BUILD=copy_for_atmel_studio
AS_CLEAN=clean_for_atmel_studio
else
AS_BUILD=
AS_CLEAN=
endif

all: print_info $(BIN) $(HEX) $(AS_BUILD)

$(ELF): Makefile $(BUILD_PATH) $(OBJECTS)
@echo ----------------------------------------------------------
@echo Creating ELF binary
"$(CC)" -L"$(PROJECT_PATH)" $(LDFLAGS) -Os -Wl,--gc-sections -save-temps -Tbootloader_samd21x18.ld -Wl,-Map,"$(BUILD_PATH)/$(NAME).map" -o "$(BUILD_PATH)/$(ELF)" -Wl,--start-group $(OBJECTS) -lm -Wl,--end-group
"$(NM)" "$(BUILD_PATH)/$(ELF)" >"$(BUILD_PATH)/$(NAME)_symbols.txt"
"$(SIZE)" --format=sysv -t -x $(BUILD_PATH)/$(ELF)

$(BIN): $(ELF)
@echo ----------------------------------------------------------
@echo Creating flash binary
"$(OBJCOPY)" -O binary $(BUILD_PATH)/$< $@

$(HEX): $(ELF)
@echo ----------------------------------------------------------
@echo Creating flash binary
"$(OBJCOPY)" -O ihex $(BUILD_PATH)/$< $@

$(BUILD_PATH)/%.o: $(BUILD_PATH)

$(BUILD_PATH)/%.o: $(PROJECT_PATH)/%.c
@echo ----------------------------------------------------------
@echo Compiling $< to $@
"$(CC)" $(CFLAGS) $(CFLAGS_EXTRA) $(INCLUDES) "$<" -o $@
@echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

$(BUILD_PATH):
@echo ----------------------------------------------------------
@echo Creating build folder
-mkdir $(BUILD_PATH)

print_info:
@echo ----------------------------------------------------------
@echo Compiling bootloader using
@echo BASE PATH = $(MODULE_PATH)
@echo GCC PATH = $(ARM_GCC_PATH)
@echo PROJ PATH = $(PROJECT_PATH)
@echo SRC_ORIG = $(SOURCES_ORIG)
@echo SRC = $(SOURCES)
@echo OBJ = $(OBJECTS)
# @echo OS = $(OS)
# @echo SHELL = $(SHELL)
# @echo TERM = $(TERM)
"$(CC)" -v
"$(MAKE)" -v
# env
@echo ----------------------------------------------------------

copy_for_atmel_studio: $(BIN) $(HEX)
@echo ----------------------------------------------------------
@echo Atmel Studio detected, copying ELF to project root for debug
cp $(BUILD_PATH)/$(ELF) .

clean_for_atmel_studio:
@echo ----------------------------------------------------------
@echo Atmel Studio detected, cleaning ELF from project root
-$(RM) ./$(ELF)

clean: $(AS_CLEAN)
@echo ----------------------------------------------------------
@echo Cleaning project
-$(RM) -f $(BIN)
-$(RM) -f $(HEX)
-$(RM) -f $(BUILD_PATH)/*
-rmdir $(BUILD_PATH)

.PHONY: print_info $(BUILD_PATH) clean_for_atmel_studio
Binary file not shown.
Loading

0 comments on commit 7e91610

Please sign in to comment.