update dfu demo and driver

This commit is contained in:
sakumisu 2022-09-18 12:00:44 +08:00
parent ed2f835857
commit b07b55095f
9 changed files with 1296 additions and 16 deletions

View File

@ -76,27 +76,62 @@
#define DFU_STATE_DFU_UPLOAD_IDLE 9U
#define DFU_STATE_DFU_ERROR 10U
/** DFU Manifestation State */
#define DFU_MANIFEST_COMPLETE 0U
#define DFU_MANIFEST_IN_PROGRESS 1U
/** Special Commands with Download Request */
#define DFU_CMD_GETCOMMANDS 0U
#define DFU_CMD_SETADDRESSPOINTER 0x21U
#define DFU_CMD_ERASE 0x41U
#define DFU_MEDIA_ERASE 0x00U
#define DFU_MEDIA_PROGRAM 0x01U
/** Other defines */
/* Bit Detach capable = bit 3 in bmAttributes field */
#define DFU_DETACH_MASK (1U << 3)
#define DFU_MANIFEST_MASK (1U << 2)
/** Run-Time Functional Descriptor */
struct dfu_runtime_descriptor {
uint8_t bLength; /**<\brief Descriptor length in bytes.*/
uint8_t bDescriptorType; /**<\brief DFU functional descriptor type.*/
uint8_t bmAttributes; /**<\brief USB DFU capabilities \ref USB_DFU_CAPAB*/
uint16_t wDetachTimeout; /**<\brief USB DFU detach timeout in ms.*/
uint16_t wTransferSize; /**<\brief USB DFU maximum transfer block size in bytes.*/
uint16_t bcdDFUVersion; /**<\brief USB DFU version \ref VERSION_BCD utility macro.*/
uint8_t bLength; /**<\brief Descriptor length in bytes.*/
uint8_t bDescriptorType; /**<\brief DFU functional descriptor type.*/
uint8_t bmAttributes; /**<\brief USB DFU capabilities \ref USB_DFU_CAPAB*/
uint16_t wDetachTimeout; /**<\brief USB DFU detach timeout in ms.*/
uint16_t wTransferSize; /**<\brief USB DFU maximum transfer block size in bytes.*/
uint16_t bcdDFUVersion; /**<\brief USB DFU version \ref VERSION_BCD utility macro.*/
} __PACKED;
/**\brief Payload packet to response in DFU_GETSTATUS request */
struct dfu_info {
uint8_t bStatus; /**<\brief An indication of the status resulting from the
uint8_t bStatus; /**<\brief An indication of the status resulting from the
* execution of the most recent request.*/
uint8_t bPollTimeout; /**<\brief Minimum time (LSB) in ms, that the host should wait
uint8_t bPollTimeout; /**<\brief Minimum time (LSB) in ms, that the host should wait
* before sending a subsequent DFU_GETSTATUS request.*/
uint16_t wPollTimeout; /**<\brief Minimum time (MSB) in ms, that the host should wait
uint16_t wPollTimeout; /**<\brief Minimum time (MSB) in ms, that the host should wait
* before sending a subsequent DFU_GETSTATUS request.*/
uint8_t bState; /**<\brief An indication of the state that the device is going
uint8_t bState; /**<\brief An indication of the state that the device is going
* to enter immediately following transmission of this response.*/
uint8_t iString; /**<\brief Index of the status string descriptor.*/
uint8_t iString; /**<\brief Index of the status string descriptor.*/
};
// clang-format off
#define DFU_DESCRIPTOR_INIT() \
0x09, /* bLength */ \
USB_DESCRIPTOR_TYPE_INTERFACE, /* bDescriptorType */ \
0x00, /* bInterfaceNumber */ \
0x00, /* bAlternateSetting */ \
0x00, /* bNumEndpoints Default Control Pipe only */ \
USB_DEVICE_CLASS_APP_SPECIFIC, /* bInterfaceClass */ \
0x01, /* bInterfaceSubClass Device Firmware Upgrade */ \
0x02, /* bInterfaceProtocol DFU mode */ \
0x04, /* iInterface */ /*!< Device Firmware Update Functional Descriptor */ \
0x09, /* bLength */ \
0x21, /* DFU Functional Descriptor */ \
0x0B, /* bmAttributes */ \
WBVAL(0x00ff), /* wDetachTimeOut */ \
WBVAL(USBD_DFU_XFER_SIZE), /* wTransferSize */ \
WBVAL(0x011a) /* bcdDFUVersion */
// clang-format on
#endif /* USB_DFU_H */

View File

@ -6,30 +6,457 @@
#include "usbd_core.h"
#include "usbd_dfu.h"
/** Modify the following three parameters according to different platforms */
#ifndef USBD_DFU_XFER_SIZE
#define USBD_DFU_XFER_SIZE 1024
#endif
#ifndef USBD_DFU_APP_DEFAULT_ADD
#define USBD_DFU_APP_DEFAULT_ADD 0x8004000
#endif
#ifndef FLASH_PROGRAM_TIME
#define FLASH_PROGRAM_TIME 50
#endif
#ifndef FLASH_ERASE_TIME
#define FLASH_ERASE_TIME 50
#endif
struct dfu_cfg_priv {
struct dfu_info info;
union {
uint32_t d32[USBD_DFU_XFER_SIZE / 4U];
uint8_t d8[USBD_DFU_XFER_SIZE];
} buffer;
uint32_t wblock_num;
uint32_t wlength;
uint32_t data_ptr;
uint32_t alt_setting;
uint8_t dev_status[6];
uint8_t ReservedForAlign[2];
uint8_t dev_state;
uint8_t manif_state;
uint8_t firmwar_flag;
} usbd_dfu_cfg;
static void dfu_reset(void)
{
memset(&usbd_dfu_cfg, 0, sizeof(usbd_dfu_cfg));
usbd_dfu_cfg.alt_setting = 0U;
usbd_dfu_cfg.data_ptr = USBD_DFU_APP_DEFAULT_ADD;
usbd_dfu_cfg.wblock_num = 0U;
usbd_dfu_cfg.wlength = 0U;
usbd_dfu_cfg.manif_state = DFU_MANIFEST_COMPLETE;
usbd_dfu_cfg.dev_state = DFU_STATE_DFU_IDLE;
usbd_dfu_cfg.dev_status[0] = DFU_STATUS_OK;
usbd_dfu_cfg.dev_status[1] = 0U;
usbd_dfu_cfg.dev_status[2] = 0U;
usbd_dfu_cfg.dev_status[3] = 0U;
usbd_dfu_cfg.dev_status[4] = DFU_STATE_DFU_IDLE;
usbd_dfu_cfg.dev_status[5] = 0U;
}
static uint16_t dfu_getstatus(uint32_t add, uint8_t cmd, uint8_t *buffer)
{
switch (cmd) {
case DFU_MEDIA_PROGRAM:
buffer[1] = (uint8_t)FLASH_PROGRAM_TIME;
buffer[2] = (uint8_t)(FLASH_PROGRAM_TIME << 8);
buffer[3] = 0;
break;
case DFU_MEDIA_ERASE:
buffer[1] = (uint8_t)FLASH_ERASE_TIME;
buffer[2] = (uint8_t)(FLASH_ERASE_TIME << 8);
buffer[3] = 0;
default:
break;
}
return (0);
}
static void dfu_request_detach(void)
{
if ((usbd_dfu_cfg.dev_state == DFU_STATE_DFU_IDLE) ||
(usbd_dfu_cfg.dev_state == DFU_STATE_DFU_DNLOAD_SYNC) ||
(usbd_dfu_cfg.dev_state == DFU_STATE_DFU_DNLOAD_IDLE) ||
(usbd_dfu_cfg.dev_state == DFU_STATE_DFU_MANIFEST_SYNC) ||
(usbd_dfu_cfg.dev_state == DFU_STATE_DFU_UPLOAD_IDLE)) {
/* Update the state machine */
usbd_dfu_cfg.dev_state = DFU_STATE_DFU_IDLE;
usbd_dfu_cfg.dev_status[0] = DFU_STATUS_OK;
usbd_dfu_cfg.dev_status[1] = 0U;
usbd_dfu_cfg.dev_status[2] = 0U;
usbd_dfu_cfg.dev_status[3] = 0U; /*bwPollTimeout=0ms*/
usbd_dfu_cfg.dev_status[4] = usbd_dfu_cfg.dev_state;
usbd_dfu_cfg.dev_status[5] = 0U; /*iString*/
usbd_dfu_cfg.wblock_num = 0U;
usbd_dfu_cfg.wlength = 0U;
}
}
static void dfu_request_upload(struct usb_setup_packet *setup, uint8_t **data, uint32_t *len)
{
struct usb_setup_packet *req = setup;
uint32_t addr;
uint8_t *phaddr;
/* Data setup request */
if (req->wLength > 0U) {
if ((usbd_dfu_cfg.dev_state == DFU_STATE_DFU_IDLE) || (usbd_dfu_cfg.dev_state == DFU_STATE_DFU_UPLOAD_IDLE)) {
/* Update the global length and block number */
usbd_dfu_cfg.wblock_num = req->wValue;
usbd_dfu_cfg.wlength = MIN(req->wLength, USBD_DFU_XFER_SIZE);
/* DFU Get Command */
if (usbd_dfu_cfg.wblock_num == 0U) {
/* Update the state machine */
usbd_dfu_cfg.dev_state = (usbd_dfu_cfg.wlength > 3U) ? DFU_STATE_DFU_IDLE : DFU_STATE_DFU_UPLOAD_IDLE;
usbd_dfu_cfg.dev_status[1] = 0U;
usbd_dfu_cfg.dev_status[2] = 0U;
usbd_dfu_cfg.dev_status[3] = 0U;
usbd_dfu_cfg.dev_status[4] = usbd_dfu_cfg.dev_state;
/* Store the values of all supported commands */
usbd_dfu_cfg.buffer.d8[0] = DFU_CMD_GETCOMMANDS;
usbd_dfu_cfg.buffer.d8[1] = DFU_CMD_SETADDRESSPOINTER;
usbd_dfu_cfg.buffer.d8[2] = DFU_CMD_ERASE;
/* Send the status data over EP0 */
*data = usbd_dfu_cfg.buffer.d8;
*len = 3;
} else if (usbd_dfu_cfg.wblock_num > 1U) {
usbd_dfu_cfg.dev_state = DFU_STATE_DFU_UPLOAD_IDLE;
usbd_dfu_cfg.dev_status[1] = 0U;
usbd_dfu_cfg.dev_status[2] = 0U;
usbd_dfu_cfg.dev_status[3] = 0U;
usbd_dfu_cfg.dev_status[4] = usbd_dfu_cfg.dev_state;
addr = ((usbd_dfu_cfg.wblock_num - 2U) * USBD_DFU_XFER_SIZE) + usbd_dfu_cfg.data_ptr;
/* Return the physical address where data are stored */
phaddr = dfu_read_flash((uint8_t *)addr, usbd_dfu_cfg.buffer.d8, usbd_dfu_cfg.wlength);
/* Send the status data over EP0 */
*data = usbd_dfu_cfg.buffer.d8;
*len = usbd_dfu_cfg.wlength;
} else /* unsupported usbd_dfu_cfg.wblock_num */
{
usbd_dfu_cfg.dev_state = DFU_STATUS_ERR_STALLEDPKT;
usbd_dfu_cfg.dev_status[1] = 0U;
usbd_dfu_cfg.dev_status[2] = 0U;
usbd_dfu_cfg.dev_status[3] = 0U;
usbd_dfu_cfg.dev_status[4] = usbd_dfu_cfg.dev_state;
/* Call the error management function (command will be NAKed */
USB_LOG_ERR("Dfu_request_upload unsupported usbd_dfu_cfg.wblock_num\r\n");
}
}
/* Unsupported state */
else {
usbd_dfu_cfg.wlength = 0U;
usbd_dfu_cfg.wblock_num = 0U;
/* Call the error management function (command will be NAKed */
USB_LOG_ERR("Dfu_request_upload unsupported state\r\n");
}
}
/* No Data setup request */
else {
usbd_dfu_cfg.dev_state = DFU_STATE_DFU_IDLE;
usbd_dfu_cfg.dev_status[1] = 0U;
usbd_dfu_cfg.dev_status[2] = 0U;
usbd_dfu_cfg.dev_status[3] = 0U;
usbd_dfu_cfg.dev_status[4] = usbd_dfu_cfg.dev_state;
}
}
static void dfu_request_dnload(struct usb_setup_packet *setup, uint8_t **data, uint32_t *len)
{
/* Data setup request */
struct usb_setup_packet *req = setup;
if (req->wLength > 0U) {
if ((usbd_dfu_cfg.dev_state == DFU_STATE_DFU_IDLE) || (usbd_dfu_cfg.dev_state == DFU_STATE_DFU_DNLOAD_IDLE)) {
/* Update the global length and block number */
usbd_dfu_cfg.wblock_num = req->wValue;
usbd_dfu_cfg.wlength = MIN(req->wLength, USBD_DFU_XFER_SIZE);
/* Update the state machine */
usbd_dfu_cfg.dev_state = DFU_STATE_DFU_DNLOAD_SYNC;
usbd_dfu_cfg.dev_status[4] = usbd_dfu_cfg.dev_state;
/*!< Data has received complete */
memcpy((uint8_t *)usbd_dfu_cfg.buffer.d8, (uint8_t *)*data, usbd_dfu_cfg.wlength);
/*!< Set flag = 1 Write the firmware to the flash in the next dfu_request_getstatus */
usbd_dfu_cfg.firmwar_flag = 1;
}
/* Unsupported state */
else {
USB_LOG_ERR("Dfu_request_dnload unsupported state\r\n");
}
}
/* 0 Data DNLOAD request */
else {
/* End of DNLOAD operation*/
if ((usbd_dfu_cfg.dev_state == DFU_STATE_DFU_DNLOAD_IDLE) || (usbd_dfu_cfg.dev_state == DFU_STATE_DFU_IDLE)) {
usbd_dfu_cfg.manif_state = DFU_MANIFEST_IN_PROGRESS;
usbd_dfu_cfg.dev_state = DFU_STATE_DFU_MANIFEST_SYNC;
usbd_dfu_cfg.dev_status[1] = 0U;
usbd_dfu_cfg.dev_status[2] = 0U;
usbd_dfu_cfg.dev_status[3] = 0U;
usbd_dfu_cfg.dev_status[4] = usbd_dfu_cfg.dev_state;
} else {
/* Call the error management function (command will be NAKed */
USB_LOG_ERR("Dfu_request_dnload End of DNLOAD operation but dev_state %02x \r\n", usbd_dfu_cfg.dev_state);
}
}
}
static int8_t dfu_getstatus_special_handler(void)
{
uint32_t addr;
if (usbd_dfu_cfg.dev_state == DFU_STATE_DFU_DNLOAD_BUSY) {
/* Decode the Special Command */
if (usbd_dfu_cfg.wblock_num == 0U) {
if (usbd_dfu_cfg.wlength == 1U) {
if (usbd_dfu_cfg.buffer.d8[0] == DFU_CMD_GETCOMMANDS) {
/* Nothing to do */
}
} else if (usbd_dfu_cfg.wlength == 5U) {
if (usbd_dfu_cfg.buffer.d8[0] == DFU_CMD_SETADDRESSPOINTER) {
usbd_dfu_cfg.data_ptr = usbd_dfu_cfg.buffer.d8[1];
usbd_dfu_cfg.data_ptr += (uint32_t)usbd_dfu_cfg.buffer.d8[2] << 8;
usbd_dfu_cfg.data_ptr += (uint32_t)usbd_dfu_cfg.buffer.d8[3] << 16;
usbd_dfu_cfg.data_ptr += (uint32_t)usbd_dfu_cfg.buffer.d8[4] << 24;
} else if (usbd_dfu_cfg.buffer.d8[0] == DFU_CMD_ERASE) {
usbd_dfu_cfg.data_ptr = usbd_dfu_cfg.buffer.d8[1];
usbd_dfu_cfg.data_ptr += (uint32_t)usbd_dfu_cfg.buffer.d8[2] << 8;
usbd_dfu_cfg.data_ptr += (uint32_t)usbd_dfu_cfg.buffer.d8[3] << 16;
usbd_dfu_cfg.data_ptr += (uint32_t)usbd_dfu_cfg.buffer.d8[4] << 24;
USB_LOG_DBG("Erase start add %08x \r\n", usbd_dfu_cfg.data_ptr);
/*!< Erase */
dfu_erase_flash(usbd_dfu_cfg.data_ptr);
} else {
return -1;
}
} else {
/* Reset the global length and block number */
usbd_dfu_cfg.wlength = 0U;
usbd_dfu_cfg.wblock_num = 0U;
/* Call the error management function (command will be NAKed) */
USB_LOG_ERR("Reset the global length and block number\r\n");
}
}
/* Regular Download Command */
else {
if (usbd_dfu_cfg.wblock_num > 1U) {
/* Decode the required address */
addr = ((usbd_dfu_cfg.wblock_num - 2U) * USBD_DFU_XFER_SIZE) + usbd_dfu_cfg.data_ptr;
/* Perform the write operation */
/* Write flash */
USB_LOG_DBG("Write start add %08x length %d\r\n", addr, usbd_dfu_cfg.wlength);
dfu_write_flash(usbd_dfu_cfg.buffer.d8, (uint8_t *)addr, usbd_dfu_cfg.wlength);
}
}
/* Reset the global length and block number */
usbd_dfu_cfg.wlength = 0U;
usbd_dfu_cfg.wblock_num = 0U;
/* Update the state machine */
usbd_dfu_cfg.dev_state = DFU_STATE_DFU_DNLOAD_SYNC;
usbd_dfu_cfg.dev_status[1] = 0U;
usbd_dfu_cfg.dev_status[2] = 0U;
usbd_dfu_cfg.dev_status[3] = 0U;
usbd_dfu_cfg.dev_status[4] = usbd_dfu_cfg.dev_state;
}
return 0;
}
static void dfu_request_getstatus(struct usb_setup_packet *setup, uint8_t **data, uint32_t *len)
{
/*!< Determine whether to leave DFU mode */
if (usbd_dfu_cfg.manif_state == DFU_MANIFEST_IN_PROGRESS &&
usbd_dfu_cfg.dev_state == DFU_STATE_DFU_MANIFEST_SYNC &&
usbd_dfu_cfg.dev_status[1] == 0U &&
usbd_dfu_cfg.dev_status[2] == 0U &&
usbd_dfu_cfg.dev_status[3] == 0U &&
usbd_dfu_cfg.dev_status[4] == usbd_dfu_cfg.dev_state) {
usbd_dfu_cfg.manif_state = DFU_MANIFEST_COMPLETE;
if ((0x0B & DFU_MANIFEST_MASK) != 0U) {
usbd_dfu_cfg.dev_state = DFU_STATE_DFU_MANIFEST_SYNC;
usbd_dfu_cfg.dev_status[1] = 0U;
usbd_dfu_cfg.dev_status[2] = 0U;
usbd_dfu_cfg.dev_status[3] = 0U;
usbd_dfu_cfg.dev_status[4] = usbd_dfu_cfg.dev_state;
return;
} else {
usbd_dfu_cfg.dev_state = DFU_STATE_DFU_MANIFEST_WAIT_RESET;
usbd_dfu_cfg.dev_status[1] = 0U;
usbd_dfu_cfg.dev_status[2] = 0U;
usbd_dfu_cfg.dev_status[3] = 0U;
usbd_dfu_cfg.dev_status[4] = usbd_dfu_cfg.dev_state;
/* Generate system reset to allow jumping to the user code */
dfu_leave();
}
}
switch (usbd_dfu_cfg.dev_state) {
case DFU_STATE_DFU_DNLOAD_SYNC:
if (usbd_dfu_cfg.wlength != 0U) {
usbd_dfu_cfg.dev_state = DFU_STATE_DFU_DNLOAD_BUSY;
usbd_dfu_cfg.dev_status[1] = 0U;
usbd_dfu_cfg.dev_status[2] = 0U;
usbd_dfu_cfg.dev_status[3] = 0U;
usbd_dfu_cfg.dev_status[4] = usbd_dfu_cfg.dev_state;
if ((usbd_dfu_cfg.wblock_num == 0U) && (usbd_dfu_cfg.buffer.d8[0] == DFU_CMD_ERASE)) {
dfu_getstatus(usbd_dfu_cfg.data_ptr, DFU_MEDIA_ERASE, usbd_dfu_cfg.dev_status);
} else {
dfu_getstatus(usbd_dfu_cfg.data_ptr, DFU_MEDIA_PROGRAM, usbd_dfu_cfg.dev_status);
}
} else /* (usbd_dfu_cfg.wlength==0)*/
{
usbd_dfu_cfg.dev_state = DFU_STATE_DFU_DNLOAD_IDLE;
usbd_dfu_cfg.dev_status[1] = 0U;
usbd_dfu_cfg.dev_status[2] = 0U;
usbd_dfu_cfg.dev_status[3] = 0U;
usbd_dfu_cfg.dev_status[4] = usbd_dfu_cfg.dev_state;
}
break;
case DFU_STATE_DFU_MANIFEST_SYNC:
if (usbd_dfu_cfg.manif_state == DFU_MANIFEST_IN_PROGRESS) {
usbd_dfu_cfg.dev_state = DFU_STATE_DFU_MANIFEST;
usbd_dfu_cfg.dev_status[1] = 1U; /*bwPollTimeout = 1ms*/
usbd_dfu_cfg.dev_status[2] = 0U;
usbd_dfu_cfg.dev_status[3] = 0U;
usbd_dfu_cfg.dev_status[4] = usbd_dfu_cfg.dev_state;
} else {
if ((usbd_dfu_cfg.manif_state == DFU_MANIFEST_COMPLETE) &&
((0x0B & DFU_MANIFEST_MASK) != 0U)) {
usbd_dfu_cfg.dev_state = DFU_STATE_DFU_IDLE;
usbd_dfu_cfg.dev_status[1] = 0U;
usbd_dfu_cfg.dev_status[2] = 0U;
usbd_dfu_cfg.dev_status[3] = 0U;
usbd_dfu_cfg.dev_status[4] = usbd_dfu_cfg.dev_state;
}
}
break;
default:
break;
}
/* Send the status data over EP0 */
uint8_t temp_data[6];
memcpy(temp_data, usbd_dfu_cfg.dev_status, 6);
*data = temp_data;
*len = 6;
if (usbd_dfu_cfg.firmwar_flag == 1) {
if (dfu_getstatus_special_handler() != 0) {
USB_LOG_ERR("dfu_getstatus_special_handler error \r\n");
}
usbd_dfu_cfg.firmwar_flag = 0;
}
}
static void dfu_request_clrstatus(void)
{
if (usbd_dfu_cfg.dev_state == DFU_STATE_DFU_ERROR) {
usbd_dfu_cfg.dev_state = DFU_STATE_DFU_IDLE;
usbd_dfu_cfg.dev_status[0] = DFU_STATUS_OK; /* bStatus */
usbd_dfu_cfg.dev_status[1] = 0U;
usbd_dfu_cfg.dev_status[2] = 0U;
usbd_dfu_cfg.dev_status[3] = 0U; /* bwPollTimeout=0ms */
usbd_dfu_cfg.dev_status[4] = usbd_dfu_cfg.dev_state; /* bState */
usbd_dfu_cfg.dev_status[5] = 0U; /* iString */
} else {
/* State Error */
usbd_dfu_cfg.dev_state = DFU_STATE_DFU_ERROR;
usbd_dfu_cfg.dev_status[0] = DFU_STATUS_ERR_UNKNOWN; /* bStatus */
usbd_dfu_cfg.dev_status[1] = 0U;
usbd_dfu_cfg.dev_status[2] = 0U;
usbd_dfu_cfg.dev_status[3] = 0U; /* bwPollTimeout=0ms */
usbd_dfu_cfg.dev_status[4] = usbd_dfu_cfg.dev_state; /* bState */
usbd_dfu_cfg.dev_status[5] = 0U; /* iString */
}
}
static void dfu_request_getstate(struct usb_setup_packet *setup, uint8_t **data, uint32_t *len)
{
/* Return the current state of the DFU interface */
*data = &usbd_dfu_cfg.dev_state;
*len = 1;
}
void dfu_request_abort(void)
{
if ((usbd_dfu_cfg.dev_state == DFU_STATE_DFU_IDLE) ||
(usbd_dfu_cfg.dev_state == DFU_STATE_DFU_DNLOAD_SYNC) ||
(usbd_dfu_cfg.dev_state == DFU_STATE_DFU_DNLOAD_IDLE) ||
(usbd_dfu_cfg.dev_state == DFU_STATE_DFU_MANIFEST_SYNC) ||
(usbd_dfu_cfg.dev_state == DFU_STATE_DFU_UPLOAD_IDLE)) {
usbd_dfu_cfg.dev_state = DFU_STATE_DFU_IDLE;
usbd_dfu_cfg.dev_status[0] = DFU_STATUS_OK;
usbd_dfu_cfg.dev_status[1] = 0U;
usbd_dfu_cfg.dev_status[2] = 0U;
usbd_dfu_cfg.dev_status[3] = 0U; /* bwPollTimeout=0ms */
usbd_dfu_cfg.dev_status[4] = usbd_dfu_cfg.dev_state;
usbd_dfu_cfg.dev_status[5] = 0U; /* iString */
usbd_dfu_cfg.wblock_num = 0U;
usbd_dfu_cfg.wlength = 0U;
}
}
static int dfu_class_interface_request_handler(struct usb_setup_packet *setup, uint8_t **data, uint32_t *len)
{
USB_LOG_WRN("DFU Class request: "
"bRequest 0x%02x\r\n",
setup->bRequest);
USB_LOG_DBG("DFU Class request: "
"bRequest 0x%02x\r\n",
setup->bRequest);
switch (setup->bRequest) {
case DFU_REQUEST_DETACH:
dfu_request_detach();
break;
case DFU_REQUEST_DNLOAD:
dfu_request_dnload(setup, data, len);
break;
case DFU_REQUEST_UPLOAD:
dfu_request_upload(setup, data, len);
break;
case DFU_REQUEST_GETSTATUS:
dfu_request_getstatus(setup, data, len);
break;
case DFU_REQUEST_CLRSTATUS:
dfu_request_clrstatus();
break;
case DFU_REQUEST_GETSTATE:
dfu_request_getstate(setup, data, len);
break;
case DFU_REQUEST_ABORT:
dfu_request_abort();
break;
default:
USB_LOG_WRN("Unhandled DFU Class bRequest 0x%02x\r\n", setup->bRequest);
@ -43,8 +470,8 @@ static void dfu_notify_handler(uint8_t event, void *arg)
{
switch (event) {
case USBD_EVENT_RESET:
dfu_reset();
break;
default:
break;
}
@ -65,3 +492,22 @@ struct usbd_interface *usbd_dfu_alloc_intf(void)
return intf;
}
__WEAK uint8_t *dfu_read_flash(uint8_t *src, uint8_t *dest, uint32_t len)
{
return dest;
}
__WEAK uint16_t dfu_write_flash(uint8_t *src, uint8_t *dest, uint32_t len)
{
return 0;
}
__WEAK uint16_t dfu_erase_flash(uint32_t add)
{
return 0;
}
__WEAK void dfu_leave(void)
{
}

View File

@ -15,6 +15,11 @@ extern "C" {
/* Alloc dfu interface driver */
struct usbd_interface *usbd_dfu_alloc_intf(void);
/* Interface functions that need to be implemented by the user */
uint8_t *dfu_read_flash(uint8_t *src, uint8_t *dest, uint32_t len);
uint16_t dfu_write_flash(uint8_t *src, uint8_t *dest, uint32_t len);
uint16_t dfu_erase_flash(uint32_t add);
void dfu_leave(void);
#ifdef __cplusplus
}
#endif

372
demo/dfu_st_cubemx_main.c Normal file
View File

@ -0,0 +1,372 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file : main.c
* @brief : Main program body
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2021 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* www.st.com/SLA0044
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "usbd_core.h"
#include "usb_dfu.h"
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
/* USER CODE END PTD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
UART_HandleTypeDef huart1;
PCD_HandleTypeDef hpcd_USB_FS;
/* USER CODE BEGIN PV */
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_USART1_UART_Init(void);
static void MX_USB_PCD_Init(void);
/* USER CODE BEGIN PFP */
typedef void (*pFunction)(void);
static void jump_app(void)
{
pFunction JumpToApplication;
uint32_t JumpAddress;
if (((*(__IO uint32_t *)USBD_DFU_APP_DEFAULT_ADD) & 0x2FFFB000) == 0x20000000)
{
/* Jump to user application */
/*!< Jump to app reset_handler */
JumpAddress = *(__IO uint32_t *)(USBD_DFU_APP_DEFAULT_ADD + 4);
JumpToApplication = (pFunction)JumpAddress;
/* Initialize user application's Stack Pointer */
__set_MSP(*(__IO uint32_t *)USBD_DFU_APP_DEFAULT_ADD);
JumpToApplication();
}
}
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
int fputc(int ch, FILE *f)
{
while ((USART1->SR & USART_SR_TXE) == 0)
;
USART1->DR = ch;
return ch;
}
void usb_dc_low_level_init(void)
{
/* Peripheral clock enable */
__HAL_RCC_USB_CLK_ENABLE();
/* USB interrupt Init */
HAL_NVIC_SetPriority(USB_LP_CAN1_RX0_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(USB_LP_CAN1_RX0_IRQn);
}
uint8_t *dfu_read_flash(uint8_t *src, uint8_t *dest, uint32_t len)
{
uint32_t i = 0;
uint8_t *psrc = src;
for (i = 0; i < len; i++)
{
dest[i] = *psrc++;
}
/* Return a valid address to avoid HardFault */
return (uint8_t *)(dest);
}
uint16_t dfu_write_flash(uint8_t *src, uint8_t *dest, uint32_t len)
{
HAL_FLASH_Unlock();
uint32_t i = 0;
for (i = 0; i < len; i += 4)
{
/* Device voltage range supposed to be [2.7V to 3.6V], the operation will
* be done by byte */
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, (uint32_t)(dest + i),
*(uint32_t *)(src + i)) == HAL_OK)
{
/* Check the written value */
if (*(uint32_t *)(src + i) != *(uint32_t *)(dest + i))
{
/* Flash content doesn't match SRAM content */
return (1);
}
}
else
{
/* Error occurred while writing data in Flash memory */
return (2);
}
}
return 0;
}
uint16_t dfu_erase_flash(uint32_t add)
{
HAL_FLASH_Unlock();
uint32_t PageError;
/* Variable contains Flash operation status */
HAL_StatusTypeDef status;
FLASH_EraseInitTypeDef eraseinitstruct;
eraseinitstruct.TypeErase = FLASH_TYPEERASE_PAGES;
eraseinitstruct.PageAddress = add;
eraseinitstruct.NbPages = 1U;
status = HAL_FLASHEx_Erase(&eraseinitstruct, &PageError);
return 0;
}
void dfu_leave(void)
{
NVIC_SystemReset();
}
/* USER CODE END 0 */
/**
* @brief The application entry point.
* @retval int
*/
int main(void)
{
/* USER CODE BEGIN 1 */
jump_app();
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART1_UART_Init();
//MX_USB_PCD_Init();
/* USER CODE BEGIN 2 */
// extern void cdc_acm_msc_init(void);
// cdc_acm_msc_init();
extern void dfu_flash_init(void);
dfu_flash_init();
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1) {
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
// extern void cdc_acm_data_send_with_dtr_test(void);
// cdc_acm_data_send_with_dtr_test();
// HAL_Delay(100);
}
/* USER CODE END 3 */
}
/**
* @brief System Clock Configuration
* @retval None
*/
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
/** Initializes the CPU, AHB and APB buses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
{
Error_Handler();
}
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLL_DIV1_5;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
{
Error_Handler();
}
}
/**
* @brief USART1 Initialization Function
* @param None
* @retval None
*/
static void MX_USART1_UART_Init(void)
{
/* USER CODE BEGIN USART1_Init 0 */
/* USER CODE END USART1_Init 0 */
/* USER CODE BEGIN USART1_Init 1 */
/* USER CODE END USART1_Init 1 */
huart1.Instance = USART1;
huart1.Init.BaudRate = 115200;
huart1.Init.WordLength = UART_WORDLENGTH_8B;
huart1.Init.StopBits = UART_STOPBITS_1;
huart1.Init.Parity = UART_PARITY_NONE;
huart1.Init.Mode = UART_MODE_TX_RX;
huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart1.Init.OverSampling = UART_OVERSAMPLING_16;
if (HAL_UART_Init(&huart1) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN USART1_Init 2 */
/* USER CODE END USART1_Init 2 */
}
/**
* @brief USB Initialization Function
* @param None
* @retval None
*/
static void MX_USB_PCD_Init(void)
{
/* USER CODE BEGIN USB_Init 0 */
/* USER CODE END USB_Init 0 */
/* USER CODE BEGIN USB_Init 1 */
/* USER CODE END USB_Init 1 */
hpcd_USB_FS.Instance = USB;
hpcd_USB_FS.Init.dev_endpoints = 8;
hpcd_USB_FS.Init.speed = PCD_SPEED_FULL;
hpcd_USB_FS.Init.low_power_enable = DISABLE;
hpcd_USB_FS.Init.lpm_enable = DISABLE;
hpcd_USB_FS.Init.battery_charging_enable = DISABLE;
if (HAL_PCD_Init(&hpcd_USB_FS) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN USB_Init 2 */
/* USER CODE END USB_Init 2 */
}
/**
* @brief GPIO Initialization Function
* @param None
* @retval None
*/
static void MX_GPIO_Init(void)
{
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOD_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
}
/* USER CODE BEGIN 4 */
/* USER CODE END 4 */
/**
* @brief This function is executed in case of error occurrence.
* @retval None
*/
void Error_Handler(void)
{
/* USER CODE BEGIN Error_Handler_Debug */
/* User can add his own implementation to report the HAL error return state */
__disable_irq();
while (1) {
}
/* USER CODE END Error_Handler_Debug */
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t *file, uint32_t line)
{
/* USER CODE BEGIN 6 */
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@ -0,0 +1,156 @@
#include "usbd_core.h"
#include "usbd_dfu.h"
#define USBD_VID 0x0483
#define USBD_PID 0xDF11
#define USBD_MAX_POWER 100
#define USBD_LANGID_STRING 1033
#define FLASH_DESC_STR "@Internal Flash /0x08000000/16*001Ka,112*01Kg"
#define USB_CONFIG_SIZE (9 + 9 + 9)
const uint8_t dfu_flash_descriptor[] = {
USB_DEVICE_DESCRIPTOR_INIT(USB_2_0, 0x00, 0x00, 0x00, USBD_VID, USBD_PID, 0x0200, 0x01),
USB_CONFIG_DESCRIPTOR_INIT(USB_CONFIG_SIZE, 0x01, 0x01, USB_CONFIG_BUS_POWERED, USBD_MAX_POWER),
DFU_DESCRIPTOR_INIT(),
///////////////////////////////////////
/// string0 descriptor
///////////////////////////////////////
USB_LANGID_INIT(USBD_LANGID_STRING),
///////////////////////////////////////
/// string1 descriptor
///////////////////////////////////////
0x14, /* bLength */
USB_DESCRIPTOR_TYPE_STRING, /* bDescriptorType */
'C', 0x00, /* wcChar0 */
'h', 0x00, /* wcChar1 */
'e', 0x00, /* wcChar2 */
'r', 0x00, /* wcChar3 */
'r', 0x00, /* wcChar4 */
'y', 0x00, /* wcChar5 */
'U', 0x00, /* wcChar6 */
'S', 0x00, /* wcChar7 */
'B', 0x00, /* wcChar8 */
///////////////////////////////////////
/// string2 descriptor
///////////////////////////////////////
0x1e, /* bLength */
USB_DESCRIPTOR_TYPE_STRING, /* bDescriptorType */
'D', 0x00, /* wcChar0 */
'F', 0x00, /* wcChar1 */
'U', 0x00, /* wcChar2 */
'W', 0x00, /* wcChar3 */
'i', 0x00, /* wcChar4 */
't', 0x00, /* wcChar5 */
'h', 0x00, /* wcChar6 */
's', 0x00, /* wcChar7 */
't', 0x00, /* wcChar8 */
' ', 0x00, /* wcChar9 */
't', 0x00, /* wcChar10 */
'o', 0x00, /* wcChar11 */
'o', 0x00, /* wcChar12 */
'l', 0x00, /* wcChar13 */
///////////////////////////////////////
/// string3 descriptor
///////////////////////////////////////
0x16, /* bLength */
USB_DESCRIPTOR_TYPE_STRING, /* bDescriptorType */
'2', 0x00, /* wcChar0 */
'0', 0x00, /* wcChar1 */
'2', 0x00, /* wcChar2 */
'2', 0x00, /* wcChar3 */
'1', 0x00, /* wcChar4 */
'2', 0x00, /* wcChar5 */
'3', 0x00, /* wcChar6 */
'4', 0x00, /* wcChar7 */
'5', 0x00, /* wcChar8 */
'6', 0x00, /* wcChar9 */
///////////////////////////////////////
/// string4 descriptor
///////////////////////////////////////
0x60, /* bLength */
USB_DESCRIPTOR_TYPE_STRING, /* bDescriptorType */
'@', 0x00, /* wcChar0 */
'I', 0x00, /* wcChar1 */
'n', 0x00, /* wcChar2 */
't', 0x00, /* wcChar3 */
'e', 0x00, /* wcChar4 */
'r', 0x00, /* wcChar5 */
'n', 0x00, /* wcChar6 */
'a', 0x00, /* wcChar7 */
'l', 0x00, /* wcChar8 */
' ', 0x00, /* wcChar9 */
'F', 0x00, /* wcChar10 */
'l', 0x00, /* wcChar11*/
'a', 0x00, /* wcChar12 */
's', 0x00, /* wcChar13 */
'h', 0x00, /* wcChar14 */
' ', 0x00, /* wcChar15 */
' ', 0x00, /* wcChar16 */
' ', 0x00, /* wcChar17 */
'/', 0x00, /* wcChar18 */
'0', 0x00, /* wcChar19 */
'x', 0x00, /* wcChar20 */
'0', 0x00, /* wcChar21*/
'8', 0x00, /* wcChar22 */
'0', 0x00, /* wcChar23 */
'0', 0x00, /* wcChar24 */
'0', 0x00, /* wcChar25 */
'0', 0x00, /* wcChar26 */
'0', 0x00, /* wcChar27 */
'0', 0x00, /* wcChar28 */
'/', 0x00, /* wcChar29 */
'1', 0x00, /* wcChar30 */
'6', 0x00, /* wcChar31*/
'*', 0x00, /* wcChar32 */
'0', 0x00, /* wcChar33 */
'0', 0x00, /* wcChar34 */
'1', 0x00, /* wcChar35 */
'K', 0x00, /* wcChar36 */
'a', 0x00, /* wcChar37 */
',', 0x00, /* wcChar38 */
'1', 0x00, /* wcChar39 */
'1', 0x00, /* wcChar40 */
'2', 0x00, /* wcChar41*/
'*', 0x00, /* wcChar42 */
'0', 0x00, /* wcChar43 */
'1', 0x00, /* wcChar44 */
'K', 0x00, /* wcChar45 */
'g', 0x00, /* wcChar46 */
#ifdef CONFIG_USB_HS
///////////////////////////////////////
/// device qualifier descriptor
///////////////////////////////////////
0x0a,
USB_DESCRIPTOR_TYPE_DEVICE_QUALIFIER,
0x00,
0x02,
0x00,
0x00,
0x00,
0x40,
0x01,
0x00,
#endif
0x00};
void usbd_configure_done_callback(void)
{
/* no out ep, do nothing */
}
/* function ------------------------------------------------------------------*/
/**
* @brief dfu flash init
* @pre none
* @param[in] none
* @retval none
*/
void dfu_flash_init(void)
{
usbd_desc_register(dfu_flash_descriptor);
usbd_add_interface(usbd_dfu_alloc_intf());
usbd_initialize();
}

Binary file not shown.

View File

@ -0,0 +1,17 @@
SLA0044 Rev5/February 2018
refer to www.st.com/sla0044
BY INSTALLING COPYING, DOWNLOADING, ACCESSING OR OTHERWISE USING THIS SOFTWARE OR ANY PART THEREOF (AND THE RELATED DOCUMENTATION) FROM STMICROELECTRONICS INTERNATIONAL N.V, SWISS BRANCH AND/OR ITS AFFILIATED COMPANIES (STMICROELECTRONICS), THE RECIPIENT, ON BEHALF OF HIMSELF OR HERSELF, OR ON BEHALF OF ANY ENTITY BY WHICH SUCH RECIPIENT IS EMPLOYED AND/OR ENGAGED AGREES TO BE BOUND BY THIS SOFTWARE LICENSE AGREEMENT.
Under STMicroelectronics intellectual property rights, the redistribution, reproduction and use in source and binary forms of the software or any part thereof, with or without modification, are permitted provided that the following conditions are met:
1. Redistribution of source code (modified or not) must retain any copyright notice, this list of conditions and the disclaimer set forth below as items 10 and 11.
2. Redistributions in binary form, except as embedded into microcontroller or microprocessor device manufactured by or for STMicroelectronics or a software update for such device, must reproduce any copyright notice provided with the binary code, this list of conditions, and the disclaimer set forth below as items 10 and 11, in documentation and/or other materials provided with the distribution.
3. Neither the name of STMicroelectronics nor the names of other contributors to this software may be used to endorse or promote products derived from this software or part thereof without specific written permission.
4. This software or any part thereof, including modifications and/or derivative works of this software, must be used and execute solely and exclusively on or in combination with a microcontroller or microprocessor device manufactured by or for STMicroelectronics.
5. No use, reproduction or redistribution of this software partially or totally may be done in any manner that would subject this software to any Open Source Terms. “Open Source Terms” shall mean any open source license which requires as part of distribution of software that the source code of such software is distributed therewith or otherwise made available, or open source license that substantially complies with the Open Source definition specified at www.opensource.org and any other comparable open source license such as for example GNU General Public License (GPL), Eclipse Public License (EPL), Apache Software License, BSD license or MIT license.
6. STMicroelectronics has no obligation to provide any maintenance, support or updates for the software.
7. The software is and will remain the exclusive property of STMicroelectronics and its licensors. The recipient will not take any action that jeopardizes STMicroelectronics and its licensors' proprietary rights or acquire any rights in the software, except the limited rights specified hereunder.
8. The recipient shall comply with all applicable laws and regulations affecting the use of the software or any part thereof including any applicable export control law or regulation.
9. Redistribution and use of this software or any part thereof other than as permitted under this license is void and will automatically terminate your rights under this license.
10. THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY RIGHTS, WHICH ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11. EXCEPT AS EXPRESSLY PERMITTED HEREUNDER, NO LICENSE OR OTHER RIGHTS, WHETHER EXPRESS OR IMPLIED, ARE GRANTED UNDER ANY PATENT OR OTHER INTELLECTUAL PROPERTY RIGHTS OF STMICROELECTRONICS OR ANY THIRD PARTY.

View File

@ -0,0 +1,71 @@
/******************** (C) COPYRIGHT 2018 STMicroelectronics ********************
* File Name : version.txt
* Author : MCD Application Team
* Version : V3.0.6
* Date : 01-June-2018
* Description : read me file for DfuSe Demonstrator
********************************************************************************
* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
* CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/
Last version
***************
- V3.0.6 - 01-June-2018
Package content
***************
+ Binaries :([INSTALLATION PATH]\BIN\) and ([INSTALLATION PATH]\BIN\STM32L) Variant with extra time for Erase.
- DfuFileMgr.exe : DFU File Manager aplication,
- DfuSeDemo.exe : DfuSe Demo application,
- DfuSeCommand.exe : DfuSe Command line application,
- STDFUTester.exe : DfuSe Tester application ,
- STDFUFiles.dll : Dll that implements .dfu files
- STDFUPRT.dll : Dll that implements Protocol for upload and download,
- STDFU.dll : Dll that issues basic DFU requests,
- STTubeDevice30.dll : Dll layer for easier driver access
+ Doc : Documentation directory
- UM0384 : DfuSe Application Programming Interface
- UM0391 : DfuSe File Format Specification
- UM0392 : DfuSe Application Programming Guide
- UM0412 : DfuSe getting started
+ Driver([INSTALLATION PATH]\Driver)
+ Sources :([INSTALLATION PATH]\Sources\)
- Binary
- DfuFileMgr
- DfuSeDemo
- DfuseCommand
- Include
- STDFU
- STDFUFiles
- STDFUPRT
- STTubeDevice
- Tools
- GUID Generator application
Supported OS
***************
+ Windows 98SE, 2000, XP, Vista, Seven , 8, 8.1, 10 (x86 & x64 Windows platforms).
How to use
***************
1- Uninstall previous versions (Start-> Settings-> Control Panel-> Add or remove programs)
2- run DfuSe setup.
3- Install your device with the driver and the inf file, go to [Driver] directory
4- Use it !
******************* (C) COPYRIGHT 2018 STMicroelectronics *****END OF FILE******

View File

@ -0,0 +1,178 @@
/******************** (C) COPYRIGHT 2018 STMicroelectronics ********************
* File Name : version.txt
* Author : MCD Application Team
* Version : V3.0.6
* Date : 01-June-2018
* Description : Version file for DfuSe Demonstrator
********************************************************************************
* FOR MORE INFORMATION PLEASE CAREFULLY READ THE LICENSE AGREEMENT FILE
* "www.st.com/sla0044"
*******************************************************************************/
* V3.0.6 - 01-June-2018
======================
New Features
************
+ DFU Driver upgraded for Win10 tests (x86 and x64). See how to install
+ License upgraded
Enhancements
************
+ Added extra Erase time for some STM32 MCUs embedded bootloader,
+ Fix of wrong descriptor decoding for some L1/L0 DFU bootloaders.
Limitations
************
+ Not using UNICODE format
+ When Progamming/reading the device memories, avoid connecting/disconnecting other USB devices on same Host.
+ When Programming using DFU Bootloader, the written bytes should be multiple of 4 bytes or 8 Bytes as specified in AN2606
padding bytes should be added in the original file from linkers.
* V3.0.5 - 01-September-2015
======================
New Features
************
+ Driver upgraded to pass WHCK Win8.1 tests
Enhancements
************
+ Some minor fix of memory leaks in some particular cases
+ Fix of DFUFileMgr not generating files in right selected directory
Limitations
************
+ Not using UNICODE format
* V3.0.4 - 20-October-2014
======================
New Features
************
+ Upgrading the whole source projects to Microsoft Visual Studio 2013
+ Removal of Options Bytes GUI and replaced by .dfu files Upload/download
+ Adding Support of all STM32 MCUs after Options bytes GUI removal
Enhancements
************
+ Some minor fix of memory leaks in some particular cases
+ Add of sources of STDFU and STTubeDriver DLLs to be able to re-compile in x64 version and recent Envirnoments
Limitations
************
+ Not using UNICODE format
* V3.0.3 - 21-November-2011
======================
New Features
************
+ Adding Support of STM32F4 and STM32L High density devices for DFU factory programmed bootloader
+ Add new DfuSeCmd ( command line version) for automatic operations
+ Upgrading the whole source project to compile and excecute on 64-bits OS
+ New license added : MCD-ST Liberty SW License Agreement V2.pdf
Enhancements
************
+ Only DfuSeDemo.exe is upgraded to V3.0.3 all others items remain the same
+ Fix and remove of wrong HID devices enumeration causing memory leaks in some cases
Limitations
************
+ use only Visual C++ 2003 and above for developpment, VC6 is not supporting x64 OS
* V3.0.2 - 09-May-2011
======================
New Features
************
+ Adding Support of STM32F2 devices for DFU factory programmed bootloader
Enhancements
************
+ Only DfuSeDemo.exe is upgraded to V3.0.2 all others items remain the same
* V3.0.1 - 06/18/2010
=====================
New Features
************
+ WHQL Certified with and published at WindowsUpdate (English only) web site :
- Microsoft Windows 2000 family,
- Microsoft Windows XP family, x86
- Microsoft Windows XP family, x64
- Microsoft Windows Vista family, x86
- Microsoft Windows Vista family, x64
- Microsoft Windows 7
+ Add Pre-compiled Libraries for x64 machines under \Binary\x64\Release
Enhancements
************
+ Fix DfuSeDemo.exe application crash while enumerating many HID devices
* V3.0.0 - 03/07/2009
=====================
New Features
************
+ Adding Support of STM32 Connectivity Line devices for DFU factory programmed bootloader :
- Adding Option bytes dialog for STM32 Connectivity Line devices,
- Adding Remove read out protection specific command for Connectivity Line devices
+ New STTub30.sys driver version (3.0.0) compatible with all 32 and 64-bit Windows distributions :
- See version.txt file under "Driver" sub-directory.
Enhancements
************
+ Fix a minor issue with read-only DFU files
* V2.2.1 - 11/11/2008
=====================
+ Removing license file from the install directory
* V2.2.0 - 14/12/2007
=====================
New Features
************
+ Enumeration of Compatible HID devices(see UM0412 document).
+ Adding HID detach command for HID devices (Combined with "Enter DFU Mode" command)
+ Verify after upgrade option added to upgrade operation
+ Transfered data size and duration time are displayed on the fly
Enhancements
************
+ UM0412 "DfuSe Getting Started" document is updated; "Step-by-step procedures" section is added
* V2.1.0 - 30/03/2007
=====================
Enhancements
************
+ Resolving binary dependencies (problem with MFC42D.dll)
+ Resolving memory access problem in the DfuSe Tester application
+ Adding "DfuSe Getting Started" document
* V2.0.0 - 16/02/2007
=====================
+ Adding source files and documentation to the initial release.
******************* (C) COPYRIGHT 2018 STMicroelectronics *****END OF FILE******