Skip to content
This repository was archived by the owner on Jan 29, 2024. It is now read-only.

Commit 81d9965

Browse files
committed
added D21 project file
1 parent 1441712 commit 81d9965

File tree

5 files changed

+140
-90
lines changed

5 files changed

+140
-90
lines changed

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
*.bak
2-
D11bootloader THUMB Debug\*
3-
D11bootloader THUMB Release\*
2+
D11bootloader THUMB Debug/*
3+
D11bootloader THUMB Release/*
4+
D11bootloader THUMB Debug/*
5+
D11bootloader THUMB Release/*
46
*.hzs

D11bootloader.hzp

Lines changed: 0 additions & 79 deletions
This file was deleted.

Dx1bootloader.hzp

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
<!DOCTYPE CrossStudio_Project_File>
2+
<solution Name="Dx1bootloader" target="8" version="2">
3+
<project Name="D11bootloader">
4+
<configuration
5+
Name="Common"
6+
Placement="Flash"
7+
Target="ATSAMD11D14AM"
8+
arm_architecture="v6M"
9+
arm_core_type="Cortex-M0+"
10+
arm_endian="Little"
11+
arm_fpu_type="None"
12+
arm_interwork="No"
13+
arm_linker_heap_size="256"
14+
arm_linker_process_stack_size="0"
15+
arm_linker_stack_size="256"
16+
arm_simulator_memory_simulation_filename="$(TargetsDir)/SAM_D/Simulator/SAM_D_SimulatorMemory_$(HostOS)_$(HostArch)$(HostDLLExt)"
17+
arm_simulator_memory_simulation_parameter="SAM D,SAM D11;FLASH,0x00000000,0x00004000,ROM;RAM,0x20000000,0x00001000,RAM"
18+
arm_target_debug_interface_type="ADIv5"
19+
arm_target_interface_type="SWD"
20+
arm_target_loader_applicable_loaders="Flash"
21+
arm_target_loader_default_loader="Flash"
22+
c_user_include_directories="$(DeviceIncludePath);$(PackagesDir)/CMSIS_4/CMSIS/Include;$(TargetsDir)/SAM_D/CMSIS/Device/Include;$(ProjectDir)"
23+
debug_initial_breakpoint="bootloader"
24+
debug_register_definition_file="$(DeviceRegisterDefinitionFile)"
25+
gcc_entry_point="Reset_Handler"
26+
linker_memory_map_file="$(DeviceMemoryMapFile)"
27+
linker_section_placement_file="$(StudioDir)/targets/Cortex_M/flash_placement.xml"
28+
macros="DeviceIncludePath=$(TargetsDir)/SAM_D/CMSIS/Device/SAMD11/Include;DeviceLoaderFile=$(TargetsDir)/SAM_D/Loader/SAM_D11_Loader.elf;DeviceMemoryMapFile=$(TargetsDir)/SAM_D/XML/ATSAMD11D14AM_MemoryMap.xml;DeviceRegisterDefinitionFile=$(TargetsDir)/SAM_D/XML/ATSAMD11D14AM_Registers.xml;DeviceFamily=SAM D;DeviceSubFamily=SAM D11"
29+
package_dependencies="SAM_D"
30+
project_directory=""
31+
project_type="Executable"
32+
property_groups_file_path="$(TargetsDir)/SAM_D/XML/property_groups.xml"
33+
target_get_partname_script="GetPartName()"
34+
target_match_partname_script="MatchPartName(&quot;$(Target)&quot;)"
35+
target_reset_script="Reset();"
36+
target_script_file="$(TargetsDir)/SAM_D/Scripts/SAM_D_Target.js"
37+
target_trace_initialize_script="EnableTrace(&quot;$(TraceInterfaceType)&quot;)" />
38+
<configuration
39+
Name="Flash"
40+
arm_target_flash_loader_file_path="$(DeviceLoaderFile)" />
41+
<folder Name="Source Files">
42+
<configuration Name="Common" filter="c;cpp;cxx;cc;h;s;asm;inc" />
43+
<file file_name="bootloader.c" />
44+
<file file_name="usb_descriptors.c" />
45+
<file file_name="startup.s" />
46+
</folder>
47+
<configuration Name="Release" linker_output_format="srec" />
48+
</project>
49+
<configuration Name="THUMB Debug" inherited_configurations="THUMB;Debug" />
50+
<configuration
51+
Name="THUMB"
52+
Platform="ARM"
53+
arm_instruction_set="Thumb"
54+
arm_library_instruction_set="Thumb"
55+
c_preprocessor_definitions="__THUMB"
56+
hidden="Yes" />
57+
<configuration
58+
Name="Debug"
59+
c_preprocessor_definitions="DEBUG"
60+
gcc_debugging_level="Level 3"
61+
gcc_omit_frame_pointer="Yes"
62+
gcc_optimization_level="None"
63+
hidden="Yes" />
64+
<configuration
65+
Name="THUMB Release"
66+
inherited_configurations="THUMB;Release" />
67+
<configuration
68+
Name="Release"
69+
c_preprocessor_definitions="NDEBUG"
70+
gcc_debugging_level="Level 3"
71+
gcc_omit_frame_pointer="Yes"
72+
gcc_optimization_level="Level 1"
73+
hidden="Yes" />
74+
<configuration Name="Common" arm_compiler_variant="clang" />
75+
<project Name="D21bootloader">
76+
<configuration
77+
CMSIS_CORE="Yes"
78+
Name="Common"
79+
Placement="Flash"
80+
Target="ATSAMD21J18A"
81+
arm_architecture="v6M"
82+
arm_core_type="Cortex-M0+"
83+
arm_endian="Little"
84+
arm_fpu_type="None"
85+
arm_interwork="No"
86+
arm_linker_heap_size="256"
87+
arm_linker_process_stack_size="0"
88+
arm_linker_stack_size="256"
89+
arm_simulator_memory_simulation_filename="$(TargetsDir)/SAM_D/Simulator/SAM_D_SimulatorMemory_$(HostOS)_$(HostArch)$(HostDLLExt)"
90+
arm_simulator_memory_simulation_parameter="SAM D,SAM D21;FLASH,0x00000000,0x00040000,ROM;RAM,0x20000000,0x00008000,RAM"
91+
arm_target_debug_interface_type="ADIv5"
92+
arm_target_device_name="ATSAMD21J18A"
93+
arm_target_interface_type="SWD"
94+
arm_target_loader_applicable_loaders="Flash"
95+
arm_target_loader_default_loader="Flash"
96+
c_user_include_directories="$(DeviceIncludePath);$(TargetsDir)/SAM_D/CMSIS/Device/Include"
97+
debug_initial_breakpoint="bootloader"
98+
debug_register_definition_file="$(DeviceRegisterDefinitionFile)"
99+
gcc_entry_point="Reset_Handler"
100+
linker_memory_map_file="$(DeviceMemoryMapFile)"
101+
linker_section_placement_file="$(StudioDir)/targets/Cortex_M/flash_placement.xml"
102+
macros="DeviceIncludePath=$(TargetsDir)/SAM_D/CMSIS/Device/SAMD21/Include;DeviceLoaderFile=$(TargetsDir)/SAM_D/Loader/SAM_D21_Loader.elf;DeviceMemoryMapFile=$(TargetsDir)/SAM_D/XML/ATSAMD21J18A_MemoryMap.xml;DeviceRegisterDefinitionFile=$(TargetsDir)/SAM_D/XML/ATSAMD21J18A_Registers.xml;DeviceFamily=SAM D;DeviceSubFamily=SAM D21"
103+
package_dependencies="SAM_D"
104+
project_directory=""
105+
project_type="Executable"
106+
property_groups_file_path="$(TargetsDir)/SAM_D/XML/property_groups.xml"
107+
target_get_partname_script="GetPartName()"
108+
target_match_partname_script="MatchPartName(&quot;$(Target)&quot;)"
109+
target_reset_script="Reset();"
110+
target_script_file="$(TargetsDir)/SAM_D/Scripts/SAM_D_Target.js"
111+
target_trace_initialize_script="EnableTrace(&quot;$(TraceInterfaceType)&quot;)" />
112+
<configuration
113+
Name="Flash"
114+
arm_target_flash_loader_file_path="$(DeviceLoaderFile)" />
115+
<configuration Name="Release" gcc_debugging_level="None" />
116+
<folder Name="Source Files">
117+
<file file_name="bootloader.c" />
118+
<file file_name="startup.s" />
119+
<file file_name="usb_descriptors.c" />
120+
</folder>
121+
<configuration Name="Release" linker_output_format="srec" />
122+
</project>
123+
</solution>

README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
USB DFU Bootloader for SAMD11
2-
=============================
1+
USB DFU Bootloader for SAMD11 / SAMD21
2+
======================================
33

4-
Bootloaders are a dime a dozen, but existing USB bootloaders for the Atmel/Microchip SAMD11 all seem to be 4kBytes in size. To spent 25% of the SAMD11's flash on the bootloader seems excessive.
4+
Bootloaders are a dime a dozen, but existing USB bootloaders for the Atmel/Microchip SAMDx1 all seem to be 4kBytes in size. To spent 25% of the SAMD11's flash on the bootloader seems quite excessive.
55

66
This bootloader is only 1kBytes and implements the industry-standard [DFU protocol](http://www.usb.org/developers/docs/devclass_docs/DFU_1.1.pdf) that is supported under multiple Operating Systems via existing tools such as [dfu-util](http://dfu-util.sourceforge.net/).
77

8-
The linker memory map of the user application must be modified to have an origin at 0x0000_0400 rather than at 0x0000_0000. This bootloader resides at 0x0000_0000.
9-
10-
When booting, the bootloader checks whether a GPIO pin (nominally PA15) is connected to ground. If so, it runs the bootloader instead of the user application.
11-
12-
When branching to the user application, the bootloader includes functionality to update the [VTOR (Vector Table Offset Register)](http://infocenter.arm.com/help/topic/com.arm.doc.dui0662a/Ciheijba.html) and update the stack pointer to suit the value in the user application's vector table.
8+
It is a much more space efficient alternative to the 4kB Atmel/Microchip [AN_42366](http://www.microchip.com//wwwAppNotes/AppNotes.aspx?appnote=en591491) SAM-BA Bootloader.
139

1410
## Usage
1511

@@ -19,6 +15,14 @@ Downloading can be accomplished with the existing [dfu-util](http://dfu-util.sou
1915
dfu-util -D write.bin
2016
```
2117

18+
## Specifics
19+
20+
The linker memory map of the user application must be modified to have an origin at 0x0000_0400 rather than at 0x0000_0000. This bootloader resides at 0x0000_0000.
21+
22+
When booting, the bootloader checks whether a GPIO pin (nominally PA15) is connected to ground. If so, it runs the bootloader instead of the user application.
23+
24+
When branching to the user application, the bootloader includes functionality to update the [VTOR (Vector Table Offset Register)](http://infocenter.arm.com/help/topic/com.arm.doc.dui0662a/Ciheijba.html) and update the stack pointer to suit the value in the user application's vector table.
25+
2226
## Requirements for compiling
2327

2428
[Rowley Crossworks for ARM](http://www.rowley.co.uk/arm/) is presently needed to compile this code. With Crossworks for ARM v4.1.1, using the Clang 5.0.1 compiler produces an 1010 byte image. The more mainstream GCC does not appear to be optimized enough to produce an image that comes anywhere close to fitting into 1024 bytes.

bootloader.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
/*- Includes ----------------------------------------------------------------*/
3939
#include <stdbool.h>
4040
#include <string.h>
41-
#include <samd11.h>
41+
#include <sam.h>
4242
#include "usb.h"
4343
#include "nvm_data.h"
4444
#include "usb_descriptors.h"

0 commit comments

Comments
 (0)