2015-07-10 06:01:56 -07:00
|
|
|
/**
|
|
|
|
* @file rusefi.cpp
|
|
|
|
* @brief Initialization code and main status reporting look
|
|
|
|
*
|
|
|
|
* @date Dec 25, 2013
|
2020-01-13 18:57:43 -08:00
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2020
|
2015-07-10 06:01:56 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @mainpage
|
2018-04-08 08:35:24 -07:00
|
|
|
* This documentation https://rusefi.com/docs/html/
|
|
|
|
*
|
|
|
|
* For version see engine_controller.cpp getRusEfiVersion
|
2015-07-10 06:01:56 -07:00
|
|
|
*
|
2020-09-11 17:20:37 -07:00
|
|
|
* @section sec_intro Intro
|
2015-07-10 06:01:56 -07:00
|
|
|
*
|
2021-03-02 19:23:17 -08:00
|
|
|
* rusEFI is implemented based on the idea that with modern 100+ MHz microprocessors the relatively
|
2015-07-10 06:01:56 -07:00
|
|
|
* undemanding task of internal combustion engine control could be implemented in a high-level, processor-independent
|
|
|
|
* (to some extent) manner. Thus the key concepts of rusEfi: dependency on high-level hardware abstraction layer, software-based PWM etc.
|
|
|
|
*
|
|
|
|
* @section sec_main Brief overview
|
|
|
|
*
|
2016-01-08 08:01:40 -08:00
|
|
|
* rusEfi runs on crank shaft or cam shaft ('trigger') position sensor events.
|
|
|
|
* Once per crank shaft revolution we evaluate the amount of needed fuel and
|
2015-07-10 06:01:56 -07:00
|
|
|
* the spark timing. Once we have decided on the parameters for this revolution
|
|
|
|
* we schedule all the actions to be triggered by the closest trigger event.
|
|
|
|
*
|
|
|
|
* We also have some utility threads like idle control thread and communication threads.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @section sec_trigger Trigger Decoding
|
|
|
|
*
|
|
|
|
* Our primary trigger decoder is based on the idea of synchronizing the primary shaft signal and simply counting events on
|
2016-01-08 08:01:40 -08:00
|
|
|
* the secondary signal. A typical scenario would be when cam shaft positions sensor is the primary signal and crankshaft is secondary,
|
|
|
|
* but sometimes there would be two signals generated by two cam shaft sensors.
|
|
|
|
* Another scenario is when we only have crank shaft position sensor, this would make it the primary signal and there would be no secondary signal.
|
2015-07-10 06:01:56 -07:00
|
|
|
*
|
|
|
|
* There is no software filtering so the signals are expected to be valid. TODO: in reality we are still catching engine stop noise as unrealisticly high RPM.
|
|
|
|
*
|
|
|
|
* The decoder is configured to act either on the primary signal rise or on the primary signal fall. It then compares the duration
|
|
|
|
* of time from the previous signal to the duration of time from the signal before previous, and if the ratio falls into the configurable
|
|
|
|
* range between 'syncRatioFrom' and 'syncRatioTo' this is assumed to be the synchronizing event.
|
|
|
|
*
|
|
|
|
* For instance, for a 36/1 skipped tooth wheel the ratio range for synchronization is from 1.5 to 3
|
|
|
|
*
|
|
|
|
* Some triggers do not require synchronization, this case we just count signals.
|
|
|
|
* A single tooth primary signal would be a typical example when synchronization is not needed.
|
|
|
|
*
|
|
|
|
*
|
2018-04-08 08:35:24 -07:00
|
|
|
* @section sec_timers Timers
|
|
|
|
* At the moment rusEfi is build using 5 times:
|
2020-09-11 17:20:37 -07:00
|
|
|
* <BR>1) 1MHz microsecond_timer.cpp
|
|
|
|
* <BR>2) 10KHz fast ADC callback pwmpcb_fast adc_inputs.cpp
|
|
|
|
* <BR>3) slow ADC callback pwmpcb_slow adc_inputs.cpp
|
|
|
|
* <BR>4) periodicFastTimer engine_controller.cpp
|
|
|
|
* <BR>5) periodicSlowTimer engine_controller.cpp
|
2015-07-10 06:01:56 -07:00
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @section sec_scheduler Event Scheduler
|
|
|
|
*
|
2016-01-08 08:01:40 -08:00
|
|
|
* It is a general agreement to measure all angles in crank shaft angles. In a four stroke
|
|
|
|
* engine, a full cycle consists of two revolutions of the crank shaft, so all the angles are
|
2015-07-10 06:01:56 -07:00
|
|
|
* running between 0 and 720 degrees.
|
|
|
|
*
|
|
|
|
* Ignition timing is a great example of a process which highlights the need of a hybrid
|
|
|
|
* approach to event scheduling.
|
|
|
|
* The most important part of controlling ignition
|
|
|
|
* is firing up the spark at the right moment - so, for this job we need 'angle-based' timing,
|
|
|
|
* for example we would need to fire up the spark at 700 degrees. Before we can fire up the spark
|
|
|
|
* at 700 degrees, we need to charge the ignition coil, for example this dwell time is 4ms - that
|
|
|
|
* means we need to turn on the coil at '4 ms before 700 degrees'. Let's assume that the engine is
|
|
|
|
* current at 600 RPM - that means 360 degrees would take 100ms so 4ms is 14.4 degrees at current RPM which
|
|
|
|
* means we need to start charting the coil at 685.6 degrees.
|
|
|
|
*
|
|
|
|
* The position sensors at our disposal are not providing us the current position at any moment of time -
|
|
|
|
* all we've got is a set of events which are happening at the knows positions. For instance, let's assume that
|
|
|
|
* our sensor sends as an event at 0 degrees, at 90 degrees, at 600 degrees and and 690 degrees.
|
|
|
|
*
|
|
|
|
* So, for this particular sensor the most precise scheduling would be possible if we schedule coil charting
|
|
|
|
* as '85.6 degrees after the 600 degrees position sensor event', and spark firing as
|
|
|
|
* '10 degrees after the 690 position sensor event'. Considering current RPM, we calculate that '10 degress after' is
|
|
|
|
* 2.777ms, so we schedule spark firing at '2.777ms after the 690 position sensor event', thus combining trigger events
|
|
|
|
* with time-based offset.
|
|
|
|
*
|
|
|
|
* @section config Persistent Configuration
|
|
|
|
* engine_configuration_s structure is kept in the internal flash memory, it has all the settings. Currently rusefi.ini has a direct mapping of this structure.
|
|
|
|
*
|
|
|
|
* Please note that due to TunerStudio protocol it's important to have the total structure size in synch between the firmware and TS .ini file -
|
|
|
|
* just to make sure that this is not forgotten the size of the structure is hard-coded as PAGE_0_SIZE constant. There is always some 'unused' fields added in advance so that
|
2016-01-08 08:01:40 -08:00
|
|
|
* one can add some fields without the pain of increasing the total configuration page size.
|
2015-07-10 06:01:56 -07:00
|
|
|
* <br>See flash_main.cpp
|
|
|
|
*
|
|
|
|
*
|
2021-03-02 19:23:17 -08:00
|
|
|
* todo: merge https://github.com/rusefi/rusefi/wiki/Dev-Tips into here
|
|
|
|
*
|
2015-07-10 06:01:56 -07:00
|
|
|
* @section sec_fuel_injection Fuel Injection
|
|
|
|
*
|
|
|
|
*
|
2020-09-11 17:20:37 -07:00
|
|
|
* @section sec_misc Misc
|
2015-07-10 06:01:56 -07:00
|
|
|
*
|
|
|
|
* <BR>See main_trigger_callback.cpp for main trigger event handler
|
|
|
|
* <BR>See fuel_math.cpp for details on fuel amount logic
|
|
|
|
* <BR>See rpm_calculator.cpp for details on how getRpm() is calculated
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2018-09-16 19:25:17 -07:00
|
|
|
#include "global.h"
|
2019-07-03 18:48:04 -07:00
|
|
|
#include "os_access.h"
|
2015-07-10 06:01:56 -07:00
|
|
|
#include "trigger_structure.h"
|
|
|
|
#include "hardware.h"
|
|
|
|
#include "engine_controller.h"
|
2019-03-29 06:11:13 -07:00
|
|
|
#include "efi_gpio.h"
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
#include "rfi_perftest.h"
|
|
|
|
#include "rusefi.h"
|
|
|
|
#include "memstreams.h"
|
|
|
|
|
|
|
|
#include "eficonsole.h"
|
|
|
|
#include "status_loop.h"
|
|
|
|
#include "pin_repository.h"
|
2018-01-28 11:49:06 -08:00
|
|
|
#include "custom_engine.h"
|
2018-02-03 07:56:29 -08:00
|
|
|
#include "engine_math.h"
|
2019-08-03 16:58:38 -07:00
|
|
|
#include "mpu_util.h"
|
2021-03-07 17:21:42 -08:00
|
|
|
#include "tunerstudio.h"
|
|
|
|
#include "mmc_card.h"
|
2021-04-10 05:35:41 -07:00
|
|
|
#include "mass_storage_init.h"
|
2021-03-11 05:38:52 -08:00
|
|
|
#include "trigger_emulator_algo.h"
|
2021-04-27 04:57:08 -07:00
|
|
|
#include "rusefi_lua.h"
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2021-07-05 15:18:58 -07:00
|
|
|
#include <setjmp.h>
|
|
|
|
|
2019-04-12 19:10:57 -07:00
|
|
|
#if EFI_ENGINE_EMULATOR
|
2015-07-10 06:01:56 -07:00
|
|
|
#include "engine_emulator.h"
|
|
|
|
#endif /* EFI_ENGINE_EMULATOR */
|
|
|
|
|
2016-01-11 16:02:19 -08:00
|
|
|
bool main_loop_started = false;
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
static char panicMessage[200];
|
|
|
|
|
|
|
|
static virtual_timer_t resetTimer;
|
|
|
|
|
|
|
|
// todo: move this into a hw-specific file
|
2019-06-28 20:33:48 -07:00
|
|
|
void rebootNow(void) {
|
2015-07-10 06:01:56 -07:00
|
|
|
NVIC_SystemReset();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Some configuration changes require full firmware reset.
|
|
|
|
* Once day we will write graceful shutdown, but that would be one day.
|
|
|
|
*/
|
|
|
|
static void scheduleReboot(void) {
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("Rebooting in 3 seconds...");
|
2020-11-19 03:56:02 -08:00
|
|
|
chibios_rt::CriticalSectionLocker csl;
|
2019-08-17 14:33:44 -07:00
|
|
|
chVTSetI(&resetTimer, TIME_MS2I(3000), (vtfunc_t) rebootNow, NULL);
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
|
2021-03-17 06:24:13 -07:00
|
|
|
// Returns false if there's an obvious problem with the loaded configuration
|
|
|
|
static bool validateConfig() {
|
2021-07-06 17:14:08 -07:00
|
|
|
if (CONFIG(specs.cylindersCount) > MAX_CYLINDER_COUNT) {
|
2021-03-17 06:24:13 -07:00
|
|
|
firmwareError(OBD_PCM_Processor_Fault, "Invalid cylinder count: %d", CONFIG(specs.cylindersCount));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-06-26 12:02:25 -07:00
|
|
|
// Fueling
|
|
|
|
{
|
|
|
|
ensureArrayIsAscending("VE load", config->veLoadBins);
|
|
|
|
ensureArrayIsAscending("VE RPM", config->veRpmBins);
|
|
|
|
|
|
|
|
ensureArrayIsAscending("Lambda/AFR load", config->lambdaLoadBins);
|
|
|
|
ensureArrayIsAscending("Lambda/AFR RPM", config->lambdaRpmBins);
|
|
|
|
|
|
|
|
ensureArrayIsAscending("Fuel CLT mult", config->cltFuelCorrBins);
|
|
|
|
ensureArrayIsAscending("Fuel IAT mult", config->iatFuelCorrBins);
|
|
|
|
|
|
|
|
ensureArrayIsAscending("Injection phase load", config->injPhaseLoadBins);
|
|
|
|
ensureArrayIsAscending("Injection phase RPM", config->injPhaseRpmBins);
|
|
|
|
|
|
|
|
ensureArrayIsAscending("TPS/TPS AE from", config->tpsTpsAccelFromRpmBins);
|
|
|
|
ensureArrayIsAscending("TPS/TPS AE to", config->tpsTpsAccelToRpmBins);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ignition
|
|
|
|
{
|
|
|
|
ensureArrayIsAscending("Dwell RPM", engineConfiguration->sparkDwellRpmBins);
|
|
|
|
|
|
|
|
ensureArrayIsAscending("Ignition load", config->ignitionLoadBins);
|
|
|
|
ensureArrayIsAscending("Ignition RPM", config->ignitionRpmBins);
|
|
|
|
|
|
|
|
ensureArrayIsAscending("Ignition CLT corr", engineConfiguration->cltTimingBins);
|
|
|
|
|
|
|
|
ensureArrayIsAscending("Ignition IAT corr IAT", config->ignitionIatCorrLoadBins);
|
|
|
|
ensureArrayIsAscending("Ignition IAT corr RPM", config->ignitionIatCorrRpmBins);
|
|
|
|
}
|
|
|
|
|
|
|
|
ensureArrayIsAscending("Map estimate TPS", config->mapEstimateTpsBins);
|
|
|
|
ensureArrayIsAscending("Map estimate RPM", config->mapEstimateRpmBins);
|
|
|
|
ensureArrayIsAscending("Ignition load", config->mafDecodingBins);
|
|
|
|
|
|
|
|
// Cranking tables
|
|
|
|
ensureArrayIsAscending("Cranking fuel mult", config->crankingFuelBins);
|
|
|
|
ensureArrayIsAscending("Cranking duration", config->crankingCycleBins);
|
|
|
|
ensureArrayIsAscending("Cranking TPS", engineConfiguration->crankingTpsBins);
|
|
|
|
|
|
|
|
// Idle tables
|
|
|
|
ensureArrayIsAscending("Idle target RPM", engineConfiguration->cltIdleRpmBins);
|
|
|
|
ensureArrayIsAscending("Idle warmup mult", config->cltIdleCorrBins);
|
|
|
|
ensureArrayIsAscending("Idle coasting position", engineConfiguration->iacCoastingBins);
|
|
|
|
ensureArrayIsAscending("Idle VE", config->idleVeBins);
|
|
|
|
ensureArrayIsAscending("Idle timing", config->idleAdvanceBins);
|
|
|
|
|
|
|
|
// Boost
|
|
|
|
ensureArrayIsAscending("Boost control TPS", config->boostTpsBins);
|
|
|
|
ensureArrayIsAscending("Boost control RPM", config->boostRpmBins);
|
|
|
|
|
|
|
|
// ETB
|
|
|
|
ensureArrayIsAscending("Pedal map pedal", config->pedalToTpsPedalBins);
|
|
|
|
ensureArrayIsAscending("Pedal map RPM", config->pedalToTpsRpmBins);
|
|
|
|
|
|
|
|
// VVT
|
|
|
|
ensureArrayIsAscending("VVT intake load", config->vvtTable1LoadBins);
|
|
|
|
ensureArrayIsAscending("VVT intake RPM", config->vvtTable1RpmBins);
|
|
|
|
ensureArrayIsAscending("VVT exhaust load", config->vvtTable2LoadBins);
|
|
|
|
ensureArrayIsAscending("VVT exhaust RPM", config->vvtTable2RpmBins);
|
|
|
|
|
2021-03-17 06:24:13 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-07-05 15:18:58 -07:00
|
|
|
static jmp_buf jmpEnv;
|
|
|
|
void onAssertionFailure() {
|
|
|
|
// There's been an assertion failure: instead of hanging, jump back to where we check
|
|
|
|
// if (setjmp(jmpEnv)) (see below for more complete explanation)
|
|
|
|
longjmp(jmpEnv, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void runRusEfiWithConfig();
|
|
|
|
void runMainLoop();
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
void runRusEfi(void) {
|
2019-02-23 09:33:49 -08:00
|
|
|
efiAssertVoid(CUSTOM_RM_STACK_1, getCurrentRemainingStack() > 512, "init s");
|
2018-02-03 07:48:35 -08:00
|
|
|
assertEngineReference();
|
2021-02-16 13:58:54 -08:00
|
|
|
engine->setConfig();
|
2021-04-18 15:46:47 -07:00
|
|
|
|
|
|
|
#if EFI_TEXT_LOGGING
|
|
|
|
// Initialize logging system early - we can't log until this is called
|
|
|
|
startLoggingProcessor();
|
|
|
|
#endif
|
|
|
|
|
2021-07-20 12:42:57 -07:00
|
|
|
#ifdef STM32F7
|
|
|
|
void sys_dual_bank(void);
|
|
|
|
addConsoleAction("dual_bank", sys_dual_bank);
|
|
|
|
#endif
|
|
|
|
|
2019-08-03 16:58:38 -07:00
|
|
|
addConsoleAction(CMD_REBOOT, scheduleReboot);
|
|
|
|
addConsoleAction(CMD_REBOOT_DFU, jump_to_bootloader);
|
2016-04-03 16:01:59 -07:00
|
|
|
|
2016-04-15 20:01:40 -07:00
|
|
|
/**
|
|
|
|
* we need to initialize table objects before default configuration can set values
|
|
|
|
*/
|
2017-05-15 20:33:22 -07:00
|
|
|
initDataStructures(PASS_ENGINE_PARAMETER_SIGNATURE);
|
2016-04-15 20:01:40 -07:00
|
|
|
|
2021-03-25 18:12:19 -07:00
|
|
|
// Perform hardware initialization that doesn't need configuration
|
2021-04-21 11:28:48 -07:00
|
|
|
initHardwareNoConfig();
|
2019-01-10 21:08:26 -08:00
|
|
|
|
2021-03-18 11:07:22 -07:00
|
|
|
#if EFI_USB_SERIAL
|
|
|
|
startUsbConsole();
|
|
|
|
#endif
|
|
|
|
|
2021-04-10 05:35:41 -07:00
|
|
|
#if HAL_USE_USB_MSD
|
|
|
|
initUsbMsd();
|
|
|
|
#endif
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
/**
|
|
|
|
* Next we should initialize serial port console, it's important to know what's going on
|
|
|
|
*/
|
2021-04-20 11:09:41 -07:00
|
|
|
initializeConsole();
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2021-07-05 15:18:58 -07:00
|
|
|
// Read configuration from flash memory
|
|
|
|
loadConfiguration(PASS_ENGINE_PARAMETER_SIGNATURE);
|
|
|
|
|
2021-03-07 17:21:42 -08:00
|
|
|
#if EFI_TUNER_STUDIO
|
|
|
|
startTunerStudioConnectivity();
|
|
|
|
#endif /* EFI_TUNER_STUDIO */
|
|
|
|
|
2021-03-28 06:06:36 -07:00
|
|
|
// Start hardware serial ports (including bluetooth, if present)
|
|
|
|
startSerialChannels();
|
|
|
|
|
2021-07-05 15:18:58 -07:00
|
|
|
runRusEfiWithConfig();
|
|
|
|
|
2021-07-08 16:33:42 -07:00
|
|
|
// periodic events need to be initialized after fuel&spark pins to avoid a warning
|
|
|
|
initPeriodicEvents(PASS_ENGINE_PARAMETER_SIGNATURE);
|
|
|
|
|
2021-07-05 15:18:58 -07:00
|
|
|
runMainLoop();
|
|
|
|
}
|
|
|
|
|
|
|
|
void runRusEfiWithConfig() {
|
|
|
|
// If some config operation caused an OS assertion failure, return immediately
|
|
|
|
// This sets the "unwind point" that we can jump back to later with longjmp if we have
|
|
|
|
// an assertion failure. If that happens, setjmp() will return non-zero, so we will
|
|
|
|
// return immediately from this function instead of trying to init hardware again (which failed last time)
|
|
|
|
if (setjmp(jmpEnv)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-07-20 11:16:43 -07:00
|
|
|
// Start this early - it will start LED blinking and such
|
|
|
|
startStatusThreads();
|
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
/**
|
|
|
|
* Initialize hardware drivers
|
|
|
|
*/
|
2021-03-25 13:22:03 -07:00
|
|
|
initHardware();
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2021-03-25 18:12:19 -07:00
|
|
|
#if EFI_FILE_LOGGING
|
|
|
|
initMmcCard();
|
|
|
|
#endif /* EFI_FILE_LOGGING */
|
|
|
|
|
2021-03-16 14:31:30 -07:00
|
|
|
#if HW_CHECK_ALWAYS_STIMULATE
|
|
|
|
// we need a special binary for final assembly check. We cannot afford to require too much software or too many steps
|
|
|
|
// to be executed at the place of assembly
|
|
|
|
enableTriggerStimulator();
|
|
|
|
#endif // HW_CHECK_ALWAYS_STIMULATE
|
|
|
|
|
2021-04-27 04:57:08 -07:00
|
|
|
#if EFI_LUA
|
|
|
|
startLua();
|
|
|
|
#endif // EFI_LUA
|
|
|
|
|
2021-03-17 06:24:13 -07:00
|
|
|
// Config could be completely bogus - don't start anything else!
|
|
|
|
if (validateConfig()) {
|
|
|
|
initStatusLoop();
|
|
|
|
/**
|
|
|
|
* Now let's initialize actual engine control logic
|
|
|
|
* todo: should we initialize some? most? controllers before hardware?
|
|
|
|
*/
|
2021-04-21 11:28:48 -07:00
|
|
|
initEngineContoller(PASS_ENGINE_PARAMETER_SIGNATURE);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2021-06-25 16:38:42 -07:00
|
|
|
#if EFI_ENGINE_EMULATOR
|
|
|
|
initEngineEmulator(PASS_ENGINE_PARAMETER_SIGNATURE);
|
|
|
|
#endif
|
|
|
|
|
2021-03-30 04:28:22 -07:00
|
|
|
// This has to happen after RegisteredOutputPins are init'd: otherwise no change will be detected, and no init will happen
|
|
|
|
rememberCurrentConfiguration(PASS_ENGINE_PARAMETER_SIGNATURE);
|
|
|
|
|
2021-03-17 06:24:13 -07:00
|
|
|
#if EFI_PERF_METRICS
|
2021-04-21 11:28:48 -07:00
|
|
|
initTimePerfActions();
|
2021-03-17 06:24:13 -07:00
|
|
|
#endif
|
2021-06-25 16:38:42 -07:00
|
|
|
|
2021-03-17 06:24:13 -07:00
|
|
|
runSchedulingPrecisionTestIfNeeded();
|
|
|
|
}
|
2021-07-05 15:18:58 -07:00
|
|
|
}
|
2018-01-28 11:03:58 -08:00
|
|
|
|
2021-07-05 15:18:58 -07:00
|
|
|
void runMainLoop() {
|
2021-04-21 09:53:13 -07:00
|
|
|
efiPrintf("Running main loop");
|
2015-07-10 06:01:56 -07:00
|
|
|
main_loop_started = true;
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
while (true) {
|
2019-02-23 09:33:49 -08:00
|
|
|
efiAssertVoid(CUSTOM_RM_STACK, getCurrentRemainingStack() > 128, "stack#1");
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2019-04-12 19:10:57 -07:00
|
|
|
#if EFI_CLI_SUPPORT && !EFI_UART_ECHO_TEST_MODE
|
2019-05-02 14:52:48 -07:00
|
|
|
// sensor state + all pending messages for our own rusEfi console
|
2020-06-13 19:46:10 -07:00
|
|
|
// todo: is this mostly dead code?
|
2017-04-09 19:26:11 -07:00
|
|
|
updateDevConsoleState();
|
2015-07-10 06:01:56 -07:00
|
|
|
#endif /* EFI_CLI_SUPPORT */
|
|
|
|
|
2020-06-13 19:46:10 -07:00
|
|
|
chThdSleepMilliseconds(200);
|
2015-07-10 06:01:56 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-23 10:18:59 -08:00
|
|
|
/**
|
|
|
|
* this depends on chcore.h patch
|
|
|
|
+void chDbgStackOverflowPanic(thread_t *otp);
|
|
|
|
+
|
|
|
|
- chSysHalt("stack overflow"); \
|
|
|
|
+ chDbgStackOverflowPanic(otp); \
|
|
|
|
|
|
|
|
*
|
|
|
|
*/
|
2017-03-30 12:06:30 -07:00
|
|
|
void chDbgStackOverflowPanic(thread_t *otp) {
|
2017-04-12 08:28:23 -07:00
|
|
|
(void)otp;
|
2015-07-10 06:01:56 -07:00
|
|
|
strcpy(panicMessage, "stack overflow: ");
|
2019-04-12 19:10:57 -07:00
|
|
|
#if defined(CH_USE_REGISTRY)
|
2016-08-31 21:02:04 -07:00
|
|
|
int p_name_len = strlen(otp->p_name);
|
2016-09-01 20:02:44 -07:00
|
|
|
if (p_name_len < sizeof(panicMessage) - 2)
|
2016-08-31 21:02:04 -07:00
|
|
|
strcat(panicMessage, otp->p_name);
|
2015-07-10 06:01:56 -07:00
|
|
|
#endif
|
|
|
|
chDbgPanic3(panicMessage, __FILE__, __LINE__);
|
|
|
|
}
|
|
|
|
|
|
|
|
|