From 482341b9d1f14b416dc78acfc1e76dacc491fba3 Mon Sep 17 00:00:00 2001 From: "Sam S. Yu" <25761223+yudataguy@users.noreply.github.com> Date: Thu, 5 Feb 2026 12:58:06 -0800 Subject: [PATCH 01/13] Switch from MallocAllocator to Zephyr k_malloc allocator (#313) Replace Fw::MallocAllocator with a ZephyrKmallocAllocator backed by Zephyr's k_malloc/k_free so that heap usage is tracked by the kernel memory pool, giving an accurate picture of runtime RAM consumption. - Implement ZephyrKmallocAllocator with alignment support via k_aligned_alloc - Unify ComCcsdsSband and ComCcsdsLora allocation namespaces into a single ComCcsds::Allocation namespace - Update ReferenceDeploymentTopology to use the shared allocator - Configure HEAP_MEM_POOL_SIZE=65536 in prj.conf for the kernel heap Co-Authored-By: Claude Opus 4.6 --- .../Top/ReferenceDeploymentTopology.cpp | 17 ++--- .../project/config/CMakeLists.txt | 2 + .../ComCcsdsSubtopologyConfig.cpp | 74 ++++++++++++++++--- .../ComCcsdsSubtopologyConfig.hpp | 12 +-- prj.conf | 1 + 5 files changed, 75 insertions(+), 31 deletions(-) diff --git a/FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentTopology.cpp b/FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentTopology.cpp index f472efb9..45127dcf 100644 --- a/FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentTopology.cpp +++ b/FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentTopology.cpp @@ -9,7 +9,7 @@ // #include // Necessary project-specified types -#include +#include #include #include @@ -34,9 +34,6 @@ static const struct gpio_dt_spec payloadBatteryLoadSwitchGpio = // Allows easy reference to objects in FPP/autocoder required namespaces using namespace ReferenceDeployment; -// Instantiate a malloc allocator for cmdSeq buffer allocation -Fw::MallocAllocator mallocator; - constexpr FwSizeType BASE_RATEGROUP_PERIOD_MS = 1; // 1Khz // Helper function to calculate the period for a given rate group frequency @@ -78,9 +75,9 @@ void configureTopology() { gpioBurnwire0.open(burnwire0Gpio, Zephyr::ZephyrGpioDriver::GpioConfiguration::OUT); gpioBurnwire1.open(burnwire1Gpio, Zephyr::ZephyrGpioDriver::GpioConfiguration::OUT); - cmdSeq.allocateBuffer(0, mallocator, 1024); - payloadSeq.allocateBuffer(0, mallocator, 1024); - safeModeSeq.allocateBuffer(0, mallocator, 1024); + cmdSeq.allocateBuffer(0, ComCcsds::Allocation::memAllocator, 1024); + payloadSeq.allocateBuffer(0, ComCcsds::Allocation::memAllocator, 1024); + safeModeSeq.allocateBuffer(0, ComCcsds::Allocation::memAllocator, 1024); gpioface4LS.open(face4LoadSwitchGpio, Zephyr::ZephyrGpioDriver::GpioConfiguration::OUT); gpioface0LS.open(face0LoadSwitchGpio, Zephyr::ZephyrGpioDriver::GpioConfiguration::OUT); gpioface1LS.open(face1LoadSwitchGpio, Zephyr::ZephyrGpioDriver::GpioConfiguration::OUT); @@ -199,8 +196,8 @@ void teardownTopology(const TopologyState& state) { stopTasks(state); freeThreads(state); tearDownComponents(state); - cmdSeq.deallocateBuffer(mallocator); - payloadSeq.deallocateBuffer(mallocator); - safeModeSeq.deallocateBuffer(mallocator); + cmdSeq.deallocateBuffer(ComCcsds::Allocation::memAllocator); + payloadSeq.deallocateBuffer(ComCcsds::Allocation::memAllocator); + safeModeSeq.deallocateBuffer(ComCcsds::Allocation::memAllocator); } }; // namespace ReferenceDeployment diff --git a/FprimeZephyrReference/project/config/CMakeLists.txt b/FprimeZephyrReference/project/config/CMakeLists.txt index 13b518c2..27950be1 100644 --- a/FprimeZephyrReference/project/config/CMakeLists.txt +++ b/FprimeZephyrReference/project/config/CMakeLists.txt @@ -10,6 +10,8 @@ register_fprime_config( "${CMAKE_CURRENT_LIST_DIR}/CdhCoreTlmConfig.fpp" "${CMAKE_CURRENT_LIST_DIR}/CdhCoreFatalHandlerConfig.fpp" "${CMAKE_CURRENT_LIST_DIR}/ComCcsdsConfig.fpp" + "${CMAKE_CURRENT_LIST_DIR}/ComCcsdsConfig/ComCcsdsSubtopologyConfig.cpp" + "${CMAKE_CURRENT_LIST_DIR}/ComCcsdsConfig/ComCcsdsSubtopologyConfig.hpp" "${CMAKE_CURRENT_LIST_DIR}/ComCfg.fpp" "${CMAKE_CURRENT_LIST_DIR}/CommandDispatcherImplCfg.hpp" "${CMAKE_CURRENT_LIST_DIR}/FileHandlingConfig.fpp" diff --git a/FprimeZephyrReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.cpp b/FprimeZephyrReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.cpp index cbcb0548..e0409261 100644 --- a/FprimeZephyrReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.cpp +++ b/FprimeZephyrReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.cpp @@ -1,17 +1,67 @@ #include "ComCcsdsSubtopologyConfig.hpp" -namespace ComCcsdsSband { -namespace Allocation { -// This instance can be changed to use a different allocator in the ComCcsdsSband Subtopology -Fw::MallocAllocator mallocatorInstance; -Fw::MemAllocator& memAllocator = mallocatorInstance; -} // namespace Allocation -} // namespace ComCcsdsSband +#include + +#include + +namespace { + +bool isPowerOfTwo(const FwSizeType value) { + return (value != 0U) && ((value & (value - 1U)) == 0U); +} + +FwSizeType roundUpToPowerOfTwo(FwSizeType value) { + if (value <= 1U) { + return 1U; + } + + value--; + value |= value >> 1; + value |= value >> 2; + value |= value >> 4; + value |= value >> 8; + value |= value >> 16; + if (sizeof(FwSizeType) > 4U) { + value |= value >> 32; + } + value++; + return value; +} + +class ZephyrKmallocAllocator final : public Fw::MemAllocator { + public: + void* allocate(const FwEnumStoreType identifier, + FwSizeType& size, + bool& recoverable, + FwSizeType alignment = alignof(std::max_align_t)) override { + static_cast(identifier); + recoverable = false; + + const FwSizeType minAlignment = static_cast(sizeof(void*)); + FwSizeType requestedAlignment = (alignment < minAlignment) ? minAlignment : alignment; + if (!isPowerOfTwo(requestedAlignment)) { + requestedAlignment = roundUpToPowerOfTwo(requestedAlignment); + } + FW_ASSERT(isPowerOfTwo(requestedAlignment), static_cast(requestedAlignment)); + + void* mem = (requestedAlignment <= minAlignment) ? k_malloc(size) : k_aligned_alloc(requestedAlignment, size); + if (mem == nullptr) { + size = 0; + } + return mem; + } + + void deallocate(const FwEnumStoreType identifier, void* ptr) override { + static_cast(identifier); + k_free(ptr); + } +}; + +} // namespace -namespace ComCcsdsLora { +namespace ComCcsds { namespace Allocation { -// This instance can be changed to use a different allocator in the ComCcsdsLora Subtopology -Fw::MallocAllocator mallocatorInstance; -Fw::MemAllocator& memAllocator = mallocatorInstance; +ZephyrKmallocAllocator allocatorInstance; +Fw::MemAllocator& memAllocator = allocatorInstance; } // namespace Allocation -} // namespace ComCcsdsLora +} // namespace ComCcsds diff --git a/FprimeZephyrReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.hpp b/FprimeZephyrReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.hpp index db0be600..0fa3c8c9 100644 --- a/FprimeZephyrReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.hpp +++ b/FprimeZephyrReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.hpp @@ -1,18 +1,12 @@ #ifndef COMCCSDSSUBTOPOLOGY_CONFIG_HPP #define COMCCSDSSUBTOPOLOGY_CONFIG_HPP -#include "Fw/Types/MallocAllocator.hpp" +#include "Fw/Types/MemAllocator.hpp" -namespace ComCcsdsSband { +namespace ComCcsds { namespace Allocation { extern Fw::MemAllocator& memAllocator; } -} // namespace ComCcsdsSband - -namespace ComCcsdsLora { -namespace Allocation { -extern Fw::MemAllocator& memAllocator; -} -} // namespace ComCcsdsLora +} // namespace ComCcsds #endif diff --git a/prj.conf b/prj.conf index cf04847f..e85cede4 100644 --- a/prj.conf +++ b/prj.conf @@ -6,6 +6,7 @@ CONFIG_REQUIRES_FULL_LIBCPP=y CONFIG_CPP_EXCEPTIONS=n CONFIG_CPP_RTTI=n CONFIG_COMMON_LIBC_MALLOC=y +CONFIG_HEAP_MEM_POOL_SIZE=65536 CONFIG_MAIN_STACK_SIZE=8192 CONFIG_POSIX_API=y CONFIG_REBOOT=y From 764933e98a7e6bf5a4af00e906f3092d419c4725 Mon Sep 17 00:00:00 2001 From: "Sam S. Yu" <25761223+yudataguy@users.noreply.github.com> Date: Wed, 25 Feb 2026 16:11:25 -0800 Subject: [PATCH 02/13] Use ZephyrKmallocAllocator from fprime-zephyr instead of local definition Update fprime-zephyr submodule to pick up the upstreamed Fw::ZephyrKmallocAllocator and remove the local copy from ComCcsdsSubtopologyConfig, keeping the same ComCcsds::Allocation interface. --- .../ComCcsdsSubtopologyConfig.cpp | 61 +------------------ .../ComCcsdsSubtopologyConfig.hpp | 2 +- lib/fprime-zephyr | 2 +- 3 files changed, 3 insertions(+), 62 deletions(-) diff --git a/FprimeZephyrReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.cpp b/FprimeZephyrReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.cpp index e0409261..a50f4923 100644 --- a/FprimeZephyrReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.cpp +++ b/FprimeZephyrReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.cpp @@ -1,67 +1,8 @@ #include "ComCcsdsSubtopologyConfig.hpp" -#include - -#include - -namespace { - -bool isPowerOfTwo(const FwSizeType value) { - return (value != 0U) && ((value & (value - 1U)) == 0U); -} - -FwSizeType roundUpToPowerOfTwo(FwSizeType value) { - if (value <= 1U) { - return 1U; - } - - value--; - value |= value >> 1; - value |= value >> 2; - value |= value >> 4; - value |= value >> 8; - value |= value >> 16; - if (sizeof(FwSizeType) > 4U) { - value |= value >> 32; - } - value++; - return value; -} - -class ZephyrKmallocAllocator final : public Fw::MemAllocator { - public: - void* allocate(const FwEnumStoreType identifier, - FwSizeType& size, - bool& recoverable, - FwSizeType alignment = alignof(std::max_align_t)) override { - static_cast(identifier); - recoverable = false; - - const FwSizeType minAlignment = static_cast(sizeof(void*)); - FwSizeType requestedAlignment = (alignment < minAlignment) ? minAlignment : alignment; - if (!isPowerOfTwo(requestedAlignment)) { - requestedAlignment = roundUpToPowerOfTwo(requestedAlignment); - } - FW_ASSERT(isPowerOfTwo(requestedAlignment), static_cast(requestedAlignment)); - - void* mem = (requestedAlignment <= minAlignment) ? k_malloc(size) : k_aligned_alloc(requestedAlignment, size); - if (mem == nullptr) { - size = 0; - } - return mem; - } - - void deallocate(const FwEnumStoreType identifier, void* ptr) override { - static_cast(identifier); - k_free(ptr); - } -}; - -} // namespace - namespace ComCcsds { namespace Allocation { -ZephyrKmallocAllocator allocatorInstance; +Fw::ZephyrKmallocAllocator allocatorInstance; Fw::MemAllocator& memAllocator = allocatorInstance; } // namespace Allocation } // namespace ComCcsds diff --git a/FprimeZephyrReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.hpp b/FprimeZephyrReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.hpp index 0fa3c8c9..0e135482 100644 --- a/FprimeZephyrReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.hpp +++ b/FprimeZephyrReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.hpp @@ -1,7 +1,7 @@ #ifndef COMCCSDSSUBTOPOLOGY_CONFIG_HPP #define COMCCSDSSUBTOPOLOGY_CONFIG_HPP -#include "Fw/Types/MemAllocator.hpp" +#include "MemoryAllocation.hpp" namespace ComCcsds { namespace Allocation { diff --git a/lib/fprime-zephyr b/lib/fprime-zephyr index 31399714..83bca639 160000 --- a/lib/fprime-zephyr +++ b/lib/fprime-zephyr @@ -1 +1 @@ -Subproject commit 313997144363ea930af66e86b52d43537cf7f489 +Subproject commit 83bca639c1d632fe4db3c4c7dceebbd4295fa9de From 4ea434f6fc5ea5f0e87d54438e8277b1802ab71c Mon Sep 17 00:00:00 2001 From: "Sam S. Yu" <25761223+yudataguy@users.noreply.github.com> Date: Wed, 25 Feb 2026 16:29:31 -0800 Subject: [PATCH 03/13] Update fprime-zephyr submodule to fix MemoryAllocation config registration --- lib/fprime-zephyr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fprime-zephyr b/lib/fprime-zephyr index 83bca639..46a0be20 160000 --- a/lib/fprime-zephyr +++ b/lib/fprime-zephyr @@ -1 +1 @@ -Subproject commit 83bca639c1d632fe4db3c4c7dceebbd4295fa9de +Subproject commit 46a0be206fe9b75978c75d44f560ac9b25918840 From 90a130917396d8f2b675a03568f58fa32b9b8785 Mon Sep 17 00:00:00 2001 From: "Sam S. Yu" <25761223+yudataguy@users.noreply.github.com> Date: Wed, 25 Feb 2026 16:35:19 -0800 Subject: [PATCH 04/13] Move MemoryAllocation.hpp include to .cpp where concrete type is needed The header only needs the base Fw::MemAllocator type for the extern declaration. The concrete ZephyrKmallocAllocator type from MemoryAllocation.hpp is only needed in the .cpp for instantiation. --- .../project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.cpp | 2 ++ .../project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.hpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/PROVESFlightControllerReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.cpp b/PROVESFlightControllerReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.cpp index a50f4923..e0bcea25 100644 --- a/PROVESFlightControllerReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.cpp +++ b/PROVESFlightControllerReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.cpp @@ -1,5 +1,7 @@ #include "ComCcsdsSubtopologyConfig.hpp" +#include "MemoryAllocation.hpp" + namespace ComCcsds { namespace Allocation { Fw::ZephyrKmallocAllocator allocatorInstance; diff --git a/PROVESFlightControllerReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.hpp b/PROVESFlightControllerReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.hpp index 0e135482..0fa3c8c9 100644 --- a/PROVESFlightControllerReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.hpp +++ b/PROVESFlightControllerReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.hpp @@ -1,7 +1,7 @@ #ifndef COMCCSDSSUBTOPOLOGY_CONFIG_HPP #define COMCCSDSSUBTOPOLOGY_CONFIG_HPP -#include "MemoryAllocation.hpp" +#include "Fw/Types/MemAllocator.hpp" namespace ComCcsds { namespace Allocation { From 8cb22f6fb4878122947367ac30045949e02de444 Mon Sep 17 00:00:00 2001 From: "Sam S. Yu" <25761223+yudataguy@users.noreply.github.com> Date: Wed, 25 Feb 2026 16:39:29 -0800 Subject: [PATCH 05/13] Fix MemoryAllocation.hpp include to use config/ prefix fprime config headers are resolved via the config/ include path prefix, matching how the framework itself includes them (e.g. in MemAllocator.cpp). --- .../project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PROVESFlightControllerReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.cpp b/PROVESFlightControllerReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.cpp index e0bcea25..546892f6 100644 --- a/PROVESFlightControllerReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.cpp +++ b/PROVESFlightControllerReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.cpp @@ -1,6 +1,6 @@ #include "ComCcsdsSubtopologyConfig.hpp" -#include "MemoryAllocation.hpp" +#include namespace ComCcsds { namespace Allocation { From 27074e8e4fb53c38cfb5878c1dd117b6c19d1002 Mon Sep 17 00:00:00 2001 From: "Sam S. Yu" <25761223+yudataguy@users.noreply.github.com> Date: Thu, 26 Feb 2026 19:21:10 -0800 Subject: [PATCH 06/13] Update fprime-zephyr submodule with allocator alignment safety guards --- lib/fprime-zephyr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fprime-zephyr b/lib/fprime-zephyr index 46a0be20..9cfbdd9b 160000 --- a/lib/fprime-zephyr +++ b/lib/fprime-zephyr @@ -1 +1 @@ -Subproject commit 46a0be206fe9b75978c75d44f560ac9b25918840 +Subproject commit 9cfbdd9b548121a492c558e3df19bf7b7730292e From 8454df28625440bcde40a8b3099662007d0966d8 Mon Sep 17 00:00:00 2001 From: "Sam S. Yu" <25761223+yudataguy@users.noreply.github.com> Date: Thu, 26 Feb 2026 19:44:52 -0800 Subject: [PATCH 07/13] Update fprime-zephyr with allocation size rounding fix Picks up the fix that rounds allocation size up to a multiple of alignment, satisfying the C11 aligned_alloc requirement and enabling ZephyrKmallocAllocator as the project-wide default allocator. --- lib/fprime-zephyr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fprime-zephyr b/lib/fprime-zephyr index 9cfbdd9b..232fdb0b 160000 --- a/lib/fprime-zephyr +++ b/lib/fprime-zephyr @@ -1 +1 @@ -Subproject commit 9cfbdd9b548121a492c558e3df19bf7b7730292e +Subproject commit 232fdb0bd619d14490c6cfe9de284062fc33967d From e0bb64a42764dc6c29e3b8a2f4714f5ca1964f0f Mon Sep 17 00:00:00 2001 From: "Sam S. Yu" <25761223+yudataguy@users.noreply.github.com> Date: Thu, 26 Feb 2026 19:58:46 -0800 Subject: [PATCH 08/13] Revert kmalloc allocator changes for a fresh approach Restore ComCcsdsSubtopologyConfig to use MallocAllocator with separate ComCcsdsSband/ComCcsdsLora namespaces (matching main), and update fprime-zephyr submodule to reverted main. --- .../ComCcsdsSubtopologyConfig.cpp | 17 ++++++++++++----- .../ComCcsdsSubtopologyConfig.hpp | 12 +++++++++--- lib/fprime-zephyr | 2 +- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/PROVESFlightControllerReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.cpp b/PROVESFlightControllerReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.cpp index 546892f6..cbcb0548 100644 --- a/PROVESFlightControllerReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.cpp +++ b/PROVESFlightControllerReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.cpp @@ -1,10 +1,17 @@ #include "ComCcsdsSubtopologyConfig.hpp" -#include +namespace ComCcsdsSband { +namespace Allocation { +// This instance can be changed to use a different allocator in the ComCcsdsSband Subtopology +Fw::MallocAllocator mallocatorInstance; +Fw::MemAllocator& memAllocator = mallocatorInstance; +} // namespace Allocation +} // namespace ComCcsdsSband -namespace ComCcsds { +namespace ComCcsdsLora { namespace Allocation { -Fw::ZephyrKmallocAllocator allocatorInstance; -Fw::MemAllocator& memAllocator = allocatorInstance; +// This instance can be changed to use a different allocator in the ComCcsdsLora Subtopology +Fw::MallocAllocator mallocatorInstance; +Fw::MemAllocator& memAllocator = mallocatorInstance; } // namespace Allocation -} // namespace ComCcsds +} // namespace ComCcsdsLora diff --git a/PROVESFlightControllerReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.hpp b/PROVESFlightControllerReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.hpp index 0fa3c8c9..db0be600 100644 --- a/PROVESFlightControllerReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.hpp +++ b/PROVESFlightControllerReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.hpp @@ -1,12 +1,18 @@ #ifndef COMCCSDSSUBTOPOLOGY_CONFIG_HPP #define COMCCSDSSUBTOPOLOGY_CONFIG_HPP -#include "Fw/Types/MemAllocator.hpp" +#include "Fw/Types/MallocAllocator.hpp" -namespace ComCcsds { +namespace ComCcsdsSband { namespace Allocation { extern Fw::MemAllocator& memAllocator; } -} // namespace ComCcsds +} // namespace ComCcsdsSband + +namespace ComCcsdsLora { +namespace Allocation { +extern Fw::MemAllocator& memAllocator; +} +} // namespace ComCcsdsLora #endif diff --git a/lib/fprime-zephyr b/lib/fprime-zephyr index 232fdb0b..b759d2d3 160000 --- a/lib/fprime-zephyr +++ b/lib/fprime-zephyr @@ -1 +1 @@ -Subproject commit 232fdb0bd619d14490c6cfe9de284062fc33967d +Subproject commit b759d2d3283eeb9eb3964b95ecc75341fd1a0b52 From 48c24d76db007f8fe233bca54e1c0204bfb4a8cd Mon Sep 17 00:00:00 2001 From: "Sam S. Yu" <25761223+yudataguy@users.noreply.github.com> Date: Thu, 26 Feb 2026 20:21:13 -0800 Subject: [PATCH 09/13] Switch ComCcsds to Zephyr k_malloc allocator from fprime-zephyr Update fprime-zephyr submodule to include ZephyrKmallocAllocator as a targeted allocator (not project-wide override). Update ComCcsds config to use unified namespace and ZephyrKmallocAllocator for S-Band and LoRa subtopologies only. --- .../ComCcsdsSubtopologyConfig.cpp | 17 +++++------------ .../ComCcsdsSubtopologyConfig.hpp | 12 +++--------- lib/fprime-zephyr | 2 +- 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/PROVESFlightControllerReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.cpp b/PROVESFlightControllerReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.cpp index cbcb0548..76b453b7 100644 --- a/PROVESFlightControllerReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.cpp +++ b/PROVESFlightControllerReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.cpp @@ -1,17 +1,10 @@ #include "ComCcsdsSubtopologyConfig.hpp" -namespace ComCcsdsSband { -namespace Allocation { -// This instance can be changed to use a different allocator in the ComCcsdsSband Subtopology -Fw::MallocAllocator mallocatorInstance; -Fw::MemAllocator& memAllocator = mallocatorInstance; -} // namespace Allocation -} // namespace ComCcsdsSband +#include -namespace ComCcsdsLora { +namespace ComCcsds { namespace Allocation { -// This instance can be changed to use a different allocator in the ComCcsdsLora Subtopology -Fw::MallocAllocator mallocatorInstance; -Fw::MemAllocator& memAllocator = mallocatorInstance; +Fw::ZephyrKmallocAllocator allocatorInstance; +Fw::MemAllocator& memAllocator = allocatorInstance; } // namespace Allocation -} // namespace ComCcsdsLora +} // namespace ComCcsds diff --git a/PROVESFlightControllerReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.hpp b/PROVESFlightControllerReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.hpp index db0be600..0fa3c8c9 100644 --- a/PROVESFlightControllerReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.hpp +++ b/PROVESFlightControllerReference/project/config/ComCcsdsConfig/ComCcsdsSubtopologyConfig.hpp @@ -1,18 +1,12 @@ #ifndef COMCCSDSSUBTOPOLOGY_CONFIG_HPP #define COMCCSDSSUBTOPOLOGY_CONFIG_HPP -#include "Fw/Types/MallocAllocator.hpp" +#include "Fw/Types/MemAllocator.hpp" -namespace ComCcsdsSband { +namespace ComCcsds { namespace Allocation { extern Fw::MemAllocator& memAllocator; } -} // namespace ComCcsdsSband - -namespace ComCcsdsLora { -namespace Allocation { -extern Fw::MemAllocator& memAllocator; -} -} // namespace ComCcsdsLora +} // namespace ComCcsds #endif diff --git a/lib/fprime-zephyr b/lib/fprime-zephyr index b759d2d3..63c59ab9 160000 --- a/lib/fprime-zephyr +++ b/lib/fprime-zephyr @@ -1 +1 @@ -Subproject commit b759d2d3283eeb9eb3964b95ecc75341fd1a0b52 +Subproject commit 63c59ab999ac344cfdf9a29b3228187290438c88 From 6af460c3dcf4261a8f777b4c3c89ffda15d50207 Mon Sep 17 00:00:00 2001 From: "Sam S. Yu" <25761223+yudataguy@users.noreply.github.com> Date: Mon, 2 Mar 2026 14:49:21 -0800 Subject: [PATCH 10/13] Update fprime-zephyr submodule with aligned_alloc size rounding fix Points to aligned-alloc-size-rounding branch (f228013) which rounds allocation sizes to a multiple of alignment before calling k_aligned_alloc, preventing undefined behavior on Zephyr targets. Co-Authored-By: Claude Opus 4.6 --- lib/fprime-zephyr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fprime-zephyr b/lib/fprime-zephyr index 63c59ab9..f228013e 160000 --- a/lib/fprime-zephyr +++ b/lib/fprime-zephyr @@ -1 +1 @@ -Subproject commit 63c59ab999ac344cfdf9a29b3228187290438c88 +Subproject commit f228013e8a94ba399b672849ef6c6b0e8af5487f From e210cb38fa3e9100ea6fb2b4dc1b5fa4cf8031f2 Mon Sep 17 00:00:00 2001 From: "Sam S. Yu" <25761223+yudataguy@users.noreply.github.com> Date: Mon, 2 Mar 2026 14:54:08 -0800 Subject: [PATCH 11/13] Update fprime-zephyr to main with merged size-rounding fix (PR #9) Points submodule to a5e01c3, the merge commit on fprime-zephyr main that includes the aligned_alloc size-rounding fix. Co-Authored-By: Claude Opus 4.6 --- lib/fprime-zephyr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fprime-zephyr b/lib/fprime-zephyr index f228013e..a5e01c39 160000 --- a/lib/fprime-zephyr +++ b/lib/fprime-zephyr @@ -1 +1 @@ -Subproject commit f228013e8a94ba399b672849ef6c6b0e8af5487f +Subproject commit a5e01c39110e3af0b8cb93fad246e81c11a24775 From 1d3441444f72635b5a869223522f75718f69be4a Mon Sep 17 00:00:00 2001 From: "Sam S. Yu" <25761223+yudataguy@users.noreply.github.com> Date: Mon, 2 Mar 2026 16:31:49 -0800 Subject: [PATCH 12/13] Update fprime-zephyr to main with ARM alignment threshold fix (PR #10) Points to 171c8cc which adds alignof(max_align_t) threshold to avoid k_aligned_alloc on ARM when not needed, on top of the size-rounding fix. --- lib/fprime-zephyr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fprime-zephyr b/lib/fprime-zephyr index a5e01c39..171c8cce 160000 --- a/lib/fprime-zephyr +++ b/lib/fprime-zephyr @@ -1 +1 @@ -Subproject commit a5e01c39110e3af0b8cb93fad246e81c11a24775 +Subproject commit 171c8cce7800c8d20cc5f49cdd562023cf6cc098 From a1aeac702c889f5da241ad7f72971d63251221ca Mon Sep 17 00:00:00 2001 From: "Sam S. Yu" <25761223+yudataguy@users.noreply.github.com> Date: Fri, 20 Mar 2026 22:22:52 -0700 Subject: [PATCH 13/13] chore: bump fprime-zephyr for allocator fix --- lib/fprime-zephyr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fprime-zephyr b/lib/fprime-zephyr index 171c8cce..e7fb94d0 160000 --- a/lib/fprime-zephyr +++ b/lib/fprime-zephyr @@ -1 +1 @@ -Subproject commit 171c8cce7800c8d20cc5f49cdd562023cf6cc098 +Subproject commit e7fb94d0d8c2b0934147eb42f30774174d594bcd