add handshake to flasher

This commit is contained in:
George Hotz 2017-05-03 16:05:05 -07:00
parent e38cbaae20
commit 43b64091ef
3 changed files with 8 additions and 8 deletions

View File

@ -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;
}
}
}

View File

@ -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");

View File

@ -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) ||