mirror of https://github.com/rusefi/wideband.git
OpenBLT reset functionality (#259)
* ts: support reset and reset to OpenBLT commands (cherry picked from commit 2f2fca401d7dc9a29e806013efec4d41570dd613) * f1_xxx: ini: reset commands (cherry picked from commit 628994ba0a70901edb9b59360646aa195b3307cf) * typo * f1_xxx: ini: update signature (cherry picked from commit 7aa57fe09c6c684855838e36c9b65d8ae3618a7a) --------- Co-authored-by: Andrey Gusakov <dron0gus@gmail.com>
This commit is contained in:
parent
7f0186705a
commit
8646d10067
|
@ -125,6 +125,23 @@ SensorType GetSensorType()
|
||||||
return cfg.sensorType;
|
return cfg.sensorType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rebootNow()
|
||||||
|
{
|
||||||
|
NVIC_SystemReset();
|
||||||
|
}
|
||||||
|
|
||||||
|
void rebootToOpenblt()
|
||||||
|
{
|
||||||
|
#if USE_OPENBLT
|
||||||
|
/* safe to call on already inited shares area */
|
||||||
|
SharedParamsInit();
|
||||||
|
/* Store flag to stay in OpenBLT */
|
||||||
|
SharedParamsWriteByIndex(0, 0x01);
|
||||||
|
|
||||||
|
rebootNow();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void ToggleESRDriver(SensorType sensor)
|
void ToggleESRDriver(SensorType sensor)
|
||||||
{
|
{
|
||||||
switch (sensor) {
|
switch (sensor) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// TS settings
|
// TS settings
|
||||||
#define TS_SIGNATURE "rusEFI 2023.03.23.wideband_dual"
|
#define TS_SIGNATURE "rusEFI 2023.05.10.wideband_dual"
|
||||||
|
|
||||||
// This board implements two channels
|
// This board implements two channels
|
||||||
#define AFR_CHANNELS 2
|
#define AFR_CHANNELS 2
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// TS settings
|
// TS settings
|
||||||
#define TS_SIGNATURE "rusEFI 2023.03.23.wideband_dual"
|
#define TS_SIGNATURE "rusEFI 2023.05.10.wideband_dual"
|
||||||
|
|
||||||
// This board implements two channels
|
// This board implements two channels
|
||||||
#define AFR_CHANNELS 2
|
#define AFR_CHANNELS 2
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// TS settings
|
// TS settings
|
||||||
#define TS_SIGNATURE "rusEFI 2023.03.23.wideband_f1"
|
#define TS_SIGNATURE "rusEFI 2023.05.10.wideband_f1"
|
||||||
|
|
||||||
// Fundamental board constants
|
// Fundamental board constants
|
||||||
#define VCC_VOLTS (3.3f)
|
#define VCC_VOLTS (3.3f)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// TS settings
|
// TS settings
|
||||||
#define TS_SIGNATURE "rusEFI 2023.03.23.wideband_f1"
|
#define TS_SIGNATURE "rusEFI 2023.05.10.wideband_f1"
|
||||||
|
|
||||||
// Fundamental board constants
|
// Fundamental board constants
|
||||||
#define VCC_VOLTS (3.3f)
|
#define VCC_VOLTS (3.3f)
|
||||||
|
|
|
@ -74,6 +74,9 @@ size_t GetConfigurationSize();
|
||||||
int SaveConfiguration();
|
int SaveConfiguration();
|
||||||
const char *getTsSignature();
|
const char *getTsSignature();
|
||||||
|
|
||||||
|
void rebootNow();
|
||||||
|
void rebootToOpenblt();
|
||||||
|
|
||||||
// LSU4.2, LSU4.9 or LSU_ADV
|
// LSU4.2, LSU4.9 or LSU_ADV
|
||||||
SensorType GetSensorType();
|
SensorType GetSensorType();
|
||||||
void SetupESRDriver(SensorType sensor);
|
void SetupESRDriver(SensorType sensor);
|
||||||
|
|
|
@ -204,13 +204,41 @@ static void handleBurnCommand(TsChannelBase* tsChannel, ts_response_format_e mod
|
||||||
sendResponseCode(mode, tsChannel, TS_RESPONSE_BURN_OK);
|
sendResponseCode(mode, tsChannel, TS_RESPONSE_BURN_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handleIoTestCommand(TsChannelBase* tsChannel, ts_response_format_e mode, uint16_t subsystem, uint16_t /* index */) {
|
||||||
|
/* index is not used yet */
|
||||||
|
|
||||||
|
switch (subsystem) {
|
||||||
|
#if 0
|
||||||
|
/* DFU */
|
||||||
|
case 0xba:
|
||||||
|
jump_to_bootloader();
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
case 0xbb:
|
||||||
|
rebootNow();
|
||||||
|
break;
|
||||||
|
|
||||||
|
#if USE_OPENBLT
|
||||||
|
case 0xbc:
|
||||||
|
/* Jump to OpenBLT if present */
|
||||||
|
rebootToOpenblt();
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
default:
|
||||||
|
tunerStudioError(tsChannel, "Unexpected IoTest command");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static bool isKnownCommand(char command) {
|
static bool isKnownCommand(char command) {
|
||||||
return command == TS_HELLO_COMMAND || command == TS_READ_COMMAND || command == TS_OUTPUT_COMMAND
|
return command == TS_HELLO_COMMAND || command == TS_READ_COMMAND || command == TS_OUTPUT_COMMAND
|
||||||
|| command == TS_BURN_COMMAND
|
|| command == TS_BURN_COMMAND
|
||||||
|| command == TS_CHUNK_WRITE_COMMAND
|
|| command == TS_CHUNK_WRITE_COMMAND
|
||||||
|| command == TS_GET_SCATTERED_GET_COMMAND
|
|| command == TS_GET_SCATTERED_GET_COMMAND
|
||||||
|| command == TS_CRC_CHECK_COMMAND
|
|| command == TS_CRC_CHECK_COMMAND
|
||||||
|| command == TS_GET_FIRMWARE_VERSION;
|
|| command == TS_GET_FIRMWARE_VERSION
|
||||||
|
|| command == TS_IO_TEST_COMMAND;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -503,13 +531,31 @@ int TunerStudio::handleCrcCommand(TsChannelBase* tsChannel, char *data, size_t i
|
||||||
if (handled)
|
if (handled)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
/* check if we can extract subsystem and index for IoTest command */
|
||||||
|
if (incomingPacketSize < sizeof(TunerStudioCmdPacketHeader)) {
|
||||||
|
sendErrorCode(tsChannel, TS_RESPONSE_UNDERRUN);
|
||||||
|
tunerStudioError(tsChannel, "ERROR: underrun");
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
const TunerStudioCmdPacketHeader* header = reinterpret_cast<TunerStudioCmdPacketHeader*>(data);
|
||||||
|
handled = true;
|
||||||
|
|
||||||
|
switch (command) {
|
||||||
|
case TS_IO_TEST_COMMAND:
|
||||||
|
handleIoTestCommand(tsChannel, TS_CRC, SWAP_UINT16(header->subsystem), SWAP_UINT16(header->index));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
/* noone of simple commands */
|
||||||
|
handled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* check if we can extract page, offset and count */
|
/* check if we can extract page, offset and count */
|
||||||
if (incomingPacketSize < sizeof(TunerStudioDataPacketHeader)) {
|
if (incomingPacketSize < sizeof(TunerStudioDataPacketHeader)) {
|
||||||
sendErrorCode(tsChannel, TS_RESPONSE_UNDERRUN);
|
sendErrorCode(tsChannel, TS_RESPONSE_UNDERRUN);
|
||||||
tunerStudioError(tsChannel, "ERROR: underrun");
|
tunerStudioError(tsChannel, "ERROR: underrun");
|
||||||
return false;
|
return false;
|
||||||
}
|
} else {
|
||||||
|
|
||||||
const TunerStudioDataPacketHeader* header = reinterpret_cast<TunerStudioDataPacketHeader*>(data);
|
const TunerStudioDataPacketHeader* header = reinterpret_cast<TunerStudioDataPacketHeader*>(data);
|
||||||
|
|
||||||
switch(command)
|
switch(command)
|
||||||
|
@ -541,6 +587,7 @@ int TunerStudio::handleCrcCommand(TsChannelBase* tsChannel, char *data, size_t i
|
||||||
tunerStudioError(tsChannel, "ERROR: ignoring unexpected command");
|
tunerStudioError(tsChannel, "ERROR: ignoring unexpected command");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,12 @@ uint8_t* getWorkingPageAddr();
|
||||||
|
|
||||||
void startTunerStudioConnectivity(void);
|
void startTunerStudioConnectivity(void);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8_t cmd;
|
||||||
|
uint16_t subsystem;
|
||||||
|
uint16_t index;
|
||||||
|
} __attribute__((packed)) TunerStudioCmdPacketHeader;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t cmd;
|
uint8_t cmd;
|
||||||
uint16_t page;
|
uint16_t page;
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#define TS_READ_COMMAND 'R'
|
#define TS_READ_COMMAND 'R'
|
||||||
#define TS_TEST_COMMAND 't'
|
#define TS_TEST_COMMAND 't'
|
||||||
#define TS_GET_SCATTERED_GET_COMMAND '9'
|
#define TS_GET_SCATTERED_GET_COMMAND '9'
|
||||||
|
#define TS_IO_TEST_COMMAND 'Z'
|
||||||
|
|
||||||
#define TS_RESPONSE_BURN_OK 4
|
#define TS_RESPONSE_BURN_OK 4
|
||||||
#define TS_RESPONSE_COMMAND_OK 7
|
#define TS_RESPONSE_COMMAND_OK 7
|
||||||
|
|
|
@ -12,12 +12,12 @@ enable2ndByteCanID = false
|
||||||
|
|
||||||
[MegaTune]
|
[MegaTune]
|
||||||
; https://rusefi.com/forum/viewtopic.php?p=36201#p36201
|
; https://rusefi.com/forum/viewtopic.php?p=36201#p36201
|
||||||
signature = "rusEFI 2023.03.23.wideband_dual"
|
signature = "rusEFI 2023.05.10.wideband_dual"
|
||||||
|
|
||||||
[TunerStudio]
|
[TunerStudio]
|
||||||
queryCommand = "S"
|
queryCommand = "S"
|
||||||
versionInfo = "V" ; firmware version for title bar.
|
versionInfo = "V" ; firmware version for title bar.
|
||||||
signature = "rusEFI 2023.03.23.wideband_dual" ; signature is expected to be 7 or more characters.
|
signature = "rusEFI 2023.05.10.wideband_dual" ; signature is expected to be 7 or more characters.
|
||||||
|
|
||||||
; TS will try to use legacy temp units in some cases, showing "deg F" on a CLT gauge that's actually deg C
|
; TS will try to use legacy temp units in some cases, showing "deg F" on a CLT gauge that's actually deg C
|
||||||
useLegacyFTempUnits = false
|
useLegacyFTempUnits = false
|
||||||
|
@ -297,6 +297,9 @@ menuDialog = main
|
||||||
subMenu = auxOut0, "AUX analog output 0"
|
subMenu = auxOut0, "AUX analog output 0"
|
||||||
subMenu = auxOut1, "AUX analog output 1"
|
subMenu = auxOut1, "AUX analog output 1"
|
||||||
|
|
||||||
|
menu = "&Controller"
|
||||||
|
subMenu = ecuTools, "ECU tools"
|
||||||
|
|
||||||
[ControllerCommands]
|
[ControllerCommands]
|
||||||
; commandName = command1, command2, commandn...
|
; commandName = command1, command2, commandn...
|
||||||
; command in standard ini format, a command name can be assigned to 1 to n commands that will be executed in order.
|
; command in standard ini format, a command name can be assigned to 1 to n commands that will be executed in order.
|
||||||
|
@ -311,6 +314,8 @@ menuDialog = main
|
||||||
cmd_reset_controller = "Z\x00\xbb\x00\x00"
|
cmd_reset_controller = "Z\x00\xbb\x00\x00"
|
||||||
; jump to DFU mode
|
; jump to DFU mode
|
||||||
cmd_dfu = "Z\x00\xba\x00\x00"
|
cmd_dfu = "Z\x00\xba\x00\x00"
|
||||||
|
; restart to OpenBlt
|
||||||
|
cmd_openblt = "Z\x00\xbc\x00\x00"
|
||||||
|
|
||||||
[UserDefined]
|
[UserDefined]
|
||||||
|
|
||||||
|
@ -328,4 +333,12 @@ dialog = auxOut1, "AUX analog out 1 Settings"
|
||||||
field = "Signal", Aux1InputSel
|
field = "Signal", Aux1InputSel
|
||||||
panel = auxOut1Curve
|
panel = auxOut1Curve
|
||||||
|
|
||||||
|
dialog = ecuReset, "Reset"
|
||||||
|
commandButton = "Reset ECU", cmd_reset_controller
|
||||||
|
commandButton = "Reset to DFU", cmd_dfu
|
||||||
|
commandButton = "Reset to OpenBLT", cmd_openblt
|
||||||
|
|
||||||
|
dialog = ecuTools, "ECU tools and Commands", xAxis
|
||||||
|
panel = ecuReset
|
||||||
|
|
||||||
[Tools]
|
[Tools]
|
||||||
|
|
|
@ -12,12 +12,12 @@ enable2ndByteCanID = false
|
||||||
|
|
||||||
[MegaTune]
|
[MegaTune]
|
||||||
; https://rusefi.com/forum/viewtopic.php?p=36201#p36201
|
; https://rusefi.com/forum/viewtopic.php?p=36201#p36201
|
||||||
signature = "rusEFI 2023.03.23.wideband_f1"
|
signature = "rusEFI 2023.05.10.wideband_f1"
|
||||||
|
|
||||||
[TunerStudio]
|
[TunerStudio]
|
||||||
queryCommand = "S"
|
queryCommand = "S"
|
||||||
versionInfo = "V" ; firmware version for title bar.
|
versionInfo = "V" ; firmware version for title bar.
|
||||||
signature = "rusEFI 2023.03.23.wideband_f1" ; signature is expected to be 7 or more characters.
|
signature = "rusEFI 2023.05.10.wideband_f1" ; signature is expected to be 7 or more characters.
|
||||||
|
|
||||||
; TS will try to use legacy temp units in some cases, showing "deg F" on a CLT gauge that's actually deg C
|
; TS will try to use legacy temp units in some cases, showing "deg F" on a CLT gauge that's actually deg C
|
||||||
useLegacyFTempUnits = false
|
useLegacyFTempUnits = false
|
||||||
|
@ -192,6 +192,8 @@ menuDialog = main
|
||||||
cmd_reset_controller = "Z\x00\xbb\x00\x00"
|
cmd_reset_controller = "Z\x00\xbb\x00\x00"
|
||||||
; jump to DFU mode
|
; jump to DFU mode
|
||||||
cmd_dfu = "Z\x00\xba\x00\x00"
|
cmd_dfu = "Z\x00\xba\x00\x00"
|
||||||
|
; restart to OpenBlt
|
||||||
|
cmd_openblt = "Z\x00\xbc\x00\x00"
|
||||||
|
|
||||||
[UserDefined]
|
[UserDefined]
|
||||||
|
|
||||||
|
@ -201,4 +203,12 @@ dialog = sensor_settings, "Sensor Settings"
|
||||||
dialog = can_settings, "CAN Settings"
|
dialog = can_settings, "CAN Settings"
|
||||||
field = "CAN message ID offset", CanIndexOffset
|
field = "CAN message ID offset", CanIndexOffset
|
||||||
|
|
||||||
|
dialog = ecuReset, "Reset"
|
||||||
|
commandButton = "Reset ECU", cmd_reset_controller
|
||||||
|
commandButton = "Reset to DFU", cmd_dfu
|
||||||
|
commandButton = "Reset to OpenBLT", cmd_openblt
|
||||||
|
|
||||||
|
dialog = ecuTools, "ECU tools and Commands", xAxis
|
||||||
|
panel = ecuReset
|
||||||
|
|
||||||
[Tools]
|
[Tools]
|
||||||
|
|
Loading…
Reference in New Issue