From 199c926edf03635a1b56eafd7e6b12122afd4514 Mon Sep 17 00:00:00 2001 From: Ray Morris Date: Sat, 5 Dec 2026 18:37:13 -0600 Subject: [PATCH] Build SITL and RP2350 with their flash size, and fail the build when a target has none common.h turns features on and off by MCU_FLASH_SIZE. SITL defined it in target.h, which platform.h includes after common.h, and RP2350 only had an unused TARGET_FLASH_SIZE. The preprocessor reads an undefined macro as 0, so both were built as 512 KB boards: SITL had no CLI help text, 34 channels, MAVLink or auto transition. cmake now passes MCU_FLASH_SIZE for SITL (2048) and RP2350 (4096), as it does for every other MCU, and common.h stops the build if a target has none. The unit tests keep the 512 KB feature set they were built with. With the flash size right, SITL and RP2350 get USE_HOTT_TEXTMODE but not HoTT telemetry, which text mode is part of; HoTT text mode is now dropped for any target without HoTT telemetry. --- cmake/rp2350.cmake | 1 + cmake/sitl.cmake | 1 + src/main/target/RP2350_PICO/target.h | 2 -- src/main/target/SITL/target.h | 2 -- src/main/target/common.h | 5 +++++ src/main/target/common_post.h | 5 +++++ src/test/unit/platform.h | 1 + 7 files changed, 13 insertions(+), 4 deletions(-) diff --git a/cmake/rp2350.cmake b/cmake/rp2350.cmake index 900aece756d..f1009921df9 100644 --- a/cmake/rp2350.cmake +++ b/cmake/rp2350.cmake @@ -234,6 +234,7 @@ set(RP2350_DEFINITIONS PICO_CONFIG_HEADER=pico_sdk_config.h PICO_NO_FPGA_CHECK=1 PICO_FLASH_SIZE_BYTES=4194304 + MCU_FLASH_SIZE=4096 MCU_RAM_SIZE=520 # Tell pico_stdio_usb that TinyUSB device mode is already linked by the application. # Without this, stdio_usb_init() would call tusb_init() a second time AND set up its diff --git a/cmake/sitl.cmake b/cmake/sitl.cmake index f27d408f269..8d79f17230b 100644 --- a/cmake/sitl.cmake +++ b/cmake/sitl.cmake @@ -91,6 +91,7 @@ endif() set(SITL_DEFINITIONS SITL_BUILD + MCU_FLASH_SIZE=2048 ) function (target_sitl name) diff --git a/src/main/target/RP2350_PICO/target.h b/src/main/target/RP2350_PICO/target.h index 3000a28bfef..8907e1e8525 100644 --- a/src/main/target/RP2350_PICO/target.h +++ b/src/main/target/RP2350_PICO/target.h @@ -182,8 +182,6 @@ #undef RP2350_FAST_CODE #define RP2350_FAST_CODE FAST_CODE -#define TARGET_FLASH_SIZE 4096 - #define LED_STRIP_TIMER 1 #define SOFTSERIAL_1_TIMER 2 #define SOFTSERIAL_2_TIMER 3 diff --git a/src/main/target/SITL/target.h b/src/main/target/SITL/target.h index 743c08bf919..b2e80712471 100644 --- a/src/main/target/SITL/target.h +++ b/src/main/target/SITL/target.h @@ -128,8 +128,6 @@ #undef USE_SPI // Some dummys -#define MCU_FLASH_SIZE 2048 - #define LED_STRIP_TIMER 1 #define SOFTSERIAL_1_TIMER 2 #define SOFTSERIAL_2_TIMER 3 diff --git a/src/main/target/common.h b/src/main/target/common.h index 71848c3134c..9ea9baabbb7 100644 --- a/src/main/target/common.h +++ b/src/main/target/common.h @@ -17,6 +17,11 @@ #pragma once +// The preprocessor reads an undefined MCU_FLASH_SIZE as 0, which would quietly build a target as a 512 KB board +#ifndef MCU_FLASH_SIZE +#error "MCU_FLASH_SIZE (KiB) must be defined by the MCU's cmake file" +#endif + #if defined(STM32F7) || defined(STM32H7) #define USE_ITCM_RAM #endif diff --git a/src/main/target/common_post.h b/src/main/target/common_post.h index 183b44a3908..63560664273 100644 --- a/src/main/target/common_post.h +++ b/src/main/target/common_post.h @@ -30,6 +30,11 @@ extern uint8_t __config_start; extern uint8_t __config_end; +// HoTT text mode is part of HoTT telemetry +#if !defined(USE_TELEMETRY_HOTT) +# undef USE_HOTT_TEXTMODE +#endif + // Backward compatibility for I2C OLED display #if !defined(USE_I2C) # undef USE_DASHBOARD diff --git a/src/test/unit/platform.h b/src/test/unit/platform.h index 12b2671167b..9a603f3d824 100644 --- a/src/test/unit/platform.h +++ b/src/test/unit/platform.h @@ -79,6 +79,7 @@ extern SysTick_Type *SysTick; #define WS2811_DMA_TC_FLAG 1 #define WS2811_DMA_HANDLER_IDENTIFER 0 +#define MCU_FLASH_SIZE 512 #include "target/common.h" #include "target.h"