From 413af16310f6ffe4e1dc351caecfda08c0d3ea02 Mon Sep 17 00:00:00 2001 From: Cristian Bulacu Date: Thu, 2 Oct 2025 16:51:59 +0300 Subject: [PATCH] openthread: platform: radio_spinel: Spinel variables on global memory This commits aims to move spinel related variables from heap to global arrays. In this way, HEAP_MEM_POOL_ADD_SIZE_ does not need to be defined, or updated if any change in data structure might occur. Signed-off-by: Cristian Bulacu --- modules/openthread/platform/radio_spinel.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/modules/openthread/platform/radio_spinel.cpp b/modules/openthread/platform/radio_spinel.cpp index 1e0e42824e38c..8d90ab1b4f5f2 100644 --- a/modules/openthread/platform/radio_spinel.cpp +++ b/modules/openthread/platform/radio_spinel.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2021, The OpenThread Authors. - * Copyright (c) 2022-2024, NXP. + * Copyright (c) 2022-2025, NXP. * * All rights reserved. * @@ -46,6 +46,8 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME, CONFIG_OPENTHREAD_PLATFORM_LOG_LEVEL); #include #include #include +#include +#include enum pending_events { PENDING_EVENT_FRAME_TO_SEND, /* There is a tx frame to send */ @@ -60,6 +62,11 @@ static ot::Url::Url *psRadioUrl; static ot::Hdlc::HdlcInterface *pSpinelInterface; static ot::Spinel::SpinelDriver *psSpinelDriver; +alignas(ot::Spinel::RadioSpinel) static uint8_t gRadioBuf[sizeof(ot::Spinel::RadioSpinel)]; +alignas(ot::Url::Url) static uint8_t gUrlBuf[sizeof(ot::Url::Url)]; +alignas(ot::Hdlc::HdlcInterface) static uint8_t gIfaceBuf[sizeof(ot::Hdlc::HdlcInterface)]; +alignas(ot::Spinel::SpinelDriver) static uint8_t gDriverBuf[sizeof(ot::Spinel::SpinelDriver)]; + static const otRadioCaps sRequiredRadioCaps = #if OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2 OT_RADIO_CAPS_TRANSMIT_SEC | OT_RADIO_CAPS_TRANSMIT_TIMING | @@ -527,11 +534,11 @@ extern "C" void platformRadioInit(void) iidList[0] = 0; - psRadioSpinel = new ot::Spinel::RadioSpinel(); - psSpinelDriver = new ot::Spinel::SpinelDriver(); + psRadioSpinel = new(gRadioBuf) ot::Spinel::RadioSpinel(); + psSpinelDriver = new(gDriverBuf) ot::Spinel::SpinelDriver(); - psRadioUrl = new ot::Url::Url(); - pSpinelInterface = new ot::Hdlc::HdlcInterface(*psRadioUrl); + psRadioUrl = new(gUrlBuf) ot::Url::Url(); + pSpinelInterface = new(gIfaceBuf) ot::Hdlc::HdlcInterface(*psRadioUrl); OT_UNUSED_VARIABLE(psSpinelDriver->Init(*pSpinelInterface, true /* aSoftwareReset */, iidList, OT_ARRAY_LENGTH(iidList)));