diff --git a/firmware/Makefile b/firmware/Makefile index 6d32c60716..bd33614086 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -294,7 +294,7 @@ INCDIR = $(CHIBIOS)/os/license \ hw_layer/lcd \ $(HW_SENSORS_INC) \ hw_layer/mass_storage \ - hw_layer/$(CPU_HWLAYER) \ + $(HW_INC) \ $(HW_LAYER_DRIVERS_INC) \ $(UTIL_INC) \ development \ diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index cb3d19b9d1..56daef4539 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -812,6 +812,6 @@ int getRusEfiVersion(void) { if (initBootloader() != 0) return 123; #endif /* EFI_BOOTLOADER_INCLUDE_CODE */ - return 20190802; + return 20190803; } #endif /* EFI_UNIT_TEST */ diff --git a/firmware/controllers/generated/rusefi_generated.h b/firmware/controllers/generated/rusefi_generated.h index b623e743c1..d239e74c28 100644 --- a/firmware/controllers/generated/rusefi_generated.h +++ b/firmware/controllers/generated/rusefi_generated.h @@ -364,6 +364,8 @@ #define clutchUpPinMode_offset_hex 3cb #define CMD_DISABLE "disable" #define CMD_ENABLE "enable" +#define CMD_REBOOT "reboot" +#define CMD_REBOOT_DFU "reboot_dfu" #define CMD_TRIGGER_HW_INPUT "trigger_hw_input" #define CMD_TRIGGERINFO "triggerinfo" #define CMD_WRITECONFIG "writeconfig" diff --git a/firmware/controllers/injector_central.cpp b/firmware/controllers/injector_central.cpp index 07949401d8..6d567fbf05 100644 --- a/firmware/controllers/injector_central.cpp +++ b/firmware/controllers/injector_central.cpp @@ -39,6 +39,7 @@ #include "tps.h" #if EFI_PROD_CODE #include "rusefi.h" +#include "mpu_util.h" #endif /* EFI_PROD_CODE */ EXTERN_ENGINE @@ -271,8 +272,6 @@ static void handleCommandX14(uint16_t index) { } -void jump_to_bootloader(); - // todo: this is probably a wrong place for this method now void executeTSCommand(uint16_t subsystem, uint16_t index) { scheduleMsg(logger, "IO test subsystem=%d index=%d", subsystem, index); diff --git a/firmware/hw_layer/hw_layer.mk b/firmware/hw_layer/hw_layer.mk index 20150308ea..e960caf304 100644 --- a/firmware/hw_layer/hw_layer.mk +++ b/firmware/hw_layer/hw_layer.mk @@ -1,6 +1,8 @@ HW_LAYER_EGT = $(PROJECT_DIR)/hw_layer/serial_over_usb/usbcfg.c \ $(PROJECT_DIR)/hw_layer/serial_over_usb/usbconsole.c +HW_INC = hw_layer/$(CPU_HWLAYER) + HW_LAYER_EGT_CPP = $(PROJECT_DIR)/hw_layer/can_hw.cpp \ $(PROJECT_DIR)/hw_layer/max31855.cpp diff --git a/firmware/hw_layer/ports/stm32/stm32_common_mpu_util.h b/firmware/hw_layer/ports/stm32/stm32_common_mpu_util.h new file mode 100644 index 0000000000..159bc53f31 --- /dev/null +++ b/firmware/hw_layer/ports/stm32/stm32_common_mpu_util.h @@ -0,0 +1,33 @@ +/** + * @file stm32_common_mpu_util.h + * @brief Low level common STM32 header + * + * @date Aug 3, 2019 + * @author Andrey Belomutskiy, (c) 2012-2019 + */ + +// burnout or 'Burn Out' +typedef enum { + BOR_Level_None = OB_BOR_OFF, // 0x0C=12 Supply voltage ranges from 1.62 to 2.10 V + BOR_Level_1 = OB_BOR_LEVEL1, // 0x08 Supply voltage ranges from 2.10 to 2.40 V + BOR_Level_2 = OB_BOR_LEVEL2, // 0x04 Supply voltage ranges from 2.40 to 2.70 V + BOR_Level_3 = OB_BOR_LEVEL3 // 0x00 Supply voltage ranges from 2.70 to 3.60 V +} BOR_Level_t; + +typedef enum { + BOR_Result_Ok = 0x00, + BOR_Result_Error +} BOR_Result_t; + +BOR_Level_t BOR_Get(void); +BOR_Result_t BOR_Set(BOR_Level_t BORValue); + +void baseHardwareInit(void); +void turnOnSpi(spi_device_e device); +void jump_to_bootloader(); + +#if HAL_USE_CAN +bool isValidCanTxPin(brain_pin_e pin); +bool isValidCanRxPin(brain_pin_e pin); +CANDriver * detectCanDevice(brain_pin_e pinRx, brain_pin_e pinTx); +#endif /* HAL_USE_CAN */ diff --git a/firmware/hw_layer/ports/stm32/stm32f4/hw_ports.mk b/firmware/hw_layer/ports/stm32/stm32f4/hw_ports.mk index bde8506727..554bf86c1c 100644 --- a/firmware/hw_layer/ports/stm32/stm32f4/hw_ports.mk +++ b/firmware/hw_layer/ports/stm32/stm32f4/hw_ports.mk @@ -7,3 +7,5 @@ HW_LAYER_EMS_CPP += $(PROJECT_DIR)/hw_layer/ports/stm32/stm32f4/mpu_util.cpp \ $(PROJECT_DIR)/hw_layer/ports/stm32/stm32_common.cpp RUSEFIASM = $(PROJECT_DIR)/hw_layer/ports/stm32/rusEfiStartup.S + +HW_INC += $(PROJECT_DIR)/hw_layer/ports/stm32 diff --git a/firmware/hw_layer/ports/stm32/stm32f4/mpu_util.h b/firmware/hw_layer/ports/stm32/stm32f4/mpu_util.h index d0d14de419..dab40184d0 100644 --- a/firmware/hw_layer/ports/stm32/stm32f4/mpu_util.h +++ b/firmware/hw_layer/ports/stm32/stm32f4/mpu_util.h @@ -8,27 +8,12 @@ #define MPU_UTIL_H_ #include "stm32f4xx_hal_flash_ex.h" +#include "stm32_common_mpu_util.h" // we are lucky - all CAN pins use the same AF #define EFI_CAN_RX_AF 9 #define EFI_CAN_TX_AF 9 -// burnout or 'Burn Out' -typedef enum { - BOR_Level_None = OB_BOR_OFF, // 0x0C=12 Supply voltage ranges from 1.62 to 2.10 V - BOR_Level_1 = OB_BOR_LEVEL1, // 0x08 Supply voltage ranges from 2.10 to 2.40 V - BOR_Level_2 = OB_BOR_LEVEL2, // 0x04 Supply voltage ranges from 2.40 to 2.70 V - BOR_Level_3 = OB_BOR_LEVEL3 // 0x00 Supply voltage ranges from 2.70 to 3.60 V -} BOR_Level_t; - -typedef enum { - BOR_Result_Ok = 0x00, - BOR_Result_Error -} BOR_Result_t; - -BOR_Level_t BOR_Get(void); -BOR_Result_t BOR_Set(BOR_Level_t BORValue); - #ifndef GPIO_AF_TIM1 #define GPIO_AF_TIM1 1 #endif @@ -72,9 +57,6 @@ BOR_Result_t BOR_Set(BOR_Level_t BORValue); #define SPI_CR1_24BIT_MODE 0 #define SPI_CR2_24BIT_MODE 0 -void baseHardwareInit(void); -void turnOnSpi(spi_device_e device); - #ifdef __cplusplus extern "C" { @@ -105,8 +87,3 @@ void initSpiModule(SPIDriver *driver, brain_pin_e sck, brain_pin_e miso, void initSpiCs(SPIConfig *spiConfig, brain_pin_e csPin); #endif /* HAL_USE_SPI */ -bool isValidCanTxPin(brain_pin_e pin); -bool isValidCanRxPin(brain_pin_e pin); -#if HAL_USE_CAN -CANDriver * detectCanDevice(brain_pin_e pinRx, brain_pin_e pinTx); -#endif /* HAL_USE_CAN */ diff --git a/firmware/hw_layer/ports/stm32/stm32f7/hw_ports.mk b/firmware/hw_layer/ports/stm32/stm32f7/hw_ports.mk index 5b27b96faa..05c5bb2ab5 100644 --- a/firmware/hw_layer/ports/stm32/stm32f7/hw_ports.mk +++ b/firmware/hw_layer/ports/stm32/stm32f7/hw_ports.mk @@ -7,4 +7,6 @@ HW_LAYER_EMS_CPP += $(PROJECT_DIR)/hw_layer/ports/stm32/stm32f7/mpu_util.cpp \ $(PROJECT_DIR)/hw_layer/ports/stm32/stm32_common.cpp RUSEFIASM = $(PROJECT_DIR)/hw_layer/ports/stm32/rusEfiStartup.S + +HW_INC += $(PROJECT_DIR)/hw_layer/ports/stm32 \ No newline at end of file diff --git a/firmware/hw_layer/ports/stm32/stm32f7/mpu_util.h b/firmware/hw_layer/ports/stm32/stm32f7/mpu_util.h index 835d3b23e2..77d003b3e9 100644 --- a/firmware/hw_layer/ports/stm32/stm32f7/mpu_util.h +++ b/firmware/hw_layer/ports/stm32/stm32f7/mpu_util.h @@ -8,26 +8,12 @@ #define MPU_UTIL_H_ #include "stm32f7xx_hal_flash_ex.h" +#include "stm32_common_mpu_util.h" // we are lucky - all CAN pins use the same AF #define EFI_CAN_RX_AF 9 #define EFI_CAN_TX_AF 9 -// burnout or 'Burn Out' -typedef enum { - BOR_Level_None = OB_BOR_OFF, // 0x0C=12 Supply voltage ranges from 1.62 to 2.10 V - BOR_Level_1 = OB_BOR_LEVEL1, // 0x08 Supply voltage ranges from 2.10 to 2.40 V - BOR_Level_2 = OB_BOR_LEVEL2, // 0x04 Supply voltage ranges from 2.40 to 2.70 V - BOR_Level_3 = OB_BOR_LEVEL3 // 0x00 Supply voltage ranges from 2.70 to 3.60 V -} BOR_Level_t; - -typedef enum { - BOR_Result_Ok = 0x00, - BOR_Result_Error -} BOR_Result_t; - -BOR_Level_t BOR_Get(void); -BOR_Result_t BOR_Set(BOR_Level_t BORValue); #ifndef GPIO_AF_TIM1 #define GPIO_AF_TIM1 1 @@ -73,8 +59,6 @@ BOR_Result_t BOR_Set(BOR_Level_t BORValue); #define SPI_CR2_24BIT_MODE SPI_CR2_DS_2 | SPI_CR2_DS_1 | SPI_CR2_DS_0 -void baseHardwareInit(void); -void turnOnSpi(spi_device_e device); #ifdef __cplusplus extern "C" @@ -106,8 +90,3 @@ void initSpiModule(SPIDriver *driver, brain_pin_e sck, brain_pin_e miso, void initSpiCs(SPIConfig *spiConfig, brain_pin_e csPin); #endif /* HAL_USE_SPI */ -#if HAL_USE_CAN -bool isValidCanTxPin(brain_pin_e pin); -bool isValidCanRxPin(brain_pin_e pin); -CANDriver * detectCanDevice(brain_pin_e pinRx, brain_pin_e pinTx); -#endif /* HAL_USE_CAN */ diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 192a98ab6e..9553f35562 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -1224,6 +1224,8 @@ end_struct #define CMD_TRIGGERINFO "triggerinfo" #define CMD_WRITECONFIG "writeconfig" +#define CMD_REBOOT "reboot" +#define CMD_REBOOT_DFU "reboot_dfu" #define CMD_ENABLE "enable" #define CMD_DISABLE "disable" #define CMD_TRIGGER_HW_INPUT "trigger_hw_input" diff --git a/firmware/rusefi.cpp b/firmware/rusefi.cpp index 9f96a152b2..7b70b416a3 100644 --- a/firmware/rusefi.cpp +++ b/firmware/rusefi.cpp @@ -122,6 +122,7 @@ #include "algo.h" #include "custom_engine.h" #include "engine_math.h" +#include "mpu_util.h" #if EFI_HD44780_LCD #include "lcd_HD44780.h" @@ -166,7 +167,8 @@ void runRusEfi(void) { engine->setConfig(config); initIntermediateLoggingBuffer(); initErrorHandling(); - addConsoleAction("reboot", scheduleReboot); + addConsoleAction(CMD_REBOOT, scheduleReboot); + addConsoleAction(CMD_REBOOT_DFU, jump_to_bootloader); #if EFI_SHAFT_POSITION_INPUT /** diff --git a/java_console/models/src/com/rusefi/config/generated/Fields.java b/java_console/models/src/com/rusefi/config/generated/Fields.java index 7ab4e5d747..b6befe6660 100644 --- a/java_console/models/src/com/rusefi/config/generated/Fields.java +++ b/java_console/models/src/com/rusefi/config/generated/Fields.java @@ -1,6 +1,6 @@ package com.rusefi.config.generated; -// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Fri Aug 02 01:26:57 EDT 2019 +// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Sat Aug 03 18:52:34 EDT 2019 // by class com.rusefi.output.JavaFieldsConsumer import com.rusefi.config.*; @@ -235,6 +235,8 @@ public class Fields { public static final int clutchUpPinMode_offset = 971; public static final String CMD_DISABLE = "disable"; public static final String CMD_ENABLE = "enable"; + public static final String CMD_REBOOT = "reboot"; + public static final String CMD_REBOOT_DFU = "reboot_dfu"; public static final String CMD_TRIGGER_HW_INPUT = "trigger_hw_input"; public static final String CMD_TRIGGERINFO = "triggerinfo"; public static final String CMD_WRITECONFIG = "writeconfig"; diff --git a/java_console/ui/src/com/rusefi/BenchTestPane.java b/java_console/ui/src/com/rusefi/BenchTestPane.java index e11e918d51..9cbb39463b 100644 --- a/java_console/ui/src/com/rusefi/BenchTestPane.java +++ b/java_console/ui/src/com/rusefi/BenchTestPane.java @@ -1,5 +1,6 @@ package com.rusefi; +import com.rusefi.config.generated.Fields; import com.rusefi.ui.MessagesView; import org.jetbrains.annotations.NotNull; @@ -24,7 +25,13 @@ public class BenchTestPane { content.add(new CommandControl("Reboot", "", "Reboot") { @Override protected String getCommand() { - return "reboot"; + return Fields.CMD_REBOOT; + } + }.getContent()); + content.add(new CommandControl("Reboot to DFU", "", "Reboot to DFU") { + @Override + protected String getCommand() { + return Fields.CMD_REBOOT_DFU; } }.getContent()); content.add(new MessagesView().messagesScroll); diff --git a/java_console/ui/src/com/rusefi/Launcher.java b/java_console/ui/src/com/rusefi/Launcher.java index b5cec67180..d4d7944514 100644 --- a/java_console/ui/src/com/rusefi/Launcher.java +++ b/java_console/ui/src/com/rusefi/Launcher.java @@ -47,7 +47,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig; * @see EngineSnifferPanel */ public class Launcher { - public static final int CONSOLE_VERSION = 20190721; + public static final int CONSOLE_VERSION = 20190803; public static final String INPUT_FILES_PATH = ".."; private static final String TAB_INDEX = "main_tab"; protected static final String PORT_KEY = "port"; diff --git a/java_console/ui/src/com/rusefi/maintenance/FirmwareFlasher.java b/java_console/ui/src/com/rusefi/maintenance/FirmwareFlasher.java index e993a0d6d4..8c786b9f6f 100644 --- a/java_console/ui/src/com/rusefi/maintenance/FirmwareFlasher.java +++ b/java_console/ui/src/com/rusefi/maintenance/FirmwareFlasher.java @@ -18,7 +18,12 @@ public class FirmwareFlasher extends ProcessStatusWindow { // Even on Windows openOCD insists on "/" for path separator public static final String IMAGE_FILE = INPUT_FILES_PATH + "/" + "rusefi.bin"; public static final String IMAGE_NO_ASSERTS_FILE = INPUT_FILES_PATH + "/" + "rusefi_no_asserts.bin"; + /** + * SWD ST-LINK/V2 mode + */ static final String OPENOCD_EXE = "openocd/openocd.exe"; + // TODO: integration with DFU command line tool + static final String DFU_EXE = "DfuSeCommand.exe -c -d --v --fn rusefi.dfu"; static final String BINARY_LOCATION = "."; private static final String SUCCESS_MESSAGE_TAG = "shutdown command invoked"; private static final String FAILED_MESSAGE_TAG = "failed";