2017-05-30 15:38:51 -07:00
|
|
|
|
2018-09-16 19:25:17 -07:00
|
|
|
#include "global.h"
|
2017-05-30 15:38:51 -07:00
|
|
|
#include "hardware.h"
|
2019-03-29 06:11:13 -07:00
|
|
|
#include "efi_gpio.h"
|
2017-05-30 15:38:51 -07:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
|
|
#include <ch.h>
|
|
|
|
#include <hal.h>
|
|
|
|
#include <stm32f4xx.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
|
|
#include "dfu.h"
|
|
|
|
|
|
|
|
LoggingWithStorage tsLogger("binary");
|
|
|
|
static bool wasCommand = false;
|
|
|
|
|
|
|
|
|
|
|
|
static THD_WORKING_AREA(waBootloaderSerial, 128);
|
|
|
|
static THD_FUNCTION(thBootloaderSerial, arg) {
|
|
|
|
(void)arg;
|
|
|
|
chRegSetThreadName("BootloaderSerial");
|
|
|
|
|
|
|
|
// start our DFU emulator
|
|
|
|
wasCommand = dfuStartLoop();
|
|
|
|
|
|
|
|
chThdExit(MSG_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(void) {
|
|
|
|
// run ChibiOS
|
|
|
|
halInit();
|
|
|
|
chSysInit();
|
2017-12-24 10:45:03 -08:00
|
|
|
// set base pin configuration based on the board
|
|
|
|
setDefaultBasePins(PASS_ENGINE_PARAMETER_SIGNATURE);
|
2017-05-30 15:38:51 -07:00
|
|
|
// set UART pads configuration based on the board
|
|
|
|
setDefaultSerialParameters(PASS_ENGINE_PARAMETER_SIGNATURE);
|
|
|
|
// set SD card configuration also
|
|
|
|
setDefaultSdCardParameters(PASS_ENGINE_PARAMETER_SIGNATURE);
|
|
|
|
|
|
|
|
// start UART
|
|
|
|
startTsPort(getTsChannel());
|
|
|
|
|
|
|
|
// start a serial port reader thread
|
|
|
|
thread_t *thrSerial = chThdCreateStatic(waBootloaderSerial, sizeof(waBootloaderSerial), NORMALPRIO, thBootloaderSerial, NULL);
|
|
|
|
|
|
|
|
// wait for the thread to finish
|
|
|
|
chThdWait(thrSerial);
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
if (wasCommand) // abnormal termination of the bootloader thread
|
|
|
|
chSysHalt("Bootloader DFU FAIL");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Run application
|
|
|
|
dfuJumpToApp(APPLICATION_ADDR);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|