Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,17 @@ Icon
Network Trash Folder
Temporary Items
.apdisk
build-mikrus.sh
build-yellowbox.sh
.vscode/launch.json
flash-yellowbox.sh
flash-mikrus.sh
firmware/hw_layer/mass_storage/ramdisk_image_compressed.h
firmware/hw_layer/mass_storage/ramdisk_image.h
/current_console_output
build-console.sh
build-mikrus.sh
firmware/config/boards/yellowbox/README.md
firmware/config/boards/yellowbox/pinmap.txt
firmware/hw_layer/mass_storage/ramdisk_image_compressed.h
firmware/hw_layer/mass_storage/ramdisk_image.h
31 changes: 31 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,37 @@
"configFiles": ["interface/stlink.cfg", "target/stm32h7x.cfg"],
"rtos": "auto",
"gdbPath": "${workspaceRoot}/firmware/ext/build-tools/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-gdb"
},
{
"name": "Debug Yellowbox",
"type": "cortex-debug",
// Use "attach" - do NOT reflash. Flash manually with flash-yellowbox.sh first.
// "launch" would overwrite the board with the raw ELF (no checksum), breaking bootloader integrity check.
"request": "attach",
"cwd": "${workspaceFolder}/firmware",
"executable": "${workspaceRoot}/firmware/build/fome.elf",
"device": "STM32H743V",
"v1": false,
"svdFile": "${workspaceRoot}/firmware/ext/cmsis-svd/STM32H743x.svd",
"servertype": "openocd",
"configFiles": ["interface/stlink.cfg", "target/stm32h7x.cfg"],
"rtos": "auto",
"gdbPath": "/usr/bin/gdb-multiarch"
},
{
"name": "Debug Yellowbox Bootloader",
"type": "cortex-debug",
// Use "attach" - do NOT reflash. Flash manually with flash-yellowbox.sh first.
"request": "attach",
"cwd": "${workspaceFolder}/firmware",
"executable": "${workspaceRoot}/firmware/bootloader/blbuild/fome_bl.elf",
"device": "STM32H743V",
"v1": false,
"svdFile": "${workspaceRoot}/firmware/ext/cmsis-svd/STM32H743x.svd",
"servertype": "openocd",
"configFiles": ["interface/stlink.cfg", "target/stm32h7x.cfg"],
"rtos": "auto",
"gdbPath": "/usr/bin/gdb-multiarch"
}
]
}
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@
"editor.formatOnSave": true
},
"C_Cpp.clang_format_style": "file",
"cortex-debug.variableUseNaturalFormat": false,
}
Empty file added ISR
Empty file.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// DO NOT EDIT MANUALLY, let automation work hard.

// auto-generated by PinoutLogic.java based on config/boards/atlas/connectors/analog.yaml
// auto-generated by PinoutLogic.java based on config/boards/atlas/connectors/can.yaml
// auto-generated by PinoutLogic.java based on config/boards/atlas/connectors/digital_in.yaml
// auto-generated by PinoutLogic.java based on config/boards/atlas/connectors/outputs.yaml
// auto-generated by PinoutLogic.java based on /home/dflak/fome-fw/firmware/config/boards/atlas/connectors/analog.yaml
// auto-generated by PinoutLogic.java based on /home/dflak/fome-fw/firmware/config/boards/atlas/connectors/can.yaml
// auto-generated by PinoutLogic.java based on /home/dflak/fome-fw/firmware/config/boards/atlas/connectors/digital_in.yaml
// auto-generated by PinoutLogic.java based on /home/dflak/fome-fw/firmware/config/boards/atlas/connectors/outputs.yaml
#include "pch.h"

// see comments at declaration in pin_repository.h
Expand Down
Empty file modified firmware/config/boards/core48/compile_core48.sh
100644 → 100755
Empty file.
Empty file modified firmware/config/boards/core8/compile_core8.sh
100644 → 100755
Empty file.
Empty file modified firmware/config/boards/frankenso/compile_frankenso_na6.sh
100644 → 100755
Empty file.
Empty file.
Empty file modified firmware/config/boards/hellen/harley81/compile_harley81.sh
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file modified firmware/config/boards/hellen/hellen128/compile_hellen128.sh
100644 → 100755
Empty file.
Empty file.
Empty file modified firmware/config/boards/hellen/hellen72/compile_hellen72.sh
100644 → 100755
Empty file.
Empty file modified firmware/config/boards/microrusefi/compile_mre_f4_recovery.sh
100644 → 100755
Empty file.
34 changes: 34 additions & 0 deletions firmware/config/boards/yellowbox/board.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Yellowbox board - STM32H743VIT

PROJECT_CPU = ARCH_STM32H7

# List of all the board related files.
BOARDCPPSRC = $(BOARD_DIR)/board_configuration.cpp

# Error LED is red PE3
DDEFS += -DLED_CRITICAL_ERROR_BRAIN_PIN=Gpio::E3

DDEFS += -DFIRMWARE_ID=\"yellowbox\"
DDEFS += -DDEFAULT_ENGINE_TYPE=MINIMAL_PINS

# ADC3 is needed for AN5 (PC2) and AN6 (PC3) which are ADC3-only on STM32H743.
# No knock sensor on this board - software knock is not enabled.
DDEFS += -DSTM32_ADC_USE_ADC3=TRUE

# SDMMC1 for SD card.
# IMPORTANT: only 1-bit wired (CMD=PD2, CLK=PC12, DAT0=PC8).
# To use 4-bit mode a future hardware revision must also wire PC9/PC10/PC11.
DDEFS += -DEFI_SDC_DEVICE=SDCD1
DDEFS += -DEFI_SDC_MODE=SDC_MODE_1BIT
DDEFS += -DBOARD_OTG_NOVBUSSENS=TRUE
# 32kHz crystal on PC14/PC15 (no bypass - crystal, not external oscillator signal)

# WiFi ATWINC1500 on SPI1
USE_WIFI = yes

# Enable the SD card bootloader
SD_BOOTLOADER = yes

DDEFS += -DHW_YELLOWBOX=1

SHORT_BOARD_NAME = yellowbox
181 changes: 181 additions & 0 deletions firmware/config/boards/yellowbox/board_configuration.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
/**
* @file boards/yellowbox/board_configuration.cpp
*
* @brief Configuration defaults for the Yellowbox board
* MCU: STM32H743VIT
*/

#include "pch.h"

// 8 injector outputs
static const brain_pin_e injPins[] = {
Gpio::D7, // IN1
Gpio::B4, // IN2
Gpio::B5, // IN3
Gpio::B6, // IN4
Gpio::B7, // IN5
Gpio::B8, // IN6
Gpio::B9, // IN7
Gpio::A8, // IN8
};

// 2 ignition outputs
static const brain_pin_e ignPins[] = {
Gpio::D4, // IGN1
Gpio::D3, // IGN2
};

static void setInjectorPins() {
for (size_t i = 0; i < efi::size(injPins); i++) {
engineConfiguration->injectionPins[i] = injPins[i];
}
}

static void setIgnitionPins() {
for (size_t i = 0; i < efi::size(ignPins); i++) {
engineConfiguration->ignitionPins[i] = ignPins[i];
}
}

// PE3 is the red error LED, defined in board.mk as LED_CRITICAL_ERROR_BRAIN_PIN
Gpio getCommsLedPin() {
return Gpio::E4; // GREEN
}

Gpio getRunningLedPin() {
return Gpio::E5; // GREEN
}

Gpio getWarningLedPin() {
return Gpio::E6; // ORANGE
}

// WiFi ATWINC1500 on SPI1
spi_device_e getWifiSpiDevice() {
return SPI_DEVICE_1;
}

Gpio getWifiCsPin() {
return Gpio::A4; // SPI_SSN
}

Gpio getWifiResetPin() {
return Gpio::B0; // RESET_N
}

Gpio getWifiIsrPin() {
return Gpio::B1; // IRQN
}

static void setupVbatt() {
// TODO: set analogInputDividerCoefficient to match the pull-up resistor
// used on sensor inputs (e.g. 1.0 if there is no additional divider).
engineConfiguration->analogInputDividerCoefficient = 1.0f;

// TODO: measure the actual resistor divider on 12VSENSE and set this.
// Example for 82k high side / 10k low side: (82+10)/10 = 9.2
engineConfiguration->vbattDividerCoeff = 9.2f;

// 12V sense on PA2 = EFI_ADC_2
engineConfiguration->vbattAdcChannel = EFI_ADC_2;

// REF31 precision 3.3V reference on VREF+
engineConfiguration->adcVcc = 3.3f;
}

static void setupEtb() {
// TLE9201SG H-bridge driver
// DIR (PD10) - direction
// DIS (PD11) - disable (active high disables driver)
// PWM (PD12) - PWM / enable

engineConfiguration->etbIo[0].controlPin = Gpio::D12; // PWM
engineConfiguration->etbIo[0].directionPin1 = Gpio::D10; // DIR
engineConfiguration->etbIo[0].disablePin = Gpio::D11; // DIS
engineConfiguration->etbIo[0].directionPin2 = Gpio::Unassigned;

// we only have pwm/dir, no dira/dirb
engineConfiguration->etb_use_two_wires = false;
}

static void setupDefaultSensorInputs() {
// HALL1 (PC6) as primary trigger, HALL2 (PE11) as secondary/cam
engineConfiguration->triggerInputPins[0] = Gpio::C6; // HALL1
engineConfiguration->triggerInputPins[1] = Gpio::E11; // HALL2

// VR1 (PE7) is available as an alternative/additional trigger.
// To use as primary VR crank input, reassign triggerInputPins[0] to Gpio::E7.

// Default analog sensor assignments - adjust to match your wiring
engineConfiguration->clt.adcChannel = EFI_ADC_10; // AN3 PC0
engineConfiguration->iat.adcChannel = EFI_ADC_11; // AN4 PC1
engineConfiguration->tps1_1AdcChannel = EFI_ADC_14; // AN1 PC4
engineConfiguration->map.sensor.hwChannel = EFI_ADC_15; // AN2 PC5

// AN5 (PC2 = EFI_ADC_12) and AN6 (PC3 = EFI_ADC_13) are on ADC3.
// AN7 (PA0 = EFI_ADC_0) and AN8 (PA1 = EFI_ADC_1) are free for wideband, etc.
}

void setBoardConfigOverrides() {
setupVbatt();

engineConfiguration->canTxPin = Gpio::D1;
engineConfiguration->canRxPin = Gpio::D0;

// WiFi SPI1 - ATWINC1500
engineConfiguration->is_enabled_spi_1 = true;
engineConfiguration->spi1sckPin = Gpio::A5; // SPI_SCK
engineConfiguration->spi1misoPin = Gpio::A6; // SPI_RXD
engineConfiguration->spi1mosiPin = Gpio::A7; // SPI_TXD

// SD card uses SDMMC1 (EFI_SDC_DEVICE=SDCD1) - disable SPI SD
engineConfiguration->sdCardCsPin = Gpio::Unassigned;
engineConfiguration->sdCardSpiDevice = SPI_NONE;
}

void setBoardDefaultConfiguration() {
setInjectorPins();
setIgnitionPins();
setupEtb();
setupDefaultSensorInputs();

engineConfiguration->isSdCardEnabled = true;

engineConfiguration->canWriteEnabled = true;
engineConfiguration->canBaudRate = B500KBPS;
}

void preHalInit() {

// Configure SDMMC1 pins (AF12).
// Only 1-bit data bus is wired on this board revision (DAT0 only).
// To upgrade to 4-bit, connect PC9=DAT1, PC10=DAT2, PC11=DAT3 and
// change EFI_SDC_MODE to SDC_MODE_4BIT in board.mk.
efiSetPadMode(
"SDMMC", Gpio::C8, PAL_MODE_ALTERNATE(12) | PAL_STM32_OSPEED_HIGHEST | PAL_STM32_PUPDR_PULLUP); // DAT0
efiSetPadMode(
"SDMMC",
Gpio::C12,
PAL_MODE_ALTERNATE(12) | PAL_STM32_OSPEED_HIGHEST | PAL_STM32_PUPDR_FLOATING); // CLK - no pullup on clock
efiSetPadMode("SDMMC", Gpio::D2, PAL_MODE_ALTERNATE(12) | PAL_STM32_OSPEED_HIGHEST | PAL_STM32_PUPDR_PULLUP); // CMD
// DAT1-3 unused for data in 1-bit mode, but DAT3 must be pulled high so the card
// selects SD mode (not SPI mode). DAT1/DAT2 pulled high per SD spec for 1-bit hosts.
// efiSetPadMode("SDMMC", Gpio::C9, PAL_MODE_INPUT | PAL_STM32_PUPDR_PULLUP); // DAT1
// efiSetPadMode("SDMMC", Gpio::C10, PAL_MODE_INPUT | PAL_STM32_PUPDR_PULLUP); // DAT2
// efiSetPadMode("SDMMC", Gpio::C11, PAL_MODE_INPUT | PAL_STM32_PUPDR_PULLUP); // DAT3 - required for SD mode
// selection
}

#if EFI_BOOTLOADER
brain_pin_e getMisoPin(spi_device_e) {
return Gpio::A6;
}

brain_pin_e getMosiPin(spi_device_e) {
return Gpio::A7;
}

brain_pin_e getSckPin(spi_device_e) {
return Gpio::A5;
}
#endif // EFI_BOOTLOADER
10 changes: 10 additions & 0 deletions firmware/config/boards/yellowbox/compile_yellowbox.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

export USE_OPENBLT=yes

# Uncomment for debug builds (no optimization, all variables visible in debugger)
# Revert to release before flashing production firmware.
# export DEBUG_LEVEL_OPT="-O0 -ggdb -g"
# export USE_LTO=no

bash ../common_make.sh yellowbox ARCH_STM32H7
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// DO NOT EDIT MANUALLY, let automation work hard.

// auto-generated by PinoutLogic.java based on /home/dflak/fome-fw/firmware/config/boards/yellowbox/connectors/main.yaml
#include "pch.h"

// see comments at declaration in pin_repository.h
const char* getBoardSpecificPinName(brain_pin_e brainPin) {
switch (brainPin) {
case Gpio::A8:
return "IN8 - Injector 8 (A8)";
case Gpio::B4:
return "IN2 - Injector 2 (B4)";
case Gpio::B5:
return "IN3 - Injector 3 (B5)";
case Gpio::B6:
return "IN4 - Injector 4 (B6)";
case Gpio::B7:
return "IN5 - Injector 5 (B7)";
case Gpio::B8:
return "IN6 - Injector 6 (B8)";
case Gpio::B9:
return "IN7 - Injector 7 (B9)";
case Gpio::C6:
return "HALL1 - Primary Trigger (C6)";
case Gpio::D10:
return "ETB Direction (D10)";
case Gpio::D11:
return "ETB Disable (D11)";
case Gpio::D12:
return "ETB PWM (D12)";
case Gpio::D3:
return "IGN2 - Ignition 2 (D3)";
case Gpio::D4:
return "IGN1 - Ignition 1 (D4)";
case Gpio::D7:
return "IN1 - Injector 1 (D7)";
case Gpio::E11:
return "HALL2 - Secondary Trigger (E11)";
case Gpio::E3:
return "LED Red / Error (E3)";
case Gpio::E4:
return "LED Green 1 / Comms (E4)";
case Gpio::E5:
return "LED Green 2 / Running (E5)";
case Gpio::E6:
return "LED Orange / Warning (E6)";
case Gpio::E7:
return "VR1 - VR/Hall Input (E7)";
default:
return nullptr;
}
return nullptr;
}
Loading