summaryrefslogtreecommitdiff
path: root/usb
diff options
context:
space:
mode:
Diffstat (limited to 'usb')
-rw-r--r--usb/device/dfu/dfu.h6
-rw-r--r--usb/device/dfu/dfu_runtime.c20
2 files changed, 26 insertions, 0 deletions
diff --git a/usb/device/dfu/dfu.h b/usb/device/dfu/dfu.h
index ad64c99..eec956b 100644
--- a/usb/device/dfu/dfu.h
+++ b/usb/device/dfu/dfu.h
@@ -110,6 +110,9 @@ const USBDDriverDescriptors dfu_descriptors;
#endif /* BOARD_USB_DFU */
+#define USB_DFU_MAGIC 0xDFDFDFDF
+#define USB_DFU_MAGIC_ADDR AT91C_IRAM
+
/* The API between the core DFU handler and the board/soc specific code */
struct dfudata {
@@ -120,8 +123,11 @@ struct dfudata {
};
extern struct dfudata g_dfu;
+
void set_usb_serial_str(const uint8_t *serial_usbstr);
+void DFURT_SwitchToDFU(void);
+
/* call-backs by the board/SOC */
extern int USBDFU_handle_dnload(uint8_t altif, unsigned int offset,
uint8_t *data, unsigned int len);
diff --git a/usb/device/dfu/dfu_runtime.c b/usb/device/dfu/dfu_runtime.c
new file mode 100644
index 0000000..5ad1038
--- /dev/null
+++ b/usb/device/dfu/dfu_runtime.c
@@ -0,0 +1,20 @@
+
+#include <board.h>
+#include <core_cm3.h>
+
+#include <usb/device/core/USBD.h>
+#include <usb/device/dfu/dfu.h>
+
+
+void DFURT_SwitchToDFU(void)
+{
+ unsigned int *dfu_except_tbl = (unsigned int *)AT91C_IFLASH0;
+ void (*toDFU)(void) = (void *)dfu_except_tbl[1];
+
+ *(unsigned int *)USB_DFU_MAGIC_ADDR = USB_DFU_MAGIC;
+
+ USBD_Disconnect();
+ __disable_irq();
+
+ toDFU();
+}
personal git repositories of Harald Welte. Your mileage may vary