From 43b64091ef731587e2a77081f844071ccae19f30 Mon Sep 17 00:00:00 2001 From: George Hotz Date: Wed, 3 May 2017 16:05:05 -0700 Subject: [PATCH] add handshake to flasher --- board/spi_flasher.h | 8 ++++---- boardesp/proxy.c | 4 ++-- boardesp/webserver.c | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/board/spi_flasher.h b/board/spi_flasher.h index 1849fd573..af12313a7 100644 --- a/board/spi_flasher.h +++ b/board/spi_flasher.h @@ -123,17 +123,17 @@ void spi_flasher() { // signal data is ready by driving low // esp must be configured as input by this point - /*GPIOB->MODER &= ~(GPIO_MODER_MODER0); + GPIOB->MODER &= ~(GPIO_MODER_MODER0); GPIOB->MODER |= GPIO_MODER_MODER0_0; - GPIOB->ODR &= ~(GPIO_ODR_ODR_0);*/ + GPIOB->ODR &= ~(GPIO_ODR_ODR_0); } if (DMA2->LISR & DMA_LISR_TCIF3) { DMA2->LIFCR = DMA_LIFCR_CTCIF3; // reset handshake back to pull up - /*GPIOB->MODER &= ~(GPIO_MODER_MODER0); - GPIOB->PUPDR |= GPIO_PUPDR_PUPDR0_0;*/ + GPIOB->MODER &= ~(GPIO_MODER_MODER0); + GPIOB->PUPDR |= GPIO_PUPDR_PUPDR0_0; } } } diff --git a/boardesp/proxy.c b/boardesp/proxy.c index 2253927bf..d5ef81bd0 100644 --- a/boardesp/proxy.c +++ b/boardesp/proxy.c @@ -54,8 +54,8 @@ static int ICACHE_FLASH_ATTR __spi_comm(char *dat, int len, uint32_t *recvData, spiData.dataLen = 0x14; SPIMasterSendData(SpiNum_HSPI, &spiData); - // give the ST time to be ready, up to 10ms - for (int i = 0;(gpio_input_get() & (1 << 4)) && i < 1000; i++) os_delay_us(10); + // give the ST time to be ready, up to 1s + for (int i = 0;(gpio_input_get() & (1 << 4)) && i < 100000; i++) os_delay_us(10); // TODO: handle this better if (gpio_input_get() & (1 << 4)) os_printf("ERROR: SPI receive failed\n"); diff --git a/boardesp/webserver.c b/boardesp/webserver.c index 74516ebee..1419e8ccd 100644 --- a/boardesp/webserver.c +++ b/boardesp/webserver.c @@ -113,13 +113,13 @@ static void ICACHE_FLASH_ATTR web_rx_cb(void *arg, char *data, uint16_t len) { st_set_boot_mode(1); // unlock flash - while (!st_cmd(0x10, 0, NULL)); + st_cmd(0x10, 0, NULL); // erase sector 1 st_cmd(0x11, 1, NULL); // wait for erase - while (!st_cmd(0xf, 0, NULL)); + st_cmd(0xf, 0, NULL); } } } else if ((memcmp(data, "PUT /espupdate1 ", 16) == 0) ||