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

Commit 05b7b13

Browse files
committed
initial commit
0 parents  commit 05b7b13

File tree

10 files changed

+926
-0
lines changed

10 files changed

+926
-0
lines changed

.gitignore

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

D11bootloader.hzp

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<!DOCTYPE CrossStudio_Project_File>
2+
<solution Name="D11bootloader" 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;DeviceHeaderFile=$(TargetsDir)/SAM_D/CMSIS/Device/SAMD11/Include/samd11.h;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;DeviceSystemFile=$(TargetsDir)/SAM_D/CMSIS/Device/SAMD11/Source/system_samd11.c;DeviceVectorsFile=$(TargetsDir)/SAM_D/Source/ATSAMD11D14AM_Vectors.s;DeviceFamily=SAM D;DeviceSubFamily=SAM D11"
29+
package_dependencies="Atmel_ATSAMD11-XPRO"
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_trace_initialize_script="EnableTrace(&quot;$(TraceInterfaceType)&quot;)" />
37+
<configuration
38+
Name="Flash"
39+
arm_target_flash_loader_file_path="$(DeviceLoaderFile)" />
40+
<folder Name="Script Files">
41+
<file file_name="$(TargetsDir)/SAM_D/Scripts/SAM_D_Target.js">
42+
<configuration Name="Common" file_type="Reset Script" />
43+
</file>
44+
</folder>
45+
<folder Name="Source Files">
46+
<configuration Name="Common" filter="c;cpp;cxx;cc;h;s;asm;inc" />
47+
<file file_name="bootloader.c" />
48+
<file file_name="usb_descriptors.c" />
49+
<file file_name="startup.s" />
50+
</folder>
51+
<folder Name="System Files" />
52+
</project>
53+
<configuration Name="THUMB Debug" inherited_configurations="THUMB;Debug" />
54+
<configuration
55+
Name="THUMB"
56+
Platform="ARM"
57+
arm_instruction_set="Thumb"
58+
arm_library_instruction_set="Thumb"
59+
c_preprocessor_definitions="__THUMB"
60+
hidden="Yes" />
61+
<configuration
62+
Name="Debug"
63+
c_preprocessor_definitions="DEBUG"
64+
gcc_debugging_level="Level 3"
65+
gcc_omit_frame_pointer="Yes"
66+
gcc_optimization_level="None"
67+
hidden="Yes" />
68+
<configuration
69+
Name="THUMB Release"
70+
inherited_configurations="THUMB;Release" />
71+
<configuration
72+
Name="Release"
73+
c_preprocessor_definitions="NDEBUG"
74+
gcc_debugging_level="Level 3"
75+
gcc_omit_frame_pointer="Yes"
76+
gcc_optimization_level="Level 1"
77+
hidden="Yes" />
78+
<configuration Name="Common" arm_compiler_variant="clang" />
79+
</solution>

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
USB DFU Bootloader for SAMD11
2+
=============================
3+
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.
5+
6+
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/).
7+
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.
13+
14+
## Usage
15+
16+
Downloading can be accomplished with the existing [dfu-util](http://dfu-util.sourceforge.net/) utilities:
17+
18+
```
19+
dfu-util -D write.bin
20+
```
21+
22+
## Requirements for compiling
23+
24+
[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.
25+
26+
There is no dependency in the code on the [Rowley Crossworks for ARM](http://www.rowley.co.uk/arm/) toolchain per se, but at this time I am not aware of any other ready-to-use Clang ARM cross-compiler package that I can readily point users to.

0 commit comments

Comments
 (0)