Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
majbthrd committed Mar 11, 2018
0 parents commit 05b7b13
Show file tree
Hide file tree
Showing 10 changed files with 926 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.bak
D11bootloader THUMB Debug\*
D11bootloader THUMB Release\*
*.hzs
79 changes: 79 additions & 0 deletions D11bootloader.hzp
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<!DOCTYPE CrossStudio_Project_File>
<solution Name="D11bootloader" target="8" version="2">
<project Name="D11bootloader">
<configuration
Name="Common"
Placement="Flash"
Target="ATSAMD11D14AM"
arm_architecture="v6M"
arm_core_type="Cortex-M0+"
arm_endian="Little"
arm_fpu_type="None"
arm_interwork="No"
arm_linker_heap_size="256"
arm_linker_process_stack_size="0"
arm_linker_stack_size="256"
arm_simulator_memory_simulation_filename="$(TargetsDir)/SAM_D/Simulator/SAM_D_SimulatorMemory_$(HostOS)_$(HostArch)$(HostDLLExt)"
arm_simulator_memory_simulation_parameter="SAM D,SAM D11;FLASH,0x00000000,0x00004000,ROM;RAM,0x20000000,0x00001000,RAM"
arm_target_debug_interface_type="ADIv5"
arm_target_interface_type="SWD"
arm_target_loader_applicable_loaders="Flash"
arm_target_loader_default_loader="Flash"
c_user_include_directories="$(DeviceIncludePath);$(PackagesDir)/CMSIS_4/CMSIS/Include;$(TargetsDir)/SAM_D/CMSIS/Device/Include;$(ProjectDir)"
debug_initial_breakpoint="bootloader"
debug_register_definition_file="$(DeviceRegisterDefinitionFile)"
gcc_entry_point="Reset_Handler"
linker_memory_map_file="$(DeviceMemoryMapFile)"
linker_section_placement_file="$(StudioDir)/targets/Cortex_M/flash_placement.xml"
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"
package_dependencies="Atmel_ATSAMD11-XPRO"
project_directory=""
project_type="Executable"
property_groups_file_path="$(TargetsDir)/SAM_D/XML/property_groups.xml"
target_get_partname_script="GetPartName()"
target_match_partname_script="MatchPartName(&quot;$(Target)&quot;)"
target_reset_script="Reset();"
target_trace_initialize_script="EnableTrace(&quot;$(TraceInterfaceType)&quot;)" />
<configuration
Name="Flash"
arm_target_flash_loader_file_path="$(DeviceLoaderFile)" />
<folder Name="Script Files">
<file file_name="$(TargetsDir)/SAM_D/Scripts/SAM_D_Target.js">
<configuration Name="Common" file_type="Reset Script" />
</file>
</folder>
<folder Name="Source Files">
<configuration Name="Common" filter="c;cpp;cxx;cc;h;s;asm;inc" />
<file file_name="bootloader.c" />
<file file_name="usb_descriptors.c" />
<file file_name="startup.s" />
</folder>
<folder Name="System Files" />
</project>
<configuration Name="THUMB Debug" inherited_configurations="THUMB;Debug" />
<configuration
Name="THUMB"
Platform="ARM"
arm_instruction_set="Thumb"
arm_library_instruction_set="Thumb"
c_preprocessor_definitions="__THUMB"
hidden="Yes" />
<configuration
Name="Debug"
c_preprocessor_definitions="DEBUG"
gcc_debugging_level="Level 3"
gcc_omit_frame_pointer="Yes"
gcc_optimization_level="None"
hidden="Yes" />
<configuration
Name="THUMB Release"
inherited_configurations="THUMB;Release" />
<configuration
Name="Release"
c_preprocessor_definitions="NDEBUG"
gcc_debugging_level="Level 3"
gcc_omit_frame_pointer="Yes"
gcc_optimization_level="Level 1"
hidden="Yes" />
<configuration Name="Common" arm_compiler_variant="clang" />
</solution>
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
USB DFU Bootloader for SAMD11
=============================

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.

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/).

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.

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.

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.

## Usage

Downloading can be accomplished with the existing [dfu-util](http://dfu-util.sourceforge.net/) utilities:

```
dfu-util -D write.bin
```

## Requirements for compiling

[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.

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.
Loading

0 comments on commit 05b7b13

Please sign in to comment.