clean up flasher

This commit is contained in:
Firmware Batman
2017-07-24 10:39:03 -07:00
parent 66c0ba5ea4
commit a2523f2d3a
2 changed files with 12 additions and 19 deletions

View File

@@ -10,9 +10,14 @@
#endif
#include "libc.h"
#include "drivers/spi.h"
#include "gpio.h"
void spi_cb_rx(uint8_t *data, int len) {};
#include "drivers/drivers.h"
#include "drivers/spi.h"
#include "crypto/rsa.h"
#include "crypto/sha.h"
@@ -20,30 +25,23 @@
#include "spi_flasher.h"
void spi_cb_rx(uint8_t *data, int len) {};
void __initialize_hardware_early() {
early();
if (is_entering_bootmode) {
spi_flasher();
}
}
void fail() {
#ifdef PANDA
volatile int i;
// detect usb host
GPIOA->PUPDR |= GPIO_PUPDR_PUPDR11_0;
for (i=0;i<PULL_EFFECTIVE_DELAY;i++);
int no_usb = GPIOA->IDR & (1 << 11);
GPIOA->PUPDR &= ~(GPIO_PUPDR_PUPDR11_0);
int no_usb = detect_with_pull(GPIOA, 11, PULL_UP);
if (no_usb) {
// no usb host, go to SPI flasher
spi_flasher();
} else {
// has usb host, go to USB flasher
enter_bootloader_mode = ENTER_BOOTLOADER_MAGIC;
NVIC_SystemReset();
}
#else
enter_bootloader_mode = ENTER_BOOTLOADER_MAGIC;
NVIC_SystemReset();

View File

@@ -243,6 +243,7 @@ void set_esp_mode(int mode) {
set_gpio_output(GPIOC, 5, 0);
break;
case ESP_ENABLED:
// ESP ON
set_gpio_output(GPIOC, 14, 1);
set_gpio_output(GPIOC, 5, 1);
break;
@@ -419,12 +420,6 @@ void early() {
} else {
set_esp_mode(ESP_ENABLED);
}
#ifdef BOOTSTUB
if (is_entering_bootmode) {
spi_flasher();
}
#endif
#endif