summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Leech <andrew.leech@planetinnovation.com.au>2020-07-01 15:05:03 +1000
committerDamien George <damien@micropython.org>2020-07-01 16:33:10 +1000
commit95ec0debec1064695b9b0ecdbfa2146f17f898bb (patch)
treeea3e06cc80656547cdf6ce2a87df7158813291b4
parent332d83343fb3ef5d2b94b4f058aa53fd0493779e (diff)
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.
-rw-r--r--ports/stm32/mboot/main.c29
1 files changed, 3 insertions, 26 deletions
diff --git a/ports/stm32/mboot/main.c b/ports/stm32/mboot/main.c
index ba0c35b8b..03620e6a3 100644
--- a/ports/stm32/mboot/main.c
+++ b/ports/stm32/mboot/main.c
@@ -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