Skip to content

Commit 413af16

Browse files
committed
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 <[email protected]>
1 parent 69548c6 commit 413af16

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

modules/openthread/platform/radio_spinel.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2021, The OpenThread Authors.
3-
* Copyright (c) 2022-2024, NXP.
3+
* Copyright (c) 2022-2025, NXP.
44
*
55
* All rights reserved.
66
*
@@ -46,6 +46,8 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME, CONFIG_OPENTHREAD_PLATFORM_LOG_LEVEL);
4646
#include <zephyr/kernel.h>
4747
#include <zephyr/net/net_pkt.h>
4848
#include <openthread-system.h>
49+
#include <stdalign.h>
50+
#include <common/new.hpp>
4951

5052
enum pending_events {
5153
PENDING_EVENT_FRAME_TO_SEND, /* There is a tx frame to send */
@@ -60,6 +62,11 @@ static ot::Url::Url *psRadioUrl;
6062
static ot::Hdlc::HdlcInterface *pSpinelInterface;
6163
static ot::Spinel::SpinelDriver *psSpinelDriver;
6264

65+
alignas(ot::Spinel::RadioSpinel) static uint8_t gRadioBuf[sizeof(ot::Spinel::RadioSpinel)];
66+
alignas(ot::Url::Url) static uint8_t gUrlBuf[sizeof(ot::Url::Url)];
67+
alignas(ot::Hdlc::HdlcInterface) static uint8_t gIfaceBuf[sizeof(ot::Hdlc::HdlcInterface)];
68+
alignas(ot::Spinel::SpinelDriver) static uint8_t gDriverBuf[sizeof(ot::Spinel::SpinelDriver)];
69+
6370
static const otRadioCaps sRequiredRadioCaps =
6471
#if OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2
6572
OT_RADIO_CAPS_TRANSMIT_SEC | OT_RADIO_CAPS_TRANSMIT_TIMING |
@@ -527,11 +534,11 @@ extern "C" void platformRadioInit(void)
527534

528535
iidList[0] = 0;
529536

530-
psRadioSpinel = new ot::Spinel::RadioSpinel();
531-
psSpinelDriver = new ot::Spinel::SpinelDriver();
537+
psRadioSpinel = new(gRadioBuf) ot::Spinel::RadioSpinel();
538+
psSpinelDriver = new(gDriverBuf) ot::Spinel::SpinelDriver();
532539

533-
psRadioUrl = new ot::Url::Url();
534-
pSpinelInterface = new ot::Hdlc::HdlcInterface(*psRadioUrl);
540+
psRadioUrl = new(gUrlBuf) ot::Url::Url();
541+
pSpinelInterface = new(gIfaceBuf) ot::Hdlc::HdlcInterface(*psRadioUrl);
535542

536543
OT_UNUSED_VARIABLE(psSpinelDriver->Init(*pSpinelInterface, true /* aSoftwareReset */,
537544
iidList, OT_ARRAY_LENGTH(iidList)));

0 commit comments

Comments
 (0)