diff --git a/Makefile b/Makefile index 035fc2943..06c529770 100644 --- a/Makefile +++ b/Makefile @@ -90,6 +90,9 @@ HSE_VALUE ?= 8000000 # used for turning on features like VCP and SDCARD FEATURES = +# used to disable features based on flash space shortage (larger => more features disabled) +FLASH_RESTRICTEDNESS_LEVEL = + include $(ROOT)/make/targets.mk REVISION := $(shell git log -1 --format="%h") @@ -155,6 +158,10 @@ ifneq ($(HSE_VALUE),) DEVICE_FLAGS := $(DEVICE_FLAGS) -DHSE_VALUE=$(HSE_VALUE) endif +ifneq ($(FLASH_RESTRICTEDNESS_LEVEL),) +DEVICE_FLAGS := $(DEVICE_FLAGS) -DFLASH_RESTRICTEDNESS_LEVEL=$(FLASH_RESTRICTEDNESS_LEVEL) +endif + TARGET_DIR = $(ROOT)/src/main/target/$(BASE_TARGET) TARGET_DIR_SRC = $(notdir $(wildcard $(TARGET_DIR)/*.c)) diff --git a/src/main/target/SPRACINGF3NEO/target.h b/src/main/target/SPRACINGF3NEO/target.h index 560968cb4..d9d61b145 100644 --- a/src/main/target/SPRACINGF3NEO/target.h +++ b/src/main/target/SPRACINGF3NEO/target.h @@ -23,40 +23,6 @@ #define TARGET_BOARD_IDENTIFIER "SP3N" #define USE_TARGET_CONFIG -// Removed to make the firmware fit into flash (in descending order of priority): -// NOTE: Don't disable USE_GYRO_OVERFLOW_CHECK - board has ICM20602 gyro -//#undef USE_GYRO_OVERFLOW_CHECK -//#undef USE_GYRO_LPF2 - -#undef USE_MSP_DISPLAYPORT -#undef USE_MSP_OVER_TELEMETRY - -#undef USE_DYN_LPF -#undef USE_D_CUT -#undef USE_LAUNCH_CONTROL - -#undef USE_ITERM_RELAX -#undef USE_RC_SMOOTHING_FILTER -#undef USE_THRUST_LINEARIZATION - -#undef USE_HUFFMAN -#undef USE_PINIO -#undef USE_PINIOBOX - -#undef USE_TELEMETRY_HOTT -#undef USE_TELEMETRY_MAVLINK -#undef USE_TELEMETRY_LTM -#undef USE_SERIALRX_XBUS -#undef USE_SERIALRX_SUMH -#undef USE_PWM - -#undef USE_BOARD_INFO -#undef USE_EXTENDED_CMS_MENUS -#undef USE_RTC_TIME -#undef USE_RX_MSP -#undef USE_ESC_SENSOR_INFO - - #define LED0_PIN PB9 #define LED1_PIN PB2 diff --git a/src/main/target/SPRACINGF3NEO/target.mk b/src/main/target/SPRACINGF3NEO/target.mk index 32ef98f4b..056983210 100644 --- a/src/main/target/SPRACINGF3NEO/target.mk +++ b/src/main/target/SPRACINGF3NEO/target.mk @@ -1,6 +1,8 @@ F3_TARGETS += $(TARGET) FEATURES = VCP SDCARD_SPI +FLASH_RESTRICTEDNESS_LEVEL = 8 + TARGET_SRC = \ drivers/accgyro/accgyro_mpu.c \ drivers/accgyro/accgyro_mpu6500.c \ diff --git a/src/main/target/common_pre.h b/src/main/target/common_pre.h index 8c39d2310..bcf1a0aa2 100644 --- a/src/main/target/common_pre.h +++ b/src/main/target/common_pre.h @@ -138,15 +138,12 @@ #define USE_GYRO_REGISTER_DUMP // Adds gyroregisters command to cli to dump configured register values #define USE_IMU_CALC #define USE_PPM -#define USE_PWM #define USE_SERIAL_RX #define USE_SERIALRX_CRSF // Team Black Sheep Crossfire protocol #define USE_SERIALRX_IBUS // FlySky and Turnigy receivers #define USE_SERIALRX_SBUS // Frsky and Futaba receivers #define USE_SERIALRX_SPEKTRUM // SRXL, DSM2 and DSMX protocol #define USE_SERIALRX_SUMD // Graupner Hott protocol -#define USE_SERIALRX_SUMH // Graupner legacy protocol -#define USE_SERIALRX_XBUS // JR #if (FLASH_SIZE > 64) #define MAX_PROFILE_COUNT 3 @@ -162,29 +159,20 @@ #define USE_SERVOS #define USE_TELEMETRY #define USE_TELEMETRY_FRSKY_HUB -#define USE_TELEMETRY_HOTT -#define USE_TELEMETRY_LTM #define USE_TELEMETRY_SMARTPORT #endif #if (FLASH_SIZE > 128) +#define USE_GYRO_OVERFLOW_CHECK + #define USE_CAMERA_CONTROL #define USE_CMS -#define USE_EXTENDED_CMS_MENUS #define USE_DSHOT_DMAR -#define USE_GYRO_OVERFLOW_CHECK #define USE_YAW_SPIN_RECOVERY -#define USE_HUFFMAN -#define USE_LAUNCH_CONTROL #define USE_MSP_DISPLAYPORT #define USE_MSP_OVER_TELEMETRY -#define USE_PINIO -#define USE_PINIOBOX #define USE_RCDEVICE -#define USE_RTC_TIME -#define USE_RX_MSP #define USE_SERIALRX_FPORT // FrSky FPort -#define USE_TPA_MODE #define USE_TELEMETRY_CRSF #define USE_TELEMETRY_SRXL #define USE_VIRTUAL_CURRENT_METER @@ -192,19 +180,42 @@ #define USE_VTX_CONTROL #define USE_VTX_SMARTAUDIO #define USE_VTX_TRAMP -#define USE_GYRO_LPF2 #define USE_ESC_SENSOR -#define USE_ESC_SENSOR_INFO -#define USE_CRSF_CMS_TELEMETRY -#define USE_BOARD_INFO -#define USE_THROTTLE_BOOST -#define USE_RC_SMOOTHING_FILTER -#define USE_ITERM_RELAX -#define USE_DYN_LPF -#define USE_INTEGRATED_YAW_CONTROL -#define USE_THRUST_LINEARIZATION -#define USE_D_CUT +#define USE_SERIAL_4WAY_BLHELI_BOOTLOADER //TODO: Fix this conditional. +#if ((FLASH_SIZE > 256) || (FLASH_RESTRICTEDNESS_LEVEL < 9)) +#define USE_GYRO_LPF2 +#endif + +#if ((FLASH_SIZE > 256) || (FLASH_RESTRICTEDNESS_LEVEL < 8)) +#define USE_LAUNCH_CONTROL +#define USE_DYN_LPF +#define USE_D_CUT +#endif + +#if ((FLASH_SIZE > 256) || (FLASH_RESTRICTEDNESS_LEVEL < 7)) +#define USE_THROTTLE_BOOST +#define USE_INTEGRATED_YAW_CONTROL +#endif + +#if ((FLASH_SIZE > 256) || (FLASH_RESTRICTEDNESS_LEVEL < 6)) +#define USE_ITERM_RELAX +#define USE_RC_SMOOTHING_FILTER +#define USE_THRUST_LINEARIZATION +#define USE_TPA_MODE +#endif + +#if ((FLASH_SIZE > 256) || (FLASH_RESTRICTEDNESS_LEVEL < 5)) +#define USE_PWM +#endif + +#if ((FLASH_SIZE > 256) || (FLASH_RESTRICTEDNESS_LEVEL < 4)) +#define USE_HUFFMAN +#define USE_PINIO +#define USE_PINIOBOX +#endif + +#if ((FLASH_SIZE > 256) || (FLASH_RESTRICTEDNESS_LEVEL < 3)) #ifdef USE_SERIALRX_SPEKTRUM #define USE_SPEKTRUM_BIND #define USE_SPEKTRUM_BIND_PLUG @@ -215,9 +226,26 @@ #define USE_SPEKTRUM_VTX_TELEMETRY #define USE_SPEKTRUM_CMS_TELEMETRY #endif -#define USE_SERIAL_4WAY_BLHELI_BOOTLOADER #endif +#if ((FLASH_SIZE > 256) || (FLASH_RESTRICTEDNESS_LEVEL < 2)) +#define USE_TELEMETRY_HOTT +#define USE_TELEMETRY_LTM +#define USE_SERIALRX_SUMH // Graupner legacy protocol +#define USE_SERIALRX_XBUS // JR +#endif + +#if ((FLASH_SIZE > 256) || (FLASH_RESTRICTEDNESS_LEVEL < 1)) +#define USE_BOARD_INFO +#define USE_EXTENDED_CMS_MENUS +#define USE_RTC_TIME +#define USE_RX_MSP +#define USE_ESC_SENSOR_INFO +#define USE_CRSF_CMS_TELEMETRY +#endif + +#endif // FLASH_SIZE > 128 + #if (FLASH_SIZE > 256) #define USE_DASHBOARD #define USE_GPS