<p>Kévin Redon has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/12516">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">add README file<br><br>this describes the project, how to compile, and how to flash the<br>USB DFU bootloader<br><br>Change-Id: If884bca373aab10fe74d16f42b79dd6685eeabcf<br>---<br>A README<br>1 file changed, 50 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-asf4-dfu refs/changes/16/12516/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/README b/README</span><br><span>new file mode 100644</span><br><span>index 0000000..031bc27</span><br><span>--- /dev/null</span><br><span>+++ b/README</span><br><span>@@ -0,0 +1,50 @@</span><br><span style="color: hsl(120, 100%, 40%);">+This is an implementation of the DFU mode of the [USB DFU Device Class Specification](https://usb.org/document-library/device-firmware-upgrade-11-new-version-31-aug-2004) for the Microchip SAM D5x/E5x micro-controller.</span><br><span style="color: hsl(120, 100%, 40%);">+It is meant to be used as bootloader to allow flashing the main application over USB.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+The code has been developed for the Microchip [SAM E54 Xplained Pro](https://www.microchip.com/DevelopmentTools/ProductDetails/PartNo/ATSAME54-XPRO) development board using a [SAM E54](https://www.microchip.com/wwwproducts/en/ATSAME54P20A) micro-controller.</span><br><span style="color: hsl(120, 100%, 40%);">+It should work on any chip of the SAM D5x/E5x device family by replacing the corresponding device-specific definitions (usually including the chip name in the file name).</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+The code uses the [Atmel START](https://start.atmel.com/) ASFv4 library.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+USB DFU</span><br><span style="color: hsl(120, 100%, 40%);">+=======</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+This implementation support the following USB DFU capabilities:</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+* can download: allowing to download the code over USB on the device (enabled per default)</span><br><span style="color: hsl(120, 100%, 40%);">+* manifestation tolerant: allowing to download after a previous download (disabled per default)</span><br><span style="color: hsl(120, 100%, 40%);">+* will detach: forcing the device the reset after a download, else it wit for a USB reset (enable per default)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Set the corresponding attributes in the 'DFUD_IFACE_DESCB' macro definition in the 'usb/class/dfu/device/dfudf_desc.h' file.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Compiling</span><br><span style="color: hsl(120, 100%, 40%);">+=========</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Use the 'Makefile' script to compile the source code using the ARM none EABI GCC cross-cimpilig toolchain:</span><br><span style="color: hsl(120, 100%, 40%);">+```</span><br><span style="color: hsl(120, 100%, 40%);">+cd gcc</span><br><span style="color: hsl(120, 100%, 40%);">+make</span><br><span style="color: hsl(120, 100%, 40%);">+```</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+The resulting firmware binary is `AtmelStart.bin`.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Flashing</span><br><span style="color: hsl(120, 100%, 40%);">+========</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+To flash the bootloader you can either use the [edbg tool](https://github.com/ataradov/edbg) over the EDBG interface of the SAM E54 Xplained Pro development board, or OpenICD with any SWJ adapter.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+The USB DFU bootloader should be flashed in a protected area of the flash memory to prevent for erasing it, as specified in data sheet section 25.6.2 Memory Organization.</span><br><span style="color: hsl(120, 100%, 40%);">+The bootloader size is configured in the NVM user configuration BOOTPROT field, as specified in data sheet section 25.6.9 NVM User Configuration.</span><br><span style="color: hsl(120, 100%, 40%);">+The bit position of the BOOTPROT field is documented in data sheet section 9.4 NVM User Page Mapping.</span><br><span style="color: hsl(120, 100%, 40%);">+We need to reserve as least 2 pages of 8192 bytes for the bootloader since it is a bit larger than 10 KB (e.g. over 8 KB).</span><br><span style="color: hsl(120, 100%, 40%);">+This setting will also tell the bootloader where to flash the application firmware to (e.g. after the bootloader reserved space).</span><br><span style="color: hsl(120, 100%, 40%);">+The LED will blink once per second if this size is not set.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+EDBG</span><br><span style="color: hsl(120, 100%, 40%);">+----</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+To flash the USB DFU bootloader, perform the following actions:</span><br><span style="color: hsl(120, 100%, 40%);">+* remove reserved bootloader space so we can erase it: `edbg --target atmel_cm4v2 --fuse wv,29:26,15`</span><br><span style="color: hsl(120, 100%, 40%);">+* erase the whole flash: `edbg --target atmel_cm4v2 --fuse v,29:26,15 --erase`</span><br><span style="color: hsl(120, 100%, 40%);">+* program the bootloader: `edbg --target atmel_cm4v2 --fuse v,29:26,15 --program --verify --file AtmelStart.bin`</span><br><span style="color: hsl(120, 100%, 40%);">+* reserve bootloader space: `edbg --target atmel_cm4v2 --fuse wv,29:26,13`</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/12516">change 12516</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/12516"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-asf4-dfu </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: If884bca373aab10fe74d16f42b79dd6685eeabcf </div>
<div style="display:none"> Gerrit-Change-Number: 12516 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Kévin Redon <kredon@sysmocom.de> </div>