### Example Output Files from Compilation Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/DEVELOPER.md Lists the typical output files generated after a successful firmware compilation. These files are located in the 'firmware/deliver/' directory and serve different flashing purposes. ```bash ls -lh deliver 657K fome.bin 18K fome_bl.bin 1.9M fome_update.srec ``` -------------------------------- ### Install Linux Firmware Dependencies Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/DEVELOPER.md Installs additional dependencies required for building the FOME firmware on a Linux system. This script should be run after cloning the repository and navigating to the firmware directory. ```bash cd fome-fw/firmware && ./setup_linux_environment.sh ``` -------------------------------- ### Build and Run Unit Tests (Bash) Source: https://context7.com/fome-tech/fome-fw/llms.txt This section outlines the process for building and running unit tests within the project. It provides a bash command example for executing the tests. ```bash ``` -------------------------------- ### Clone FOME Firmware Repository Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/DEVELOPER.md Clones the FOME firmware repository to your local machine. Replace '' with your actual GitHub username. This is a prerequisite for local development. ```bash git clone https://github.com//fome-fw.git ``` -------------------------------- ### Writing a Unit Test in C++ Source: https://context7.com/fome-tech/fome-fw/llms.txt Example C++ code for writing unit tests using the gtest framework. It demonstrates setting up a test fixture, defining test cases for basic operations, edge cases, and error handling, including assertions like EXPECT_FLOAT_EQ and EXPECT_NO_THROW. ```cpp // tests/test_my_feature.cpp #include "pch.h" #include "gtest/gtest.h" // Test fixture for feature tests class MyFeatureTest : public ::testing::Test { protected: void SetUp() override { // Setup code before each test EngineTestHelper eth(engine_type_e::TEST_ENGINE); engineConfiguration->myFeatureEnabled = true; } void TearDown() override { // Cleanup after each test } }; // Test basic functionality TEST_F(MyFeatureTest, testBasicOperation) { // Arrange float input = 10.0f; float expected = 20.0f; // Act float result = myFeatureCalculate(input); // Assert EXPECT_FLOAT_EQ(expected, result); } // Test edge cases TEST_F(MyFeatureTest, testEdgeCases) { EXPECT_FLOAT_EQ(0.0f, myFeatureCalculate(0.0f)); EXPECT_FLOAT_EQ(100.0f, myFeatureCalculate(50.0f)); } // Test error conditions TEST_F(MyFeatureTest, testErrorHandling) { // Should handle invalid input gracefully EXPECT_NO_THROW(myFeatureCalculate(-1.0f)); // Should return safe value on error float result = myFeatureCalculate(INFINITY); EXPECT_TRUE(std::isfinite(result)); } ``` -------------------------------- ### Compile FOME Firmware for Different ECU Boards Source: https://context7.com/fome-tech/fome-fw/llms.txt This command series demonstrates how to compile FOME firmware for various supported ECU boards. Each board has a dedicated compilation script located within the `firmware/config/boards//` directory. Examples include Proteus boards with STM32F4, F7, H7, and other configurations like Hellen and MicroRusEFI. ```bash # Each board has its own compile script cd firmware/config/boards// # Examples: ./compile_proteus_f4.sh # Proteus with STM32F4 ./compile_proteus_f7.sh # Proteus with STM32F7 ./compile_proteus_h7.sh # Proteus with STM32H7 ./compile_hellen121nissan_f4.sh # Hellen 121 Nissan ./compile_hellen128_f4.sh # Hellen 128 ./compile_microrusefi_f4.sh # MicroRusEFI F4 ./compile_microrusefi_f7.sh # MicroRusEFI F7 ``` -------------------------------- ### Enable/Disable Presets (C Preprocessor) Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/config/boards/hellen/hellenNA8_96/prepend.txt These macros determine which predefined configuration presets are available for selection. They allow users to easily switch between different hardware setups or experimental configurations without manually changing numerous settings. These are C preprocessor directives. ```c #define show_test_presets false #define show_Frankenso_presets false #define show_microRusEFI_presets false #define show_Proteus_presets false #define show_Hellen_presets true #define show_HellenNB1_presets false #define show_Hellen96_presets true ``` -------------------------------- ### Configure Trigger Wheel (C++) Source: https://context7.com/fome-tech/fome-fw/llms.txt Configures the engine's crank and cam trigger wheel system. Examples include common setups like 60-2 and 36-1 tooth wheels, as well as options for VVT sensors and pre-defined OEM patterns for various vehicle models. ```cpp // 60-2 trigger wheel (common on many engines) void configure60Minus2Trigger() { engineConfiguration->trigger.type = TT_TOOTHED_WHEEL; engineConfiguration->trigger.customTotalToothCount = 60; engineConfiguration->trigger.customSkippedToothCount = 2; engineConfiguration->trigger.customIsSynchronizationNeeded = true; // VVT/cam sensor (optional) engineConfiguration->vvtMode[0] = VVT_SINGLE_TOOTH; engineConfiguration->vvtOffsets[0] = 20; // degrees } // 36-1 trigger wheel (Honda, Nissan, others) void configure36Minus1Trigger() { engineConfiguration->trigger.type = TT_TOOTHED_WHEEL; engineConfiguration->trigger.customTotalToothCount = 36; engineConfiguration->trigger.customSkippedToothCount = 1; } // OEM trigger patterns (pre-defined) void configureOEMTrigger() { // Mazda Miata NB (4-1 + cam) engineConfiguration->trigger.type = TT_MIATA_VVT; // Honda K-series // engineConfiguration->trigger.type = TT_HONDA_K_CRANK_12_1; // GM LS (24x + 1x) // engineConfiguration->trigger.type = TT_GM_LS_24; // Nissan SR20/QR25 // engineConfiguration->trigger.type = TT_NISSAN_SR20VE; } ``` -------------------------------- ### Post-Cranking Enrichment Table Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/integration/fome_config.txt Defines the post-cranking enrichment table, which applies a fuel enrichment multiplier after the engine starts. It includes bins for temperature, runtime, and the enrichment ratio. ```c uint8_t[8 x 8] autoscale postCrankingEnrichTable; // ratio int8_t[8] postCrankingEnrichTempBins; // deg C uint8_t[8] postCrankingEnrichRuntimeBins; // sec ``` -------------------------------- ### Compile FOME Firmware for Proteus F7 Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/DEVELOPER.md Compiles the FOME firmware specifically for the Proteus ECU with an STM32F7 microcontroller. This command is typically run from the 'config/boards/proteus' directory. ```bash cd config/boards/proteus ./compile_proteus_f7.sh ``` -------------------------------- ### Create Live Data View for Custom Controller in C++ Source: https://context7.com/fome-tech/fome-fw/llms.txt This C++ code shows how to create a live data view for a custom controller, integrating with TunerStudio. It involves defining a state structure (my_controller_s), adding it to the LiveData.yaml configuration, and updating the state variables within the controller's callback function. The example includes PID control logic updates. ```cpp // 1. Create state structure file: my_controller.txt // Located in firmware/controllers/my_module/ /* struct_no_prefix my_controller_s float targetValue;Target setpoint;"units",1,0,0,100,2 float currentValue;Current value;"units",1,0,0,100,2 float errorValue;Control error;"units",1,0,-50,50,2 float integralValue;Integral term;"",1,0,0,0,2 float derivativeValue;Derivative term;"",1,0,0,0,2 bit isActive;Controller active bit hasError;Controller error bit isInBounds;Within limits uint16_t loopCounter;Loop count;"",1,0,0,65535,0 uint16_t errorCounter;Error count;"",1,0,0,65535,0 */ // 2. Add to LiveData.yaml /* - name: my_controller folder: controllers/my_module constexpr: "engine->myController" outputs: - my_controller */ // 3. Use in code struct my_controller_s { float targetValue = 0; float currentValue = 0; float errorValue = 0; float integralValue = 0; float derivativeValue = 0; bool isActive : 1 = false; bool hasError : 1 = false; bool isInBounds : 1 = false; uint16_t loopCounter = 0; uint16_t errorCounter = 0; }; // Update in controller void MyController::onFastCallback() { auto& state = engine->myController; state.targetValue = calculateTarget(); state.currentValue = readSensor(); state.errorValue = state.targetValue - state.currentValue; // PID control logic... state.integralValue += state.errorValue * 0.01f; state.derivativeValue = (state.errorValue - lastError) / 0.005f; state.isActive = true; state.loopCounter++; // Values automatically appear in TunerStudio live data view } ``` -------------------------------- ### Configure Feature Display Macros Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/config/boards/hellen/hellen-gm-e67/prepend.txt These C preprocessor macros control the visibility of various features within the Fome-FW project's user interface. They are boolean flags that enable or disable specific display elements. No external dependencies are required. Examples include enabling SPI, SD card display, and tunerstudio port visibility. ```c #define ts_show_egt false #define ts_show_etb_pins false #define ts_show_analog_divider false #define ts_show_spi true #define ts_show_sd_card true #define ts_show_can_pins false #define ts_show_tunerstudio_port true #define ts_show_can2 false #define ts_show_software_knock true #define ts_show_hardware_simulator false #define ts_show_sd_pins false ``` -------------------------------- ### Configure Hardware Feature Visibility (C Preprocessor) Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/config/boards/hellen/hellen121vag/prepend.txt These definitions control the visibility and enabling of various hardware-related features within the firmware. They are used as compile-time flags to include or exclude specific code paths. Examples include enabling SPI, SD card functionality, and software knock detection, while disabling CAN bus extensions or hardware simulators. ```c #define ts_show_egt false #define ts_show_etb_pins false #define ts_show_analog_divider false #define ts_show_spi true #define ts_show_sd_card true #define ts_show_can_pins false #define ts_show_tunerstudio_port false #define ts_show_can2 false #define ts_show_software_knock true #define ts_show_hardware_simulator false #define ts_show_sd_pins false ``` -------------------------------- ### Create Custom FOME Engine Module in C++ Source: https://context7.com/fome-tech/fome-fw/llms.txt This C++ code defines a custom engine module by inheriting from `EngineModule`. It overrides callback methods like `onSlowCallback` and `onFastCallback` for periodic updates, and `onConfigurationChange` to react to configuration changes. The example shows how to read sensor values, manipulate target values, control output pins, and register the custom module during engine initialization. ```cpp // my_module.h #pragma once #include "engine_module.h" class MyCustomModule : public EngineModule { public: void onSlowCallback() override; void onFastCallback() override; void onConfigurationChange(engine_configuration_s const* config) override; private: float targetValue; float currentValue; }; // my_module.cpp #include "pch.h" #include "my_module.h" void MyCustomModule::onConfigurationChange(engine_configuration_s const* config) { // Called when configuration is burned/changed targetValue = config->myTargetParameter; } void MyCustomModule::onSlowCallback() { // Called at ~20Hz - good for non-critical calculations if (Sensor::get(SensorType::Clt).value_or(0) > 80) { targetValue *= 1.1f; // Adjust target when hot } } void MyCustomModule::onFastCallback() { // Called at ~200Hz - use for time-critical control currentValue = currentValue * 0.9f + targetValue * 0.1f; // Simple filter if (currentValue > 100) { enginePins.myOutputPin.setValue(true); } else { enginePins.myOutputPin.setValue(false); } } // Register module in engine initialization static MyCustomModule myModule; void initMyModule() { engine->engineModules.registerModule(myModule); } ``` -------------------------------- ### Building and Running the Simulator Source: https://context7.com/fome-tech/fome-fw/llms.txt Instructions to navigate to the simulator directory, build the simulator using make, and then run it. It outlines the simulator's features, including self-stimulation, mocked sensors/outputs, a console interface, and TunerStudio connectivity. ```bash # Navigate to simulator directory cd simulator # Build simulator make # Run simulator ./build/fome_simulator # Simulator provides: # - Self-stimulation for trigger events # - Mocked analog sensors # - Mocked digital outputs # - Console interface for debugging # - Same TunerStudio connectivity as real ECU # Connect TunerStudio to simulator # Port: /dev/pts/X (Linux) or COM port (Windows) # Baud: 115200 ``` -------------------------------- ### Define Main Help URL (C/C++) Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/config/boards/hellen/alphax-4chan/prepend.txt This macro defines the URL for the main help documentation, accessible from the firmware interface. It points to an external web resource. No direct code execution, purely a configuration string. ```c #define MAIN_HELP_URL "https://rusefi.com/s/4chan" ``` -------------------------------- ### Navigate and Build Unit Tests Source: https://context7.com/fome-tech/fome-fw/llms.txt Commands to navigate to the unit test directory, build all tests using make, and then run all tests or specific test suites/cases. It also shows how to run tests with verbose output and generate code coverage reports. ```bash # Navigate to unit tests directory cd unit_tests # Build all tests make # Run all tests ./build/fome_test # Run specific test suite ./build/fome_test --gtest_filter=TriggerDecoder.* # Run specific test case ./build/fome_test --gtest_filter=TriggerDecoder.test60minus2 # Run with verbose output ./build/fome_test --gtest_filter=MyTest.* --gtest_verbose=1 # Generate code coverage report ./ci_gcov.sh # View coverage report at coverage/index.html ``` -------------------------------- ### Engine Start Pulse Filtering Configuration Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/integration/fome_config.txt Configures the number of initial pulses to ignore when the engine starts moving to mitigate noise from trigger hardware. The value is an unsigned 8-bit integer. ```C uint8_t triggerSkipPulses; // Some trigger hardware may generate noise when the engine starts moving. Set this to ignore the first pulses when the engine starts moving. ``` -------------------------------- ### Configure Stepper Idle Valve Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/integration/fome_config.txt Enables the use of a stepper motor for idle control, provided a compatible stepper motor driver is installed. ```C++ bit useStepperIdle;This setting should only be used if you have a stepper motor idle valve and a stepper motor driver installed. ``` -------------------------------- ### Help URL Definition (C/C++) Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/config/boards/hellen/hellen81/prepend.txt Defines the URL for accessing help documentation related to the project. This is a simple macro substitution. It has no inputs or outputs and is a static configuration value. ```c #define MAIN_HELP_URL "https://rusefi.com/s/hellen81" ``` -------------------------------- ### Define Main Help URL (C Preprocessor) Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/config/boards/hellen/hellen121vag/prepend.txt This definition sets the primary URL for accessing help documentation related to the firmware. It is used to direct users to relevant online resources for support and detailed information. ```c #define MAIN_HELP_URL "https://rusefi.com/s/hellen121vag" ``` -------------------------------- ### Combined Thermistor Configuration Structure Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/integration/fome_config.txt A convenience structure that combines the detailed thermistor configuration with the specific ADC channel it is connected to. Simplifies sensor setup by grouping related parameters. ```c struct ThermistorConf thermistor_conf_s config; adc_channel_e adcChannel; end_struct ``` -------------------------------- ### Define Main Help URL Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/config/boards/hellen/hellen64_miataNA6_94/prepend.txt This directive defines the URL for the main help documentation, likely used for integration with diagnostic or configuration tools. It's a simple string definition. ```c #define MAIN_HELP_URL "https://rusefi.com/s/hellenNA6" ``` -------------------------------- ### Trigger Gap Override Configuration Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/integration/fome_config.txt Sets override values for trigger gap tracking, defining a start and end ratio. These are autoscaled parameters used for fine-tuning trigger signal synchronization. ```C uint16_t[GAP_TRACKING_LENGTH iterate] autoscale triggerGapOverrideFrom; // "ratio" ``` ```C uint16_t[GAP_TRACKING_LENGTH iterate] autoscale triggerGapOverrideTo; // "ratio" ``` -------------------------------- ### Main Help URL Definition Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/config/boards/hellen/hellen121nissan/prepend.txt Defines the URL for the main help documentation accessible within the Fome-FW project. This is a string literal used to point users to external resources for assistance. Dependencies: None. Inputs: None. Outputs: None. Limitations: This is a compile-time constant. ```c #define MAIN_HELP_URL "https://rusefi.com/s/hellen121nissan" ``` -------------------------------- ### Prime Fuel Injection Values Configuration Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/integration/fome_config.txt Sets the prime injection values, likely for initial fuel delivery upon engine start. These values are autoscaled and measured in milligrams (mg). ```C uint8_t[8] autoscale primeValues; // "mg" ``` -------------------------------- ### Define Main Help URL (C/C++) Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/config/boards/hellen/alphax-8chan/prepend.txt Defines a preprocessor macro for the main help URL used within the Fome-FW project. This URL likely points to external documentation or support resources. It's a simple string definition with no runtime dependencies. ```c #define MAIN_HELP_URL "https://rusefi.com/s/8chan" ``` -------------------------------- ### Main Help URL Definition (C/C++) Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/config/boards/hellen/hellen128/prepend.txt Defines a preprocessor macro for the main help URL, pointing to the Hellen128merc documentation on ruSEtitor.com. This is a simple string definition used for referencing help documentation within the firmware. It has no functional impact on runtime behavior beyond providing a reference. ```c #define MAIN_HELP_URL "https://rusefi.com/s/hellen128merc" ``` -------------------------------- ### Spark Dwell Curve Configuration Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/integration/fome_config.txt Configuration for spark dwell tables. This includes RPM bins and corresponding dwell time values in milliseconds. Dwell time needs to be reduced at high RPMs for certain ignition setups. ```c uint16_t[DWELL_CURVE_SIZE] sparkDwellRpmBins; // On Single Coil or Wasted Spark setups you have to lower dwell at high RPM;"RPM", 1, 0, 0, 25000, 0 uint16_t[DWELL_CURVE_SIZE] autoscale sparkDwellValues; //"ms", 0.01, 0, 0, 30, 2 ``` -------------------------------- ### Define Main Help URL Macro Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/config/boards/hellen/hellen-gm-e67/prepend.txt Defines the URL for the main help documentation, likely used for in-application help links or external references. This is a string literal macro. No external dependencies are required. ```c #define MAIN_HELP_URL "https://rusefi.com/s/gm-e67" ``` -------------------------------- ### Injection Timing and Debug Mode Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/integration/fome_config.txt Configuration for injection timing modes and debug output. Allows setting whether the injection phase table controls the start, center, or end of injection, and configures the UART console baud rate. ```c custom InjectionTimingMode 1 bits, U08, @OFFSET@, [0:1], "End of injection", "Start of injection", "Center of injection" InjectionTimingMode injectionTimingMode;Sets what part of injection's is controlled by the injection phase table. debug_mode_e debugMode;See https://wiki.fome.tech/r/debugmode uint32_t uartConsoleSerialSpeed;Band rate for primary TTL;"BPs", 1, 0, 0, 1000000, 0 ``` -------------------------------- ### Main Help URL Definition (C Preprocessor) Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/config/boards/hellen/hellen88bmw/prepend.txt Defines the main help URL for the project, likely used for directing users to online documentation or support. This is a simple string definition controlled by the C preprocessor. ```c #define MAIN_HELP_URL "https://rusefi.com/s/hellen88bmw" ``` -------------------------------- ### Configure Idle PID RPM Upper Limit Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/integration/fome_config.txt Defines the upper limit in RPM above the target idle speed that is considered part of the idling state. For example, if the target is 800 RPM and this limit is 200 RPM, any speed below 1000 RPM is considered idle. ```C++ int16_t idlePidRpmUpperLimit;How far above idle speed do we consider idling? For example, if target = 800, this param = 200, then anything below 1000 RPM is considered idle.;"RPM", 1, 0, 0, 500, 0 ``` -------------------------------- ### Define Help URL (C) Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/config/boards/hellen/hellen154hyundai/prepend.txt This C preprocessor macro defines a URL for accessing help documentation or project-specific information. It is a simple string literal assignment. ```c #define MAIN_HELP_URL "https://rusefi.com/s/hellen154hyuindai" ``` -------------------------------- ### Create Release Branch and Tag Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/release.md This snippet demonstrates creating a new release branch from master and then creating a versioned tag on that branch. The branch and tag formats are specified for proper organization and future patch releases. ```shell git checkout -b release_YYMMDD git tag release_YYMMDD_nn git push && git push --tags ``` -------------------------------- ### Build FOME Firmware for Proteus F7 Board Source: https://context7.com/fome-tech/fome-fw/llms.txt This script builds the FOME firmware specifically for the Proteus F7 board. It first clones the repository, sets up the Linux environment including the ARM GCC toolchain, and then executes the board-specific compilation script. The output includes the full image, bootloader only, and an update file. ```bash # Clone repository git clone https://github.com/FOME-Tech/fome-fw.git cd fome-fw/firmware # Setup Linux environment (installs ARM GCC toolchain) ./setup_linux_environment.sh # Build for Proteus F7 board cd config/boards/proteus ./compile_proteus_f7.sh # Output files generated in firmware/deliver/: # - fome.bin (full image with bootloader) # - fome_bl.bin (bootloader only) # - fome_update.srec (update via bootloader) ``` -------------------------------- ### Main Help URL Definition Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/config/boards/proteus/prepend.txt Defines the URL for the main help documentation, specifically the Proteus Manual on GitHub. This is a simple string literal used for referencing external documentation. It has no functional impact on the firmware's operation. ```c #define MAIN_HELP_URL "https://github.com/rusefi/rusefi/wiki/Proteus-Manual" ``` -------------------------------- ### Injection Phase and Load/RPM Bin Configuration Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/integration/fome_config.txt Configures the injection phase based on RPM and load, along with bin definitions for load and RPM. ```c int16_t[IGN_RPM_COUNT x IGN_LOAD_COUNT] injectionPhase;"deg", 1, 0, -720, 720, 0 uint16_t[FUEL_LOAD_COUNT] injPhaseLoadBins;"Load", 1, 0, 0, 1000, 0 uint16_t[FUEL_RPM_COUNT] injPhaseRpmBins;"RPM", 1, 0, 0, 18000, 0 ``` -------------------------------- ### Configure Feature Visibility in fome-fw Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/config/boards/hellen/hellen-honda-k/prepend.txt These C preprocessor directives (`#define`) are used to control the visibility and enablement of various features within the fome-fw project. They impact settings such as tuner studio integration, hardware monitoring capabilities, and preset options. Setting a directive to `true` typically enables the feature, while `false` disables it. The `MAIN_HELP_URL` directive specifies a URL for primary help documentation. ```c #define MAIN_HELP_URL "https://rusefi.com/s/hellen154hyuindai" #define ts_show_egt false #define ts_show_etb_pins false #define ts_show_analog_divider false #define ts_show_spi true #define ts_show_sd_card true #define ts_show_can_pins false #define ts_show_tunerstudio_port false #define ts_show_can2 false #define ts_show_software_knock true #define ts_show_hardware_simulator false #define ts_show_sd_pins false #define ts_show_injectionPinMode false #define ts_show_ignitionPinMode false #define show_test_presets false #define show_Frankenso_presets false #define show_microRusEFI_presets false #define show_Proteus_presets false #define show_Hellen_hyundai_154 false ``` -------------------------------- ### Configure Preset Display Options (C/C++) Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/config/boards/hellen/hellen72/prepend.txt These macros determine which sets of pre-configured firmware settings are available for loading. This allows for easy selection of specific hardware configurations or tuning profiles. They are preprocessor directives with no runtime dependencies. ```c #define show_test_presets false #define show_Frankenso_presets false #define show_microRusEFI_presets false #define show_Proteus_presets false #define show_HellenNB2_presets true ``` -------------------------------- ### Configure Preset Visibility (C Preprocessor) Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/config/boards/hellen/hellen121vag/prepend.txt These preprocessor directives determine which sets of configuration presets are available for loading within the firmware. By setting specific defines to 'true', the corresponding presets become selectable by the user. The Hellen121vag presets are explicitly enabled in this configuration. ```c #define show_test_presets false #define show_Frankenso_presets false #define show_microRusEFI_presets false #define show_Proteus_presets false #define show_Hellen121vag_presets true ``` -------------------------------- ### Startup and Auxiliary Parameters Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/integration/fome_config.txt Settings for startup procedures and auxiliary functions. This includes the fuel pump duration on ignition, fan idle percentage, and general pin mode configurations. ```c int16_t startUpFuelPumpDuration;When ignition is turned on, turn fuel pump on to build fuel pressure;"seconds", 1, 0, 0, 6000, 0 pin_input_mode_e startStopButtonMode; uint8_t fan1ExtraIdle;Additional idle % when fan #1 is active;"%", 1, 0, 0, 100, 0 ``` -------------------------------- ### Preset Display Options (C/C++) Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/config/boards/hellen/hellen128/prepend.txt Defines boolean flags to control the visibility of different preset configurations. These macros determine whether specific preset groups like 'test', 'Frankenso', 'microRusEFI', 'Proteus', and 'Hellen128merc' are shown. These are compile-time configurations with no external dependencies. ```c #define show_test_presets false #define show_Frankenso_presets false #define show_microRusEFI_presets false #define show_Proteus_presets false #define show_Hellen128merc_presets true ``` -------------------------------- ### Enable TunerStudio Feature Displays (C/C++) Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/config/boards/hellen/hellen81/prepend.txt These directives control the visibility of specific diagnostic and configuration options within the TunerStudio interface. They are preprocessor macros that, when set to 'true', enable the corresponding display or functionality. Dependencies include the TunerStudio software and the firmware's integration with it. No direct inputs or outputs are associated with these definitions, as they are compile-time flags. Limitations may arise if a feature is enabled here but not supported by the hardware or firmware logic. ```c #define ts_show_egt true #define ts_show_etb_pins false #define ts_show_analog_divider false #define ts_show_spi true #define ts_show_sd_card true #define ts_show_can_pins false #define ts_show_tunerstudio_port false #define ts_show_can2 false #define ts_show_software_knock false #define ts_show_hardware_simulator false #define ts_show_sd_pins false ``` -------------------------------- ### Enable Preset Displays (C/C++) Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/config/boards/hellen/hellen81/prepend.txt These directives determine whether specific preset configurations are available for selection within the firmware or associated software. Setting these to 'true' makes the respective presets visible and selectable. These are compile-time options and do not have direct inputs or outputs. Their functionality is dependent on the firmware's implementation of these presets. ```c #define show_test_presets false #define show_Frankenso_presets false #define show_microRusEFI_presets false #define show_Proteus_presets false ``` -------------------------------- ### Mock Pedal Position Sensor Commands Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/integration/fome_config.txt Defines preprocessor macros for commands used to mock the Pedal Position Sensor (PPS) input, allowing for simulation and testing of throttle control systems. ```c #define MOCK_PPS_POSITION_COMMAND "mock_pps_position" #define MOCK_PPS_VOLTAGE_COMMAND "mock_pps_voltage" ``` -------------------------------- ### Configure Launch Control (C++) Source: https://context7.com/fome-tech/fome-fw/llms.txt Sets up the Launch Control system, enabling the feature and defining the input pin for activation. It configures launch conditions such as speed threshold, target RPM, and RPM window, along with ignition retard, fuel enrichment, boost control settings, and activation delay. ```cpp void configureLaunchControl() { // Enable launch control engineConfiguration->launchControlEnabled = true; // Launch button input engineConfiguration->launchActivatePin = PROTEUS_IN_D1; // Launch conditions engineConfiguration->launchSpeedThreshold = 5; // kph - disable above this speed engineConfiguration->launchRpm = 4000; // Target launch RPM engineConfiguration->launchRpmWindow = 200; // RPM window for activation // Ignition retard during launch engineConfiguration->launchTimingRetard = 10; // degrees to retard // Fuel enrichment engineConfiguration->launchFuelAdded = 10; // % extra fuel // Boost control during launch engineConfiguration->launchBoostDuty = 50; // % wastegate duty // Launch timing engineConfiguration->launchActivateDelay = 0.3f; // seconds delay before activation } ``` -------------------------------- ### Configure TunerStudio Display Options (C/C++) Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/config/boards/hellen/alphax-8chan/prepend.txt Defines preprocessor macros to control the visibility of various elements within the TunerStudio interface. These settings allow developers to customize the displayed information and input options based on hardware capabilities or desired features. No external dependencies are required as these are compile-time configurations. ```c #define ts_show_egt false #define ts_show_etb_pins false #define ts_show_analog_divider false #define ts_show_spi true #define ts_show_can_pins false #define ts_show_tunerstudio_port true #define ts_show_can2 false #define ts_show_software_knock true #define ts_show_hardware_simulator false ``` -------------------------------- ### Flash FOME Firmware using ST-Link, OpenBLT, or DFU Source: https://context7.com/fome-tech/fome-fw/llms.txt These commands illustrate different methods for flashing the compiled FOME firmware onto the ECU. The `st-flash` utility is used for a full reflash via ST-Link. For updates, the `fome_update.srec` file can be uploaded via the OpenBLT bootloader using TunerStudio or a dedicated tool. DFU mode is utilized with `dfu-util` for flashing via the STM32 USB bootloader. ```bash # Via ST-Link (blank ECU or full reflash) st-flash write deliver/fome.bin 0x08000000 # Via OpenBLT bootloader (update existing installation) # Upload fome_update.srec via TunerStudio or bootloader tool # Via DFU mode (STM32 USB bootloader) dfu-util -a 0 -s 0x08000000:leave -D deliver/fome.bin ``` -------------------------------- ### Create Patch Release Tag Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/release.md This snippet shows the process of creating a new tag for a patch release. The tag format increments the sequence number from the previous tag on the same release branch, ensuring proper sorting for subsequent patches. ```shell git tag release_YYMMDD_nn git push && git push --tags ``` -------------------------------- ### Add Custom Console Commands in C++ Source: https://context7.com/fome-tech/fome-fw/llms.txt Demonstrates how to define and register custom commands for the system's console interface. Supports commands with no parameters, integer, float, and multiple parameter types. Commands are registered using `addConsoleAction*` functions during initialization. ```cpp // Simple command with no parameters static void myCommand() { efiPrintf("Hello from my command!"); efiPrintf("Current RPM: %d", engine->rpmCalculator.getRpm()); efiPrintf("Coolant: %.1f°C", Sensor::get(SensorType::Clt).value_or(0)); } // Command with integer parameter static void setMyValue(int value) { if (value < 0 || value > 100) { efiPrintf("Value must be 0-100"); return; } engineConfiguration->myCustomValue = value; efiPrintf("Set value to %d", value); } // Command with float parameter static void setMyFloatValue(float value) { engineConfiguration->myFloatValue = value; efiPrintf("Set float value to %.2f", value); } // Command with two parameters static void setMyTwoValues(int value1, float value2) { efiPrintf("Setting values: %d and %.2f", value1, value2); } // Register commands during initialization void initMyConsoleCommands() { addConsoleAction("mycommand", myCommand); addConsoleActionI("setvalue", setMyValue); addConsoleActionF("setfloat", setMyFloatValue); addConsoleActionIF("settwo", setMyTwoValues); } ``` -------------------------------- ### Common Console Commands Source: https://context7.com/fome-tech/fome-fw/llms.txt Lists essential built-in commands for interacting with the ECU console. These include commands for displaying help, system information, thread status, getting/setting configuration values, rebooting the system, and triggering test errors. ```bash # Get help > help # System information > info # Thread information > threadsinfo # Get configuration value > get cylindersCount cylindersCount = 4 # Set configuration value > set cylindersCount 6 cylindersCount = 6 # Reboot ECU > reboot # Jump to bootloader for firmware update > reboot_dfu # Trigger error (for testing) > error # Trigger critical error > critical ``` -------------------------------- ### Boost Control Tables (Open and Closed Loop) Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/integration/fome_config.txt Configuration for boost control, including both open-loop and closed-loop strategies. Defines RPM and load (TPS) bins for mapping boost targets. The closed-loop table includes separate X and Y axis bins. ```c uint8_t[BOOST_RPM_COUNT x BOOST_LOAD_COUNT] autoscale boostTableOpenLoop; //"", {1/2}, 0, 0, 100, 1 int16_t[BOOST_RPM_COUNT] boostRpmBins; //"", 1, 0, -10000, 10000, 0 int16_t[BOOST_LOAD_COUNT] boostTpsBins; //"", 1, 0, -10000, 10000, 0 uint8_t[BOOST_RPM_COUNT x BOOST_LOAD_COUNT] autoscale boostTableClosedLoop; //"", 2, 0, 0, 3000, 0 int16_t[BOOST_RPM_COUNT] boostClosedLoopXAxisBins; //"", 1, 0, -10000, 10000, 0 int16_t[BOOST_LOAD_COUNT] boostClosedLoopYAxisBins; //"", 1, 0, -10000, 10000, 0 ``` -------------------------------- ### Configure TunerStudio Display Options (C/C++) Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/config/boards/hellen/hellen-nb1/prepend.txt These C preprocessor directives control the visibility of various options within the TunerStudio interface. They determine whether specific sensor readings, pin configurations, and communication interfaces are displayed. These settings are static and compiled into the firmware. ```c #define MAIN_HELP_URL "https://rusefi.com/s/hellenNB1" #define ts_show_egt false #define ts_show_etb_pins false #define ts_show_analog_divider false #define ts_show_spi true #define ts_show_sd_card true #define ts_show_can_pins false #define ts_show_tunerstudio_port true #define ts_show_can2 false #define ts_show_software_knock true #define ts_show_hardware_simulator false #define ts_show_sd_pins false ``` -------------------------------- ### Configure Boost Control (C++) Source: https://context7.com/fome-tech/fome-fw/llms.txt Enables and configures the Boost Control system, assigning the wastegate solenoid output pin and PWM frequency. It includes setting up open-loop boost pressure tables and PID tuning parameters for closed-loop control, along with safety cut-off pressure. ```cpp void configureBoostControl() { // Enable boost control engineConfiguration->isBoostControlEnabled = true; // Wastegate solenoid output engineConfiguration->boostControlPin = PROTEUS_LS_6; engineConfiguration->boostPwmFrequency = 30; // Hz // Target boost pressure (kPa) engineConfiguration->boostTableOpenLoop[0][0] = 100; // Low RPM, low TPS engineConfiguration->boostTableOpenLoop[7][7] = 180; // High RPM, high TPS // Fill remaining table values... // PID tuning for closed-loop control engineConfiguration->boostPid.pFactor = 0.5f; engineConfiguration->boostPid.iFactor = 0.01f; engineConfiguration->boostPid.dFactor = 0.0f; engineConfiguration->boostPid.periodMs = 100; // Boost safety limits engineConfiguration->boostCutPressure = 200; // kPa - fuel cut if exceeded } ``` -------------------------------- ### Command Definitions (C) Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/integration/fome_config.txt Defines for various commands used to interact with the Fome FW system. These cover setting parameters, diagnostic bench tests, pin configurations, and operational modes. ```c #define CMD_SET "set" #define CMD_GET "get" #define CMD_ENGINESNIFFERRPMTHRESHOLD "engineSnifferRpmThreshold" #define CMD_MIL_BENCH "milbench" #define CMD_FUEL_BENCH "fuelbench" #define CMD_FUEL_PUMP_BENCH "fuelpumpbench" #define CMD_IDLE_BENCH "idlebench" #define CMD_SPARK_BENCH "sparkbench" #define CMD_STARTER_BENCH "starterbench" #define CMD_HPFP_BENCH "hpfpbench" #define CMD_AC_RELAY_BENCH "acrelaybench" #define CMD_FAN_BENCH "fanbench" #define CMD_FAN2_BENCH "fan2bench" #define CMD_PINS "pins" #define CMD_ETB_DUTY "set_etb_duty" #define CMD_SELF_STIMULATION "self_stimulation" #define CMD_EXTERNAL_STIMULATION "ext_stimulation" #define CMD_RPM "rpm" #define CMD_VSS_PIN "vss_pin" #define CMD_TRIGGER_PIN "set_trigger_input_pin" #define CMD_LOGIC_PIN "set_logic_input_pin" #define CMD_ALTERNATOR_PIN "set_alternator_pin" #define CMD_IDLE_PIN "set_idle_pin" #define CMD_BOOST_PIN "set_boost_pin" #define CMD_TRIGGER_SIMULATOR_PIN "set_trigger_simulator_pin" #define CMD_IGNITION_PIN "set_ignition_pin" #define CMD_RESET_ENGINE_SNIFFER "reset_engine_chart" #define CMD_FUNCTIONAL_TEST_MODE "test_mode" #define CMD_ENGINE_TYPE "engine_type" #define CMD_INJECTION "injection" #define CMD_IGNITION "ignition" #define CMD_PWM "pwm" #define CMD_TRIGGERINFO "triggerinfo" #define CMD_WRITECONFIG "writeconfig" #define CMD_BURNCONFIG "burnconfig" #define CMD_DATE "date" #define CMD_REBOOT "reboot" #define CMD_REBOOT_DFU "reboot_dfu" #define CMD_REBOOT_OPENBLT "reboot_openblt" #define CMD_ENABLE "enable" #define CMD_DISABLE "disable" #define CMD_TRIGGER_HW_INPUT "trigger_hw_input" ``` -------------------------------- ### TunerStudio Protocol Command Definitions (C) Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/integration/fome_config.txt Defines representing commands and responses used for communication between the Fome FW device and TunerStudio. This includes commands for querying information, sending data, and controlling device modes. ```c #define TS_PROTOCOL "001" ! These commands are used by TunerStudio and the FOME console ! 0x4F ochGetCommand #define TS_OUTPUT_COMMAND 'O' ! 0x53 queryCommand #define TS_HELLO_COMMAND 'S' ! todo: replace all usages of TS_HELLO_COMMAND with TS_QUERY_COMMAND ! TS auto-detect depends on well-known queryCommand value 'Q' #define TS_QUERY_COMMAND 'Q' ! 0x6B 107 #define TS_CRC_CHECK_COMMAND 'k' ! 0x52 82 #define TS_READ_COMMAND 'R' ! 0x47 #define TS_GET_TEXT 'G' ! 0x45 #define TS_EXECUTE 'E' #define TS_ONLINE_PROTOCOL 'z' #define TS_QUERY_BOOTLOADER 'L' #define TS_QUERY_BOOTLOADER_NONE 0 #define TS_QUERY_BOOTLOADER_OPENBLT 1 ! Performance tracing #define TS_PERF_TRACE_BEGIN '_' #define TS_PERF_TRACE_GET_BUFFER 'b' ! 0x46 #define TS_COMMAND_F 'F' #define TS_GET_PROTOCOL_VERSION_COMMAND_F 'F' ! versionInfo 0x56 86 #define TS_GET_FIRMWARE_VERSION 'V' ! returns getFirmwareError(), works together with ind_hasFatalError #define TS_GET_CONFIG_ERROR 'e' ! 0x57 pageValueWrite #define TS_SINGLE_WRITE_COMMAND 'W' ! 0x43 pageChunkWrite #define TS_CHUNK_WRITE_COMMAND 'C' ! 0x42 burnCommand #define TS_BURN_COMMAND 'B' ! 0x77 #define TS_IO_TEST_COMMAND 'Z' #define TS_RESPONSE_OK 0 #define TS_RESPONSE_BURN_OK 4 ! Engine Sniffer time stamp unit, in microseconds #define ENGINE_SNIFFER_UNIT_US 10 ! High speed logger commands #define TS_SET_LOGGER_SWITCH 'l' #define TS_COMPOSITE_ENABLE 1 #define TS_COMPOSITE_DISABLE 2 #define TS_COMPOSITE_READ 3 #define TS_TRIGGER_SCOPE_ENABLE 4 #define TS_TRIGGER_SCOPE_DISABLE 5 #define TS_TRIGGER_SCOPE_READ 6 ! Generic channel names, your board may want to override these #define TS_TRIGGER_SCOPE_CHANNEL_1_NAME "Channel 1" #define TS_TRIGGER_SCOPE_CHANNEL_2_NAME "Channel 2" #define PROTOCOL_COIL1_SHORT_NAME "c1" #define PROTOCOL_INJ1_SHORT_NAME "i1" #define PROTOCOL_INJ1_STAGE2_SHORT_NAME "j1" ! some board files override this value using prepend file #define ts_show_vr_threshold_all true ``` -------------------------------- ### Configure Preset Display Macros Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/config/boards/hellen/hellen-gm-e67/prepend.txt These C preprocessor macros determine which preset configurations are displayed or available within the Fome-FW project. They are boolean flags used to filter or enable specific preset types. No external dependencies are required. For instance, enabling Hellen presets. ```c #define show_test_presets false #define show_Frankenso_presets false #define show_microRusEFI_presets false #define show_Proteus_presets false #define show_Hellen_presets true ``` -------------------------------- ### Initialize and Update Git Submodules Source: https://github.com/fome-tech/fome-fw/blob/master/misc/git_scripts/git_cheat_sheet.txt These commands are used to download and initialize submodules within a Git repository. The first command initializes new submodules, while the second recursively updates existing ones and fetches the latest changes from their remote repositories. ```bash git submodule update --init ``` ```bash git submodule update --recursive --remote ``` -------------------------------- ### Instantaneous RPM and Test Bench Iteration (C) Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/console/binary/output_channels.txt Variables to record the instantaneous engine RPM and a counter for test bench iterations. ```c uint16_t instantRpm;;"rpm", 1, 0, 0, 0, 0 uint16_t testBenchIter;;"count",1, 0, 0, 0, 0 ``` -------------------------------- ### Configure Preset Options (C) Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/config/boards/hellen/hellen154hyundai/prepend.txt These C preprocessor macros determine which presets are available or displayed within the firmware's interface. Setting them to 'true' enables the respective preset option. These are compiled into the firmware. ```c #define show_test_presets false #define show_Frankenso_presets false #define show_microRusEFI_presets false #define show_Proteus_presets false #define show_Hellen_hyundai_154 true ``` -------------------------------- ### Configure TunerStudio Feature Visibility (C) Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/config/boards/microrusefi/prepend.txt These C preprocessor directives control which features and UI elements are displayed or enabled within the TunerStudio software. They are used to customize the firmware's behavior based on the hardware and desired functionality. No external dependencies are required, and the input is implicit through the definition values. ```c #define MAIN_HELP_URL "https://rusefi.com/s/microrusefi" #define ts_show_egt true #define ts_show_etb_pins false #define ts_show_analog_divider false #define ts_show_spi true #define ts_show_sd_card true #define ts_show_can_pins false #define ts_show_tunerstudio_port false #define ts_show_main_relay false #define ts_show_main_relay_microRusEFI_message true #define ts_show_can2 false #define ts_show_software_knock true #define ts_show_hardware_simulator false #define ts_show_sd_pins true #define ts_show_vbatt false #define ts_show_clt_iat_pullup false #define ts_show_inj_fault true #define ts_show_tle8888 true #define show_test_presets false #define show_Frankenso_presets false #define show_microRusEFI_presets true ``` -------------------------------- ### Ignition and IAT Correction Table Configuration Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/integration/fome_config.txt Sets up ignition timing correction based on IAT and load. Includes a 2D table for ignition correction and bin definitions for temperature, load, and RPM. ```c int8_t[8 x 8] autoscale ignitionIatCorrTable;"deg", 0.1, 0, -25, 25, 1 int8_t[8] ignitionIatCorrTempBins;"C", 1, 0, -40, 120, 0 uint8_t[8] autoscale ignitionIatCorrLoadBins;"Load", 5, 0, 0, 1000, 0 ``` -------------------------------- ### Configure Preset Display Options (C/C++) Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/config/boards/hellen/hellen-nb1/prepend.txt These C preprocessor directives determine which firmware presets are available or displayed. They allow for conditional compilation of different preset configurations, enabling specific hardware or software profiles. These settings are determined at compile time. ```c #define show_test_presets false #define show_Frankenso_presets false #define show_microRusEFI_presets false #define show_Proteus_presets false #define show_Hellen_presets true #define show_HellenNB1_presets true ``` -------------------------------- ### Starter State and Multi-Spark Counter (C) Source: https://github.com/fome-tech/fome-fw/blob/master/firmware/console/binary/output_channels.txt Variables to track the state of the starter motor, whether the starter relay is disabled, and the count of multi-spark events during ignition. ```c uint8_t starterState;;"", 1, 0, -10000, 10000, 3 uint8_t starterRelayDisable;;"", 1, 0, -10000, 10000, 3 uint8_t multiSparkCounter;Ign: Multispark count;"", 1, 0, -10000, 10000, 3 ```