move some initialization steps earlier (#2480)
* early hw init * s * Revert "s" This reverts commit 10d3039168613cfb2b0cf1c960d2f18894745ce3. * bor * I can't type Co-authored-by: Matthew Kennedy <makenne@microsoft.com>
This commit is contained in:
parent
1c473934b9
commit
6f05bbc332
|
@ -32,7 +32,7 @@
|
|||
#include "serial_hw.h"
|
||||
|
||||
#include "mpu_util.h"
|
||||
//#include "usb_msd.h"
|
||||
#include "mmc_card.h"
|
||||
|
||||
#include "AdcConfiguration.h"
|
||||
#include "idle_hardware.h"
|
||||
|
@ -463,16 +463,16 @@ void showBor(void) {
|
|||
scheduleMsg(sharedLogger, "BOR=%d", (int)BOR_Get());
|
||||
}
|
||||
|
||||
void initHardware(Logging *l) {
|
||||
// This function initializes hardware that can do so before configuration is loaded
|
||||
void initHardwareNoConfig(Logging *l) {
|
||||
efiAssertVoid(CUSTOM_IH_STACK, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "init h");
|
||||
sharedLogger = l;
|
||||
efiAssertVoid(CUSTOM_EC_NULL, engineConfiguration!=NULL, "engineConfiguration");
|
||||
|
||||
|
||||
printMsg(sharedLogger, "initHardware()");
|
||||
// todo: enable protection. it's disabled because it takes
|
||||
// 10 extra seconds to re-flash the chip
|
||||
//flashProtect();
|
||||
|
||||
initPinRepository();
|
||||
|
||||
#if EFI_HISTOGRAMS
|
||||
/**
|
||||
|
@ -486,12 +486,27 @@ void initHardware(Logging *l) {
|
|||
*/
|
||||
initPrimaryPins(sharedLogger);
|
||||
|
||||
if (hasFirmwareError()) {
|
||||
return;
|
||||
}
|
||||
// it's important to initialize this pretty early in the game before any scheduling usages
|
||||
initSingleTimerExecutorHardware();
|
||||
|
||||
initRtc();
|
||||
|
||||
#if EFI_INTERNAL_FLASH
|
||||
initFlash(sharedLogger);
|
||||
#endif
|
||||
|
||||
#if EFI_SHAFT_POSITION_INPUT
|
||||
// todo: figure out better startup logic
|
||||
initTriggerCentral(sharedLogger);
|
||||
#endif /* EFI_SHAFT_POSITION_INPUT */
|
||||
|
||||
#if EFI_FILE_LOGGING
|
||||
initEarlyMmcCard();
|
||||
#endif // EFI_FILE_LOGGING
|
||||
}
|
||||
|
||||
void initHardware() {
|
||||
#if EFI_INTERNAL_FLASH
|
||||
#ifdef CONFIG_RESET_SWITCH_PORT
|
||||
// this pin is not configurable at runtime so that we have a reliable way to reset configuration
|
||||
#define SHOULD_IGNORE_FLASH() (palReadPad(CONFIG_RESET_SWITCH_PORT, CONFIG_RESET_SWITCH_PIN) == 0)
|
||||
|
@ -503,7 +518,6 @@ void initHardware(Logging *l) {
|
|||
palSetPadMode(CONFIG_RESET_SWITCH_PORT, CONFIG_RESET_SWITCH_PIN, PAL_MODE_INPUT_PULLUP);
|
||||
#endif /* CONFIG_RESET_SWITCH_PORT */
|
||||
|
||||
initFlash(sharedLogger);
|
||||
/**
|
||||
* this call reads configuration from flash memory or sets default configuration
|
||||
* if flash state does not look right.
|
||||
|
@ -522,9 +536,6 @@ void initHardware(Logging *l) {
|
|||
resetConfigurationExt(sharedLogger, engineConfiguration->engineType PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
#endif /* EFI_INTERNAL_FLASH */
|
||||
|
||||
// it's important to initialize this pretty early in the game before any scheduling usages
|
||||
initSingleTimerExecutorHardware();
|
||||
|
||||
#if EFI_HD44780_LCD
|
||||
lcd_HD44780_init(sharedLogger);
|
||||
if (hasFirmwareError())
|
||||
|
@ -549,8 +560,6 @@ void initHardware(Logging *l) {
|
|||
initSoftwareKnock();
|
||||
#endif /* EFI_SOFTWARE_KNOCK */
|
||||
|
||||
initRtc();
|
||||
|
||||
#if HAL_USE_SPI
|
||||
initSpiModules(engineConfiguration);
|
||||
#endif /* HAL_USE_SPI */
|
||||
|
@ -582,11 +591,6 @@ void initHardware(Logging *l) {
|
|||
// init_adc_mcp3208(&adcState, &SPID2);
|
||||
// requestAdcValue(&adcState, 0);
|
||||
|
||||
#if EFI_SHAFT_POSITION_INPUT
|
||||
// todo: figure out better startup logic
|
||||
initTriggerCentral(sharedLogger);
|
||||
#endif /* EFI_SHAFT_POSITION_INPUT */
|
||||
|
||||
turnOnHardware(sharedLogger);
|
||||
|
||||
#if EFI_HIP_9011
|
||||
|
@ -596,15 +600,11 @@ void initHardware(Logging *l) {
|
|||
#if EFI_MEMS
|
||||
initAccelerometer(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
#endif
|
||||
// initFixedLeds();
|
||||
|
||||
|
||||
#if EFI_BOSCH_YAW
|
||||
initBoschYawRateSensor();
|
||||
#endif /* EFI_BOSCH_YAW */
|
||||
|
||||
// initBooleanInputs();
|
||||
|
||||
#if EFI_UART_GPS
|
||||
initGps();
|
||||
#endif
|
||||
|
|
|
@ -49,7 +49,13 @@ brain_pin_e getSckPin(spi_device_e device);
|
|||
#include "debounce.h"
|
||||
|
||||
void applyNewHardwareSettings(void);
|
||||
void initHardware(Logging *logging);
|
||||
|
||||
// Initialize hardware that doesn't require configuration to be loaded
|
||||
void initHardwareNoConfig(Logging *l);
|
||||
|
||||
// Initialize hardware with configuration loaded
|
||||
void initHardware();
|
||||
|
||||
#endif /* EFI_PROD_CODE */
|
||||
|
||||
void showBor(void);
|
||||
|
|
|
@ -534,19 +534,22 @@ bool isSdCardAlive(void) {
|
|||
return fs_ready;
|
||||
}
|
||||
|
||||
void initMmcCard(void) {
|
||||
// Pre-config load init
|
||||
void initEarlyMmcCard() {
|
||||
logName[0] = 0;
|
||||
|
||||
#if HAL_USE_USB_MSD
|
||||
chBSemObjectInit(&usbConnectedSemaphore, true);
|
||||
#endif
|
||||
|
||||
chThdCreateStatic(mmcThreadStack, sizeof(mmcThreadStack), PRIO_MMC, (tfunc_t)(void*) MMCmonThread, NULL);
|
||||
|
||||
addConsoleAction("sdinfo", sdStatistics);
|
||||
addConsoleActionS("ls", listDirectory);
|
||||
addConsoleActionS("del", removeFile);
|
||||
addConsoleAction("incfilename", incLogFileName);
|
||||
}
|
||||
|
||||
void initMmcCard() {
|
||||
chThdCreateStatic(mmcThreadStack, sizeof(mmcThreadStack), PRIO_MMC, (tfunc_t)(void*) MMCmonThread, NULL);
|
||||
}
|
||||
|
||||
#endif /* EFI_FILE_LOGGING */
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
#define DOT_MLG ".mlg"
|
||||
|
||||
bool isLogFile(const char *fileName);
|
||||
void initMmcCard(void);
|
||||
void initEarlyMmcCard();
|
||||
void initMmcCard();
|
||||
bool isSdCardAlive(void);
|
||||
|
||||
void readLogFileContent(char *buffer, short fileId, short offset, short length);
|
||||
|
|
|
@ -192,10 +192,7 @@ void runRusEfi(void) {
|
|||
*/
|
||||
initDataStructures(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
||||
/**
|
||||
* First data structure keeps track of which hardware I/O pins are used by whom
|
||||
*/
|
||||
initPinRepository();
|
||||
initHardwareNoConfig(&sharedLogger);
|
||||
|
||||
#if EFI_INTERNAL_FLASH
|
||||
#if IGNORE_FLASH_CONFIGURATION
|
||||
|
@ -234,7 +231,7 @@ void runRusEfi(void) {
|
|||
/**
|
||||
* Initialize hardware drivers
|
||||
*/
|
||||
initHardware(&sharedLogger);
|
||||
initHardware();
|
||||
|
||||
#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
|
||||
|
|
Loading…
Reference in New Issue