DFU command & refactoring

This commit is contained in:
rusEfi 2019-08-03 19:58:38 -04:00
parent dfc4f3451a
commit d6daeaa77f
16 changed files with 68 additions and 54 deletions

View File

@ -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 \

View File

@ -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 */

View File

@ -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"

View File

@ -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);

View File

@ -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

View File

@ -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 */

View File

@ -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

View File

@ -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 */

View File

@ -8,3 +8,5 @@ HW_LAYER_EMS_CPP += $(PROJECT_DIR)/hw_layer/ports/stm32/stm32f7/mpu_util.cpp \
RUSEFIASM = $(PROJECT_DIR)/hw_layer/ports/stm32/rusEfiStartup.S
HW_INC += $(PROJECT_DIR)/hw_layer/ports/stm32

View File

@ -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 */

View File

@ -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"

View File

@ -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
/**

View File

@ -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";

View File

@ -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);

View File

@ -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";

View File

@ -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";