mirror of
https://gitea.osmocom.org/sim-card/simtrace2.git
synced 2026-03-24 09:18:33 +03:00
dfu: let the device reset itself
dfu flashing the ST12 was easy, but i was never able to get ST34 into dfu mode. Changing the firmware so it resets itself just like the octsim instead of starting a timer and waiting for a reset from the host made it work every time for me. Change-Id: Ida636ec925f40d6d56551f170150181350d03bbd
This commit is contained in:
@@ -39,8 +39,8 @@ struct dfu_desc {
|
|||||||
#define DFU_FUNC_DESC { \
|
#define DFU_FUNC_DESC { \
|
||||||
.bLength = USB_DT_DFU_SIZE, \
|
.bLength = USB_DT_DFU_SIZE, \
|
||||||
.bDescriptorType = USB_DT_DFU, \
|
.bDescriptorType = USB_DT_DFU, \
|
||||||
.bmAttributes = USB_DFU_CAN_UPLOAD | USB_DFU_CAN_DOWNLOAD, \
|
.bmAttributes = USB_DFU_CAN_UPLOAD | USB_DFU_CAN_DOWNLOAD | USB_DFU_WILL_DETACH, \
|
||||||
.wDetachTimeOut = 0xff00, \
|
.wDetachTimeOut = 0x00, \
|
||||||
.wTransferSize = BOARD_DFU_PAGE_SIZE, \
|
.wTransferSize = BOARD_DFU_PAGE_SIZE, \
|
||||||
.bcdDFUVersion = 0x0100, \
|
.bcdDFUVersion = 0x0100, \
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -165,6 +165,8 @@ void USBDFU_Runtime_RequestHandler(const USBGenericRequest *request)
|
|||||||
* will then trigger DFURT_SwitchToDFU() below */
|
* will then trigger DFURT_SwitchToDFU() below */
|
||||||
TRACE_DEBUG("\r\n====dfu_detach\n\r");
|
TRACE_DEBUG("\r\n====dfu_detach\n\r");
|
||||||
g_dfu->state = DFU_STATE_appDETACH;
|
g_dfu->state = DFU_STATE_appDETACH;
|
||||||
|
USBD_Write(0, 0, 0, 0, 0);
|
||||||
|
DFURT_SwitchToDFU();
|
||||||
ret = DFU_RET_ZLP;
|
ret = DFU_RET_ZLP;
|
||||||
goto out;
|
goto out;
|
||||||
break;
|
break;
|
||||||
@@ -209,13 +211,14 @@ out:
|
|||||||
|
|
||||||
void DFURT_SwitchToDFU(void)
|
void DFURT_SwitchToDFU(void)
|
||||||
{
|
{
|
||||||
|
__disable_irq();
|
||||||
|
|
||||||
/* store the magic value that the DFU loader can detect and
|
/* store the magic value that the DFU loader can detect and
|
||||||
* activate itself, rather than boot into the application */
|
* activate itself, rather than boot into the application */
|
||||||
g_dfu->magic = USB_DFU_MAGIC;
|
g_dfu->magic = USB_DFU_MAGIC;
|
||||||
|
__DMB();
|
||||||
/* Disconnect the USB by removing the pull-up */
|
/* Disconnect the USB by removing the pull-up */
|
||||||
USBD_Disconnect();
|
USBD_Disconnect();
|
||||||
__disable_irq();
|
|
||||||
|
|
||||||
/* reset the processor, we will start execution with the
|
/* reset the processor, we will start execution with the
|
||||||
* ResetVector of the bootloader */
|
* ResetVector of the bootloader */
|
||||||
|
|||||||
Reference in New Issue
Block a user