summaryrefslogtreecommitdiff
path: root/at91lib/usb/device/dfu
diff options
context:
space:
mode:
Diffstat (limited to 'at91lib/usb/device/dfu')
-rw-r--r--at91lib/usb/device/dfu/dfu.c50
-rw-r--r--at91lib/usb/device/dfu/dfu.h75
2 files changed, 125 insertions, 0 deletions
diff --git a/at91lib/usb/device/dfu/dfu.c b/at91lib/usb/device/dfu/dfu.c
new file mode 100644
index 0000000..89b5f3a
--- /dev/null
+++ b/at91lib/usb/device/dfu/dfu.c
@@ -0,0 +1,50 @@
+
+#include <usb/common/core/USBInterfaceDescriptor.h>
+#include <usb/common/core/USBGenericDescriptor.h>
+#include <usb/device/dfu/dfu.h>
+
+
+/* String 1 "SimTrace DFU Interface - Application Partition" */
+const struct USBStringDescriptor USBDFU_string1 = {
+ .hdr = {
+ .bLength = sizeof(USBGenericDescriptor) + 46 * sizeof(unsigned short),
+ .bDescriptorType = USBGenericDescriptor_STRING,
+ },
+ .wData = { 0x0053, 0x0069, 0x006d, 0x0054, 0x0072, 0x0061,
+ 0x0063, 0x0065, 0x0020, 0x0044, 0x0046, 0x0055,
+ 0x0020, 0x0049, 0x006e, 0x0074, 0x0065, 0x0072,
+ 0x0066, 0x0061, 0x0063, 0x0065, 0x0020, 0x002d,
+ 0x0020, 0x0041, 0x0070, 0x0070, 0x006c, 0x0069,
+ 0x0063, 0x0061, 0x0074, 0x0069, 0x006f, 0x006e,
+ 0x0020, 0x0050, 0x0061, 0x0072, 0x0074, 0x0069,
+ 0x0074, 0x0069, 0x006f, 0x006e, },
+};
+
+/* String 2 "SimTrace DFU Interface - Bootloader Partition" */
+const struct USBStringDescriptor USBDFU_string2 = {
+ .hdr = {
+ .bLength = sizeof(USBGenericDescriptor) + 45 * sizeof(unsigned short),
+ .bDescriptorType = USBGenericDescriptor_STRING,
+ },
+ .wData = { 0x0053, 0x0069, 0x006d, 0x0054, 0x0072, 0x0061,
+ 0x0063, 0x0065, 0x0020, 0x0044, 0x0046, 0x0055,
+ 0x0020, 0x0049, 0x006e, 0x0074, 0x0065, 0x0072,
+ 0x0066, 0x0061, 0x0063, 0x0065, 0x0020, 0x002d,
+ 0x0020, 0x0042, 0x006f, 0x006f, 0x0074, 0x006c,
+ 0x006f, 0x0061, 0x0064, 0x0065, 0x0072, 0x0020,
+ 0x0050, 0x0061, 0x0072, 0x0074, 0x0069, 0x0074,
+ 0x0069, 0x006f, 0x006e, },
+};
+
+/* String 3 "SimTrace DFU Interface - RAM" */
+const struct USBStringDescriptor USBDFU_string3 = {
+ .hdr = {
+ .bLength = sizeof(USBGenericDescriptor) + 28 * sizeof(unsigned short),
+ .bDescriptorType = USBGenericDescriptor_STRING,
+ },
+ .wData = { 0x0053, 0x0069, 0x006d, 0x0054, 0x0072, 0x0061,
+ 0x0063, 0x0065, 0x0020, 0x0044, 0x0046, 0x0055,
+ 0x0020, 0x0049, 0x006e, 0x0074, 0x0065, 0x0072,
+ 0x0066, 0x0061, 0x0063, 0x0065, 0x0020, 0x002d,
+ 0x0020, 0x0052, 0x0041, 0x004d, },
+};
diff --git a/at91lib/usb/device/dfu/dfu.h b/at91lib/usb/device/dfu/dfu.h
new file mode 100644
index 0000000..f1323c1
--- /dev/null
+++ b/at91lib/usb/device/dfu/dfu.h
@@ -0,0 +1,75 @@
+#ifndef _USB_DFU_DESC_H
+#define _USB_DFU_DESC_H
+
+#include <usb/common/core/USBGenericDescriptor.h>
+
+#define CONFIG_DFU_NUM_APP_IF 1
+#define CONFIG_DFU_NUM_APP_STR 4
+
+struct USBStringDescriptor {
+ USBGenericDescriptor hdr;
+ unsigned short wData[];
+} __attribute__((packed));
+
+
+#ifdef BOARD_USB_DFU
+
+#define DFU_NUM_IF 3
+#define DFU_IF_DESCRIPTORS { \
+ { \
+ .bLength = sizeof(USBInterfaceDescriptor), \
+ .bDescriptorType = USBGenericDescriptor_INTERFACE, \
+ .bInterfaceNumber = CONFIG_DFU_NUM_APP_IF, \
+ .bAlternateSetting = 0, \
+ .bNumEndpoints = 0, \
+ .bInterfaceClass = 0xFE, \
+ .bInterfaceSubClass = 0x01, \
+ .bInterfaceProtocol = 0x01, \
+ .iInterface = CONFIG_DFU_NUM_APP_STR, \
+ }, \
+ { \
+ .bLength = sizeof(USBInterfaceDescriptor), \
+ .bDescriptorType = USBGenericDescriptor_INTERFACE, \
+ .bInterfaceNumber = CONFIG_DFU_NUM_APP_IF+1, \
+ .bAlternateSetting = 0, \
+ .bNumEndpoints = 0, \
+ .bInterfaceClass = 0xFE, \
+ .bInterfaceSubClass = 0x01, \
+ .bInterfaceProtocol = 0x01, \
+ .iInterface = CONFIG_DFU_NUM_APP_STR+1, \
+ }, \
+ { \
+ .bLength = sizeof(USBInterfaceDescriptor), \
+ .bDescriptorType = USBGenericDescriptor_INTERFACE, \
+ .bInterfaceNumber = CONFIG_DFU_NUM_APP_IF+2, \
+ .bAlternateSetting = 0, \
+ .bNumEndpoints = 0, \
+ .bInterfaceClass = 0xFE, \
+ .bInterfaceSubClass = 0x01, \
+ .bInterfaceProtocol = 0x01, \
+ .iInterface = CONFIG_DFU_NUM_APP_STR+2, \
+ }, \
+}
+
+extern const struct USBStringDescriptor USBDFU_string1;
+extern const struct USBStringDescriptor USBDFU_string2;
+extern const struct USBStringDescriptor USBDFU_string3;
+
+#define DFU_NUM_STRINGS 3
+#define DFU_STRING_DESCRIPTORS \
+ &USBDFU_string1, \
+ &USBDFU_string2, \
+ &USBDFU_string3,
+
+#else /* BOARD_USB_DFU */
+
+/* no DFU bootloader is being used */
+#define DFU_NUM_IF 0
+#define DFU_IF_DESCRIPTORS
+
+#define DFU_NUM_STRINGS 0
+#define DFU_STRING_DESCRIPTORS
+
+#endif /* BOARD_USB_DFU */
+
+#endif
personal git repositories of Harald Welte. Your mileage may vary