Added 2K DFU bootloader versions

This commit is contained in:
Alex Taradov 2021-05-27 09:11:53 -07:00
parent 550bc0ff25
commit 14e7993ca4
4 changed files with 174 additions and 4 deletions

View File

@ -28,8 +28,8 @@
MEMORY
{
flash (rx) : ORIGIN = 0x00001000, LENGTH = 0x3000
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x1000
flash (rx) : ORIGIN = 0x00000800, LENGTH = 14K
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 4K
}
__top_flash = ORIGIN(flash) + LENGTH(flash);

View File

@ -0,0 +1,82 @@
/*
* Copyright (c) 2016-2017, Alex Taradov <alex@taradov.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
MEMORY
{
flash (rx) : ORIGIN = 0x00001000, LENGTH = 12K
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 4K
}
__top_flash = ORIGIN(flash) + LENGTH(flash);
__top_ram = ORIGIN(ram) + LENGTH(ram);
ENTRY(irq_handler_reset)
SECTIONS
{
.text : ALIGN(4)
{
FILL(0xff)
KEEP(*(.vectors))
*(.text*)
*(.rodata)
*(.rodata.*)
. = ALIGN(4);
} > flash
. = ALIGN(4);
_etext = .;
.uninit_RESERVED : ALIGN(4)
{
KEEP(*(.bss.$RESERVED*))
} > ram
.data : ALIGN(4)
{
FILL(0xff)
_data = .;
*(.ramfunc .ramfunc.*);
*(vtable)
*(.data*)
. = ALIGN(4);
_edata = .;
} > ram AT > flash
.bss : ALIGN(4)
{
_bss = .;
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .;
PROVIDE(_end = .);
} > ram
PROVIDE(_stack_top = __top_ram - 0);
}

View File

@ -0,0 +1,88 @@
##############################################################################
BUILD = build
BIN = free_dap_d11_bl_2k
##############################################################################
.PHONY: all directory clean size dfu
CC = arm-none-eabi-gcc
OBJCOPY = arm-none-eabi-objcopy
SIZE = arm-none-eabi-size
ifeq ($(OS), Windows_NT)
MKDIR = gmkdir
else
MKDIR = mkdir
endif
CFLAGS += -W -Wall --std=gnu11 -Os
CFLAGS += -fno-diagnostics-show-caret
CFLAGS += -fdata-sections -ffunction-sections
CFLAGS += -funsigned-char -funsigned-bitfields
CFLAGS += -mcpu=cortex-m0plus -mthumb
CFLAGS += -MD -MP -MT $(BUILD)/$(*F).o -MF $(BUILD)/$(@F).d
CFLAGS += -flto
LDFLAGS += -mcpu=cortex-m0plus -mthumb
LDFLAGS += -Wl,--gc-sections
LDFLAGS += -Wl,--script=../linker/samd11d14_bl_2k.ld
LDFLAGS += -flto
INCLUDES += \
-I../include \
-I../../.. \
-I..
SRCS += \
../../../dap.c \
../main.c \
../udc.c \
../usb.c \
../usb_descriptors.c \
../startup_samd11.c
DEFINES += \
-D__SAMD11C14A__ \
-DDONT_USE_CMSIS_INIT \
-DF_CPU=48000000
CFLAGS += $(INCLUDES) $(DEFINES)
OBJS = $(addprefix $(BUILD)/, $(notdir %/$(subst .c,.o, $(SRCS))))
all: directory $(BUILD)/$(BIN).elf $(BUILD)/$(BIN).hex $(BUILD)/$(BIN).bin size
$(BUILD)/$(BIN).elf: $(OBJS)
@echo LD $@
@$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $@
$(BUILD)/$(BIN).hex: $(BUILD)/$(BIN).elf
@echo OBJCOPY $@
@$(OBJCOPY) -O ihex $^ $@
$(BUILD)/$(BIN).bin: $(BUILD)/$(BIN).elf
@echo OBJCOPY $@
@$(OBJCOPY) -O binary $^ $@
%.o:
@echo CC $@
@$(CC) $(CFLAGS) $(filter %/$(subst .o,.c,$(notdir $@)), $(SRCS)) -c -o $@
directory:
@$(MKDIR) -p $(BUILD)
size: $(BUILD)/$(BIN).elf
@echo size:
@$(SIZE) -t $^
clean:
@echo clean
@-rm -rf $(BUILD)
dfu: $(BUILD)/$(BIN).bin
@echo DFU $^
@cp $(BUILD)/$(BIN).bin $(BUILD)/$(BIN).dfu
@dfu-suffix -a $(BUILD)/$(BIN).dfu -v ffff -p ffff -d ffff
-include $(wildcard $(BUILD)/*.d)

View File

@ -1,6 +1,6 @@
##############################################################################
BUILD = build
BIN = free_dap_d11_bl
BIN = free_dap_d11_bl_4k
##############################################################################
.PHONY: all directory clean size
@ -25,7 +25,7 @@ CFLAGS += -flto
LDFLAGS += -mcpu=cortex-m0plus -mthumb
LDFLAGS += -Wl,--gc-sections
LDFLAGS += -Wl,--script=../linker/samd11d14_bl.ld
LDFLAGS += -Wl,--script=../linker/samd11d14_bl_4k.ld
LDFLAGS += -flto
INCLUDES += \