From d7c46fbb21171b9695fe327803c57b20dbb0bcb6 Mon Sep 17 00:00:00 2001 From: andreika-git Date: Sun, 24 Dec 2017 20:45:03 +0200 Subject: [PATCH] Bootloader set default pin states (#524) * Set default pin states needed by Bootloader * Small Bootloader fix --- firmware/bootloader/src/dfu.h | 4 ++-- firmware/bootloader/src/main.cpp | 2 ++ firmware/config/boards/ST_STM32F4/board.c | 7 +++++++ firmware/config/boards/ST_STM32F4/board.h | 1 + firmware/controllers/algo/engine_configuration.cpp | 5 +++++ firmware/controllers/algo/engine_configuration.h | 1 + 6 files changed, 18 insertions(+), 2 deletions(-) diff --git a/firmware/bootloader/src/dfu.h b/firmware/bootloader/src/dfu.h index f47347e535..fcaf5e9c44 100644 --- a/firmware/bootloader/src/dfu.h +++ b/firmware/bootloader/src/dfu.h @@ -6,7 +6,7 @@ // This is where the bootloader starts #define BOOTLOADER_ADDR 0x08000000 // Bootloader code max. size, in bytes -#define BOOTLOADER_SIZE 0x4000 +#define BOOTLOADER_SIZE 0x8000 // Number of sectors for the bootloader #define BOOTLOADER_NUM_SECTORS (BOOTLOADER_SIZE/0x4000) @@ -32,7 +32,7 @@ #define DFU_ACK_BYTE 0x79 // Acknowledge byte ID #define DFU_NACK_BYTE 0x1F // Not-Acknowledge byte ID -#define DFU_SR5_TIMEOUT_FIRST MS2ST(100) +#define DFU_SR5_TIMEOUT_FIRST MS2ST(200) #define DFU_SR5_TIMEOUT_NORMAL MS2ST(1000) #define MCU_REVISION_MASK 0xfff // MCU Revision ID is needed by DFU protocol diff --git a/firmware/bootloader/src/main.cpp b/firmware/bootloader/src/main.cpp index e6b429395e..f55926be6e 100644 --- a/firmware/bootloader/src/main.cpp +++ b/firmware/bootloader/src/main.cpp @@ -38,6 +38,8 @@ int main(void) { // run ChibiOS halInit(); chSysInit(); + // set base pin configuration based on the board + setDefaultBasePins(PASS_ENGINE_PARAMETER_SIGNATURE); // set UART pads configuration based on the board setDefaultSerialParameters(PASS_ENGINE_PARAMETER_SIGNATURE); // set SD card configuration also diff --git a/firmware/config/boards/ST_STM32F4/board.c b/firmware/config/boards/ST_STM32F4/board.c index 23b17bd820..d55ce780b3 100644 --- a/firmware/config/boards/ST_STM32F4/board.c +++ b/firmware/config/boards/ST_STM32F4/board.c @@ -135,6 +135,13 @@ void boardInit(void) { void setBoardConfigurationOverrides(void) { } +/** + * @brief Board-specific pin configuration code overrides. Needed by bootloader code. + * @todo Add your board-specific code, if any. + */ +void setPinConfigurationOverrides(void) { +} + /** * @brief Board-specific Serial configuration code overrides. Needed by bootloader code. * @todo Add your board-specific code, if any. diff --git a/firmware/config/boards/ST_STM32F4/board.h b/firmware/config/boards/ST_STM32F4/board.h index 88be52846a..183856e2b8 100644 --- a/firmware/config/boards/ST_STM32F4/board.h +++ b/firmware/config/boards/ST_STM32F4/board.h @@ -1345,6 +1345,7 @@ extern "C" { #endif void boardInit(void); void setBoardConfigurationOverrides(void); + void setPinConfigurationOverrides(void); void setSerialConfigurationOverrides(void); void setSdCardConfigurationOverrides(void); #ifdef __cplusplus diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index dc2542f48d..609df94e5a 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -370,6 +370,11 @@ void setDefaultBasePins(DECLARE_ENGINE_PARAMETER_SIGNATURE) { engineConfiguration->fatalErrorPin = GPIOD_14; engineConfiguration->warninigPin = GPIOD_13; engineConfiguration->configResetPin = GPIOB_1; +#if EFI_PROD_CODE || defined(__DOXYGEN__) + // call overrided board-specific serial configuration setup, if needed (for custom boards only) + // needed also by bootloader code + setPinConfigurationOverrides(); +#endif } // needed also by bootloader code diff --git a/firmware/controllers/algo/engine_configuration.h b/firmware/controllers/algo/engine_configuration.h index 49188144ba..260bc52a6f 100644 --- a/firmware/controllers/algo/engine_configuration.h +++ b/firmware/controllers/algo/engine_configuration.h @@ -59,6 +59,7 @@ void setConstantDwell(floatms_t dwellMs DECLARE_ENGINE_PARAMETER_SUFFIX); void printFloatArray(const char *prefix, float array[], int size); // needed by bootloader +void setDefaultBasePins(DECLARE_ENGINE_PARAMETER_SIGNATURE); void setDefaultSerialParameters(DECLARE_ENGINE_PARAMETER_SIGNATURE); void setDefaultSdCardParameters(DECLARE_ENGINE_PARAMETER_SIGNATURE);