Allow to connect to OpenBLT in normal boot mode https://github.com/rusefi/rusefi/issues/6246

This commit is contained in:
andreika-git 2024-03-18 20:48:58 +02:00 committed by rusefillc
parent bb7ca864b6
commit d5f2e98b1d
3 changed files with 32 additions and 9 deletions

View File

@ -9,6 +9,8 @@ extern "C" {
#include "shared_params.h"
}
static blt_bool waitedLongerThanTimeout = BLT_FALSE;
class BlinkyThread : public chibios_rt::BaseStaticThread<256> {
protected:
void main(void) override {
@ -55,6 +57,16 @@ protected:
static BlinkyThread blinky;
static blt_bool checkIfInOpenBltMode(void) {
uint8_t value = 0x00;
if (SharedParamsReadByIndex(0, &value) && (value == 0x01)) {
/* clear */
SharedParamsWriteByIndex(0, 0x00);
return BLT_TRUE;
}
return BLT_FALSE;
}
int main(void) {
halInit();
chSysInit();
@ -70,8 +82,22 @@ int main(void) {
// Init openblt itself
BootInit();
blt_bool stayInBootloader = checkIfInOpenBltMode();
blt_bool wasConnected = BLT_FALSE;
while (true) {
BootTask();
// since BOOT_BACKDOOR_HOOKS_ENABLE==TRUE, BackDoorCheck() is not working
// so we have to manually check if we need to jump to the main firmware
if (ComIsConnected() == BLT_TRUE)
wasConnected = BLT_TRUE;
blt_bool isTimeout = (TIME_I2MS(chVTGetSystemTime()) >= BOOT_BACKDOOR_ENTRY_TIMEOUT_MS);
if (isTimeout == BLT_TRUE) {
waitedLongerThanTimeout = BLT_TRUE;
if (wasConnected == BLT_FALSE && stayInBootloader == BLT_FALSE) {
CpuStartUserProgram();
}
}
}
}

View File

@ -189,6 +189,10 @@
#define BOOT_XCP_UPLOAD_ENABLE (0)
#ifndef BOOT_BACKDOOR_ENTRY_TIMEOUT_MS
#define BOOT_BACKDOOR_ENTRY_TIMEOUT_MS (500)
#endif
#endif /* BLT_CONF_H */
/*********************************** end of blt_conf.h *********************************/

View File

@ -30,7 +30,6 @@
* Include files
****************************************************************************************/
#include "boot.h" /* bootloader generic header */
#include "shared_params.h" /* Shared parameters header */
#include "led.h" /* LED driver header */
#ifdef STM32F429xx
#include "stm32f4xx.h" /* STM32 CPU and HAL header */
@ -62,16 +61,10 @@ void BackDoorInitHook(void)
** \return BLT_TRUE if the backdoor entry is requested, BLT_FALSE otherwise.
**
****************************************************************************************/
blt_bool BackDoorEntryHook(void)
{
uint8_t value = 0x00;
if (SharedParamsReadByIndex(0, &value) &&
(value == 0x01)) {
/* clear */
SharedParamsWriteByIndex(0, 0x00);
return BLT_TRUE;
}
return BLT_FALSE;
return BLT_TRUE;
} /*** end of BackDoorEntryHook ***/
#endif /* BOOT_BACKDOOR_HOOKS_ENABLE > 0 */