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 315 of file rusefi.cpp.

315 {
316 (void)otp;
317 strcpy(panicMessage, "stack overflow: ");
318#if defined(CH_USE_REGISTRY)
319 int p_name_len = strlen(otp->p_name);
320 if (p_name_len < sizeof(panicMessage) - 2)
321 strcat(panicMessage, otp->p_name);
322#endif
323 chDbgPanic3(panicMessage, __FILE__, __LINE__);
324}
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 254 of file rusefi.cpp.

254 {
255 // If some config operation caused an OS assertion failure, return immediately
256 // This sets the "unwind point" that we can jump back to later with longjmp if we have
257 // an assertion failure. If that happens, setjmp() will return non-zero, so we will
258 // return immediately from this function instead of trying to init hardware again (which failed last time)
259 if (setjmp(jmpEnv)) {
260 return;
261 }
262
264
265#if EFI_WIFI
267#endif
268
269 // Config could be completely bogus - don't start anything else!
271 /**
272 * Now let's initialize actual engine control logic
273 * todo: should we initialize some? most? controllers before hardware?
274 */
276
277
278 // This has to happen after RegisteredOutputPins are init'd: otherwise no change will be detected, and no init will happen
280
281 #if EFI_PERF_METRICS
283 #endif
284
285 }
286}
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 288 of file rusefi.cpp.

288 {
289 efiPrintf("Running main loop");
290 main_loop_started = true;
291 /**
292 * This loop is the closes we have to 'main loop' - but here we only publish the status. The main logic of engine
293 * control is around main_trigger_callback
294 */
295 while (true) {
296#if EFI_CLI_SUPPORT && !EFI_UART_ECHO_TEST_MODE
297 // sensor state + all pending messages for our own rusEfi console
298 // todo: is this mostly dead code?
300#endif /* EFI_CLI_SUPPORT */
301
302 chThdSleepMilliseconds(200);
303 }
304}
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 engine->engineModules.apply_all([](auto & m) {
217 m.initNoConfiguration();
218 });
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 initMainLoop();
250
251 runMainLoop();
252}
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:397
type_list< Mockable< InjectorModelPrimary >, Mockable< InjectorModelSecondary >,#if EFI_IDLE_CONTROL Mockable< IdleController >,#endif TriggerScheduler,#if EFI_HPFP &&EFI_ENGINE_CONTROL Mockable< HpfpController >,#endif #if EFI_ENGINE_CONTROL Mockable< ThrottleModel >,#endif #if EFI_ALTERNATOR_CONTROL AlternatorController,#endif MainRelayController, Mockable< IgnitionController >, Mockable< AcController >, PrimeController, DfcoController,#if EFI_HD_ACR HarleyAcr,#endif Mockable< WallFuelController >, KnockController, SensorChecker,#if EFI_ENGINE_CONTROL Mockable< LimpManager >,#endif #if EFI_VVT_PID VvtController1, VvtController2, VvtController3, VvtController4,#endif #if EFI_BOOST_CONTROL BoostController,#endif TpsAccelEnrichment,#if EFI_LAUNCH_CONTROL NitrousController,#endif #if EFI_LTFT_CONTROL LongTermFuelTrim,#endif ShortTermFuelTrim,#include "modules_list_generated.h" EngineModule > engineModules
Definition engine.h:194
void addConsoleAction(const char *token, Void callback)
Register console action without parameters.
void detectBoardType()
void initializeConsole()
void startUsbConsole()
static EngineAccessor engine
Definition engine.h:413
void loadConfiguration()
void initPeriodicEvents()
void initDataStructures()
void errorHandlerInit()
void errorHandlerShowBootReasonAndErrors()
void initHardwareNoConfig()
Definition hardware.cpp:427
void startLoggingProcessor()
void initMainLoop()
Definition main_loop.cpp:67
void initUsbMsd()
void scheduleReboot()
Definition rusefi.cpp:158
void initEfiWithConfig()
Definition rusefi.cpp:254
__NO_RETURN void runMainLoop()
Definition rusefi.cpp:288
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 MLG::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.