3
* BlueZ - Bluetooth protocol stack for Linux
5
* Copyright (C) 2003-2008 Marcel Holtmann <marcel@holtmann.org>
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2 of the License, or
11
* (at your option) any later version.
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with this program; if not, write to the Free Software
20
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27
uint32_t crc32_init(void);
28
uint32_t crc32_byte(uint32_t accum, uint8_t delta);
31
struct usb_dfu_descriptor {
33
u_int8_t bDescriptorType;
34
u_int8_t bmAttributes;
35
u_int16_t wDetachTimeout;
36
u_int16_t wTransferSize;
43
#define DFU_GETSTATUS 3
44
#define DFU_CLRSTATUS 4
45
#define DFU_GETSTATE 5
51
uint8_t bwPollTimeout[3];
54
} __attribute__ ((packed));
55
#define DFU_STATUS_SIZE 6
59
#define DFU_ERR_TARGET 0x01
60
#define DFU_ERR_FILE 0x02
61
#define DFU_ERR_WRITE 0x03
62
#define DFU_ERR_ERASE 0x04
63
#define DFU_ERR_CHECK_ERASED 0x05
64
#define DFU_ERR_PROG 0x06
65
#define DFU_ERR_VERIFY 0x07
66
#define DFU_ERR_ADDRESS 0x08
67
#define DFU_ERR_NOTDONE 0x09
68
#define DFU_ERR_FIRMWARE 0x0a
69
#define DFU_ERR_VENDOR 0x0b
70
#define DFU_ERR_USBR 0x0c
71
#define DFU_ERR_POR 0x0d
72
#define DFU_ERR_UNKNOWN 0x0e
73
#define DFU_ERR_STALLEDPKT 0x0f
76
#define DFU_STATE_APP_IDLE 0
77
#define DFU_STATE_APP_DETACH 1
78
#define DFU_STATE_DFU_IDLE 2
79
#define DFU_STATE_DFU_DNLOAD_SYNC 3
80
#define DFU_STATE_DFU_DNLOAD_BUSY 4
81
#define DFU_STATE_DFU_DNLOAD_IDLE 5
82
#define DFU_STATE_DFU_MANIFEST_SYNC 6
83
#define DFU_STATE_DFU_MANIFEST 7
84
#define DFU_STATE_MANIFEST_WAIT_RESET 8
85
#define DFU_STATE_UPLOAD_IDLE 9
86
#define DFU_STATE_ERROR 10
94
uint8_t ucDfuSignature[3];
97
} __attribute__ ((packed));
98
#define DFU_SUFFIX_SIZE 16
101
int dfu_detach(struct usb_dev_handle *udev, int intf);
102
int dfu_upload(struct usb_dev_handle *udev, int intf, int block, char *buffer, int size);
103
int dfu_download(struct usb_dev_handle *udev, int intf, int block, char *buffer, int size);
104
int dfu_get_status(struct usb_dev_handle *udev, int intf, struct dfu_status *status);
105
int dfu_clear_status(struct usb_dev_handle *udev, int intf);
106
int dfu_get_state(struct usb_dev_handle *udev, int intf, uint8_t *state);
107
int dfu_abort(struct usb_dev_handle *udev, int intf);