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

Detailed Description

Initialization code and main status reporting look.

Date
Dec 25, 2013
Author
Andrey Belomutskiy, (c) 2012-2021

Definition in file rusefi.cpp.

Functions

void rebootNow ()
 
void scheduleReboot ()
 
void onAssertionFailure ()
 
void initEfiWithConfig ()
 
__NO_RETURN void runMainLoop ()
 
void runRusEfi ()
 
void chDbgStackOverflowPanic (thread_t *otp)
 

Variables

bool main_loop_started = false
 
static char panicMessage [200]
 
static virtual_timer_t resetTimer
 
static jmp_buf jmpEnv
 

Function Documentation

◆ chDbgStackOverflowPanic()

void chDbgStackOverflowPanic ( thread_t *  otp)

this depends on chcore.h patch +void chDbgStackOverflowPanic(thread_t *otp);

  • chSysHalt("stack overflow"); \
  • chDbgStackOverflowPanic(otp); \

Definition at line 314 of file rusefi.cpp.

314 {
315 (void)otp;
316 strcpy(panicMessage, "stack overflow: ");
317#if defined(CH_USE_REGISTRY)
318 int p_name_len = strlen(otp->p_name);
319 if (p_name_len < sizeof(panicMessage) - 2)
320 strcat(panicMessage, otp->p_name);
321#endif
322 chDbgPanic3(panicMessage, __FILE__, __LINE__);
323}
void chDbgPanic3(const char *, const char *, int)
static char panicMessage[200]
Definition rusefi.cpp:145
Here is the call graph for this function:

◆ initEfiWithConfig()

void initEfiWithConfig ( )

Now let's initialize actual engine control logic todo: should we initialize some? most? controllers before hardware?

Definition at line 253 of file rusefi.cpp.

253 {
254 // If some config operation caused an OS assertion failure, return immediately
255 // This sets the "unwind point" that we can jump back to later with longjmp if we have
256 // an assertion failure. If that happens, setjmp() will return non-zero, so we will
257 // return immediately from this function instead of trying to init hardware again (which failed last time)
258 if (setjmp(jmpEnv)) {
259 return;
260 }
261
263
264#if EFI_WIFI
266#endif
267
268 // Config could be completely bogus - don't start anything else!
270 /**
271 * Now let's initialize actual engine control logic
272 * todo: should we initialize some? most? controllers before hardware?
273 */
275
276
277 // This has to happen after RegisteredOutputPins are init'd: otherwise no change will be detected, and no init will happen
279
280 #if EFI_PERF_METRICS
282 #endif
283
284 }
285}
void startWifiConsole()
void rememberCurrentConfiguration()
bool validateConfigOnStartUpOrBurn()
void commonEarlyInit()
void initRealHardwareEngineController()
int setjmp(jmp_buf)
void initTimePerfActions()
static jmp_buf jmpEnv
Definition rusefi.cpp:164

Referenced by runRusEfi().

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

◆ onAssertionFailure()

void onAssertionFailure ( )

Definition at line 165 of file rusefi.cpp.

165 {
166 // There's been an assertion failure: instead of hanging, jump back to where we check
167 // if (setjmp(jmpEnv)) (see below for more complete explanation)
168 longjmp(jmpEnv, 1);
169}
void longjmp(jmp_buf, int)

Referenced by chDbgPanic3().

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

◆ rebootNow()

void rebootNow ( )

Definition at line 150 of file rusefi.cpp.

150 {
151 NVIC_SystemReset();
152}

Referenced by executeTSCommand(), and scheduleReboot().

Here is the caller graph for this function:

◆ runMainLoop()

void runMainLoop ( )

This loop is the closes we have to 'main loop' - but here we only publish the status. The main logic of engine control is around main_trigger_callback

Definition at line 287 of file rusefi.cpp.

287 {
288 efiPrintf("Running main loop");
289 main_loop_started = true;
290 /**
291 * This loop is the closes we have to 'main loop' - but here we only publish the status. The main logic of engine
292 * control is around main_trigger_callback
293 */
294 while (true) {
295#if EFI_CLI_SUPPORT && !EFI_UART_ECHO_TEST_MODE
296 // sensor state + all pending messages for our own rusEfi console
297 // todo: is this mostly dead code?
299#endif /* EFI_CLI_SUPPORT */
300
301 chThdSleepMilliseconds(200);
302 }
303}
bool main_loop_started
Definition rusefi.cpp:143
void updateDevConsoleState()
Sends all pending data to rusEfi console.

Referenced by runRusEfi().

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

◆ runRusEfi()

void runRusEfi ( )

we need to initialize table objects before default configuration can set values

Next we should initialize serial port console, it's important to know what's going on

Definition at line 174 of file rusefi.cpp.

174 {
175 engine->setConfig();
176
177#if EFI_TEXT_LOGGING
178 // Initialize logging system early - we can't log until this is called
180#endif
181
182#if HAL_USE_WDG
183 setWatchdogResetPeriod(WATCHDOG_RESET_MS);
185#endif // HAL_USE_WDG
186
187#if EFI_PROD_CODE
190#endif
191
192#if defined(STM32F4) || defined(STM32F7)
193 addConsoleAction("stm32_standby", stm32_standby);
194#endif
195
196 addConsoleAction(CMD_REBOOT, scheduleReboot);
197#if EFI_DFU_JUMP
198 addConsoleAction(CMD_REBOOT_DFU, jump_to_bootloader);
199#endif /* EFI_DFU_JUMP */
200
201#if EFI_USE_OPENBLT
202 addConsoleAction(CMD_REBOOT_OPENBLT, jump_to_openblt);
203#endif
204
205 /**
206 * we need to initialize table objects before default configuration can set values
207 */
209
210 // Perform hardware initialization that doesn't need configuration
212
213 // at the moment that's always hellen board ID
215
216#if EFI_ETHERNET
218#endif
219
220#if EFI_USB_SERIAL
222#endif
223
224#if HAL_USE_USB_MSD
225 initUsbMsd();
226#endif
227
228 /**
229 * Next we should initialize serial port console, it's important to know what's going on
230 */
232
233 // Read configuration from flash memory
235
236#if EFI_TUNER_STUDIO
238#endif /* EFI_TUNER_STUDIO */
239
240 // Start hardware serial ports (including bluetooth, if present)
241#if EFI_TUNER_STUDIO
243#endif // EFI_TUNER_STUDIO
244
246
247 // periodic events need to be initialized after fuel&spark pins to avoid a warning
249
250 runMainLoop();
251}
void stm32_standby()
Definition mpu_util.cpp:18
void startWatchdog(int)
void setWatchdogResetPeriod(int)
void jump_to_openblt()
void jump_to_bootloader()
void setConfig()
Definition engine.cpp:388
void addConsoleAction(const char *token, Void callback)
Register console action without parameters.
void detectBoardType()
void initializeConsole()
void startEthernetConsole()
void startUsbConsole()
static Engine *const engine
Definition engine.h:389
void loadConfiguration()
void initPeriodicEvents()
void initDataStructures()
void errorHandlerInit()
void errorHandlerShowBootReasonAndErrors()
void initHardwareNoConfig()
Definition hardware.cpp:441
void startLoggingProcessor()
void initUsbMsd()
void scheduleReboot()
Definition rusefi.cpp:158
void initEfiWithConfig()
Definition rusefi.cpp:253
__NO_RETURN void runMainLoop()
Definition rusefi.cpp:287
void startTunerStudioConnectivity()
void startSerialChannels()

Referenced by main().

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

◆ scheduleReboot()

void scheduleReboot ( )

Some configuration changes require full firmware reset. Once day we will write graceful shutdown, but that would be one day.

Definition at line 158 of file rusefi.cpp.

158 {
159 efiPrintf("Rebooting in 3 seconds...");
160 chibios_rt::CriticalSectionLocker csl;
161 chVTSetI(&resetTimer, TIME_MS2I(3000), (vtfunc_t) rebootNow, NULL);
162}
static virtual_timer_t resetTimer
Definition rusefi.cpp:147
void rebootNow()
Definition rusefi.cpp:150

Referenced by processCanQcBenchTest(), runRusEfi(), and unlockEcu().

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

Variable Documentation

◆ jmpEnv

jmp_buf jmpEnv
static

Definition at line 164 of file rusefi.cpp.

Referenced by initEfiWithConfig(), and onAssertionFailure().

◆ main_loop_started

bool main_loop_started = false

Definition at line 143 of file rusefi.cpp.

Referenced by runMainLoop(), tooSoonToHandleSignal(), and writeSdLogLine().

◆ panicMessage

char panicMessage[200]
static

Definition at line 145 of file rusefi.cpp.

Referenced by chDbgStackOverflowPanic().

◆ resetTimer

virtual_timer_t resetTimer
static

Definition at line 147 of file rusefi.cpp.

Referenced by scheduleReboot().

Go to the source code of this file.