boards: add CONSTRAINED_MEMORY build option

- currently the main change is that it reduces the max number of ORB multi instances to 4, but usage will be expanded as needed
 - limits number of EKF2 multi instances to 2.
 - enabled on all cortex m4 boards
This commit is contained in:
Daniel Agar
2021-01-30 21:56:36 -05:00
committed by Lorenz Meier
parent 834ac38841
commit 78dff6adcb
41 changed files with 70 additions and 7 deletions

View File

@@ -6,6 +6,7 @@ px4_add_board(
LABEL default
TOOLCHAIN arm-none-eabi
ARCHITECTURE cortex-m4
CONSTRAINED_MEMORY
ROMFSROOT px4fmu_common
TESTING
UAVCAN_INTERFACES 1

View File

@@ -24,6 +24,7 @@ px4_add_board(
LABEL canbootloader
TOOLCHAIN arm-none-eabi
ARCHITECTURE cortex-m4
CONSTRAINED_MEMORY
DRIVERS
bootloaders
)

View File

@@ -25,6 +25,7 @@ px4_add_board(
LABEL default
TOOLCHAIN arm-none-eabi
ARCHITECTURE cortex-m4
CONSTRAINED_MEMORY
ROMFSROOT cannode
UAVCAN_INTERFACES 1
DRIVERS

View File

@@ -5,6 +5,7 @@ px4_add_board(
MODEL crazyflie
TOOLCHAIN arm-none-eabi
ARCHITECTURE cortex-m4
CONSTRAINED_MEMORY
ROMFSROOT px4fmu_common
CONSTRAINED_FLASH
DRIVERS

View File

@@ -5,6 +5,7 @@ px4_add_board(
MODEL crazyflie21
TOOLCHAIN arm-none-eabi
ARCHITECTURE cortex-m4
CONSTRAINED_MEMORY
ROMFSROOT px4fmu_common
CONSTRAINED_FLASH
DRIVERS

View File

@@ -24,6 +24,7 @@ px4_add_board(
LABEL canbootloader
TOOLCHAIN arm-none-eabi
ARCHITECTURE cortex-m4
CONSTRAINED_MEMORY
DRIVERS
bootloaders
)

View File

@@ -26,6 +26,7 @@ px4_add_board(
LABEL default
TOOLCHAIN arm-none-eabi
ARCHITECTURE cortex-m4
CONSTRAINED_MEMORY
ROMFSROOT cannode
UAVCAN_INTERFACES 1
DRIVERS

View File

@@ -6,6 +6,7 @@ px4_add_board(
LABEL default
TOOLCHAIN arm-none-eabi
ARCHITECTURE cortex-m4
CONSTRAINED_MEMORY
ROMFSROOT px4fmu_common
CONSTRAINED_FLASH
SERIAL_PORTS

View File

@@ -6,6 +6,7 @@ px4_add_board(
LABEL rtps
TOOLCHAIN arm-none-eabi
ARCHITECTURE cortex-m4
CONSTRAINED_MEMORY
ROMFSROOT px4fmu_common
SERIAL_PORTS
GPS1:/dev/ttyS5

View File

@@ -6,6 +6,7 @@ px4_add_board(
LABEL default
TOOLCHAIN arm-none-eabi
ARCHITECTURE cortex-m4
CONSTRAINED_MEMORY
ROMFSROOT px4fmu_common
IO px4_io-v2_default
TESTING

View File

@@ -6,6 +6,7 @@ px4_add_board(
LABEL default
TOOLCHAIN arm-none-eabi
ARCHITECTURE cortex-m4
CONSTRAINED_MEMORY
ROMFSROOT px4fmu_common
TESTING
UAVCAN_INTERFACES 2

View File

@@ -6,6 +6,7 @@ px4_add_board(
LABEL socketcan
TOOLCHAIN arm-none-eabi
ARCHITECTURE cortex-m4
CONSTRAINED_MEMORY
ROMFSROOT px4fmu_common
TESTING
UAVCAN_INTERFACES 2

View File

@@ -6,6 +6,7 @@ px4_add_board(
LABEL default
TOOLCHAIN arm-none-eabi
ARCHITECTURE cortex-m4
CONSTRAINED_MEMORY
ROMFSROOT px4fmu_common
TESTING
UAVCAN_INTERFACES 2

View File

@@ -6,6 +6,7 @@ px4_add_board(
LABEL rtps
TOOLCHAIN arm-none-eabi
ARCHITECTURE cortex-m4
CONSTRAINED_MEMORY
ROMFSROOT px4fmu_common
TESTING
UAVCAN_INTERFACES 2

View File

@@ -6,6 +6,7 @@ px4_add_board(
LABEL socketcan
TOOLCHAIN arm-none-eabi
ARCHITECTURE cortex-m4
CONSTRAINED_MEMORY
ROMFSROOT px4fmu_common
TESTING
UAVCAN_INTERFACES 2

View File

@@ -25,6 +25,7 @@ px4_add_board(
LABEL default
TOOLCHAIN arm-none-eabi
ARCHITECTURE cortex-m4
CONSTRAINED_MEMORY
ROMFSROOT cannode
UAVCAN_INTERFACES 2
DRIVERS

View File

@@ -5,6 +5,7 @@ px4_add_board(
MODEL f4sd
TOOLCHAIN arm-none-eabi
ARCHITECTURE cortex-m4
CONSTRAINED_MEMORY
ROMFSROOT px4fmu_common
CONSTRAINED_FLASH
SERIAL_PORTS

View File

@@ -6,6 +6,7 @@ px4_add_board(
LABEL default
TOOLCHAIN arm-none-eabi
ARCHITECTURE cortex-m4
CONSTRAINED_MEMORY
ROMFSROOT px4fmu_common
BOOTLOADER ${PX4_SOURCE_DIR}/ROMFS/px4fmu_common/extras/px4fmuv3_bl.bin
IO px4_io-v2_default

View File

@@ -6,6 +6,7 @@ px4_add_board(
LABEL fixedwing
TOOLCHAIN arm-none-eabi
ARCHITECTURE cortex-m4
CONSTRAINED_MEMORY
ROMFSROOT px4fmu_common
IO px4_io-v2_default
#TESTING

View File

@@ -6,6 +6,7 @@ px4_add_board(
LABEL lpe
TOOLCHAIN arm-none-eabi
ARCHITECTURE cortex-m4
CONSTRAINED_MEMORY
ROMFSROOT px4fmu_common
BOOTLOADER ${PX4_SOURCE_DIR}/ROMFS/px4fmu_common/extras/px4fmuv3_bl.bin
IO px4_io-v2_default

View File

@@ -6,6 +6,7 @@ px4_add_board(
LABEL multicopter
TOOLCHAIN arm-none-eabi
ARCHITECTURE cortex-m4
CONSTRAINED_MEMORY
ROMFSROOT px4fmu_common
IO px4_io-v2_default
#UAVCAN_INTERFACES 2

View File

@@ -6,6 +6,7 @@ px4_add_board(
LABEL rover
TOOLCHAIN arm-none-eabi
ARCHITECTURE cortex-m4
CONSTRAINED_MEMORY
ROMFSROOT px4fmu_common
IO px4_io-v2_default
CONSTRAINED_FLASH

View File

@@ -6,6 +6,7 @@ px4_add_board(
LABEL test
TOOLCHAIN arm-none-eabi
ARCHITECTURE cortex-m4
CONSTRAINED_MEMORY
ROMFSROOT px4fmu_test
IO px4_io-v2_default
TESTING

View File

@@ -8,6 +8,7 @@ px4_add_board(
LABEL ctrlalloc
TOOLCHAIN arm-none-eabi
ARCHITECTURE cortex-m4
CONSTRAINED_MEMORY
ROMFSROOT px4fmu_common
IO px4_io-v2_default
TESTING

View File

@@ -8,6 +8,7 @@ px4_add_board(
LABEL default
TOOLCHAIN arm-none-eabi
ARCHITECTURE cortex-m4
CONSTRAINED_MEMORY
ROMFSROOT px4fmu_common
IO px4_io-v2_default
TESTING

View File

@@ -8,6 +8,7 @@ px4_add_board(
LABEL rtps
TOOLCHAIN arm-none-eabi
ARCHITECTURE cortex-m4
CONSTRAINED_MEMORY
ROMFSROOT px4fmu_common
IO px4_io-v2_default
TESTING

View File

@@ -8,6 +8,7 @@ px4_add_board(
LABEL stackcheck
TOOLCHAIN arm-none-eabi
ARCHITECTURE cortex-m4
CONSTRAINED_MEMORY
ROMFSROOT px4fmu_common
IO px4_io-v2_default
TESTING

View File

@@ -25,6 +25,7 @@ px4_add_board(
LABEL cannode
TOOLCHAIN arm-none-eabi
ARCHITECTURE cortex-m4
CONSTRAINED_MEMORY
ROMFSROOT cannode
UAVCAN_INTERFACES 1
SERIAL_PORTS

View File

@@ -6,6 +6,7 @@ px4_add_board(
LABEL ctrlalloc
TOOLCHAIN arm-none-eabi
ARCHITECTURE cortex-m4
CONSTRAINED_MEMORY
ROMFSROOT px4fmu_common
TESTING
UAVCAN_INTERFACES 1

View File

@@ -6,6 +6,7 @@ px4_add_board(
LABEL default
TOOLCHAIN arm-none-eabi
ARCHITECTURE cortex-m4
CONSTRAINED_MEMORY
ROMFSROOT px4fmu_common
TESTING
UAVCAN_INTERFACES 1

View File

@@ -10,6 +10,7 @@ px4_add_board(
LABEL optimized
TOOLCHAIN arm-none-eabi
ARCHITECTURE cortex-m4
CONSTRAINED_MEMORY
ROMFSROOT px4fmu_common
TESTING
UAVCAN_INTERFACES 1

View File

@@ -6,6 +6,7 @@ px4_add_board(
LABEL rtps
TOOLCHAIN arm-none-eabi
ARCHITECTURE cortex-m4
CONSTRAINED_MEMORY
ROMFSROOT px4fmu_common
TESTING
UAVCAN_INTERFACES 1

View File

@@ -6,6 +6,7 @@ px4_add_board(
LABEL stackcheck
TOOLCHAIN arm-none-eabi
ARCHITECTURE cortex-m4
CONSTRAINED_MEMORY
ROMFSROOT px4fmu_common
TESTING
#UAVCAN_INTERFACES 1

View File

@@ -6,6 +6,7 @@ px4_add_board(
LABEL default
TOOLCHAIN arm-none-eabi
ARCHITECTURE cortex-m4
CONSTRAINED_MEMORY
ROMFSROOT px4fmu_common
IO px4_io-v2_default
TESTING

View File

@@ -6,6 +6,7 @@ px4_add_board(
LABEL rtps
TOOLCHAIN arm-none-eabi
ARCHITECTURE cortex-m4
CONSTRAINED_MEMORY
ROMFSROOT px4fmu_common
IO px4_io-v2_default
TESTING

View File

@@ -6,6 +6,7 @@ px4_add_board(
LABEL default
TOOLCHAIN arm-none-eabi
ARCHITECTURE cortex-m4
CONSTRAINED_MEMORY
ROMFSROOT px4fmu_common
UAVCAN_INTERFACES 1
SERIAL_PORTS

View File

@@ -56,6 +56,7 @@
# [ EXAMPLES <list> ]
# [ SERIAL_PORTS <list> ]
# [ CONSTRAINED_FLASH ]
# [ CONSTRAINED_MEMORY ]
# [ TESTING ]
# [ LINKER_PREFIX <string> ]
# [ EMBEDDED_METADATA <string> ]
@@ -80,6 +81,7 @@
# SERIAL_PORTS : mapping of user configurable serial ports and param facing name
# EMBEDDED_METADATA : list of metadata to embed to ROMFS
# CONSTRAINED_FLASH : flag to enable constrained flash options (eg limit init script status text)
# CONSTRAINED_MEMORY : flag to enable constrained memory options (eg limit maximum number of uORB publications)
# TESTING : flag to enable automatic inclusion of PX4 testing modules
# LINKER_PREFIX : optional to prefix on the Linker script.
#
@@ -156,6 +158,7 @@ function(px4_add_board)
OPTIONS
BUILD_BOOTLOADER
CONSTRAINED_FLASH
CONSTRAINED_MEMORY
TESTING
REQUIRED
PLATFORM
@@ -248,6 +251,11 @@ function(px4_add_board)
add_definitions(-DCONSTRAINED_FLASH)
endif()
if(CONSTRAINED_MEMORY)
set(px4_constrained_memory_build "1" CACHE INTERNAL "constrained memory build" FORCE)
add_definitions(-DCONSTRAINED_MEMORY)
endif()
if(TESTING)
set(PX4_TESTING "1" CACHE INTERNAL "testing enabled" FORCE)
endif()

View File

@@ -53,8 +53,11 @@
#include <uORB/topics/vehicle_global_position.h>
#include <uORB/topics/vehicle_odometry.h>
static constexpr uint8_t EKF2_MAX_INSTANCES{9};
static_assert(EKF2_MAX_INSTANCES <= ORB_MULTI_MAX_INSTANCES, "EKF2_MAX_INSTANCES must be <= ORB_MULTI_MAX_INSTANCES");
#if CONSTRAINED_MEMORY
# define EKF2_MAX_INSTANCES 2
#else
# define EKF2_MAX_INSTANCES 9
#endif
using namespace time_literals;
@@ -84,6 +87,7 @@ private:
// Subscriptions (per estimator instance)
struct EstimatorInstance {
EstimatorInstance(EKF2Selector *selector, uint8_t i) :
estimator_attitude_sub{selector, ORB_ID(estimator_attitude), i},
estimator_status_sub{selector, ORB_ID(estimator_status), i},
@@ -119,13 +123,17 @@ private:
EstimatorInstance _instance[EKF2_MAX_INSTANCES] {
{this, 0},
{this, 1},
#if EKF2_MAX_INSTANCES > 2
{this, 2},
{this, 3},
#if EKF2_MAX_INSTANCES > 4
{this, 4},
{this, 5},
{this, 6},
{this, 7},
{this, 8},
#endif
#endif
};
static constexpr uint8_t IMU_STATUS_SIZE = (sizeof(sensors_status_imu_s::gyro_inconsistency_rad_s) / sizeof(
@@ -136,7 +144,7 @@ private:
static_assert(IMU_STATUS_SIZE == sizeof(estimator_selector_status_s::accumulated_accel_error) / sizeof(
estimator_selector_status_s::accumulated_accel_error[0]),
"increase estimator_selector_status_s::accumulated_accel_error size");
static_assert(EKF2_MAX_INSTANCES == sizeof(estimator_selector_status_s::combined_test_ratio) / sizeof(
static_assert(EKF2_MAX_INSTANCES <= sizeof(estimator_selector_status_s::combined_test_ratio) / sizeof(
estimator_selector_status_s::combined_test_ratio[0]),
"increase estimator_selector_status_s::combined_test_ratio size");

View File

@@ -111,7 +111,7 @@ void LoggedTopics::add_default_topics()
add_topic("vehicle_status_flags");
add_topic("vtol_vehicle_status", 200);
// Control allocaton topics
// Control allocation topics
add_topic("vehicle_angular_acceleration_setpoint", 20);
add_topic("vehicle_angular_acceleration", 20);
add_topic("vehicle_thrust_setpoint", 20);
@@ -126,7 +126,12 @@ void LoggedTopics::add_default_topics()
add_topic_multi("telemetry_status", 1000, 4);
// EKF multi topics (currently max 9 estimators)
static constexpr uint8_t MAX_ESTIMATOR_INSTANCES = 4;
#if CONSTRAINED_MEMORY
static constexpr uint8_t MAX_ESTIMATOR_INSTANCES = 2;
#else
static constexpr uint8_t MAX_ESTIMATOR_INSTANCES = 6; // artificailly limited until PlotJuggler fixed
#endif
add_topic("estimator_selector_status");
add_topic_multi("ekf_gps_drift", 1000, MAX_ESTIMATOR_INSTANCES);
add_topic_multi("estimator_attitude", 500, MAX_ESTIMATOR_INSTANCES);

View File

@@ -58,9 +58,13 @@ struct orb_metadata {
typedef const struct orb_metadata *orb_id_t;
/**
* Maximum number of multi topic instances
* Maximum number of multi topic instances. This must be <= 10 (because it's the last char of the node path)
*/
#define ORB_MULTI_MAX_INSTANCES 10 // This must be <= 10 (because it's the last char of the node path)
#if defined(CONSTRAINED_MEMORY)
# define ORB_MULTI_MAX_INSTANCES 4
#else
# define ORB_MULTI_MAX_INSTANCES 10
#endif
/**
* Generates a pointer to the uORB metadata structure for

View File

@@ -727,12 +727,14 @@ int uORBTest::UnitTest::test_SubscriptionMulti()
ORB_ID::orb_test,
ORB_ID::orb_test,
ORB_ID::orb_test,
#if ORB_MULTI_MAX_INSTANCES > 4
ORB_ID::orb_test,
ORB_ID::orb_test,
ORB_ID::orb_test,
ORB_ID::orb_test,
ORB_ID::orb_test,
ORB_ID::orb_test,
#endif
};
uORB::SubscriptionMultiArray<orb_test_s> orb_test_sub_multi_array{ORB_ID::orb_test};