Minor hardware changes + bootloader mode

This commit is contained in:
Alex Taradov 2017-01-26 18:38:25 -08:00
parent bc0f5f6d17
commit 348cbff254
12 changed files with 230 additions and 1515 deletions

View File

@ -62,7 +62,7 @@
<wire x1="17.45" y1="12.182" x2="0" y2="12.182" width="0.1524" layer="20"/>
<wire x1="0" y1="12.182" x2="0" y2="0" width="0.1524" layer="20"/>
<circle x="15.748" y="9.906" radius="1.143" width="0.3048" layer="27"/>
<text x="12.7" y="0.508" size="0.762" layer="28" font="vector" rot="MR0" align="bottom-center">1/24/17</text>
<text x="12.7" y="0.508" size="0.762" layer="28" font="vector" rot="MR0" align="bottom-center">1/26/17</text>
<text x="4.572" y="10.16" size="1.27" layer="28" font="vector" rot="MR0" align="bottom-center">AT</text>
</plain>
<libraries>
@ -308,34 +308,17 @@ Source: http://www.cypressindustries.com/pdf/32005-201.pdf</description>
</package>
</packages>
</library>
<library name="led">
<description>&lt;b&gt;LEDs&lt;/b&gt;&lt;p&gt;
&lt;author&gt;Created by librarian@cadsoft.de&lt;/author&gt;&lt;br&gt;
Extended by Federico Battaglin &lt;author&gt;&amp;lt;federico.rd@fdpinternational.com&amp;gt;&lt;/author&gt; with DUOLED</description>
<library name="ataradov_led">
<description>Alex Taradov Library (LEDs and other indication devices)</description>
<packages>
<package name="CHIPLED_0603">
<description>&lt;b&gt;CHIPLED&lt;/b&gt;&lt;p&gt;
Source: http://www.osram.convergy.de/ ... LG_LY Q971.pdf</description>
<wire x1="-0.3" y1="0.8" x2="0.3" y2="0.8" width="0.1016" layer="51" curve="170.055574"/>
<wire x1="-0.275" y1="-0.825" x2="0.275" y2="-0.825" width="0.0508" layer="51" curve="-180"/>
<wire x1="-0.4" y1="0.375" x2="-0.4" y2="-0.35" width="0.1016" layer="51"/>
<wire x1="0.4" y1="0.35" x2="0.4" y2="-0.35" width="0.1016" layer="51"/>
<circle x="-0.35" y="0.625" radius="0.075" width="0.0508" layer="51"/>
<smd name="C" x="0" y="0.75" dx="0.8" dy="0.8" layer="1"/>
<smd name="A" x="0" y="-0.75" dx="0.8" dy="0.8" layer="1"/>
<text x="-0.635" y="-1.27" size="1.27" layer="25" rot="R90">&gt;NAME</text>
<text x="1.905" y="-1.27" size="1.27" layer="27" rot="R90">&gt;VALUE</text>
<rectangle x1="-0.45" y1="0.7" x2="-0.25" y2="0.85" layer="51"/>
<rectangle x1="-0.275" y1="0.55" x2="-0.225" y2="0.6" layer="51"/>
<rectangle x1="-0.45" y1="0.35" x2="-0.4" y2="0.725" layer="51"/>
<rectangle x1="0.25" y1="0.55" x2="0.45" y2="0.85" layer="51"/>
<rectangle x1="-0.45" y1="0.35" x2="0.45" y2="0.575" layer="51"/>
<rectangle x1="-0.45" y1="-0.85" x2="-0.25" y2="-0.35" layer="51"/>
<rectangle x1="0.25" y1="-0.85" x2="0.45" y2="-0.35" layer="51"/>
<rectangle x1="-0.275" y1="-0.575" x2="0.275" y2="-0.35" layer="51"/>
<rectangle x1="-0.275" y1="-0.65" x2="-0.175" y2="-0.55" layer="51"/>
<rectangle x1="0.175" y1="-0.65" x2="0.275" y2="-0.55" layer="51"/>
<rectangle x1="-0.125" y1="0" x2="0.125" y2="0.25" layer="21"/>
<package name="SMD0603">
<wire x1="-1.5" y1="0.75" x2="1.5" y2="0.75" width="0.1" layer="21"/>
<wire x1="1.5" y1="0.75" x2="1.5" y2="-0.75" width="0.1" layer="21"/>
<wire x1="1.5" y1="-0.75" x2="-1.5" y2="-0.75" width="0.1" layer="21"/>
<wire x1="-1.5" y1="-0.75" x2="-1.5" y2="0.75" width="0.1" layer="21"/>
<smd name="1" x="-0.8" y="0" dx="0.9" dy="0.9" layer="1"/>
<smd name="2" x="0.8" y="0" dx="0.9" dy="0.9" layer="1"/>
<text x="0" y="1.016" size="1.27" layer="25" font="vector" align="bottom-center">&gt;NAME</text>
</package>
</packages>
</library>
@ -567,7 +550,7 @@ Please make sure your boards conform to these design rules.</description>
<element name="TP2" library="ataradov_misc" package="TP-1.27MM" value="" x="9.398" y="1.524" rot="MR0"/>
<element name="TP3" library="ataradov_misc" package="TP-1.27MM" value="" x="6.858" y="1.524" rot="MR0"/>
<element name="TP4" library="ataradov_misc" package="TP-1.27MM" value="" x="1.778" y="1.524" rot="MR0"/>
<element name="LED1" library="led" package="CHIPLED_0603" value="" x="11.43" y="3.302" rot="R270"/>
<element name="LED1" library="ataradov_led" package="SMD0603" value="" x="11.43" y="3.302"/>
</elements>
<signals>
<signal name="GND">
@ -660,18 +643,17 @@ Please make sure your boards conform to these design rules.</description>
<wire x1="12.23" y1="4.826" x2="12.38" y2="4.976" width="0.254" layer="1"/>
<wire x1="12.38" y1="4.976" x2="12.38" y2="6.574" width="0.254" layer="1"/>
<wire x1="12.23" y1="3.302" x2="12.23" y2="4.826" width="0.254" layer="16"/>
<wire x1="10.668" y1="3.302" x2="10.68" y2="3.302" width="0.254" layer="1"/>
<wire x1="10.68" y1="3.302" x2="10.706" y2="3.302" width="0.254" layer="1"/>
<wire x1="10.706" y1="3.302" x2="10.706" y2="3.01" width="0.254" layer="1"/>
<wire x1="10.706" y1="3.01" x2="11.43" y2="2.286" width="0.254" layer="1"/>
<wire x1="11.43" y1="2.286" x2="11.43" y2="2.032" width="0.254" layer="1"/>
<via x="11.43" y="2.032" extent="1-16" drill="0.508" diameter="0.8636"/>
<wire x1="11.43" y1="2.032" x2="11.43" y2="2.502" width="0.254" layer="16"/>
<wire x1="11.43" y1="2.502" x2="12.23" y2="3.302" width="0.254" layer="16"/>
<contactref element="LED1" pad="1"/>
<wire x1="10.63" y1="3.302" x2="6.096" y2="3.302" width="0.254" layer="1"/>
<wire x1="10.63" y1="3.302" x2="10.63" y2="2.832" width="0.254" layer="1"/>
<wire x1="10.63" y1="2.832" x2="10.668" y2="2.794" width="0.254" layer="1"/>
<wire x1="10.668" y1="2.794" x2="11.43" y2="2.032" width="0.254" layer="1"/>
<wire x1="12.23" y1="4.826" x2="12.192" y2="4.826" width="0.254" layer="1"/>
<wire x1="12.192" y1="4.826" x2="10.668" y2="3.302" width="0.254" layer="1"/>
<contactref element="LED1" pad="A"/>
<wire x1="6.096" y1="3.302" x2="10.68" y2="3.302" width="0.254" layer="1"/>
<wire x1="10.668" y1="3.302" x2="10.668" y2="2.794" width="0.254" layer="1"/>
</signal>
<signal name="SWDIO">
<contactref element="IC2" pad="8"/>
@ -766,15 +748,15 @@ Please make sure your boards conform to these design rules.</description>
</signal>
<signal name="N$6">
<contactref element="R7" pad="2"/>
<contactref element="LED1" pad="C"/>
<wire x1="12.23" y1="6.35" x2="12.954" y2="6.35" width="0.254" layer="16"/>
<wire x1="12.954" y1="6.35" x2="13.208" y2="6.096" width="0.254" layer="16"/>
<wire x1="13.208" y1="6.096" x2="13.208" y2="2.286" width="0.254" layer="16"/>
<wire x1="13.208" y1="2.286" x2="12.954" y2="2.032" width="0.254" layer="16"/>
<wire x1="12.954" y1="2.032" x2="12.7" y2="2.032" width="0.254" layer="16"/>
<via x="12.7" y="2.032" extent="1-16" drill="0.508" diameter="0.8636"/>
<wire x1="12.7" y1="2.032" x2="12.18" y2="2.552" width="0.254" layer="1"/>
<wire x1="12.18" y1="2.552" x2="12.18" y2="3.302" width="0.254" layer="1"/>
<contactref element="LED1" pad="2"/>
<wire x1="12.23" y1="3.302" x2="12.23" y2="2.502" width="0.254" layer="1"/>
<wire x1="12.23" y1="2.502" x2="12.7" y2="2.032" width="0.254" layer="1"/>
</signal>
</signals>
</board>

File diff suppressed because it is too large Load Diff

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 = 0x3000
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x1000
}
__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

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, Alex Taradov <alex@taradov.com>
* Copyright (c) 2016-2017, Alex Taradov <alex@taradov.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without

View File

@ -28,9 +28,10 @@
/*- Includes ----------------------------------------------------------------*/
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <stdalign.h>
#include "samd11.h"
#include "hal_gpio.h"
#include "nvm_data.h"
@ -49,8 +50,8 @@ HAL_GPIO_PIN(LED, A, 14)
#define APP_PWM_BRIGHT 0
/*- Variables ---------------------------------------------------------------*/
ALIGNED(4) uint8_t app_request_buffer[DAP_CONFIG_PACKET_SIZE];
ALIGNED(4) uint8_t app_response_buffer[DAP_CONFIG_PACKET_SIZE];
alignas(4) uint8_t app_request_buffer[DAP_CONFIG_PACKET_SIZE];
alignas(4) uint8_t app_response_buffer[DAP_CONFIG_PACKET_SIZE];
/*- Implementations ---------------------------------------------------------*/

View File

@ -1,6 +1,6 @@
##############################################################################
BUILD = build
BIN = free_dap
BIN = free_dap_d11_bl
##############################################################################
.PHONY: all directory clean size
@ -18,7 +18,7 @@ CFLAGS += -MD -MP -MT $(BUILD)/$(*F).o -MF $(BUILD)/$(@F).d
LDFLAGS += -mcpu=cortex-m0plus -mthumb
LDFLAGS += -Wl,--gc-sections
LDFLAGS += -Wl,--script=../linker/samd11d14.ld
LDFLAGS += -Wl,--script=../linker/samd11d14_bl.ld
INCLUDES += \
-I../include \

View File

@ -0,0 +1,74 @@
##############################################################################
BUILD = build
BIN = free_dap_d11_std
##############################################################################
.PHONY: all directory clean size
CC = arm-none-eabi-gcc
OBJCOPY = arm-none-eabi-objcopy
SIZE = arm-none-eabi-size
CFLAGS += -W -Wall --std=gnu99 -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
LDFLAGS += -mcpu=cortex-m0plus -mthumb
LDFLAGS += -Wl,--gc-sections
LDFLAGS += -Wl,--script=../linker/samd11d14_std.ld
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:
@gmkdir -p $(BUILD)
size: $(BUILD)/$(BIN).elf
@echo size:
@$(SIZE) -t $^
clean:
@echo clean
@-rm -rf $(BUILD)
-include $(wildcard $(BUILD)/*.d)

View File

@ -26,6 +26,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
//-----------------------------------------------------------------------------
#include "samd11.h"
//-----------------------------------------------------------------------------
#define DUMMY __attribute__ ((weak, alias ("irq_handler_dummy")))
@ -125,6 +128,8 @@ void irq_handler_reset(void)
while (dst < &_ebss)
*dst++ = 0;
SCB->VTOR = (uint32_t)vectors;
main();
while (1);
}

View File

@ -256,7 +256,7 @@ void usb_handle_standard_request(usb_request_t *request)
length = LIMIT(length, sizeof(usb_hid_report_descriptor));
udc_control_send(usb_hid_report_descriptor, length);
udc_control_send((uint8_t *)usb_hid_report_descriptor, length);
} break;
default:

View File

@ -28,11 +28,12 @@
/*- Includes ----------------------------------------------------------------*/
#include <stdalign.h>
#include "usb.h"
#include "usb_descriptors.h"
/*- Variables ---------------------------------------------------------------*/
ALIGNED(4) usb_device_descriptor_t usb_device_descriptor =
const alignas(4) usb_device_descriptor_t usb_device_descriptor =
{
.bLength = sizeof(usb_device_descriptor_t),
.bDescriptorType = USB_DEVICE_DESCRIPTOR,
@ -50,7 +51,7 @@ ALIGNED(4) usb_device_descriptor_t usb_device_descriptor =
.bNumConfigurations = 1,
};
ALIGNED(4) usb_configuration_hierarchy_t usb_configuration_hierarchy =
const alignas(4) usb_configuration_hierarchy_t usb_configuration_hierarchy =
{
.configuration =
{
@ -109,7 +110,7 @@ ALIGNED(4) usb_configuration_hierarchy_t usb_configuration_hierarchy =
},
};
ALIGNED(4) uint8_t usb_hid_report_descriptor[33] =
const alignas(4) uint8_t usb_hid_report_descriptor[33] =
{
0x06, 0x00, 0xff, // Usage Page (Vendor Defined 0xFF00)
0x09, 0x01, // Usage (0x01)
@ -129,7 +130,7 @@ ALIGNED(4) uint8_t usb_hid_report_descriptor[33] =
0xc0, // End Collection
};
ALIGNED(4) usb_string_descriptor_zero_t usb_string_descriptor_zero =
const alignas(4) usb_string_descriptor_zero_t usb_string_descriptor_zero =
{
.bLength = sizeof(usb_string_descriptor_zero_t),
.bDescriptorType = USB_STRING_DESCRIPTOR,
@ -145,5 +146,5 @@ char *usb_strings[] =
[USB_STR_INTERFACE] = "Main Interface",
};
ALIGNED(4) uint8_t usb_string_descriptor_buffer[64];
alignas(4) uint8_t usb_string_descriptor_buffer[64];

View File

@ -74,10 +74,10 @@ typedef struct PACK
} usb_configuration_hierarchy_t;
//-----------------------------------------------------------------------------
extern usb_device_descriptor_t usb_device_descriptor;
extern usb_configuration_hierarchy_t usb_configuration_hierarchy;
extern uint8_t usb_hid_report_descriptor[33];
extern usb_string_descriptor_zero_t usb_string_descriptor_zero;
extern const usb_device_descriptor_t usb_device_descriptor;
extern const usb_configuration_hierarchy_t usb_configuration_hierarchy;
extern const uint8_t usb_hid_report_descriptor[33];
extern const usb_string_descriptor_zero_t usb_string_descriptor_zero;
extern char *usb_strings[];
extern uint8_t usb_string_descriptor_buffer[64];

View File

@ -30,8 +30,6 @@
#define _UTILS_H_
/*- Definitions -------------------------------------------------------------*/
#define ALIGNED(a) __attribute__((__aligned__(a)))
#define PACK __attribute__((packed))
#define INLINE static inline __attribute__((always_inline))