Skip to content

Commit 4b1ec7d

Browse files
committed
mini6ch: add the secondary TunerStudio channel for Bluetooth
The board had no secondary channel at all. Every line of it sits behind #ifdef TS_SECONDARY_UxART_PORT and no Mazduino board defined that, so the binarySerial pins in TunerStudio were inert and the ECU never wrote a byte towards a Bluetooth module - the module still paired and still looked connected, because that is between the module and the phone. Uses the ChibiOS Serial driver on USART3 (SD3), the way the reference f407-discovery board does it. The UART driver would have needed HAL_USE_UART, and halconf.h only turns that on when TS_PRIMARY_UxART_PORT is defined - upstream rusEFI has the same condition, which is why upstream never hit it: no board there drives a secondary channel off the UART driver. Pin defaults are PB10/PB11 (TXD3/RXD3 on this board). rusEFI's own defaults are PC10/PC11, which every Mazduino board uses for the SD card on SPI3. PB10/PB11 are free on mini6ch; on mazduino-lite and -core they carry the LPS25 baro, so this is not portable to those boards as-is. Baud follows tunerStudioSerialSpeed, 38400 by default, and the channel is started once at boot - changing that value needs an ECU restart, not just a burn. 38400 is also where HC-05 and JDY modules stop keeping up: 115200 was tried on hardware and broke config page reads outright, because the limit is SPP forwarding rather than the UART. Costs 3.4KB of flash and no RAM. mazduino-mini6ch-bigfuel picks it up too, sharing the same board.mk.
1 parent 20e8bbb commit 4b1ec7d

9 files changed

Lines changed: 287 additions & 23 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ All notable changes to Mazduino firmware are documented here.
99
- LTFT trim map now has its own axes (`ltftLoadBins` / `ltftRpmBins`) instead of borrowing the VE table axes. Every board gains these two fields, so all boards need a matching firmware and INI; table dimensions are unchanged on existing boards, so tune values still carry over
1010

1111
### Added
12+
- mazduino-mini6ch: secondary TunerStudio channel on USART3 (PB10 = TXD3, PB11 = RXD3), for a Bluetooth module such as an HC-05. The firmware previously had no secondary channel at all — the whole thing is behind `#ifdef TS_SECONDARY_UxART_PORT` and no Mazduino board defined it, so the `binarySerial` pins in TunerStudio did nothing and the ECU never sent a byte to the module. Uses the ChibiOS Serial driver (SD3), the same way the reference f407-discovery board does; the UART driver would need `HAL_USE_UART`, which halconf.h only enables when `TS_PRIMARY_UxART_PORT` is defined. Pin defaults are PB10/PB11 because rusEFI's own defaults, PC10/PC11, are the SD card's SPI3 pins on every Mazduino board. Baud follows `tunerStudioSerialSpeed` (38400 by default), and the channel is started once at boot, so changing that value needs an ECU restart, not just a burn. Applies to mazduino-mini6ch-bigfuel too
1213
- BIGFUEL board variants: `mazduino-compact-bigfuel`, `mazduino-core-bigfuel`, `mazduino-lite-bigfuel` and `mazduino-mini6ch-bigfuel`. Identical hardware and pinout to the board they are named after, with a 32x32 VE table and 32x32 ignition table (stock boards stay 16x16) for finer resolution on high-output builds. Tunes are not interchangeable between a board and its BIGFUEL variant
1314
- BIGFUEL variants trade the engine sniffer for the bigger tables: the persistent config lives in the 64KB CCM RAM and its leftovers feed the Lua heap, so 32x32 tables overflowed CCM by ~1.4KB. Disabling the engine sniffer frees its 5000-byte `WAVE_LOGGING_BUFFER` from CCM. All other features are unchanged from the base board — the real-time trigger oscilloscope in TunerStudio is the only thing missing
1415
- Separate `LTFT_LOAD_COUNT` / `LTFT_RPM_COUNT` sizing for the long-term fuel trim map, independent of the VE table. The learned trim map stays 16x16 even on BIGFUEL boards, saving 6KB of RAM versus following a 32x32 VE table, with no loss of tuning resolution. LTFT trims are now interpolated onto the VE table when applied, so the two grids no longer have to match

‎boards/mazduino-mini6ch/board.mk‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ endif
1616
# the flash-size register, and both parts are 1MB, so they match. Both chips
1717
# run at 168MHz, keeping USB 48MHz exact (PLLN=336, PLLQ=7).
1818

19+
# Secondary TunerStudio channel on USART3 (PB10 = TXD3, PB11 = RXD3), for a
20+
# Bluetooth module such as an HC-05. Without TS_SECONDARY_UxART_PORT the whole
21+
# secondary channel is compiled out (tunerstudio_io_serial_ports.cpp) and the
22+
# binarySerial pins in TunerStudio do nothing at all.
23+
#
24+
# Uses the ChibiOS Serial driver (SD3), matching how the reference f407-discovery
25+
# board wires up its secondary channel. The UART driver would need HAL_USE_UART,
26+
# which halconf.h only turns on when TS_PRIMARY_UxART_PORT is defined.
27+
DDEFS += -DSTM32_SERIAL_USE_USART3=TRUE -DSTM32_SERIAL_USART3_PRIORITY=6
28+
DDEFS += -DTS_SECONDARY_UxART_PORT=SD3 -DEFI_TS_SECONDARY_IS_SERIAL=TRUE
29+
1930
DDEFS += -DEFI_WIDEBAND_FIRMWARE_UPDATE=FALSE
2031
DDEFS += -DRAM_UNUSED_SIZE=100
2132
DDEFS += -DSTM32_ADC_USE_ADC3=TRUE

‎boards/mazduino-mini6ch/board_configuration.cpp‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@ static void customBoardDefaultConfiguration() {
7878
engineConfiguration->canTxPin = Gpio::D1;
7979
engineConfiguration->canRxPin = Gpio::D0;
8080

81+
// Secondary TS channel (Bluetooth) on USART3. rusEFI defaults these to
82+
// PC10/PC11, which this board uses for the SD card on SPI3, so the default
83+
// would collide. PB10/PB11 are free on mini6ch (mazduino-lite and -core use
84+
// them for the LPS25 baro; mini6ch has no baro fitted).
85+
// Wiring: PB10 -> HC-05 RXD, PB11 <- HC-05 TXD.
86+
engineConfiguration->binarySerialTxPin = Gpio::B10;
87+
engineConfiguration->binarySerialRxPin = Gpio::B11;
88+
8189
// SD card - SPI3
8290
engineConfiguration->is_enabled_spi_3 = true;
8391
engineConfiguration->spi3mosiPin = Gpio::C12;

‎generated/controllers/generated/page_4_generated.h‎

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,92 +12,92 @@ struct page4_s {
1212
scaled_channel<uint16_t, 10, 1> secondVeTable[VE_LOAD_COUNT][VE_RPM_COUNT] = {};
1313
/**
1414
* units: {bitStringValue(veLoadUnitLabels, veLoadUnitIdxPcv)}
15-
* offset 2048
15+
* offset 512
1616
*/
1717
uint16_t secondVeLoadBins[VE_LOAD_COUNT] = {};
1818
/**
1919
* units: RPM
20-
* offset 2112
20+
* offset 544
2121
*/
2222
uint16_t secondVeRpmBins[VE_RPM_COUNT] = {};
2323
/**
2424
* Pin that activates the second VE table (hard switch, overrides blend)
25-
* offset 2176
25+
* offset 576
2626
*/
2727
switch_input_pin_e secondVeTableInput;
2828
/**
29-
* offset 2178
29+
* offset 578
3030
*/
3131
pin_input_mode_e secondVeTableInputMode;
3232
/**
3333
* Input that controls the blend ratio between primary and second VE table
34-
* offset 2179
34+
* offset 579
3535
*/
3636
gppwm_channel_e secondVeBlendParameter;
3737
/**
38-
* offset 2180
38+
* offset 580
3939
*/
4040
scaled_channel<int16_t, 10, 1> secondVeBlendBins[BLEND_FACTOR_SIZE] = {};
4141
/**
4242
* units: %
43-
* offset 2196
43+
* offset 596
4444
*/
4545
scaled_channel<uint8_t, 2, 1> secondVeBlendValues[BLEND_FACTOR_SIZE] = {};
4646
/**
4747
* units: deg
48-
* offset 2204
48+
* offset 604
4949
*/
5050
scaled_channel<int16_t, 10, 1> secondIgnitionTable[IGN_LOAD_COUNT][IGN_RPM_COUNT] = {};
5151
/**
5252
* units: {bitStringValue(ignLoadUnitLabels, ignLoadUnitIdxPcv)}
53-
* offset 4252
53+
* offset 1116
5454
*/
5555
uint16_t secondIgnitionLoadBins[IGN_LOAD_COUNT] = {};
5656
/**
5757
* units: RPM
58-
* offset 4316
58+
* offset 1148
5959
*/
6060
uint16_t secondIgnitionRpmBins[IGN_RPM_COUNT] = {};
6161
/**
6262
* Pin that activates the second ignition table (hard switch, overrides blend)
63-
* offset 4380
63+
* offset 1180
6464
*/
6565
switch_input_pin_e secondIgnitionTableInput;
6666
/**
67-
* offset 4382
67+
* offset 1182
6868
*/
6969
pin_input_mode_e secondIgnitionTableInputMode;
7070
/**
7171
* Input that controls the blend ratio between primary and second ignition table
72-
* offset 4383
72+
* offset 1183
7373
*/
7474
gppwm_channel_e secondIgnitionBlendParameter;
7575
/**
76-
* offset 4384
76+
* offset 1184
7777
*/
7878
scaled_channel<int16_t, 10, 1> secondIgnitionBlendBins[BLEND_FACTOR_SIZE] = {};
7979
/**
8080
* units: %
81-
* offset 4400
81+
* offset 1200
8282
*/
8383
scaled_channel<uint8_t, 2, 1> secondIgnitionBlendValues[BLEND_FACTOR_SIZE] = {};
8484
/**
8585
* units: Nm
86-
* offset 4408
86+
* offset 1208
8787
*/
8888
scaled_channel<uint8_t, 1, 10> torqueTable[TORQUE_CURVE_SIZE][TORQUE_CURVE_RPM_SIZE] = {};
8989
/**
9090
* units: RPM
91-
* offset 4444
91+
* offset 1244
9292
*/
9393
uint16_t torqueRpmBins[TORQUE_CURVE_RPM_SIZE] = {};
9494
/**
9595
* units: Load
96-
* offset 4456
96+
* offset 1256
9797
*/
9898
uint16_t torqueLoadBins[TORQUE_CURVE_SIZE] = {};
9999
};
100-
static_assert(sizeof(page4_s) == 4468);
100+
static_assert(sizeof(page4_s) == 1268);
101101

102102
// end
103103
// this section was generated automatically by rusEFI tool config_definition-all.jar based on gen_config.sh integration/config_page_4.txt

0 commit comments

Comments
 (0)