mirror of
https://gitea.osmocom.org/sim-card/simtrace2.git
synced 2026-03-22 16:28:32 +03:00
DFU: fix transitions between runtime and DFU mode
we now always go through a processor reset to avoid any state that might be persistent/left-over during the switch.
This commit is contained in:
@@ -86,12 +86,11 @@ extern const USBDDriverDescriptors dfu_descriptors;
|
||||
/* magic value we use during boot to detect if we should start in DFU
|
||||
* mode or runtime mode */
|
||||
#define USB_DFU_MAGIC 0xDFDFDFDF
|
||||
/* RAM address for this magic value above */
|
||||
#define USB_DFU_MAGIC_ADDR IRAM_ADDR
|
||||
|
||||
/* The API between the core DFU handler and the board/soc specific code */
|
||||
|
||||
struct dfudata {
|
||||
uint32_t magic;
|
||||
uint8_t status;
|
||||
uint32_t state;
|
||||
int past_manifest;
|
||||
|
||||
@@ -457,7 +457,7 @@ void USBDFU_Initialize(const USBDDriverDescriptors *pDescriptors)
|
||||
void USBDFU_SwitchToApp(void)
|
||||
{
|
||||
/* make sure the MAGIC is not set to enter DFU again */
|
||||
*(unsigned int *)USB_DFU_MAGIC_ADDR = 0;
|
||||
g_dfu->magic = 0;
|
||||
|
||||
printf("switching to app\r\n");
|
||||
|
||||
@@ -468,7 +468,6 @@ void USBDFU_SwitchToApp(void)
|
||||
__disable_irq();
|
||||
|
||||
/* Tell the hybrid to execute FTL JUMP! */
|
||||
//BootIntoApp();
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
|
||||
@@ -178,15 +178,17 @@ out:
|
||||
|
||||
void DFURT_SwitchToDFU(void)
|
||||
{
|
||||
unsigned int *dfu_except_tbl = (unsigned int *)IFLASH_ADDR;
|
||||
void (*toDFU)(void) = (void *)dfu_except_tbl[1];
|
||||
|
||||
*(unsigned int *)USB_DFU_MAGIC_ADDR = USB_DFU_MAGIC;
|
||||
/* store the magic value that the DFU loader can detect and
|
||||
* activate itself, rather than boot into the application */
|
||||
g_dfu->magic = USB_DFU_MAGIC;
|
||||
|
||||
/* Disconnect the USB by remoting the pull-up */
|
||||
USBD_Disconnect();
|
||||
__disable_irq();
|
||||
|
||||
toDFU();
|
||||
/* reset the processor, we will start execution with the
|
||||
* ResetVector of the bootloader */
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
void USBDCallbacks_RequestReceived(const USBGenericRequest *request)
|
||||
|
||||
Reference in New Issue
Block a user