From 0cedba8c4e1b1a4486d1119b6919b95c38eb7f8f Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Wed, 28 Aug 2024 02:11:37 -0700 Subject: [PATCH 1/5] all ECUs can use big blocking factor! --- firmware/config/boards/atlas/prepend.txt | 2 -- firmware/config/boards/nucleo_f767/prepend.txt | 1 - firmware/config/boards/proteus/prepend.txt | 1 - firmware/console/binary/tunerstudio_commands.cpp | 9 +++++---- firmware/console/usb_console.cpp | 1 - firmware/integration/rusefi_config.txt | 2 +- 6 files changed, 6 insertions(+), 10 deletions(-) diff --git a/firmware/config/boards/atlas/prepend.txt b/firmware/config/boards/atlas/prepend.txt index 787227bf91..a0b0fc96ab 100644 --- a/firmware/config/boards/atlas/prepend.txt +++ b/firmware/config/boards/atlas/prepend.txt @@ -3,5 +3,3 @@ ! Atlas is guaranteed dual bank flash, so there's no delay when sending the burn command. ! All commands should complete effectively instantly. #define TS_BLOCK_READ_TIMEOUT 250 - -#define BLOCKING_FACTOR 1500 diff --git a/firmware/config/boards/nucleo_f767/prepend.txt b/firmware/config/boards/nucleo_f767/prepend.txt index 1615a2926b..e69de29bb2 100644 --- a/firmware/config/boards/nucleo_f767/prepend.txt +++ b/firmware/config/boards/nucleo_f767/prepend.txt @@ -1 +0,0 @@ -#define BLOCKING_FACTOR 1500 diff --git a/firmware/config/boards/proteus/prepend.txt b/firmware/config/boards/proteus/prepend.txt index e13a2547d7..79c6dda983 100644 --- a/firmware/config/boards/proteus/prepend.txt +++ b/firmware/config/boards/proteus/prepend.txt @@ -23,4 +23,3 @@ #define show_Proteus_presets true #define LUA_SCRIPT_SIZE 12000 -#define BLOCKING_FACTOR 1500 diff --git a/firmware/console/binary/tunerstudio_commands.cpp b/firmware/console/binary/tunerstudio_commands.cpp index 74a4018213..ea946b3065 100644 --- a/firmware/console/binary/tunerstudio_commands.cpp +++ b/firmware/console/binary/tunerstudio_commands.cpp @@ -42,6 +42,9 @@ static Timer requestPeriodTimer; * Gauges refresh */ void TunerStudio::cmdOutputChannels(TsChannelBase* tsChannel, uint16_t offset, uint16_t count) { + // Assert that the entire output channels block will fit in a single TS transaction + static_assert(BLOCKING_FACTOR >= TS_TOTAL_OUTPUT_SIZE + 10); + if (offset + count > TS_TOTAL_OUTPUT_SIZE) { efiPrintf("TS: Version Mismatch? Too much outputs requested %d/%d/%d", offset, count, sizeof(TunerStudioOutputChannels)); @@ -49,10 +52,8 @@ void TunerStudio::cmdOutputChannels(TsChannelBase* tsChannel, uint16_t offset, u return; } - if (offset < BLOCKING_FACTOR) { - engine->outputChannels.outputRequestPeriod - = 1e6 * requestPeriodTimer.getElapsedSecondsAndReset(getTimeNowNt()); - } + engine->outputChannels.outputRequestPeriod + = 1e6 * requestPeriodTimer.getElapsedSecondsAndReset(getTimeNowNt()); tsState.outputChannelsCommandCounter++; updateTunerStudioState(); diff --git a/firmware/console/usb_console.cpp b/firmware/console/usb_console.cpp index b8048f9405..57eeb2f4a7 100644 --- a/firmware/console/usb_console.cpp +++ b/firmware/console/usb_console.cpp @@ -6,7 +6,6 @@ #include "thread_controller.h" #include "tunerstudio.h" - // Assert that the USB tx/rx buffers are large enough to fit one full packet static_assert(SERIAL_USB_BUFFERS_SIZE >= BLOCKING_FACTOR + 10); diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 277009c6b3..4f4d66d3e5 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -106,7 +106,7 @@ struct_no_prefix persistent_config_s struct_no_prefix engine_configuration_s -#define BLOCKING_FACTOR 750 +#define BLOCKING_FACTOR 1400 #define SENT_INPUT_COUNT 1 From f20516a506755a622b440c9de31288ee52afa48e Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Wed, 28 Aug 2024 03:04:56 -0700 Subject: [PATCH 2/5] reclaim 100 bytes of blocking factor --- firmware/console/binary/output_channels.txt | 2 -- firmware/integration/rusefi_config.txt | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/firmware/console/binary/output_channels.txt b/firmware/console/binary/output_channels.txt index 6891f765dc..7d9e5dd18e 100644 --- a/firmware/console/binary/output_channels.txt +++ b/firmware/console/binary/output_channels.txt @@ -371,6 +371,4 @@ float mapFast uint16_t mapAveragingSamples uint8_t[12 iterate] mapPerCylinder;;"kPa", 1, 0, 0, 0, 0 - - uint8_t[102 iterate] unusedAtTheEnd;;"",1, 0, 0, 0, 0 end_struct diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 4f4d66d3e5..d3305c6622 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -106,7 +106,7 @@ struct_no_prefix persistent_config_s struct_no_prefix engine_configuration_s -#define BLOCKING_FACTOR 1400 +#define BLOCKING_FACTOR 1300 #define SENT_INPUT_COUNT 1 From e24d596053071f59e05efc533949ed29a1eff031 Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Thu, 29 Aug 2024 13:22:50 -0700 Subject: [PATCH 3/5] fits on ethernet f4 --- firmware/config/stm32f4ems/efifeatures.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/config/stm32f4ems/efifeatures.h b/firmware/config/stm32f4ems/efifeatures.h index 243b6ac985..ab0a36e260 100644 --- a/firmware/config/stm32f4ems/efifeatures.h +++ b/firmware/config/stm32f4ems/efifeatures.h @@ -262,7 +262,7 @@ #if MODULE_ETHERNET_CONSOLE // F4 ethernet needs some extra space - #define LUA_USER_HEAP 40000 + #define LUA_USER_HEAP 25000 #else // MODULE_ETHERNET_CONSOLE #define LUA_USER_HEAP 50000 #endif From 589a10e962b1697ce5188289c3a4e0ef72703336 Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Fri, 30 Aug 2024 10:50:09 -0700 Subject: [PATCH 4/5] ch-ch-ch-ch-changelog --- firmware/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/firmware/CHANGELOG.md b/firmware/CHANGELOG.md index a2020aba28..dabebe5651 100644 --- a/firmware/CHANGELOG.md +++ b/firmware/CHANGELOG.md @@ -53,6 +53,7 @@ or - Fix decel fuel cutoff (DFCO) on engines without a MAP sensor #457 - Automatic calculation of knock sense frequency based on cylinder bore #379 - Removed MAP sampling option that can result in inaccurate MAP sensor readings + - Improve TunerStudio performance on STM32F4-based ECUs #474 ## December 2023 Release From 3c028cf5ce2029787625c3f3b98253df5e8f01c3 Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Fri, 30 Aug 2024 10:57:26 -0700 Subject: [PATCH 5/5] bump it a little --- firmware/integration/rusefi_config.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 9be2c4b9dc..8129c9addd 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -106,7 +106,7 @@ struct_no_prefix persistent_config_s struct_no_prefix engine_configuration_s -#define BLOCKING_FACTOR 1300 +#define BLOCKING_FACTOR 1320 #define SENT_INPUT_COUNT 1