From 711fd112b73124450fd1effbd9312841d452aff9 Mon Sep 17 00:00:00 2001 From: Chris Vickery Date: Wed, 11 Apr 2018 16:15:32 -0700 Subject: [PATCH] Enable compiler optimizations, fix things it breaks --- board/build.mk | 3 ++- board/drivers/spi.h | 4 +++- boardesp/proxy.c | 9 ++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/board/build.mk b/board/build.mk index 069a00e1a04058..a918ba25f4471a 100644 --- a/board/build.mk +++ b/board/build.mk @@ -1,4 +1,5 @@ -CFLAGS += -I inc -I ../ -nostdlib -fno-builtin -std=gnu11 -O0 +CFLAGS += -I inc -I ../ -nostdlib -fno-builtin -std=gnu11 -Os + CFLAGS += -Tstm32_flash.ld CC = arm-none-eabi-gcc diff --git a/board/drivers/spi.h b/board/drivers/spi.h index fc6a5ab26dca0f..7a5945d37257cb 100644 --- a/board/drivers/spi.h +++ b/board/drivers/spi.h @@ -40,6 +40,7 @@ void spi_tx_dma(void *addr, int len) { // channel3, increment memory, memory -> periph, enable DMA2_Stream3->CR = DMA_SxCR_CHSEL_1 | DMA_SxCR_CHSEL_0 | DMA_SxCR_MINC | DMA_SxCR_DIR_0 | DMA_SxCR_EN; + delay(0); DMA2_Stream3->CR |= DMA_SxCR_TCIE; SPI1->CR2 |= SPI_CR2_TXDMAEN; @@ -65,6 +66,7 @@ void spi_rx_dma(void *addr, int len) { // channel3, increment memory, periph -> memory, enable DMA2_Stream2->CR = DMA_SxCR_CHSEL_1 | DMA_SxCR_CHSEL_0 | DMA_SxCR_MINC | DMA_SxCR_EN; + delay(0); DMA2_Stream2->CR |= DMA_SxCR_TCIE; SPI1->CR2 |= SPI_CR2_RXDMAEN; @@ -95,7 +97,7 @@ void DMA2_Stream2_IRQHandler(void) { void DMA2_Stream3_IRQHandler(void) { #ifdef DEBUG_SPI puts("SPI handshake\n"); - #endif + #endif // reset handshake back to pull up set_gpio_mode(GPIOB, 0, MODE_INPUT); diff --git a/boardesp/proxy.c b/boardesp/proxy.c index 35493869fde893..bb89743c198ec9 100644 --- a/boardesp/proxy.c +++ b/boardesp/proxy.c @@ -264,7 +264,7 @@ void ICACHE_FLASH_ATTR wifi_configure(int secure) { void ICACHE_FLASH_ATTR wifi_init() { // default ssid and password memset(ssid, 0, 32); - os_sprintf(ssid, "panda-%08x-BROKEN", system_get_chip_id()); + os_sprintf(ssid, "panda-%08x-BROKEN", system_get_chip_id()); // fetch secure ssid and password // update, try 20 times, for 1 second @@ -283,6 +283,9 @@ void ICACHE_FLASH_ATTR wifi_init() { } os_delay_us(50000); } + os_printf("Finished getting SID\n"); + os_printf(ssid); + os_printf("\n"); // set IP wifi_softap_dhcps_stop(); //stop DHCP before setting static IP @@ -311,7 +314,7 @@ void ICACHE_FLASH_ATTR user_init() { gpio_init(); // configure UART TXD to be GPIO1, set as output - PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_GPIO1); + PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_GPIO1); gpio_output_set(0, 0, (1 << pin), 0); // configure SPI @@ -331,7 +334,7 @@ void ICACHE_FLASH_ATTR user_init() { //SPICsPinSelect(SpiNum_HSPI, SpiPinCS_1); // configure UART TXD to be GPIO1, set as output - PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO5_U, FUNC_GPIO5); + PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO5_U, FUNC_GPIO5); gpio_output_set(0, 0, (1 << 5), 0); gpio_output_set((1 << 5), 0, 0, 0);