aboutsummaryrefslogtreecommitdiff
path: root/atmel-samd/asf4/samd21/gcc
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2017-09-22 18:05:51 -0700
committerDan Halbert <halbert@halwitz.org>2017-09-22 21:05:51 -0400
commit6839fff31303463d5c7942387fa498895edf1abf (patch)
treef4c5b94c6534c8d5c65ea6b7209cd2d681508f5f /atmel-samd/asf4/samd21/gcc
parent3ad01ddb04b160b74b4baee9fce043da17dbcef5 (diff)
Move to ASF4 and introduce SAMD51 support. (#258)3.0.0-alpha.0
* atmel-samd: Remove ASF3. This will break builds. * atmel-samd: Add ASF4 for the SAMD21 and SAMD51. * Introduce the supervisor concept to facilitate porting. The supervisor is the code which runs individual MicroPython VMs. By splitting it out we make it more consistent and easier to find. This also adds very basic SAMD21 and SAMD51 support using the supervisor. Only the REPL currently works. This begins the work for #178.
Diffstat (limited to 'atmel-samd/asf4/samd21/gcc')
-rw-r--r--atmel-samd/asf4/samd21/gcc/Makefile282
-rw-r--r--atmel-samd/asf4/samd21/gcc/gcc/samd21g18a_flash.ld142
-rw-r--r--atmel-samd/asf4/samd21/gcc/gcc/samd21g18a_sram.ld141
-rw-r--r--atmel-samd/asf4/samd21/gcc/gcc/startup_samd21.c265
-rw-r--r--atmel-samd/asf4/samd21/gcc/system_samd21.c63
5 files changed, 893 insertions, 0 deletions
diff --git a/atmel-samd/asf4/samd21/gcc/Makefile b/atmel-samd/asf4/samd21/gcc/Makefile
new file mode 100644
index 000000000..8e31a0231
--- /dev/null
+++ b/atmel-samd/asf4/samd21/gcc/Makefile
@@ -0,0 +1,282 @@
+
+################################################################################
+# Automatically-generated file. Do not edit!
+################################################################################
+
+ifdef SystemRoot
+ SHELL = cmd.exe
+ MK_DIR = mkdir
+else
+ ifeq ($(shell uname), Linux)
+ MK_DIR = mkdir -p
+ endif
+
+ ifeq ($(shell uname | cut -d _ -f 1), CYGWIN)
+ MK_DIR = mkdir -p
+ endif
+
+ ifeq ($(shell uname | cut -d _ -f 1), MINGW32)
+ MK_DIR = mkdir -p
+ endif
+
+ ifeq ($(shell uname | cut -d _ -f 1), MINGW64)
+ MK_DIR = mkdir -p
+ endif
+endif
+
+# List the subdirectories for creating object files
+SUB_DIRS += \
+ \
+hpl/adc \
+hal/src \
+examples \
+hpl/systick \
+hpl/tc \
+usb \
+hpl/dmac \
+usb/class/cdc/device \
+hal/utils/src \
+hpl/rtc \
+usb/class/hid/device \
+hpl/usb \
+samd21a/gcc/gcc \
+hpl/pm \
+hpl/sysctrl \
+hpl/gclk \
+usb/device \
+hpl/dac \
+samd21a/gcc \
+hpl/sercom \
+hpl/nvmctrl \
+hpl/core
+
+# List the object files
+OBJS += \
+hal/src/hal_io.o \
+hpl/systick/hpl_systick.o \
+samd21a/gcc/gcc/startup_samd21.o \
+usb/usb_protocol.o \
+usb/class/hid/device/hiddf_generic.o \
+usb/class/cdc/device/cdcdf_acm.o \
+hal/utils/src/utils_syscalls.o \
+hpl/nvmctrl/hpl_nvmctrl.o \
+hal/src/hal_spi_m_sync.o \
+hal/src/hal_timer.o \
+hal/src/hal_pwm.o \
+hpl/usb/hpl_usb.o \
+hal/src/hal_i2c_m_sync.o \
+hal/src/hal_delay.o \
+hpl/sysctrl/hpl_sysctrl.o \
+hpl/core/hpl_init.o \
+hal/utils/src/utils_list.o \
+hpl/core/hpl_core_m0plus_base.o \
+hal/utils/src/utils_assert.o \
+hpl/dmac/hpl_dmac.o \
+hpl/pm/hpl_pm.o \
+usb/class/hid/device/hiddf_keyboard.o \
+hal/src/hal_usart_sync.o \
+hpl/dac/hpl_dac.o \
+hpl/gclk/hpl_gclk.o \
+hal/src/hal_flash.o \
+hal/src/hal_init.o \
+hal/src/hal_usb_device.o \
+main.o \
+samd21a/gcc/system_samd21.o \
+hpl/rtc/hpl_rtc.o \
+examples/driver_examples.o \
+driver_init.o \
+hal/src/hal_adc_sync.o \
+hal/src/hal_dac_sync.o \
+hpl/sercom/hpl_sercom.o \
+hal/src/hal_gpio.o \
+usb/class/hid/device/hiddf_mouse.o \
+hal/utils/src/utils_event.o \
+hal/src/hal_sleep.o \
+usb_start.o \
+atmel_start.o \
+usb/device/usbdc.o \
+hpl/tc/hpl_tc.o \
+hal/src/hal_atomic.o \
+hpl/adc/hpl_adc.o
+
+OBJS_AS_ARGS += \
+"hal/src/hal_io.o" \
+"hpl/systick/hpl_systick.o" \
+"samd21a/gcc/gcc/startup_samd21.o" \
+"usb/usb_protocol.o" \
+"usb/class/hid/device/hiddf_generic.o" \
+"usb/class/cdc/device/cdcdf_acm.o" \
+"hal/utils/src/utils_syscalls.o" \
+"hpl/nvmctrl/hpl_nvmctrl.o" \
+"hal/src/hal_spi_m_sync.o" \
+"hal/src/hal_timer.o" \
+"hal/src/hal_pwm.o" \
+"hpl/usb/hpl_usb.o" \
+"hal/src/hal_i2c_m_sync.o" \
+"hal/src/hal_delay.o" \
+"hpl/sysctrl/hpl_sysctrl.o" \
+"hpl/core/hpl_init.o" \
+"hal/utils/src/utils_list.o" \
+"hpl/core/hpl_core_m0plus_base.o" \
+"hal/utils/src/utils_assert.o" \
+"hpl/dmac/hpl_dmac.o" \
+"hpl/pm/hpl_pm.o" \
+"usb/class/hid/device/hiddf_keyboard.o" \
+"hal/src/hal_usart_sync.o" \
+"hpl/dac/hpl_dac.o" \
+"hpl/gclk/hpl_gclk.o" \
+"hal/src/hal_flash.o" \
+"hal/src/hal_init.o" \
+"hal/src/hal_usb_device.o" \
+"main.o" \
+"samd21a/gcc/system_samd21.o" \
+"hpl/rtc/hpl_rtc.o" \
+"examples/driver_examples.o" \
+"driver_init.o" \
+"hal/src/hal_adc_sync.o" \
+"hal/src/hal_dac_sync.o" \
+"hpl/sercom/hpl_sercom.o" \
+"hal/src/hal_gpio.o" \
+"usb/class/hid/device/hiddf_mouse.o" \
+"hal/utils/src/utils_event.o" \
+"hal/src/hal_sleep.o" \
+"usb_start.o" \
+"atmel_start.o" \
+"usb/device/usbdc.o" \
+"hpl/tc/hpl_tc.o" \
+"hal/src/hal_atomic.o" \
+"hpl/adc/hpl_adc.o"
+
+# List the dependency files
+DEPS := $(OBJS:%.o=%.d)
+
+DEPS_AS_ARGS += \
+"usb/usb_protocol.d" \
+"samd21a/gcc/gcc/startup_samd21.d" \
+"hal/utils/src/utils_event.d" \
+"hal/src/hal_io.d" \
+"hpl/systick/hpl_systick.d" \
+"usb/class/hid/device/hiddf_generic.d" \
+"hal/utils/src/utils_syscalls.d" \
+"usb/class/cdc/device/cdcdf_acm.d" \
+"usb/class/hid/device/hiddf_mouse.d" \
+"hal/src/hal_i2c_m_sync.d" \
+"hpl/usb/hpl_usb.d" \
+"hpl/nvmctrl/hpl_nvmctrl.d" \
+"hal/src/hal_pwm.d" \
+"hal/src/hal_timer.d" \
+"hal/src/hal_spi_m_sync.d" \
+"hpl/core/hpl_core_m0plus_base.d" \
+"hal/utils/src/utils_list.d" \
+"hpl/dmac/hpl_dmac.d" \
+"hal/utils/src/utils_assert.d" \
+"hal/src/hal_delay.d" \
+"hpl/core/hpl_init.d" \
+"hpl/sysctrl/hpl_sysctrl.d" \
+"hal/src/hal_flash.d" \
+"hpl/gclk/hpl_gclk.d" \
+"hal/src/hal_usb_device.d" \
+"usb_start.d" \
+"hal/src/hal_init.d" \
+"hal/src/hal_usart_sync.d" \
+"usb/class/hid/device/hiddf_keyboard.d" \
+"hpl/dac/hpl_dac.d" \
+"driver_init.d" \
+"hal/src/hal_adc_sync.d" \
+"samd21a/gcc/system_samd21.d" \
+"main.d" \
+"examples/driver_examples.d" \
+"hpl/rtc/hpl_rtc.d" \
+"hal/src/hal_sleep.d" \
+"hpl/sercom/hpl_sercom.d" \
+"hal/src/hal_dac_sync.d" \
+"hal/src/hal_gpio.d" \
+"hal/src/hal_atomic.d" \
+"hpl/tc/hpl_tc.d" \
+"usb/device/usbdc.d" \
+"hpl/pm/hpl_pm.d" \
+"hpl/adc/hpl_adc.d" \
+"atmel_start.d"
+
+OUTPUT_FILE_NAME :=AtmelStart
+QUOTE := "
+OUTPUT_FILE_PATH +=$(OUTPUT_FILE_NAME).elf
+OUTPUT_FILE_PATH_AS_ARGS +=$(OUTPUT_FILE_NAME).elf
+
+vpath %.c ../
+vpath %.s ../
+vpath %.S ../
+
+# All Target
+all: $(SUB_DIRS) $(OUTPUT_FILE_PATH)
+
+# Linker target
+
+
+$(OUTPUT_FILE_PATH): $(OBJS)
+ @echo Building target: $@
+ @echo Invoking: ARM/GNU Linker
+ $(QUOTE)arm-none-eabi-gcc$(QUOTE) -o $(OUTPUT_FILE_NAME).elf $(OBJS_AS_ARGS) -Wl,--start-group -lm -Wl,--end-group -mthumb \
+-Wl,-Map="$(OUTPUT_FILE_NAME).map" --specs=nano.specs -Wl,--gc-sections -mcpu=cortex-m0plus \
+ \
+ \
+-T"../samd21a/gcc/gcc/samd21g18a_flash.ld" \
+-L"../samd21a/gcc/gcc"
+ @echo Finished building target: $@
+
+ "arm-none-eabi-objcopy" -O binary "$(OUTPUT_FILE_NAME).elf" "$(OUTPUT_FILE_NAME).bin"
+ "arm-none-eabi-objcopy" -O ihex -R .eeprom -R .fuse -R .lock -R .signature \
+ "$(OUTPUT_FILE_NAME).elf" "$(OUTPUT_FILE_NAME).hex"
+ "arm-none-eabi-objcopy" -j .eeprom --set-section-flags=.eeprom=alloc,load --change-section-lma \
+ .eeprom=0 --no-change-warnings -O binary "$(OUTPUT_FILE_NAME).elf" \
+ "$(OUTPUT_FILE_NAME).eep" || exit 0
+ "arm-none-eabi-objdump" -h -S "$(OUTPUT_FILE_NAME).elf" > "$(OUTPUT_FILE_NAME).lss"
+ "arm-none-eabi-size" "$(OUTPUT_FILE_NAME).elf"
+
+# Compiler targets
+
+
+%.o: %.c
+ @echo Building file: $<
+ @echo ARM/GNU C Compiler
+ $(QUOTE)arm-none-eabi-gcc$(QUOTE) -x c -mthumb -DDEBUG -Os -ffunction-sections -mlong-calls -g3 -Wall -c -std=gnu99 \
+-D__SAMD21G18A__ -mcpu=cortex-m0plus \
+-I"../" -I"../config" -I"../examples" -I"../hal/include" -I"../hal/utils/include" -I"../hpl/adc" -I"../hpl/core" -I"../hpl/dac" -I"../hpl/dmac" -I"../hpl/gclk" -I"../hpl/nvmctrl" -I"../hpl/pm" -I"../hpl/port" -I"../hpl/rtc" -I"../hpl/sercom" -I"../hpl/sysctrl" -I"../hpl/systick" -I"../hpl/tc" -I"../hpl/usb" -I"../hri" -I"../" -I"../usb" -I"../usb/class/cdc" -I"../usb/class/cdc/device" -I"../usb/class/composite/device" -I"../usb/class/hid" -I"../usb/class/hid/device" -I"../usb/class/hub" -I"../usb/class/msc" -I"../usb/class/vendor" -I"../usb/device" -I"../" -I"../CMSIS/Include" -I"../samd21a/include" \
+-MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<"
+ @echo Finished building: $<
+
+%.o: %.s
+ @echo Building file: $<
+ @echo ARM/GNU Assembler
+ $(QUOTE)arm-none-eabi-as$(QUOTE) -x c -mthumb -DDEBUG -Os -ffunction-sections -mlong-calls -g3 -Wall -c -std=gnu99 \
+-D__SAMD21G18A__ -mcpu=cortex-m0plus \
+-I"../" -I"../config" -I"../examples" -I"../hal/include" -I"../hal/utils/include" -I"../hpl/adc" -I"../hpl/core" -I"../hpl/dac" -I"../hpl/dmac" -I"../hpl/gclk" -I"../hpl/nvmctrl" -I"../hpl/pm" -I"../hpl/port" -I"../hpl/rtc" -I"../hpl/sercom" -I"../hpl/sysctrl" -I"../hpl/systick" -I"../hpl/tc" -I"../hpl/usb" -I"../hri" -I"../" -I"../usb" -I"../usb/class/cdc" -I"../usb/class/cdc/device" -I"../usb/class/composite/device" -I"../usb/class/hid" -I"../usb/class/hid/device" -I"../usb/class/hub" -I"../usb/class/msc" -I"../usb/class/vendor" -I"../usb/device" -I"../" -I"../CMSIS/Include" -I"../samd21a/include" \
+-MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<"
+ @echo Finished building: $<
+
+%.o: %.S
+ @echo Building file: $<
+ @echo ARM/GNU Preprocessing Assembler
+ $(QUOTE)arm-none-eabi-gcc$(QUOTE) -x c -mthumb -DDEBUG -Os -ffunction-sections -mlong-calls -g3 -Wall -c -std=gnu99 \
+-D__SAMD21G18A__ -mcpu=cortex-m0plus \
+-I"../" -I"../config" -I"../examples" -I"../hal/include" -I"../hal/utils/include" -I"../hpl/adc" -I"../hpl/core" -I"../hpl/dac" -I"../hpl/dmac" -I"../hpl/gclk" -I"../hpl/nvmctrl" -I"../hpl/pm" -I"../hpl/port" -I"../hpl/rtc" -I"../hpl/sercom" -I"../hpl/sysctrl" -I"../hpl/systick" -I"../hpl/tc" -I"../hpl/usb" -I"../hri" -I"../" -I"../usb" -I"../usb/class/cdc" -I"../usb/class/cdc/device" -I"../usb/class/composite/device" -I"../usb/class/hid" -I"../usb/class/hid/device" -I"../usb/class/hub" -I"../usb/class/msc" -I"../usb/class/vendor" -I"../usb/device" -I"../" -I"../CMSIS/Include" -I"../samd21a/include" \
+-MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<"
+ @echo Finished building: $<
+
+# Detect changes in the dependent files and recompile the respective object files.
+ifneq ($(MAKECMDGOALS),clean)
+ifneq ($(strip $(DEPS)),)
+-include $(DEPS)
+endif
+endif
+
+$(SUB_DIRS):
+ $(MK_DIR) "$@"
+
+clean:
+ rm -f $(OBJS_AS_ARGS)
+ rm -f $(OUTPUT_FILE_PATH)
+ rm -f $(DEPS_AS_ARGS)
+ rm -f $(OUTPUT_FILE_NAME).a $(OUTPUT_FILE_NAME).hex $(OUTPUT_FILE_NAME).bin \
+ $(OUTPUT_FILE_NAME).lss $(OUTPUT_FILE_NAME).eep $(OUTPUT_FILE_NAME).map \
+ $(OUTPUT_FILE_NAME).srec
diff --git a/atmel-samd/asf4/samd21/gcc/gcc/samd21g18a_flash.ld b/atmel-samd/asf4/samd21/gcc/gcc/samd21g18a_flash.ld
new file mode 100644
index 000000000..2c94a53ba
--- /dev/null
+++ b/atmel-samd/asf4/samd21/gcc/gcc/samd21g18a_flash.ld
@@ -0,0 +1,142 @@
+/**
+ * \file
+ *
+ * \brief Linker script for running in internal FLASH on the SAMD21G18A
+ *
+ * Copyright (c) 2016 Atmel Corporation,
+ * a wholly owned subsidiary of Microchip Technology Inc.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the Licence at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * \asf_license_stop
+ *
+ */
+
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+SEARCH_DIR(.)
+
+/* Memory Spaces Definitions */
+MEMORY
+{
+ rom (rx) : ORIGIN = 0x00000000, LENGTH = 0x00040000
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000
+}
+
+/* The stack size used by the application. NOTE: you need to adjust according to your application. */
+STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
+
+/* Section Definitions */
+SECTIONS
+{
+ .text :
+ {
+ . = ALIGN(4);
+ _sfixed = .;
+ KEEP(*(.vectors .vectors.*))
+ *(.text .text.* .gnu.linkonce.t.*)
+ *(.glue_7t) *(.glue_7)
+ *(.rodata .rodata* .gnu.linkonce.r.*)
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+
+ /* Support C constructors, and C destructors in both user code
+ and the C library. This also provides support for C++ code. */
+ . = ALIGN(4);
+ KEEP(*(.init))
+ . = ALIGN(4);
+ __preinit_array_start = .;
+ KEEP (*(.preinit_array))
+ __preinit_array_end = .;
+
+ . = ALIGN(4);
+ __init_array_start = .;
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ __init_array_end = .;
+
+ . = ALIGN(4);
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*crtend.o(.ctors))
+
+ . = ALIGN(4);
+ KEEP(*(.fini))
+
+ . = ALIGN(4);
+ __fini_array_start = .;
+ KEEP (*(.fini_array))
+ KEEP (*(SORT(.fini_array.*)))
+ __fini_array_end = .;
+
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*crtend.o(.dtors))
+
+ . = ALIGN(4);
+ _efixed = .; /* End of text section */
+ } > rom
+
+ /* .ARM.exidx is sorted, so has to go in its own output section. */
+ PROVIDE_HIDDEN (__exidx_start = .);
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > rom
+ PROVIDE_HIDDEN (__exidx_end = .);
+
+ . = ALIGN(4);
+ _etext = .;
+
+ .relocate : AT (_etext)
+ {
+ . = ALIGN(4);
+ _srelocate = .;
+ *(.ramfunc .ramfunc.*);
+ *(.data .data.*);
+ . = ALIGN(4);
+ _erelocate = .;
+ } > ram
+
+ /* .bss section which is used for uninitialized data */
+ .bss (NOLOAD) :
+ {
+ . = ALIGN(4);
+ _sbss = . ;
+ _szero = .;
+ *(.bss .bss.*)
+ *(COMMON)
+ . = ALIGN(4);
+ _ebss = . ;
+ _ezero = .;
+ } > ram
+
+ /* stack section */
+ .stack (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sstack = .;
+ . = . + STACK_SIZE;
+ . = ALIGN(8);
+ _estack = .;
+ } > ram
+
+ . = ALIGN(4);
+ _end = . ;
+}
diff --git a/atmel-samd/asf4/samd21/gcc/gcc/samd21g18a_sram.ld b/atmel-samd/asf4/samd21/gcc/gcc/samd21g18a_sram.ld
new file mode 100644
index 000000000..f0462a22d
--- /dev/null
+++ b/atmel-samd/asf4/samd21/gcc/gcc/samd21g18a_sram.ld
@@ -0,0 +1,141 @@
+/**
+ * \file
+ *
+ * \brief Linker script for running in internal SRAM on the SAMD21G18A
+ *
+ * Copyright (c) 2016 Atmel Corporation,
+ * a wholly owned subsidiary of Microchip Technology Inc.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the Licence at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * \asf_license_stop
+ *
+ */
+
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+SEARCH_DIR(.)
+
+/* Memory Spaces Definitions */
+MEMORY
+{
+ ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000
+}
+
+/* The stack size used by the application. NOTE: you need to adjust according to your application. */
+STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : DEFINED(__stack_size__) ? __stack_size__ : 0x2000;
+
+/* Section Definitions */
+SECTIONS
+{
+ .text :
+ {
+ . = ALIGN(4);
+ _sfixed = .;
+ KEEP(*(.vectors .vectors.*))
+ *(.text .text.* .gnu.linkonce.t.*)
+ *(.glue_7t) *(.glue_7)
+ *(.rodata .rodata* .gnu.linkonce.r.*)
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+
+ /* Support C constructors, and C destructors in both user code
+ and the C library. This also provides support for C++ code. */
+ . = ALIGN(4);
+ KEEP(*(.init))
+ . = ALIGN(4);
+ __preinit_array_start = .;
+ KEEP (*(.preinit_array))
+ __preinit_array_end = .;
+
+ . = ALIGN(4);
+ __init_array_start = .;
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ __init_array_end = .;
+
+ . = ALIGN(4);
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*crtend.o(.ctors))
+
+ . = ALIGN(4);
+ KEEP(*(.fini))
+
+ . = ALIGN(4);
+ __fini_array_start = .;
+ KEEP (*(.fini_array))
+ KEEP (*(SORT(.fini_array.*)))
+ __fini_array_end = .;
+
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*crtend.o(.dtors))
+
+ . = ALIGN(4);
+ _efixed = .; /* End of text section */
+ } > ram
+
+ /* .ARM.exidx is sorted, so has to go in its own output section. */
+ PROVIDE_HIDDEN (__exidx_start = .);
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } > ram
+ PROVIDE_HIDDEN (__exidx_end = .);
+
+ . = ALIGN(4);
+ _etext = .;
+
+ .relocate : AT (_etext)
+ {
+ . = ALIGN(4);
+ _srelocate = .;
+ *(.ramfunc .ramfunc.*);
+ *(.data .data.*);
+ . = ALIGN(4);
+ _erelocate = .;
+ } > ram
+
+ /* .bss section which is used for uninitialized data */
+ .bss (NOLOAD) :
+ {
+ . = ALIGN(4);
+ _sbss = . ;
+ _szero = .;
+ *(.bss .bss.*)
+ *(COMMON)
+ . = ALIGN(4);
+ _ebss = . ;
+ _ezero = .;
+ } > ram
+
+ /* stack section */
+ .stack (NOLOAD):
+ {
+ . = ALIGN(8);
+ _sstack = .;
+ . = . + STACK_SIZE;
+ . = ALIGN(8);
+ _estack = .;
+ } > ram
+
+ . = ALIGN(4);
+ _end = . ;
+}
diff --git a/atmel-samd/asf4/samd21/gcc/gcc/startup_samd21.c b/atmel-samd/asf4/samd21/gcc/gcc/startup_samd21.c
new file mode 100644
index 000000000..ddc0580d7
--- /dev/null
+++ b/atmel-samd/asf4/samd21/gcc/gcc/startup_samd21.c
@@ -0,0 +1,265 @@
+/**
+ * \file
+ *
+ * \brief gcc starttup file for SAMD21
+ *
+ * Copyright (c) 2016 Atmel Corporation,
+ * a wholly owned subsidiary of Microchip Technology Inc.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the Licence at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * \asf_license_stop
+ *
+ */
+
+#include "samd21.h"
+
+/* Initialize segments */
+extern uint32_t _sfixed;
+extern uint32_t _efixed;
+extern uint32_t _etext;
+extern uint32_t _srelocate;
+extern uint32_t _erelocate;
+extern uint32_t _szero;
+extern uint32_t _ezero;
+extern uint32_t _sstack;
+extern uint32_t _estack;
+
+/** \cond DOXYGEN_SHOULD_SKIP_THIS */
+int main(void);
+/** \endcond */
+
+void __libc_init_array(void);
+
+/* Default empty handler */
+void Dummy_Handler(void);
+
+/* Cortex-M0+ core handlers */
+void NMI_Handler(void) __attribute__((weak, alias("Guilty_Handler")));
+void HardFault_Handler(void) __attribute__((weak, alias("Guilty_Handler")));
+void SVC_Handler(void) __attribute__((weak, alias("Dummy_Handler")));
+void PendSV_Handler(void) __attribute__((weak, alias("Dummy_Handler")));
+void SysTick_Handler(void) __attribute__((weak, alias("Dummy_Handler")));
+
+/* Peripherals handlers */
+void PM_Handler(void) __attribute__((weak, alias("Dummy_Handler")));
+void SYSCTRL_Handler(void) __attribute__((weak, alias("Dummy_Handler")));
+void WDT_Handler(void) __attribute__((weak, alias("Dummy_Handler")));
+void RTC_Handler(void) __attribute__((weak, alias("Dummy_Handler")));
+void EIC_Handler(void) __attribute__((weak, alias("Dummy_Handler")));
+void NVMCTRL_Handler(void) __attribute__((weak, alias("Dummy_Handler")));
+void DMAC_Handler(void) __attribute__((weak, alias("Dummy_Handler")));
+#ifdef ID_USB
+void USB_Handler(void) __attribute__((weak, alias("Guilty_Handler")));
+#endif
+void EVSYS_Handler(void) __attribute__((weak, alias("Dummy_Handler")));
+void SERCOM0_Handler(void) __attribute__((weak, alias("Dummy_Handler")));
+void SERCOM1_Handler(void) __attribute__((weak, alias("Dummy_Handler")));
+void SERCOM2_Handler(void) __attribute__((weak, alias("Dummy_Handler")));
+void SERCOM3_Handler(void) __attribute__((weak, alias("Dummy_Handler")));
+#ifdef ID_SERCOM4
+void SERCOM4_Handler(void) __attribute__((weak, alias("Dummy_Handler")));
+#endif
+#ifdef ID_SERCOM5
+void SERCOM5_Handler(void) __attribute__((weak, alias("Dummy_Handler")));
+#endif
+void TCC0_Handler(void) __attribute__((weak, alias("Dummy_Handler")));
+void TCC1_Handler(void) __attribute__((weak, alias("Dummy_Handler")));
+void TCC2_Handler(void) __attribute__((weak, alias("Dummy_Handler")));
+void TC3_Handler(void) __attribute__((weak, alias("Dummy_Handler")));
+void TC4_Handler(void) __attribute__((weak, alias("Dummy_Handler")));
+void TC5_Handler(void) __attribute__((weak, alias("Dummy_Handler")));
+#ifdef ID_TC6
+void TC6_Handler(void) __attribute__((weak, alias("Dummy_Handler")));
+#endif
+#ifdef ID_TC7
+void TC7_Handler(void) __attribute__((weak, alias("Dummy_Handler")));
+#endif
+#ifdef ID_ADC
+void ADC_Handler(void) __attribute__((weak, alias("Dummy_Handler")));
+#endif
+#ifdef ID_AC
+void AC_Handler(void) __attribute__((weak, alias("Dummy_Handler")));
+#endif
+#ifdef ID_DAC
+void DAC_Handler(void) __attribute__((weak, alias("Dummy_Handler")));
+#endif
+#ifdef ID_PTC
+void PTC_Handler(void) __attribute__((weak, alias("Dummy_Handler")));
+#endif
+void I2S_Handler(void) __attribute__((weak, alias("Dummy_Handler")));
+
+/* Exception Table */
+__attribute__((section(".vectors"), used)) const DeviceVectors exception_table = {
+
+ /* Configure Initial Stack Pointer, using linker-generated symbols */
+ .pvStack = (void *)(&_estack),
+
+ .pfnReset_Handler = (void *)Reset_Handler,
+ .pfnNMI_Handler = (void *)NMI_Handler,
+ .pfnHardFault_Handler = (void *)HardFault_Handler,
+ .pvReservedM12 = (void *)(0UL), /* Reserved */
+ .pvReservedM11 = (void *)(0UL), /* Reserved */
+ .pvReservedM10 = (void *)(0UL), /* Reserved */
+ .pvReservedM9 = (void *)(0UL), /* Reserved */
+ .pvReservedM8 = (void *)(0UL), /* Reserved */
+ .pvReservedM7 = (void *)(0UL), /* Reserved */
+ .pvReservedM6 = (void *)(0UL), /* Reserved */
+ .pfnSVC_Handler = (void *)SVC_Handler,
+ .pvReservedM4 = (void *)(0UL), /* Reserved */
+ .pvReservedM3 = (void *)(0UL), /* Reserved */
+ .pfnPendSV_Handler = (void *)PendSV_Handler,
+ .pfnSysTick_Handler = (void *)SysTick_Handler,
+
+ /* Configurable interrupts */
+ .pfnPM_Handler = (void *)PM_Handler, /* 0 Power Manager */
+ .pfnSYSCTRL_Handler = (void *)SYSCTRL_Handler, /* 1 System Control */
+ .pfnWDT_Handler = (void *)WDT_Handler, /* 2 Watchdog Timer */
+ .pfnRTC_Handler = (void *)RTC_Handler, /* 3 Real-Time Counter */
+ .pfnEIC_Handler = (void *)EIC_Handler, /* 4 External Interrupt Controller */
+ .pfnNVMCTRL_Handler = (void *)NVMCTRL_Handler, /* 5 Non-Volatile Memory Controller */
+ .pfnDMAC_Handler = (void *)DMAC_Handler, /* 6 Direct Memory Access Controller */
+#ifdef ID_USB
+ .pfnUSB_Handler = (void *)USB_Handler, /* 7 Universal Serial Bus */
+#else
+ .pvReserved7 = (void *)(0UL), /* 7 Reserved */
+#endif
+ .pfnEVSYS_Handler = (void *)EVSYS_Handler, /* 8 Event System Interface */
+ .pfnSERCOM0_Handler = (void *)SERCOM0_Handler, /* 9 Serial Communication Interface 0 */
+ .pfnSERCOM1_Handler = (void *)SERCOM1_Handler, /* 10 Serial Communication Interface 1 */
+ .pfnSERCOM2_Handler = (void *)SERCOM2_Handler, /* 11 Serial Communication Interface 2 */
+ .pfnSERCOM3_Handler = (void *)SERCOM3_Handler, /* 12 Serial Communication Interface 3 */
+#ifdef ID_SERCOM4
+ .pfnSERCOM4_Handler = (void *)SERCOM4_Handler, /* 13 Serial Communication Interface 4 */
+#else
+ .pvReserved13 = (void *)(0UL), /* 13 Reserved */
+#endif
+#ifdef ID_SERCOM5
+ .pfnSERCOM5_Handler = (void *)SERCOM5_Handler, /* 14 Serial Communication Interface 5 */
+#else
+ .pvReserved14 = (void *)(0UL), /* 14 Reserved */
+#endif
+ .pfnTCC0_Handler = (void *)TCC0_Handler, /* 15 Timer Counter Control 0 */
+ .pfnTCC1_Handler = (void *)TCC1_Handler, /* 16 Timer Counter Control 1 */
+ .pfnTCC2_Handler = (void *)TCC2_Handler, /* 17 Timer Counter Control 2 */
+ .pfnTC3_Handler = (void *)TC3_Handler, /* 18 Basic Timer Counter 0 */
+ .pfnTC4_Handler = (void *)TC4_Handler, /* 19 Basic Timer Counter 1 */
+ .pfnTC5_Handler = (void *)TC5_Handler, /* 20 Basic Timer Counter 2 */
+#ifdef ID_TC6
+ .pfnTC6_Handler = (void *)TC6_Handler, /* 21 Basic Timer Counter 3 */
+#else
+ .pvReserved21 = (void *)(0UL), /* 21 Reserved */
+#endif
+#ifdef ID_TC7
+ .pfnTC7_Handler = (void *)TC7_Handler, /* 22 Basic Timer Counter 4 */
+#else
+ .pvReserved22 = (void *)(0UL), /* 22 Reserved */
+#endif
+#ifdef ID_ADC
+ .pfnADC_Handler = (void *)ADC_Handler, /* 23 Analog Digital Converter */
+#else
+ .pvReserved23 = (void *)(0UL), /* 23 Reserved */
+#endif
+#ifdef ID_AC
+ .pfnAC_Handler = (void *)AC_Handler, /* 24 Analog Comparators */
+#else
+ .pvReserved24 = (void *)(0UL), /* 24 Reserved */
+#endif
+#ifdef ID_DAC
+ .pfnDAC_Handler = (void *)DAC_Handler, /* 25 Digital Analog Converter */
+#else
+ .pvReserved25 = (void *)(0UL), /* 25 Reserved */
+#endif
+#ifdef ID_PTC
+ .pfnPTC_Handler = (void *)PTC_Handler, /* 26 Peripheral Touch Controller */
+#else
+ .pvReserved26 = (void *)(0UL), /* 26 Reserved */
+#endif
+ .pfnI2S_Handler = (void *)I2S_Handler, /* 27 Inter-IC Sound Interface */
+ .pvReserved28 = (void *)(0UL) /* 28 Reserved */
+};
+
+/**
+ * \brief This is the code that gets called on processor reset.
+ * To initialize the device, and call the main() routine.
+ */
+void Reset_Handler(void)
+{
+ uint32_t *pSrc, *pDest;
+
+ /* Initialize the relocate segment */
+ pSrc = &_etext;
+ pDest = &_srelocate;
+
+ if (pSrc != pDest) {
+ for (; pDest < &_erelocate;) {
+ *pDest++ = *pSrc++;
+ }
+ }
+
+ /* Clear the zero segment */
+ for (pDest = &_szero; pDest < &_ezero;) {
+ *pDest++ = 0;
+ }
+
+ /* Set the vector table base address */
+ pSrc = (uint32_t *)&_sfixed;
+ SCB->VTOR = ((uint32_t)pSrc & SCB_VTOR_TBLOFF_Msk);
+
+ /* Change default QOS values to have the best performance and correct USB behaviour */
+ SBMATRIX->SFR[SBMATRIX_SLAVE_HMCRAMC0].reg = 2;
+#if defined(ID_USB)
+ USB->DEVICE.QOSCTRL.bit.CQOS = 2;
+ USB->DEVICE.QOSCTRL.bit.DQOS = 2;
+#endif
+ DMAC->QOSCTRL.bit.DQOS = 2;
+ DMAC->QOSCTRL.bit.FQOS = 2;
+ DMAC->QOSCTRL.bit.WRBQOS = 2;
+
+ /* Overwriting the default value of the NVMCTRL.CTRLB.MANW bit (errata reference 13134) */
+ NVMCTRL->CTRLB.bit.MANW = 1;
+
+ /* Initialize the C library */
+ // __libc_init_array();
+
+ /* Branch to main function */
+ main();
+
+ /* Infinite loop */
+ while (1)
+ ;
+}
+
+/**
+ * \brief Default interrupt handler for unused IRQs.
+ */
+__attribute__((used)) void Dummy_Handler(void)
+{
+ while (1) {
+ asm("");
+ }
+}
+
+/**
+ * \brief Default interrupt handler for unused IRQs.
+ */
+void Guilty_Handler(void)
+{
+ while (1) {
+ asm("");
+ }
+}
diff --git a/atmel-samd/asf4/samd21/gcc/system_samd21.c b/atmel-samd/asf4/samd21/gcc/system_samd21.c
new file mode 100644
index 000000000..274ecccb8
--- /dev/null
+++ b/atmel-samd/asf4/samd21/gcc/system_samd21.c
@@ -0,0 +1,63 @@
+/**
+ * \file
+ *
+ * \brief Low-level initialization functions called upon chip startup.
+ *
+ * Copyright (c) 2016 Atmel Corporation,
+ * a wholly owned subsidiary of Microchip Technology Inc.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the Licence at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * \asf_license_stop
+ *
+ */
+
+#include "samd21.h"
+
+/**
+ * Initial system clock frequency. The System RC Oscillator (RCSYS) provides
+ * the source for the main clock at chip startup.
+ */
+#define __SYSTEM_CLOCK (1000000)
+
+uint32_t SystemCoreClock = __SYSTEM_CLOCK; /*!< System Clock Frequency (Core Clock)*/
+
+/**
+ * Initialize the system
+ *
+ * @brief Setup the microcontroller system.
+ * Initialize the System and update the SystemCoreClock variable.
+ */
+void SystemInit(void)
+{
+ // Keep the default device state after reset
+ SystemCoreClock = __SYSTEM_CLOCK;
+ return;
+}
+
+/**
+ * Update SystemCoreClock variable
+ *
+ * @brief Updates the SystemCoreClock with current core Clock
+ * retrieved from cpu registers.
+ */
+void SystemCoreClockUpdate(void)
+{
+ // Not implemented
+ SystemCoreClock = __SYSTEM_CLOCK;
+ return;
+}