rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Functions | Variables
bootloader_main.cpp File Reference

Functions

void CopInitHook (void)
 
void CopServiceHook (void)
 
PUBLIC_API_WEAK bool OpenBltIsBoardOk ()
 
static blt_bool checkIfRebootIntoOpenBltRequested (void)
 
static blt_bool checkIfResetLoop (void)
 
int main (void)
 
void efiSetPadMode (const char *msg, brain_pin_e brainPin, iomode_t mode)
 

Variables

blt_bool stayInBootloader
 
static blt_bool waitedLongerThanTimeout = BLT_FALSE
 
static blt_bool rebootLoop
 
static blt_bool wdReset
 
static const uint8_t maxWdRebootCounter = 10
 
static BlinkyThread blinky
 

Function Documentation

◆ checkIfRebootIntoOpenBltRequested()

static blt_bool checkIfRebootIntoOpenBltRequested ( void  )
static

Definition at line 133 of file bootloader_main.cpp.

133 {
134 uint8_t value = 0x00;
135 if (SharedParamsReadByIndex(0, &value) && (value == 0x01)) {
136 /* clear */
138 return BLT_TRUE;
139 }
140 return BLT_FALSE;
141}
bool SharedParamsWriteByIndex(uint32_t idx, uint8_t value)
Writes a data byte to the shared parameter buffer at the specified index.
bool SharedParamsReadByIndex(uint32_t idx, uint8_t *value)
Reads a data byte from the shared parameter buffer at the specified index.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkIfResetLoop()

static blt_bool checkIfResetLoop ( void  )
static

Definition at line 143 of file bootloader_main.cpp.

143 {
144 uint8_t wd_counter = 0;
148 // One of watchdogs
149 SharedParamsReadByIndex(1, &wd_counter);
150 wd_counter++;
151 SharedParamsWriteByIndex(1, wd_counter);
152 wdReset = BLT_TRUE;
153 } else if ((resetCause == Reset_Cause_NRST_Pin) ||
155 // power on or NRST reset
156 // cleat WD counter
157 SharedParamsWriteByIndex(1, wd_counter);
158 }
159
160 return (wd_counter > maxWdRebootCounter);
161}
Reset_Cause_t getMCUResetCause()
static const uint8_t maxWdRebootCounter
static blt_bool wdReset
Reset_Cause_t
Definition mpu_util.h:104
@ Reset_Cause_WWatchdog
Definition mpu_util.h:107
@ Reset_Cause_NRST_Pin
Definition mpu_util.h:109
@ Reset_Cause_POR
Definition mpu_util.h:110
@ Reset_Cause_IWatchdog
Definition mpu_util.h:106
static const volatile Reset_Cause_t resetCause

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CopInitHook()

void CopInitHook ( void  )

Definition at line 32 of file bootloader_main.cpp.

32 {
33 // Nothing to do...
34}

◆ CopServiceHook()

void CopServiceHook ( void  )

Definition at line 36 of file bootloader_main.cpp.

36 {
37 // We need to reset WDT here
38#if HAL_USE_WDG
39 wdgResetI(&WDGD1);
40#endif // HAL_USE_WDG
41}

◆ efiSetPadMode()

void efiSetPadMode ( const char msg,
brain_pin_e  brainPin,
iomode_t  mode 
)

Definition at line 207 of file bootloader_main.cpp.

207 {
208 ioportid_t port = getHwPort(msg, brainPin);
209 ioportmask_t pin = getHwPin(msg, brainPin);
210 /* paranoid */
211 if (!port) {
212 return;
213 }
214
215 palSetPadMode(port, pin, mode);
216}
ioportid_t getHwPort(const char *msg, brain_pin_e brainPin)
ioportmask_t getHwPin(const char *msg, brain_pin_e brainPin)
uint32_t ioportmask_t
Digital I/O port sized unsigned type.
Definition hal_pal_lld.h:78
GPIO_TypeDef * ioportid_t
Port Identifier.
brain_pin_e pin
Definition stm32_adc.cpp:15

Referenced by efiExtiEnablePin(), hellen154_hyundai_boardConfigOverrides(), GenericGearController::init(), BitbangI2c::init(), init5vpDiag(), initAuxDigital(), initDac(), initGps(), initIfValid(), OutputPin::initPin(), initSoftwareKnock(), initSpiCs(), initSpiModule(), initTriggerScope(), nucleo_f429_preHalInit(), nucleo_h743_preHalInit(), setEepromTestConfiguration(), startInputPinIfValid(), startKLine(), startSent(), ButtonDebounce::stopConfiguration(), and usb_serial_start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( void  )

Definition at line 163 of file bootloader_main.cpp.

163 {
164 halInit();
165 chSysInit();
166
167 baseMCUInit();
168
169 // Init openblt shared params
173
174 // start the blinky thread
175 blinky.start(NORMALPRIO + 10);
176
177 // Init openblt itself
178 BootInit();
179
180 blt_bool wasConnected = BLT_FALSE;
181
182 while (true) {
183 BootTask();
184
185 // since BOOT_BACKDOOR_HOOKS_ENABLE==TRUE, BackDoorCheck() is not working
186 // so we have to manually check if we need to jump to the main firmware
187 if (ComIsConnected() == BLT_TRUE) {
188 // remember we had connection attempt
189 wasConnected = BLT_TRUE;
190 continue;
191 }
192 if (stayInBootloader || wasConnected)
193 continue;
194#if (BOOT_BACKDOOR_ENTRY_TIMEOUT_MS > 0)
195 blt_bool isTimeout = (TIME_I2MS(chVTGetSystemTime()) >= BOOT_BACKDOOR_ENTRY_TIMEOUT_MS);
196#else
197 blt_bool isTimeout = BLT_TRUE;
198#endif // BOOT_BACKDOOR_ENTRY_TIMEOUT_MS
199 if (isTimeout == BLT_TRUE) {
200 waitedLongerThanTimeout = BLT_TRUE;
202 }
203 }
204}
void baseMCUInit()
static blt_bool checkIfRebootIntoOpenBltRequested(void)
static blt_bool checkIfResetLoop(void)
blt_bool stayInBootloader
static blt_bool rebootLoop
static blt_bool waitedLongerThanTimeout
static BlinkyThread blinky
void CpuStartUserProgram(void)
void SharedParamsInit(void)
Initializes the shared RAM parameters module.
unsigned char blt_bool
Definition types.h:46
Here is the call graph for this function:

◆ OpenBltIsBoardOk()

PUBLIC_API_WEAK bool OpenBltIsBoardOk ( )

Definition at line 44 of file bootloader_main.cpp.

45{
46 return true;
47}

Variable Documentation

◆ blinky

BlinkyThread blinky
static

Definition at line 131 of file bootloader_main.cpp.

Referenced by main().

◆ maxWdRebootCounter

const uint8_t maxWdRebootCounter = 10
static

Definition at line 23 of file bootloader_main.cpp.

Referenced by checkIfResetLoop().

◆ rebootLoop

blt_bool rebootLoop
static

Definition at line 20 of file bootloader_main.cpp.

Referenced by main().

◆ stayInBootloader

blt_bool stayInBootloader

Definition at line 17 of file bootloader_main.cpp.

Referenced by main(), and Rs232Init().

◆ waitedLongerThanTimeout

blt_bool waitedLongerThanTimeout = BLT_FALSE
static

Definition at line 19 of file bootloader_main.cpp.

Referenced by main().

◆ wdReset

blt_bool wdReset
static

Definition at line 21 of file bootloader_main.cpp.

Referenced by checkIfResetLoop().

Go to the source code of this file.