stm32/mboot: Remove the use of timeout in DFU_GETSTATUS.
This is treated more like a "delay before continuing" in the spec and official tools and does not appear to be really needed. In particular, downloading firmware is much slower with non-zero timeouts because the host must pause by the timeout between sending each DFU_GETSTATUS to poll for download/erase complete.
This commit is contained in:
parent
332d83343f
commit
95ec0debec
|
@ -800,28 +800,6 @@ static void dfu_init(void) {
|
|||
dfu_context.addr = 0x08000000;
|
||||
}
|
||||
|
||||
// The DFU_GETSTATUS response before dfu_process_dnload is run should include the needed timeout adjustments
|
||||
static size_t get_timeout_ms(void) {
|
||||
if (dfu_context.wBlockNum == 0) {
|
||||
// download control commands
|
||||
if (dfu_context.wLength >= 1 && dfu_context.buf[0] == DFU_CMD_DNLOAD_ERASE) {
|
||||
if (dfu_context.wLength == 1) {
|
||||
// mass erase command
|
||||
// It takes 10-12 seconds to erase a 2MB stm part. Extrapolate a suitable timeout from this.
|
||||
return APPLICATION_FLASH_LENGTH / 170;
|
||||
|
||||
} else if (dfu_context.wLength == 5) {
|
||||
// erase page command
|
||||
return 500;
|
||||
}
|
||||
}
|
||||
} else if (dfu_context.wBlockNum > 1) {
|
||||
// write data to memory command
|
||||
return 500;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dfu_process_dnload(void) {
|
||||
int ret = -1;
|
||||
if (dfu_context.wBlockNum == 0) {
|
||||
|
@ -922,11 +900,10 @@ static int dfu_handle_tx(int cmd, int arg, int len, uint8_t *buf, int max_len) {
|
|||
default:
|
||||
dfu_context.state = DFU_STATE_BUSY;
|
||||
}
|
||||
size_t timeout_ms = get_timeout_ms();
|
||||
buf[0] = dfu_context.status; // bStatus
|
||||
buf[1] = (timeout_ms >> 16) & 0xFF; // bwPollTimeout (ms)
|
||||
buf[2] = (timeout_ms >> 8) & 0xFF; // bwPollTimeout (ms)
|
||||
buf[3] = timeout_ms & 0xFF; // bwPollTimeout (ms)
|
||||
buf[1] = 0; // bwPollTimeout_lsb (ms)
|
||||
buf[2] = 0; // bwPollTimeout (ms)
|
||||
buf[3] = 0; // bwPollTimeout_msb (ms)
|
||||
buf[4] = dfu_context.state; // bState
|
||||
buf[5] = dfu_context.error; // iString
|
||||
// Clear errors now they've been sent
|
||||
|
|
Loading…
Reference in New Issue