mirror of
https://gitea.osmocom.org/sim-card/simtrace2.git
synced 2026-03-19 14:58:35 +03:00
DFU: Introduce board/app-specific override for booting in DFU mode
Using the USBDFU_OverrideEnterDFU() function, a board/application can define extra conditions when the system should boot in DFU mode, even if it was not explicitly switched to DFU mode from the application. The app/dfu/main.c uses this mechanism to boot into DFU mode if the stack + reset vector addresses are not plausible (i.e. some random junk appears to be flashed in the application partition) or if the user places a jumper accross the RxD+TxD lines of the debug UART. The idea is that the system can be recovered by placing this jumper and then re-installing the application from DFU.
This commit is contained in:
@@ -110,6 +110,7 @@ extern int USBDFU_handle_dnload(uint8_t altif, unsigned int offset,
|
||||
uint8_t *data, unsigned int len);
|
||||
extern int USBDFU_handle_upload(uint8_t altif, unsigned int offset,
|
||||
uint8_t *data, unsigned int req_len);
|
||||
extern int USBDFU_OverrideEnterDFU(void);
|
||||
|
||||
/* function to be called at end of EP0 handler during runtime */
|
||||
void USBDFU_Runtime_RequestHandler(const USBGenericRequest *request);
|
||||
|
||||
@@ -472,6 +472,14 @@ void USBDFU_SwitchToApp(void)
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
/* A board can provide a function overriding this, enabling a
|
||||
* board-specific 'boot into DFU' override, like a specific GPIO that
|
||||
* needs to be pulled a certain way. */
|
||||
WEAK int USBDFU_OverrideEnterDFU(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void USBDCallbacks_RequestReceived(const USBGenericRequest *request)
|
||||
{
|
||||
USBDFU_DFU_RequestHandler(request);
|
||||
|
||||
Reference in New Issue
Block a user