<p>laforge <strong>submitted</strong> this change.</p><p><a href="https://gerrit.osmocom.org/c/simtrace2/+/22529">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">dfu: let the device reset itself<br><br>dfu flashing the ST12 was easy, but i was never able to<br>get ST34 into dfu mode. Changing the firmware so it resets<br>itself just like the octsim instead of starting a timer and<br>waiting for a reset from the host made it work every time for me.<br><br>Change-Id: Ida636ec925f40d6d56551f170150181350d03bbd<br>---<br>M firmware/atmel_softpack_libraries/usb/device/dfu/dfu.h<br>M firmware/atmel_softpack_libraries/usb/device/dfu/dfu_runtime.c<br>2 files changed, 7 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/firmware/atmel_softpack_libraries/usb/device/dfu/dfu.h b/firmware/atmel_softpack_libraries/usb/device/dfu/dfu.h</span><br><span>index 5bd8684..84ce14e 100644</span><br><span>--- a/firmware/atmel_softpack_libraries/usb/device/dfu/dfu.h</span><br><span>+++ b/firmware/atmel_softpack_libraries/usb/device/dfu/dfu.h</span><br><span>@@ -39,8 +39,8 @@</span><br><span> #define DFU_FUNC_DESC  {                                                \</span><br><span>    .bLength                = USB_DT_DFU_SIZE,                      \</span><br><span>    .bDescriptorType        = USB_DT_DFU,                           \</span><br><span style="color: hsl(0, 100%, 40%);">-       .bmAttributes           = USB_DFU_CAN_UPLOAD | USB_DFU_CAN_DOWNLOAD, \</span><br><span style="color: hsl(0, 100%, 40%);">-  .wDetachTimeOut         = 0xff00,                               \</span><br><span style="color: hsl(120, 100%, 40%);">+     .bmAttributes           = USB_DFU_CAN_UPLOAD | USB_DFU_CAN_DOWNLOAD | USB_DFU_WILL_DETACH, \</span><br><span style="color: hsl(120, 100%, 40%);">+  .wDetachTimeOut         = 0x00,                         \</span><br><span>    .wTransferSize          = BOARD_DFU_PAGE_SIZE,                  \</span><br><span>    .bcdDFUVersion          = 0x0100,                               \</span><br><span> }</span><br><span>diff --git a/firmware/atmel_softpack_libraries/usb/device/dfu/dfu_runtime.c b/firmware/atmel_softpack_libraries/usb/device/dfu/dfu_runtime.c</span><br><span>index 4467cc9..f2cf64c 100644</span><br><span>--- a/firmware/atmel_softpack_libraries/usb/device/dfu/dfu_runtime.c</span><br><span>+++ b/firmware/atmel_softpack_libraries/usb/device/dfu/dfu_runtime.c</span><br><span>@@ -165,6 +165,8 @@</span><br><span>                     * will then trigger DFURT_SwitchToDFU() below */</span><br><span>                    TRACE_DEBUG("\r\n====dfu_detach\n\r");</span><br><span>                     g_dfu->state = DFU_STATE_appDETACH;</span><br><span style="color: hsl(120, 100%, 40%);">+                        USBD_Write(0, 0, 0, 0, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+                    DFURT_SwitchToDFU();</span><br><span>                         ret = DFU_RET_ZLP;</span><br><span>                   goto out;</span><br><span>                    break;</span><br><span>@@ -209,13 +211,14 @@</span><br><span> </span><br><span> void DFURT_SwitchToDFU(void)</span><br><span> {</span><br><span style="color: hsl(120, 100%, 40%);">+       __disable_irq();</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>   /* store the magic value that the DFU loader can detect and</span><br><span>   * activate itself, rather than boot into the application */</span><br><span>         g_dfu->magic = USB_DFU_MAGIC;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(120, 100%, 40%);">+      __DMB();</span><br><span>     /* Disconnect the USB by removing the pull-up */</span><br><span>     USBD_Disconnect();</span><br><span style="color: hsl(0, 100%, 40%);">-      __disable_irq();</span><br><span> </span><br><span>         /* reset the processor, we will start execution with the</span><br><span>      * ResetVector of the bootloader */</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/simtrace2/+/22529">change 22529</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/c/simtrace2/+/22529"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: simtrace2 </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Ida636ec925f40d6d56551f170150181350d03bbd </div>
<div style="display:none"> Gerrit-Change-Number: 22529 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: Hoernchen <ewild@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-Reviewer: mschramm <mschramm@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>