Project

General

Profile

Download (2.13 KB) Statistics
| Branch: | Tag: | Revision:
1 43d61cf0 (no author)
#ifndef _USB_DFU_H
2
#define _USB_DFU_H
3
/* USB Device Firmware Update Implementation for OpenPCD
4
 * (C) 2006 by Harald Welte <hwelte@hmw-consulting.de>
5
 *
6
 * Protocol definitions for USB DFU
7
 *
8
 * This ought to be compliant to the USB DFU Spec 1.0 as available from
9
 * http://www.usb.org/developers/devclass_docs/usbdfu10.pdf
10
 *
11
 */
12
13
#include <sys/types.h>
14
15
#define USB_DT_DFU			0x21
16
17
struct usb_dfu_func_descriptor {
18 373c172a Harald Welte
	uint8_t		bLength;
19
	uint8_t		bDescriptorType;
20
	uint8_t		bmAttributes;
21 43d61cf0 (no author)
#define USB_DFU_CAN_DOWNLOAD	(1 << 0)
22
#define USB_DFU_CAN_UPLOAD	(1 << 1)
23
#define USB_DFU_MANIFEST_TOL	(1 << 2)
24
#define USB_DFU_WILL_DETACH	(1 << 3)
25 373c172a Harald Welte
	uint16_t		wDetachTimeOut;
26
	uint16_t		wTransferSize;
27
	uint16_t		bcdDFUVersion;
28 43d61cf0 (no author)
} __attribute__ ((packed));
29
30
#define USB_DT_DFU_SIZE			9
31
32
#define USB_TYPE_DFU		(USB_TYPE_CLASS|USB_RECIP_INTERFACE)
33
34
/* DFU class-specific requests (Section 3, DFU Rev 1.1) */
35
#define USB_REQ_DFU_DETACH	0x00
36
#define USB_REQ_DFU_DNLOAD	0x01
37
#define USB_REQ_DFU_UPLOAD	0x02
38
#define USB_REQ_DFU_GETSTATUS	0x03
39
#define USB_REQ_DFU_CLRSTATUS	0x04
40
#define USB_REQ_DFU_GETSTATE	0x05
41
#define USB_REQ_DFU_ABORT	0x06
42
43
struct dfu_status {
44 373c172a Harald Welte
	uint8_t bStatus;
45
	uint8_t bwPollTimeout[3];
46
	uint8_t bState;
47
	uint8_t iString;
48 43d61cf0 (no author)
} __attribute__((packed));
49
50
#define DFU_STATUS_OK			0x00
51
#define DFU_STATUS_errTARGET		0x01
52
#define DFU_STATUS_errFILE		0x02
53
#define DFU_STATUS_errWRITE		0x03
54
#define DFU_STATUS_errERASE		0x04
55
#define DFU_STATUS_errCHECK_ERASED	0x05
56
#define DFU_STATUS_errPROG		0x06
57
#define DFU_STATUS_errVERIFY		0x07
58
#define DFU_STATUS_errADDRESS		0x08
59
#define DFU_STATUS_errNOTDONE		0x09
60
#define DFU_STATUS_errFIRMWARE		0x0a
61
#define DFU_STATUS_errVENDOR		0x0b
62
#define DFU_STATUS_errUSBR		0x0c
63
#define DFU_STATUS_errPOR		0x0d
64
#define DFU_STATUS_errUNKNOWN		0x0e
65
#define DFU_STATUS_errSTALLEDPKT	0x0f
66
67
enum dfu_state {
68
	DFU_STATE_appIDLE		= 0,
69
	DFU_STATE_appDETACH		= 1,
70
	DFU_STATE_dfuIDLE		= 2,
71
	DFU_STATE_dfuDNLOAD_SYNC	= 3,
72
	DFU_STATE_dfuDNBUSY		= 4,
73
	DFU_STATE_dfuDNLOAD_IDLE	= 5,
74
	DFU_STATE_dfuMANIFEST_SYNC	= 6,
75
	DFU_STATE_dfuMANIFEST		= 7,
76
	DFU_STATE_dfuMANIFEST_WAIT_RST	= 8,
77
	DFU_STATE_dfuUPLOAD_IDLE	= 9,
78
	DFU_STATE_dfuERROR		= 10,
79
};
80
81
#endif /* _USB_DFU_H */
Add picture from clipboard (Maximum size: 48.8 MB)