From 72785058e5001121821c61547db62599a13dd118 Mon Sep 17 00:00:00 2001 From: Junior Martinez <67972863+jmartinez-silabs@users.noreply.github.com> Date: Wed, 19 Jun 2024 17:44:13 -0400 Subject: [PATCH 01/12] add simplicity sdk as submodule. remove gecko_sdk. Change wifi sdk branch --- .gitmodules | 10 +++++----- src/platform/silabs/efr32/args.gni | 2 +- third_party/silabs/efr32_sdk.gni | 2 +- third_party/silabs/gecko_sdk | 1 - third_party/silabs/simplicity_sdk | 1 + third_party/silabs/wifi_sdk | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) delete mode 160000 third_party/silabs/gecko_sdk create mode 160000 third_party/silabs/simplicity_sdk diff --git a/.gitmodules b/.gitmodules index b2e1bc8d4ebd98..dee55fa9536e7e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -231,10 +231,10 @@ url = https://github.com/SiliconLabs/sdk_support.git branch = main platforms = silabs,silabs_docker -[submodule "third_party/silabs/gecko_sdk"] - path = third_party/silabs/gecko_sdk - url = https://github.com/SiliconLabs/gecko_sdk.git - branch = v4.4.2 +[submodule "third_party/silabs/simplicity_sdk"] + path = third_party/silabs/simplicity_sdk + url = https://github.com/SiliconLabs/simplicity_sdk.git + branch = v2024.6.0 platforms = silabs [submodule "third_party/silabs/wiseconnect-wifi-bt-sdk"] path = third_party/silabs/wiseconnect-wifi-bt-sdk @@ -244,7 +244,7 @@ [submodule "third_party/silabs/wifi_sdk"] path = third_party/silabs/wifi_sdk url = https://github.com/SiliconLabs/wiseconnect.git - branch = v3.1.3-matter-hotfix.4 + branch = v3.3.0 platforms = silabs [submodule "editline"] path = third_party/editline/repo diff --git a/src/platform/silabs/efr32/args.gni b/src/platform/silabs/efr32/args.gni index ad124dec8e63c0..394e4bb1bd806a 100644 --- a/src/platform/silabs/efr32/args.gni +++ b/src/platform/silabs/efr32/args.gni @@ -48,7 +48,7 @@ chip_build_tests = false chip_use_transitional_commissionable_data_provider = false openthread_root = - "${chip_root}/third_party/silabs/gecko_sdk/util/third_party/openthread" + "${chip_root}/third_party/silabs/simplicity_sdk/util/third_party/openthread" openthread_core_config_platform_check_file = "openthread-core-efr32-config-check.h" diff --git a/third_party/silabs/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index a563f8eb4a9731..60622f4c75e71e 100644 --- a/third_party/silabs/efr32_sdk.gni +++ b/third_party/silabs/efr32_sdk.gni @@ -23,7 +23,7 @@ import("silabs_board.gni") declare_args() { # Location of the efr32 SDK. - efr32_sdk_root = "${chip_root}/third_party/silabs/gecko_sdk" + efr32_sdk_root = "${chip_root}/third_party/silabs/simplicity_sdk" sdk_support_root = "${chip_root}/third_party/silabs/matter_support" wiseconnect_sdk_root = "${chip_root}/third_party/silabs/wiseconnect-wifi-bt-sdk" diff --git a/third_party/silabs/gecko_sdk b/third_party/silabs/gecko_sdk deleted file mode 160000 index e359ba40a2ba5b..00000000000000 --- a/third_party/silabs/gecko_sdk +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e359ba40a2ba5b127964a6e7afe9e70ff5f9a1cf diff --git a/third_party/silabs/simplicity_sdk b/third_party/silabs/simplicity_sdk new file mode 160000 index 00000000000000..a1a37fa7dda1f7 --- /dev/null +++ b/third_party/silabs/simplicity_sdk @@ -0,0 +1 @@ +Subproject commit a1a37fa7dda1f76ea70229aa4ffe2e47cb066edc diff --git a/third_party/silabs/wifi_sdk b/third_party/silabs/wifi_sdk index aa514d4fac4b56..e97a0ed00ddda3 160000 --- a/third_party/silabs/wifi_sdk +++ b/third_party/silabs/wifi_sdk @@ -1 +1 @@ -Subproject commit aa514d4fac4b568d03e1f6d3d19c7811034d5077 +Subproject commit e97a0ed00ddda347a8a39e8276f470e1c5fea469 From ca68e0996a2257e14c2d697277b5221edc859a71 Mon Sep 17 00:00:00 2001 From: Junior Martinez <67972863+jmartinez-silabs@users.noreply.github.com> Date: Thu, 20 Jun 2024 22:47:33 -0400 Subject: [PATCH 02/12] Reamove Heap_4_silabs, replace by sl_memory_manager Update matter-platform.slcp for simplicity sdk --- examples/platform/silabs/SiWx917/BUILD.gn | 8 +- examples/platform/silabs/efr32/BUILD.gn | 8 +- examples/platform/silabs/heap_4_silabs.c | 673 ------------------ examples/platform/silabs/heap_4_silabs.h | 49 -- .../platform/silabs/ldscripts/efr32mg24.ld | 262 ++++--- examples/platform/silabs/matter-platform.slcp | 28 +- src/platform/silabs/CHIPMem-Platform.cpp | 18 +- .../silabs/DiagnosticDataProviderImpl.cpp | 26 +- src/test_driver/efr32/BUILD.gn | 1 - third_party/silabs/slc_gen/run_slc.py | 21 +- 10 files changed, 164 insertions(+), 930 deletions(-) delete mode 100644 examples/platform/silabs/heap_4_silabs.c delete mode 100644 examples/platform/silabs/heap_4_silabs.h diff --git a/examples/platform/silabs/SiWx917/BUILD.gn b/examples/platform/silabs/SiWx917/BUILD.gn index e8fce7e11279f6..084339723a0037 100644 --- a/examples/platform/silabs/SiWx917/BUILD.gn +++ b/examples/platform/silabs/SiWx917/BUILD.gn @@ -59,13 +59,8 @@ config("chip_examples_project_config") { include_dirs = [ "project_include" ] # Link options that provide a replacement for dynamic memory operations in standard - # library with the FreeRTOS malloc in platform code. + # library with the sl_memory_manager in platform code. ldflags = [ - # memory allocation -- these must be re-entrant and do locking - "-Wl,--wrap=malloc", - "-Wl,--wrap=free", - "-Wl,--wrap=realloc", - "-Wl,--wrap=calloc", "-Wl,--wrap=MemoryAlloc", # Wrap these in case internal newlib call them (e.g. strdup will) @@ -234,7 +229,6 @@ source_set("siwx917-common") { "${silabs_common_plat_dir}/LEDWidget.cpp", "${silabs_common_plat_dir}/MatterConfig.cpp", "${silabs_common_plat_dir}/SoftwareFaultReports.cpp", - "${silabs_common_plat_dir}/heap_4_silabs.c", "${silabs_common_plat_dir}/silabs_utils.cpp", "${silabs_common_plat_dir}/syscalls_stubs.cpp", "${silabs_plat_si91x_wifi_dir}/dhcp_client.cpp", diff --git a/examples/platform/silabs/efr32/BUILD.gn b/examples/platform/silabs/efr32/BUILD.gn index aa6c72a98c24b2..20180ecb57656a 100644 --- a/examples/platform/silabs/efr32/BUILD.gn +++ b/examples/platform/silabs/efr32/BUILD.gn @@ -76,13 +76,8 @@ config("chip_examples_project_config") { include_dirs = [ "project_include" ] # Link options that provide a replacement for dynamic memory operations in standard - # library with the FreeRTOS malloc in platform code. + # library with the sl_memory_manager in platform code. ldflags = [ - # memory allocation -- these must be re-entrant and do locking - "-Wl,--wrap=malloc", - "-Wl,--wrap=free", - "-Wl,--wrap=realloc", - "-Wl,--wrap=calloc", "-Wl,--wrap=MemoryAlloc", # Wrap these in case internal newlib call them (e.g. strdup will) @@ -280,7 +275,6 @@ source_set("efr32-common") { "${silabs_common_plat_dir}/LEDWidget.cpp", "${silabs_common_plat_dir}/MatterConfig.cpp", "${silabs_common_plat_dir}/SoftwareFaultReports.cpp", - "${silabs_common_plat_dir}/heap_4_silabs.c", "${silabs_common_plat_dir}/silabs_utils.cpp", "${silabs_common_plat_dir}/syscalls_stubs.cpp", ] diff --git a/examples/platform/silabs/heap_4_silabs.c b/examples/platform/silabs/heap_4_silabs.c deleted file mode 100644 index 8abb295caefd2d..00000000000000 --- a/examples/platform/silabs/heap_4_silabs.c +++ /dev/null @@ -1,673 +0,0 @@ -/* - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * FreeRTOS Kernel V10.4.3 - * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * https://www.FreeRTOS.org - * https://github.com/FreeRTOS - * - */ - -/* - * A sample implementation of pvPortMalloc() and vPortFree() that combines - * (coalescences) adjacent memory blocks as they are freed, and in so doing - * limits memory fragmentation. - * - * See heap_1.c, heap_2.c and heap_3.c for alternative implementations, and the - * memory management pages of https://www.FreeRTOS.org for more information. - */ -#include - -/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining -all the API functions to use the MPU wrappers. That should only be done when -task.h is included from an application file. */ -#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE - -#include "heap_4_silabs.h" -#include "task.h" -#include -#include - -#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE - -#if (configSUPPORT_DYNAMIC_ALLOCATION == 0) -#error This file must not be used if configSUPPORT_DYNAMIC_ALLOCATION is 0 -#endif - -/* Block sizes must not get too small. */ -#define heapMINIMUM_BLOCK_SIZE ((size_t) (xHeapStructSize << 1)) - -/* Assumes 8bit bytes! */ -#define heapBITS_PER_BYTE ((size_t) 8) - -/* Allocate the memory for the heap. */ -#if (configAPPLICATION_ALLOCATED_HEAP == 1) -/* The application writer has already defined the array used for the RTOS -heap - probably so it can be placed in a special segment or address. */ -extern uint8_t ucHeap[configTOTAL_HEAP_SIZE]; -#else -static uint8_t ucHeap[configTOTAL_HEAP_SIZE]; -#endif /* configAPPLICATION_ALLOCATED_HEAP */ - -/* Define the linked list structure. This is used to link free blocks in order -of their memory address. */ -typedef struct A_BLOCK_LINK -{ - struct A_BLOCK_LINK * pxNextFreeBlock; /*<< The next free block in the list. */ - size_t xBlockSize; /*<< The size of the free block. */ -} BlockLink_t; - -/*-----------------------------------------------------------*/ - -/* - * Inserts a block of memory that is being freed into the correct position in - * the list of free memory blocks. The block being freed will be merged with - * the block in front it and/or the block behind it if the memory blocks are - * adjacent to each other. - */ -static void prvInsertBlockIntoFreeList(BlockLink_t * pxBlockToInsert); - -/* - * Called automatically to setup the required heap structures the first time - * pvPortMalloc() is called. - */ -static void prvHeapInit(void); - -/*-----------------------------------------------------------*/ - -/* The size of the structure placed at the beginning of each allocated memory - * block must by correctly byte aligned. */ -static const size_t xHeapStructSize = - (sizeof(BlockLink_t) + ((size_t) (portBYTE_ALIGNMENT - 1))) & ~((size_t) portBYTE_ALIGNMENT_MASK); - -/* Create a couple of list links to mark the start and end of the list. */ -static BlockLink_t xStart, *pxEnd = NULL; - -/* Keeps track of the number of calls to allocate and free memory as well as the - * number of free bytes remaining, but says nothing about fragmentation. */ -static size_t xFreeBytesRemaining = 0U; -static size_t xMinimumEverFreeBytesRemaining = 0U; -static size_t xNumberOfSuccessfulAllocations = 0; -static size_t xNumberOfSuccessfulFrees = 0; - -/* Gets set to the top bit of an size_t type. When this bit in the xBlockSize - * member of an BlockLink_t structure is set then the block belongs to the - * application. When the bit is free the block is still part of the free heap - * space. */ -static size_t xBlockAllocatedBit = 0; - -/** - * @brief xPortPointerSize is based on the malloc implementation of heap_4 - * Returns the size of allocated block associated to the pointer - * - * @param pv pointer - * @return size_t block size - */ -size_t xPortPointerSize(void * pv) -{ - uint8_t * puc = (uint8_t *) pv; - BlockLink_t * pxLink; - void * voidp; - size_t sz = 0; - - if (pv != NULL) - { - vTaskSuspendAll(); - { - /* The memory being checked will have an BlockLink_t structure immediately - before it. */ - puc -= xHeapStructSize; - - /* This casting is to keep the compiler from issuing warnings. */ - voidp = (void *) puc; - pxLink = (BlockLink_t *) voidp; - - /* Check if the block is actually allocated. */ - configASSERT((pxLink->xBlockSize & xBlockAllocatedBit) != 0); - configASSERT(pxLink->pxNextFreeBlock == NULL); - - sz = (pxLink->xBlockSize & ~xBlockAllocatedBit) - xHeapStructSize; - } - (void) xTaskResumeAll(); - } - - return sz; -} - -/*-----------------------------------------------------------*/ - -void * pvPortMalloc(size_t xWantedSize) -{ - BlockLink_t *pxBlock, *pxPreviousBlock, *pxNewBlockLink; - void * pvReturn = NULL; - - vTaskSuspendAll(); - { - /* If this is the first call to malloc then the heap will require - * initialisation to setup the list of free blocks. */ - if (pxEnd == NULL) - { - prvHeapInit(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - /* Check the requested block size is not so large that the top bit is - * set. The top bit of the block size member of the BlockLink_t structure - * is used to determine who owns the block - the application or the - * kernel, so it must be free. */ - if ((xWantedSize & xBlockAllocatedBit) == 0) - { - /* The wanted size must be increased so it can contain a BlockLink_t - * structure in addition to the requested amount of bytes. */ - if ((xWantedSize > 0) && ((xWantedSize + xHeapStructSize) > xWantedSize)) /* Overflow check */ - { - xWantedSize += xHeapStructSize; - - /* Ensure that blocks are always aligned. */ - if ((xWantedSize & portBYTE_ALIGNMENT_MASK) != 0x00) - { - /* Byte alignment required. Check for overflow. */ - if ((xWantedSize + (portBYTE_ALIGNMENT - (xWantedSize & portBYTE_ALIGNMENT_MASK))) > xWantedSize) - { - xWantedSize += (portBYTE_ALIGNMENT - (xWantedSize & portBYTE_ALIGNMENT_MASK)); - configASSERT((xWantedSize & portBYTE_ALIGNMENT_MASK) == 0); - } - else - { - xWantedSize = 0; - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - xWantedSize = 0; - } - - if ((xWantedSize > 0) && (xWantedSize <= xFreeBytesRemaining)) - { - /* Traverse the list from the start (lowest address) block until - * one of adequate size is found. */ - pxPreviousBlock = &xStart; - pxBlock = xStart.pxNextFreeBlock; - - while ((pxBlock->xBlockSize < xWantedSize) && (pxBlock->pxNextFreeBlock != NULL)) - { - pxPreviousBlock = pxBlock; - pxBlock = pxBlock->pxNextFreeBlock; - } - - /* If the end marker was reached then a block of adequate size - * was not found. */ - if (pxBlock != pxEnd) - { - /* Return the memory space pointed to - jumping over the - * BlockLink_t structure at its start. */ - pvReturn = (void *) (((uint8_t *) pxPreviousBlock->pxNextFreeBlock) + xHeapStructSize); - - /* This block is being returned for use so must be taken out - * of the list of free blocks. */ - pxPreviousBlock->pxNextFreeBlock = pxBlock->pxNextFreeBlock; - - /* If the block is larger than required it can be split into - * two. */ - if ((pxBlock->xBlockSize - xWantedSize) > heapMINIMUM_BLOCK_SIZE) - { - /* This block is to be split into two. Create a new - * block following the number of bytes requested. The void - * cast is used to prevent byte alignment warnings from the - * compiler. */ - pxNewBlockLink = (void *) (((uint8_t *) pxBlock) + xWantedSize); - configASSERT((((size_t) pxNewBlockLink) & portBYTE_ALIGNMENT_MASK) == 0); - - /* Calculate the sizes of two blocks split from the - * single block. */ - pxNewBlockLink->xBlockSize = pxBlock->xBlockSize - xWantedSize; - pxBlock->xBlockSize = xWantedSize; - - /* Insert the new block into the list of free blocks. */ - prvInsertBlockIntoFreeList(pxNewBlockLink); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - xFreeBytesRemaining -= pxBlock->xBlockSize; - - if (xFreeBytesRemaining < xMinimumEverFreeBytesRemaining) - { - xMinimumEverFreeBytesRemaining = xFreeBytesRemaining; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - /* The block is being returned - it is allocated and owned - * by the application and has no "next" block. */ - pxBlock->xBlockSize |= xBlockAllocatedBit; - pxBlock->pxNextFreeBlock = NULL; - xNumberOfSuccessfulAllocations++; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - traceMALLOC(pvReturn, xWantedSize); - } - (void) xTaskResumeAll(); - -#if (configUSE_MALLOC_FAILED_HOOK == 1) - { - if (pvReturn == NULL) - { - extern void vApplicationMallocFailedHook(void); - vApplicationMallocFailedHook(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } -#endif /* if ( configUSE_MALLOC_FAILED_HOOK == 1 ) */ - - configASSERT((((size_t) pvReturn) & (size_t) portBYTE_ALIGNMENT_MASK) == 0); - return pvReturn; -} -/*-----------------------------------------------------------*/ - -void * pvPortCalloc(size_t num, size_t size) -{ - size_t total = num * size; - // check for multiplication overflow - if ((size != 0) && ((total / size) != num)) - { - return NULL; - } - - void * ptr = pvPortMalloc(total); - if (ptr != NULL) - { - memset(ptr, 0, total); - } - - return ptr; -} - -void * pvPortRealloc(void * pv, size_t size) -{ - void * resized_ptr = NULL; - size_t current_size = xPortPointerSize(pv); - - if (current_size > 0) // pv is allocated - { - if (size) // New size is not 0 - { - if (size == current_size) // if existing pointer is the same size - { - resized_ptr = pv; - } - else // New size is a different from current size - { - resized_ptr = pvPortCalloc(1, size); - if (resized_ptr != NULL) - { - size_t smallest_size = size < current_size ? size : current_size; - memcpy(resized_ptr, pv, smallest_size); - - vPortFree(pv); - } - } - } - else // If size if 0, free pointer - { - vPortFree(pv); - } - } - else // pv is not allocated, allocate a new pointer - { - resized_ptr = pvPortCalloc(1, size); - } - - return resized_ptr; -} - -/*-----------------------------------------------------------*/ - -void vPortFree(void * pv) -{ - uint8_t * puc = (uint8_t *) pv; - BlockLink_t * pxLink; - - if (pv != NULL) - { - /* The memory being freed will have an BlockLink_t structure immediately - * before it. */ - puc -= xHeapStructSize; - - /* This casting is to keep the compiler from issuing warnings. */ - pxLink = (void *) puc; - - /* Check the block is actually allocated. */ - configASSERT((pxLink->xBlockSize & xBlockAllocatedBit) != 0); - configASSERT(pxLink->pxNextFreeBlock == NULL); - - if ((pxLink->xBlockSize & xBlockAllocatedBit) != 0) - { - if (pxLink->pxNextFreeBlock == NULL) - { - /* The block is being returned to the heap - it is no longer - * allocated. */ - pxLink->xBlockSize &= ~xBlockAllocatedBit; - - vTaskSuspendAll(); - { - /* Add this block to the list of free blocks. */ - xFreeBytesRemaining += pxLink->xBlockSize; - traceFREE(pv, pxLink->xBlockSize); - prvInsertBlockIntoFreeList(((BlockLink_t *) pxLink)); - xNumberOfSuccessfulFrees++; - } - (void) xTaskResumeAll(); - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - } -} -/*-----------------------------------------------------------*/ - -size_t xPortGetFreeHeapSize(void) -{ - return xFreeBytesRemaining; -} -/*-----------------------------------------------------------*/ - -size_t xPortGetMinimumEverFreeHeapSize(void) -{ - return xMinimumEverFreeBytesRemaining; -} - -void xPortResetHeapMinimumEverFreeHeapSize(void) -{ - taskENTER_CRITICAL(); - { - xMinimumEverFreeBytesRemaining = xFreeBytesRemaining; - } - taskEXIT_CRITICAL(); -} - -/*-----------------------------------------------------------*/ - -void vPortInitialiseBlocks(void) -{ - /* This just exists to keep the linker quiet. */ -} -/*-----------------------------------------------------------*/ - -static void prvHeapInit(void) -{ - BlockLink_t * pxFirstFreeBlock; - uint8_t * pucAlignedHeap; - size_t uxAddress; - size_t xTotalHeapSize = configTOTAL_HEAP_SIZE; - - /* Ensure the heap starts on a correctly aligned boundary. */ - uxAddress = (size_t) ucHeap; - - if ((uxAddress & portBYTE_ALIGNMENT_MASK) != 0) - { - uxAddress += (portBYTE_ALIGNMENT - 1); - uxAddress &= ~((size_t) portBYTE_ALIGNMENT_MASK); - xTotalHeapSize -= uxAddress - (size_t) ucHeap; - } - - pucAlignedHeap = (uint8_t *) uxAddress; - - /* xStart is used to hold a pointer to the first item in the list of free - * blocks. The void cast is used to prevent compiler warnings. */ - xStart.pxNextFreeBlock = (void *) pucAlignedHeap; - xStart.xBlockSize = (size_t) 0; - - /* pxEnd is used to mark the end of the list of free blocks and is inserted - * at the end of the heap space. */ - uxAddress = ((size_t) pucAlignedHeap) + xTotalHeapSize; - uxAddress -= xHeapStructSize; - uxAddress &= ~((size_t) portBYTE_ALIGNMENT_MASK); - pxEnd = (void *) uxAddress; - pxEnd->xBlockSize = 0; - pxEnd->pxNextFreeBlock = NULL; - - /* To start with there is a single free block that is sized to take up the - * entire heap space, minus the space taken by pxEnd. */ - pxFirstFreeBlock = (void *) pucAlignedHeap; - pxFirstFreeBlock->xBlockSize = uxAddress - (size_t) pxFirstFreeBlock; - pxFirstFreeBlock->pxNextFreeBlock = pxEnd; - - /* Only one block exists - and it covers the entire usable heap space. */ - xMinimumEverFreeBytesRemaining = pxFirstFreeBlock->xBlockSize; - xFreeBytesRemaining = pxFirstFreeBlock->xBlockSize; - - /* Work out the position of the top bit in a size_t variable. */ - xBlockAllocatedBit = ((size_t) 1) << ((sizeof(size_t) * heapBITS_PER_BYTE) - 1); -} -/*-----------------------------------------------------------*/ - -static void prvInsertBlockIntoFreeList(BlockLink_t * pxBlockToInsert) -{ - BlockLink_t * pxIterator; - uint8_t * puc; - - if (xStart.pxNextFreeBlock == 0) - { - // configASSERT( xStart.pxNextFreeBlock!=0); - HeapStats_t Stats; - vPortGetHeapStats(&Stats); - } - /* Iterate through the list until a block is found that has a higher address - * than the block being inserted. */ - for (pxIterator = &xStart; pxIterator->pxNextFreeBlock < pxBlockToInsert; pxIterator = pxIterator->pxNextFreeBlock) - { - /* Nothing to do here, just iterate to the right position. */ - } - - /* Do the block being inserted, and the block it is being inserted after - * make a contiguous block of memory? */ - puc = (uint8_t *) pxIterator; - - if ((puc + pxIterator->xBlockSize) == (uint8_t *) pxBlockToInsert) - { - pxIterator->xBlockSize += pxBlockToInsert->xBlockSize; - pxBlockToInsert = pxIterator; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } - - /* Do the block being inserted, and the block it is being inserted before - * make a contiguous block of memory? */ - puc = (uint8_t *) pxBlockToInsert; - - if ((puc + pxBlockToInsert->xBlockSize) == (uint8_t *) pxIterator->pxNextFreeBlock) - { - if (pxIterator->pxNextFreeBlock != pxEnd) - { - /* Form one big block from the two blocks. */ - pxBlockToInsert->xBlockSize += pxIterator->pxNextFreeBlock->xBlockSize; - pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock->pxNextFreeBlock; - } - else - { - pxBlockToInsert->pxNextFreeBlock = pxEnd; - } - } - else - { - pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock; - } - - /* If the block being inserted plugged a gab, so was merged with the block - * before and the block after, then it's pxNextFreeBlock pointer will have - * already been set, and should not be set here as that would make it point - * to itself. */ - if (pxIterator != pxBlockToInsert) - { - pxIterator->pxNextFreeBlock = pxBlockToInsert; - } - else - { - mtCOVERAGE_TEST_MARKER(); - } -} -/*-----------------------------------------------------------*/ - -void vPortGetHeapStats(HeapStats_t * pxHeapStats) -{ - BlockLink_t * pxBlock; - size_t xBlocks = 0, xMaxSize = 0, - xMinSize = portMAX_DELAY; /* portMAX_DELAY used as a portable way of getting the maximum value. */ - - vTaskSuspendAll(); - { - pxBlock = xStart.pxNextFreeBlock; - - /* pxBlock will be NULL if the heap has not been initialised. The heap - * is initialised automatically when the first allocation is made. */ - if (pxBlock != NULL) - { - do - { - /* Increment the number of blocks and record the largest block seen - * so far. */ - xBlocks++; - - if (pxBlock->xBlockSize > xMaxSize) - { - xMaxSize = pxBlock->xBlockSize; - } - - if (pxBlock->xBlockSize < xMinSize) - { - xMinSize = pxBlock->xBlockSize; - } - - /* Move to the next block in the chain until the last block is - * reached. */ - pxBlock = pxBlock->pxNextFreeBlock; - } while (pxBlock != pxEnd); - } - } - (void) xTaskResumeAll(); - - pxHeapStats->xSizeOfLargestFreeBlockInBytes = xMaxSize; - pxHeapStats->xSizeOfSmallestFreeBlockInBytes = xMinSize; - pxHeapStats->xNumberOfFreeBlocks = xBlocks; - - taskENTER_CRITICAL(); - { - pxHeapStats->xAvailableHeapSpaceInBytes = xFreeBytesRemaining; - pxHeapStats->xNumberOfSuccessfulAllocations = xNumberOfSuccessfulAllocations; - pxHeapStats->xNumberOfSuccessfulFrees = xNumberOfSuccessfulFrees; - pxHeapStats->xMinimumEverFreeBytesRemaining = xMinimumEverFreeBytesRemaining; - } - taskEXIT_CRITICAL(); -} - -/* - * Wrapper functions to override default memory allocation functions - */ -void * __wrap_malloc(size_t size) -{ - return pvPortMalloc(size); -} - -void __wrap_free(void * ptr) -{ - vPortFree(ptr); -} - -void * __wrap_realloc(void * ptr, size_t new_size) -{ - return pvPortRealloc(ptr, new_size); -} - -__attribute__((used)) void * __wrap_calloc(size_t num, size_t size) -{ - return pvPortCalloc(num, size); -} - -void * __wrap__calloc_r(void * REENT, size_t num, size_t size) -{ - return __wrap_calloc(num, size); -} - -void * __wrap__malloc_r(void * REENT, size_t size) -{ - return __wrap_malloc(size); -} - -void __wrap__free_r(void * REENT, void * ptr) -{ - __wrap_free(ptr); -} - -void * __wrap__realloc_r(void * REENT, void * ptr, size_t new_size) -{ - return __wrap_realloc(ptr, new_size); -} diff --git a/examples/platform/silabs/heap_4_silabs.h b/examples/platform/silabs/heap_4_silabs.h deleted file mode 100644 index ed773f59f0a33c..00000000000000 --- a/examples/platform/silabs/heap_4_silabs.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/******************************************************************************* - * @file - * @brief heap_4_silabs.h - ******************************************************************************* - * # License - * Copyright 2018 Silicon Laboratories Inc. www.silabs.com - ******************************************************************************* - * - * The licensor of this software is Silicon Laboratories Inc. Your use of this - * software is governed by the terms of Silicon Labs Master Software License - * Agreement (MSLA) available at - * www.silabs.com/about-us/legal/master-software-license-agreement. This - * software is distributed to you in Source Code format and is governed by the - * sections of the MSLA applicable to Source Code. - * - ******************************************************************************/ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "FreeRTOS.h" -#include - -void * pvPortCalloc(size_t num, size_t size); -void * pvPortRealloc(void * pv, size_t size); - -void xPortResetHeapMinimumEverFreeHeapSize(void); - -#ifdef __cplusplus -} -#endif diff --git a/examples/platform/silabs/ldscripts/efr32mg24.ld b/examples/platform/silabs/ldscripts/efr32mg24.ld index b911b1339741d4..16066c24195cec 100644 --- a/examples/platform/silabs/ldscripts/efr32mg24.ld +++ b/examples/platform/silabs/ldscripts/efr32mg24.ld @@ -1,43 +1,22 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ /***************************************************************************//** - * @file gcc_EFR32MG24.ld - * @brief GNU Linker Script for Cortex-M based device - * @version V2.2.0 - * @date 16. December 2020 - * Linker script for Silicon Labs EFR32MG24 devices + * GCC Linker script for Silicon Labs devices ******************************************************************************* * # License - * Copyright 2022 Silicon Laboratories, Inc. www.silabs.com + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com ******************************************************************************* * * SPDX-License-Identifier: Zlib - * + * * The licensor of this software is Silicon Laboratories Inc. - * + * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. - * + * * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely, subject to the following restrictions: - * + * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software * in a product, an acknowledgment in the product documentation would be @@ -48,52 +27,81 @@ * ******************************************************************************/ -MEMORY -{ - FLASH (rx) : ORIGIN = 0x08006000, LENGTH = 0x17A000 - RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x40000 -} - -/* Linker script to place sections and symbol values. Should be used together - * with other linker script that defines memory regions FLASH and RAM. - * It references following symbols, which must be defined in code: - * Reset_Handler : Entry of reset handler - * - * It defines following symbols, which code can use without definition: - * __exidx_start - * __exidx_end - * __copy_table_start__ - * __copy_table_end__ - * __zero_table_start__ - * __zero_table_end__ - * __etext - * __data_start__ - * __preinit_array_start - * __preinit_array_end - * __init_array_start - * __init_array_end - * __fini_array_start - * __fini_array_end - * __data_end__ - * __bss_start__ - * __bss_end__ - * __end__ - * end - * __HeapLimit - * __StackLimit - * __StackTop - * __stack - * __StackSeal (only if ARMv8-M stack sealing is used) - */ + MEMORY + { + FLASH (rx) : ORIGIN = 0x8006000, LENGTH = 0x178000 + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x40000 + } ENTRY(Reset_Handler) SECTIONS { - .text : + + .vectors : { + linker_vectors_begin = .; KEEP(*(.vectors)) - *(.text*) + linker_vectors_end = .; + + __Vectors_End = .; + __Vectors_Size = __Vectors_End - __Vectors; + __lma_ramfuncs_start__ = .; + } > FLASH + + .stack (NOLOAD): + { + . = ALIGN(8); + __StackLimit = .; + KEEP(*(.stack*)) + . = ALIGN(4); + __StackTop = .; + PROVIDE(__stack = __StackTop); + } > RAM + + + .noinit (NOLOAD): + { + *(.noinit*); + } > RAM + + .bss : + { + . = ALIGN(4); + __bss_start__ = .; + *(SORT_BY_ALIGNMENT(.bss*)) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; + } > RAM + + text_application_ram : + { + . = ALIGN(4); + __vma_ramfuncs_start__ = .; + __text_application_ram_start__ = .; + + *(text_application_ram) + + . = ALIGN(4); + __vma_ramfuncs_end__ = .; + __text_application_ram_end__ = .; + } > RAM AT > FLASH + + .rodata : + { + __lma_ramfuncs_end__ = .; + __rodata_start__ = .; + __rodata_end__ = .; + } > FLASH + + .text : + { + linker_code_begin = .; + *(SORT_BY_ALIGNMENT(.text*)) + *(SORT_BY_ALIGNMENT(text_*)) + . = ALIGN(32); + linker_code_end = .; KEEP(*(.init)) KEEP(*(.fini)) @@ -111,16 +119,11 @@ SECTIONS *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) *(SORT(.dtors.*)) *(.dtors) - - __code_classification_validator_start__ = .; - . = . + 0x20; - *(code_classification_validator) - . = ALIGN(32); - __code_classification_validator_end__ = .; + *(.rodata*) - - KEEP(*(.eh_frame*)) + *(.eh_frame*) } > FLASH + .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) @@ -142,6 +145,13 @@ SECTIONS LONG (__data_start__) LONG ((__data_end__ - __data_start__) / 4) + /* Add each additional data section here */ + /* + LONG (__etext2) + LONG (__data2_start__) + LONG ((__data2_end__ - __data2_start__) / 4) + */ + __copy_table_end__ = .; } > FLASH @@ -149,19 +159,23 @@ SECTIONS { . = ALIGN(4); __zero_table_start__ = .; + /* Add each additional bss section here */ + /* + LONG (__bss2_start__) + LONG ((__bss2_end__ - __bss2_start__) / 4) + */ + __zero_table_end__ = .; - __etext = ALIGN(4); + __etext = .; } > FLASH - .data : AT (__etext) + .data : { + . = ALIGN(4); __data_start__ = .; *(vtable) - *(.data*) - . = ALIGN (4); - PROVIDE (__ram_func_section_start = .); - *(.ram) - PROVIDE (__ram_func_section_end = .); + *(SORT_BY_ALIGNMENT(.data*)) + . = ALIGN(4); . = ALIGN(4); /* preinit data */ @@ -183,87 +197,49 @@ SECTIONS KEEP(*(.fini_array)) PROVIDE_HIDDEN (__fini_array_end = .); - KEEP(*(.jcr*)) . = ALIGN(4); /* All data end */ __data_end__ = .; - } > RAM - - .bss : - { - . = ALIGN(4); - __bss_start__ = .; - *(.bss) - *(.bss.*) - *(COMMON) - . = ALIGN(4); - __bss_end__ = .; - } > RAM AT > RAM - - __ramfuncs_start__ = .; - - __vma_ramfuncs_start__ = .; - __lma_ramfuncs_start__ = __etext + SIZEOF(.data); - - __text_application_ram_offset__ = . - __vma_ramfuncs_start__; - text_application_ram . : AT(__lma_ramfuncs_start__ + __text_application_ram_offset__) - { - . = ALIGN(4); - __text_application_ram_start__ = .; - *(text_application_ram) - . = ALIGN(4); - __text_application_ram_end__ = .; - } > RAM - - . = ALIGN(4); - __vma_ramfuncs_end__ = .; - __lma_ramfuncs_end__ = __lma_ramfuncs_start__ + __text_application_ram_offset__ + SIZEOF(text_application_ram); - - __ramfuncs_end__ = .; - - .heap (COPY): + } > RAM AT > FLASH + .memory_manager_heap (NOLOAD): { + . = ALIGN(8); __HeapBase = .; __end__ = .; end = __end__; _end = __end__; - KEEP(*(.heap*)) - __HeapLimit = .; + KEEP(*(.memory_manager_heap*)) + __HeapLimit = ORIGIN(RAM) + LENGTH(RAM); } > RAM - __main_flash_end__ = ORIGIN(FLASH) + LENGTH(FLASH); + __heap_size = __HeapLimit - __HeapBase; + __ram_end__ = 0x20000000 + 0x40000; + __main_flash_end__ = 0x8006000 + 0x178000; - /* .stack_dummy section doesn't contains any symbols. It is only - * used for linker to calculate size of stack sections, and assign - * values to stack symbols later */ - .stack_dummy (COPY): - { - KEEP(*(.stack*)) - /* KEEP(*(.stackseal*))*/ - } > RAM + /* This is where we handle flash storage blocks. We use dummy sections for finding the configured + * block sizes and then "place" them at the end of flash when the size is known. */ + .internal_storage (DSECT) : { + KEEP(*(.internal_storage*)) + } > FLASH - /* Set stack top to end of RAM, and stack limit move down by - * size of stack_dummy section */ - __StackTop = ORIGIN(RAM) + LENGTH(RAM); - __StackLimit = __StackTop - SIZEOF(.stack_dummy); - PROVIDE(__stack = __StackTop); - .nvm (DSECT) : { + .nvm (DSECT) : { KEEP(*(.simee*)) } > FLASH - /* Last page of flash is reserved for the manufacturing token space */ - linker_nvm_end = __main_flash_end__ - 8192; + __ramfuncs_start__ = __vma_ramfuncs_start__; + __ramfuncs_end__ = __vma_ramfuncs_end__; + + linker_nvm_end = __main_flash_end__; linker_nvm_begin = linker_nvm_end - SIZEOF(.nvm); - linker_nvm_size = SIZEOF(.nvm); + linker_storage_end = linker_nvm_begin; __nvm3Base = linker_nvm_begin; - __attestation_credentials_base = linker_nvm_end; - /* Check if data + heap + stack exceeds RAM limit */ - /*ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")*/ - ASSERT( (linker_nvm_begin + SIZEOF(.nvm)) <= __main_flash_end__, "NVM3 is excessing the flash size !") + linker_storage_begin = linker_storage_end - SIZEOF(.internal_storage); + ASSERT((linker_storage_begin >= (__etext + SIZEOF(.data))), "FLASH memory overflowed !") + - /* Check if FLASH usage exceeds FLASH size */ - ASSERT( LENGTH(FLASH) >= (__etext + SIZEOF(.data)), "FLASH memory overflowed !") + app_flash_end = 0x8006000 + 0x178000; + ASSERT( (linker_nvm_begin + SIZEOF(.nvm)) <= app_flash_end, "NVM3 is excessing the flash size !") } diff --git a/examples/platform/silabs/matter-platform.slcp b/examples/platform/silabs/matter-platform.slcp index 4f5d1ef2c05064..c8075656e9f74d 100644 --- a/examples/platform/silabs/matter-platform.slcp +++ b/examples/platform/silabs/matter-platform.slcp @@ -27,7 +27,7 @@ include: file_list: - {path: app.h} - {path: reset_util.h} -sdk: {id: gecko_sdk, version: 4.4.2} +sdk: {id: simplicity_sdk, version: 2024.6.0} toolchain_settings: [] component: @@ -38,13 +38,26 @@ component: - {id: bluetooth_feature_connection} - {id: bluetooth_feature_system} - {id: bluetooth_stack} -# Other components +# Platform support +- {id: cpp_support} +- {id: sl_system} +- {id: device_init} +- {id: board_control} +- {id: memory_manager} +- {id: silabs_core_memory_manager} +- {id: clock_manager} +- {id: silabs_core_circular_queue} +- {id: sleeptimer} - {id: nvm3_lib} - {id: freertos} +- {id: freertos_heap_3} +- {id: iostream_rtt} +- {id: toolchain_gcc} - {id: brd4002a} - {id: rail_util_pti} - {id: rail_lib_multiprotocol} - {id: rail_util_power_manager_init} +# crypto components - {id: psa_crypto} - {id: psa_crypto_aes} - {id: psa_crypto_ccm} @@ -59,7 +72,6 @@ component: - {id: mbedtls_platform_dynamic_memory_allocation_config_init_runtime } - {id: mbedtls_base64} - {id: ot_psa_crypto} -- {id: iostream_rtt} # Necessary componenets for ot coap cert lib # - {id: mbedtls_dtls} # Requried by COAP lib # - {id: mbedtls_tls_server} # Requried by COAP lib @@ -86,9 +98,15 @@ configuration: name: SL_IOSTREAM_USART_VCOM_RX_BUFFER_SIZE value: '128' - {name: SL_HEAP_SIZE, value: '0'} -- {name: SL_STACK_SIZE, value: '0'} +- {name: SL_STACK_SIZE, value: '4608'} - {name: SL_BOARD_ENABLE_VCOM, value: '0'} - {name: EMDRV_UARTDRV_FLOW_CONTROL_ENABLE, value: '0'} +- {name: NVM3_DEFAULT_MAX_OBJECT_SIZE, value: '4092'} +- {name: CIRCULAR_QUEUE_LEN_MAX, value: '16'} +- {name: SL_CLOCK_MANAGER_HFRCO_DPLL_EN, value: 1} +- {name: SL_BT_RTOS_LINK_LAYER_TASK_STACK_SIZE, value: 1024} +- {name: SL_BT_RTOS_HOST_STACK_TASK_STACK_SIZE, value: 2048} +- {name: SL_BT_RTOS_EVENT_HANDLER_STACK_SIZE, value: 1536} template_contribution: - name: mbedtls_ssl_content_len_in_requirement @@ -97,8 +115,6 @@ template_contribution: value: 900 requires: -- condition: [device_series_1] - name: uartdrv_usart - condition: [device_series_2] name: uartdrv_eusart - condition: [device_series_2] diff --git a/src/platform/silabs/CHIPMem-Platform.cpp b/src/platform/silabs/CHIPMem-Platform.cpp index 20859100f129c4..2a6c372804b998 100644 --- a/src/platform/silabs/CHIPMem-Platform.cpp +++ b/src/platform/silabs/CHIPMem-Platform.cpp @@ -44,9 +44,6 @@ // #include #include -#include "heap_4_silabs.h" -#include "task.h" - #include #include #include @@ -104,7 +101,7 @@ void * MemoryAlloc(size_t size) { void * ptr; VERIFY_INITIALIZED(); - ptr = pvPortMalloc(size); + ptr = malloc(size); trackAlloc(ptr, size); return ptr; } @@ -113,7 +110,7 @@ void * MemoryAlloc(size_t size, bool isLongTermAlloc) { void * ptr; VERIFY_INITIALIZED(); - ptr = pvPortMalloc(size); + ptr = malloc(size); trackAlloc(ptr, size); return ptr; } @@ -122,7 +119,7 @@ void * MemoryCalloc(size_t num, size_t size) { VERIFY_INITIALIZED(); - void * ptr = pvPortCalloc(num, size); + void * ptr = calloc(num, size); trackAlloc(ptr, size * num); return ptr; } @@ -131,7 +128,7 @@ void * MemoryRealloc(void * p, size_t size) { VERIFY_INITIALIZED(); - p = pvPortRealloc(p, size); + p = realloc(p, size); return p; } @@ -139,7 +136,7 @@ void MemoryFree(void * p) { VERIFY_INITIALIZED(); trackFree(p, 0); - vPortFree(p); + free(p); } bool MemoryInternalCheckPointer(const void * p, size_t min_size) @@ -150,12 +147,7 @@ bool MemoryInternalCheckPointer(const void * p, size_t min_size) } // namespace Platform } // namespace chip -#ifdef BRD4325A -extern "C" void memMonitoringTrackAlloc(void * ptr, size_t size) {} -extern "C" void memMonitoringTrackFree(void * ptr, size_t size) {} -#else extern "C" __WEAK void memMonitoringTrackAlloc(void * ptr, size_t size) {} extern "C" __WEAK void memMonitoringTrackFree(void * ptr, size_t size) {} -#endif // BRD4325A #endif // CHIP_CONFIG_MEMORY_MGMT_PLATFORM diff --git a/src/platform/silabs/DiagnosticDataProviderImpl.cpp b/src/platform/silabs/DiagnosticDataProviderImpl.cpp index 1dc408394f7a71..4be7113bb67b5b 100644 --- a/src/platform/silabs/DiagnosticDataProviderImpl.cpp +++ b/src/platform/silabs/DiagnosticDataProviderImpl.cpp @@ -29,7 +29,7 @@ #include #endif #include "FreeRTOS.h" -#include "heap_4_silabs.h" +#include "sl_memory_manager.h" #include #include @@ -46,38 +46,28 @@ DiagnosticDataProviderImpl & DiagnosticDataProviderImpl::GetDefaultInstance() // Software Diagnostics Getters /* - * The following Heap stats are compiled values done by the FreeRTOS Heap4 implementation. - * See /examples/platform/silabs/heap_4_silabs.c + * The following Heap stats are compiled values done by the sl_memory_manager. * It keeps track of the number of calls to allocate and free memory as well as the * number of free bytes remaining, but says nothing about fragmentation. */ CHIP_ERROR DiagnosticDataProviderImpl::GetCurrentHeapFree(uint64_t & currentHeapFree) { - size_t freeHeapSize = xPortGetFreeHeapSize(); + size_t freeHeapSize = sl_memory_get_free_heap_size(); currentHeapFree = static_cast(freeHeapSize); return CHIP_NO_ERROR; } CHIP_ERROR DiagnosticDataProviderImpl::GetCurrentHeapUsed(uint64_t & currentHeapUsed) { - // Calculate the Heap used based on Total heap - Free heap - int64_t heapUsed = (configTOTAL_HEAP_SIZE - xPortGetFreeHeapSize()); - - // Something went wrong, this should not happen - VerifyOrReturnError(heapUsed >= 0, CHIP_ERROR_INVALID_INTEGER_VALUE); + size_t heapUsed = sl_memory_get_used_heap_size(); currentHeapUsed = static_cast(heapUsed); return CHIP_NO_ERROR; } CHIP_ERROR DiagnosticDataProviderImpl::GetCurrentHeapHighWatermark(uint64_t & currentHeapHighWatermark) { - // FreeRTOS records the lowest amount of available heap during runtime - // currentHeapHighWatermark wants the highest heap usage point so we calculate it here - int64_t HighestHeapUsageRecorded = (configTOTAL_HEAP_SIZE - xPortGetMinimumEverFreeHeapSize()); - - // Something went wrong, this should not happen - VerifyOrReturnError(HighestHeapUsageRecorded >= 0, CHIP_ERROR_INVALID_INTEGER_VALUE); - currentHeapHighWatermark = static_cast(HighestHeapUsageRecorded); + size_t HighestHeapUsageRecorded = sl_memory_get_heap_high_watermark(); + currentHeapHighWatermark = static_cast(HighestHeapUsageRecorded); return CHIP_NO_ERROR; } @@ -86,9 +76,7 @@ CHIP_ERROR DiagnosticDataProviderImpl::ResetWatermarks() { // If implemented, the server SHALL set the value of the CurrentHeapHighWatermark attribute to the // value of the CurrentHeapUsed. - - xPortResetHeapMinimumEverFreeHeapSize(); - + sl_memory_reset_heap_high_watermark(); return CHIP_NO_ERROR; } diff --git a/src/test_driver/efr32/BUILD.gn b/src/test_driver/efr32/BUILD.gn index 76b4df8e8bc8ec..ad0c1a22d270d3 100644 --- a/src/test_driver/efr32/BUILD.gn +++ b/src/test_driver/efr32/BUILD.gn @@ -70,7 +70,6 @@ silabs_executable("efr32_device_tests") { "${chip_root}/examples/common/pigweed/RpcService.cpp", "${chip_root}/examples/common/pigweed/efr32/PigweedLoggerMutex.cpp", "${examples_common_plat_dir}/PigweedLogger.cpp", - "${examples_common_plat_dir}/heap_4_silabs.c", "${examples_common_plat_dir}/syscalls_stubs.cpp", "${examples_plat_dir}/uart.cpp", "src/main.cpp", diff --git a/third_party/silabs/slc_gen/run_slc.py b/third_party/silabs/slc_gen/run_slc.py index 4ec7f59b9ae600..b3bad4355f85d8 100644 --- a/third_party/silabs/slc_gen/run_slc.py +++ b/third_party/silabs/slc_gen/run_slc.py @@ -14,11 +14,10 @@ def asBoolean(valueToTest): def isMG24(partnumber): - if "EFR32MG24" in partnumber or "MGM240" in partnumber: - return True - else: - return False + return ("EFR32MG24" in partnumber or "MGM240" in partnumber) +def isMG26(partnumber): + return ("EFR32MG26" in partnumber) root_path = sys.argv[1] silabs_board = str(sys.argv[2]).lower() @@ -35,10 +34,8 @@ def isMG24(partnumber): slc_arguments = "" # Add Familly specific component -if isMG24(silabs_mcu): +if isMG24(silabs_mcu) or isMG26(silabs_mcu): slc_arguments += "uartdrv_eusart:vcom," -else: - slc_arguments += "uartdrv_usart:vcom," # Translate GN arguments in SLC arguments if not disable_lcd: @@ -58,15 +55,15 @@ def isMG24(partnumber): print(slc_arguments) -if "GSDK_ROOT" in os.environ: - gsdk_root = os.getenv('GSDK_ROOT') +if "SISDK_ROOT" in os.environ: + sisdk_root = os.getenv('SISDK_ROOT') else: # If no gsdk path is set in the environment, use the standard path to the submodule - gsdk_root = os.path.join(root_path, "third_party/silabs/gecko_sdk/") + sisdk_root = os.path.join(root_path, "third_party/silabs/simplicity_sdk/") # make sure we have a configured and trusted gsdk in slc -subprocess.run(["slc", "configuration", "--sdk", gsdk_root], check=True) -subprocess.run(["slc", "signature", "trust", "--sdk", gsdk_root], check=True) +subprocess.run(["slc", "configuration", "--sdk", sisdk_root], check=True) +subprocess.run(["slc", "signature", "trust", "--sdk", sisdk_root], check=True) subprocess.run(["slc", "generate", slcp_file_path, "-d", output_path, "--with", slc_arguments], check=True) From d1a436074024a8706c08ec678025cf800dfffd98 Mon Sep 17 00:00:00 2001 From: Junior Martinez <67972863+jmartinez-silabs@users.noreply.github.com> Date: Mon, 24 Jun 2024 08:31:15 -0400 Subject: [PATCH 03/12] Update 917 apis for wifi sdk 3.3.0 --- .../silabs/SiWx917/SiWx917/sl_wifi_if.cpp | 170 ++++++------------ examples/platform/silabs/display/lcd.cpp | 7 +- src/platform/silabs/CHIPMem-Platform.cpp | 4 +- .../silabs/SiWx917/wifi/ethernetif.cpp | 103 ++--------- .../silabs/SiWx917/wifi/wfx_host_events.h | 9 +- .../silabs/efr32/wifi/wfx_host_events.h | 6 - .../openthread/platforms/efr32/BUILD.gn | 17 +- third_party/silabs/BUILD.gn | 15 +- third_party/silabs/SiWx917_sdk.gni | 25 +++ third_party/silabs/efr32_sdk.gni | 118 +++++++----- 10 files changed, 198 insertions(+), 276 deletions(-) diff --git a/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.cpp b/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.cpp index 741dc96496aeb5..54b36b123794d4 100644 --- a/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.cpp +++ b/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.cpp @@ -21,6 +21,7 @@ #include "silabs_utils.h" #include "sl_status.h" +#include #include "FreeRTOS.h" #include "event_groups.h" @@ -39,9 +40,12 @@ extern "C" { #include "ble_config.h" -#if SL_ICD_ENABLED && SLI_SI91X_MCU_INTERFACE +#if CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE #include "rsi_rom_power_save.h" #include "sl_si91x_button_pin_config.h" +#if DISPLAY_ENABLED +#include "sl_memlcd.h" +#endif // DISPLAY_ENABLED extern "C" { #include "sl_si91x_driver.h" #include "sl_si91x_m4_ps.h" @@ -50,7 +54,7 @@ extern "C" { // TODO: should be removed once we are getting the press interrupt for button 0 with sleep #define BUTTON_PRESSED 1 bool btn0_pressed = false; -#endif // SL_ICD_ENABLED && SLI_SI91X_MCU_INTERFACE +#endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE #include "dhcp_client.h" #include "wfx_host_events.h" @@ -70,19 +74,14 @@ extern "C" { #include "sl_wifi.h" #include "sl_wifi_callback_framework.h" #include "wfx_host_events.h" -#if TINYCRYPT_PRIMITIVES +#if SLI_SI91X_MCU_INTERFACE #include "sl_si91x_trng.h" #define TRNGKEY_SIZE 4 -#endif // TINYCRYPT_PRIMITIVES -} +#endif // SLI_SI91X_MCU_INTERFACE +} // extern "C" { WfxRsi_t wfx_rsi; -// TODO: remove this. Added only to monitor how many watch dog reset have happened during testing. -#ifdef SLI_SI91X_MCU_INTERFACE -volatile uint32_t watchdog_reset = 0; -#endif // SLI_SI91X_MCU_INTERFACE - /* Declare a variable to hold the data associated with the created event group. */ StaticEventGroup_t rsiDriverEventGroup; @@ -246,10 +245,9 @@ sl_status_t join_callback_handler(sl_wifi_event_t event, char * result, uint32_t wfx_rsi.dev_state &= ~(WFX_RSI_ST_STA_CONNECTING); if (SL_WIFI_CHECK_IF_EVENT_FAILED(event)) { - SILABS_LOG("F: Join Event received with %u bytes payload\n", result_length); callback_status = *(sl_status_t *) result; + SILABS_LOG("join_callback_handler: failed: 0x%X", callback_status); wfx_rsi.dev_state &= ~(WFX_RSI_ST_STA_CONNECTED); - is_wifi_disconnection_event = true; wfx_retry_interval_handler(is_wifi_disconnection_event, wfx_rsi.join_retries++); if (is_wifi_disconnection_event || wfx_rsi.join_retries <= WFX_RSI_CONFIG_MAX_JOIN) { @@ -262,26 +260,22 @@ sl_status_t join_callback_handler(sl_wifi_event_t event, char * result, uint32_t * Join was complete - Do the DHCP */ memset(&temp_reset, 0, sizeof(wfx_wifi_scan_ext_t)); - SILABS_LOG("join_callback_handler: join completed."); - SILABS_LOG("%c: Join Event received with %u bytes payload\n", *result, result_length); + SILABS_LOG("join_callback_handler: success"); WfxEvent.eventType = WFX_EVT_STA_CONN; WfxPostEvent(&WfxEvent); wfx_rsi.join_retries = 0; retryInterval = WLAN_MIN_RETRY_TIMER_MS; - if (is_wifi_disconnection_event) - { - is_wifi_disconnection_event = false; - } - callback_status = SL_STATUS_OK; + // Once the join passes setting the disconnection event to true to differentiate between the first connection and reconnection + is_wifi_disconnection_event = true; + callback_status = SL_STATUS_OK; return SL_STATUS_OK; } -#if SL_ICD_ENABLED - -#if SI917_M4_SLEEP_ENABLED +#if CHIP_CONFIG_ENABLE_ICD_SERVER +#if SLI_SI91X_MCU_INTERFACE // Required to invoke button press event during sleep as falling edge is not detected -void invoke_btn_press_event() +void sl_si91x_invoke_btn_press_event() { // TODO: should be removed once we are getting the press interrupt for button 0 with sleep if (!RSI_NPSSGPIO_GetPin(SL_BUTTON_BTN0_PIN) && !btn0_pressed) @@ -295,36 +289,28 @@ void invoke_btn_press_event() } } -/** - * @brief Checks if the Wi-Fi module is ready for sleep. - * - * This function checks if the Wi-Fi module is ready to enter sleep mode. - * - * @return true if the Wi-Fi module is ready for sleep, false otherwise. - */ -bool wfx_is_sleep_ready() -{ - // BRD4002A board BTN_PRESS is 0 when pressed, release is 1 - // sli_si91x_is_sleep_ready requires OS Scheduler to be active - return ((RSI_NPSSGPIO_GetPin(SL_BUTTON_BTN0_PIN) != 0) && (wfx_rsi.dev_state & WFX_RSI_ST_SLEEP_READY) && - sli_si91x_is_sleep_ready()); -} - -/** - * @brief Sleeps for a specified duration and then wakes up. - * - * This function puts the SI91x host into sleep mode for the specified duration - * in milliseconds and then wakes it up. - * - * @param sleep_time_ms The duration in milliseconds to sleep. - */ -void sl_wfx_host_si91x_sleep(uint16_t * sleep_time_ms) +/****************************************************************** + * @fn sl_app_sleep_ready() + * @brief + * Called from the supress ticks from tickless to check if it + * is ok to go to sleep + * @param[in] None + * @return + * None + *********************************************************************/ +uint32_t sl_app_sleep_ready() { - SL_ASSERT(sleep_time_ms != NULL); - sl_si91x_m4_sleep_wakeup(sleep_time_ms); + if (wfx_rsi.dev_state & WFX_RSI_ST_SLEEP_READY) + { +#if DISPLAY_ENABLED + // Powering down the LCD + sl_memlcd_power_on(NULL, false); +#endif /* DISPLAY_ENABLED */ + return true; + } + return false; } - -#endif // SI917_M4_SLEEP_ENABLED +#endif // SLI_SI91X_MCU_INTERFACE /****************************************************************** * @fn wfx_rsi_power_save() @@ -363,7 +349,7 @@ int32_t wfx_rsi_power_save(rsi_power_save_profile_mode_t sl_si91x_ble_state, sl_ } return status; } -#endif /* SL_ICD_ENABLED */ +#endif /* CHIP_CONFIG_ENABLE_ICD_SERVER */ /************************************************************************************* * @fn static int32_t wfx_wifi_rsi_init(void) @@ -378,13 +364,6 @@ int32_t wfx_wifi_rsi_init(void) SILABS_LOG("wfx_wifi_rsi_init started"); sl_status_t status; status = sl_wifi_init(&config, NULL, sl_wifi_default_event_handler); -#ifdef SLI_SI91X_MCU_INTERFACE - // TODO: remove this. Added only to monitor how many watch dog reset have happened during testing. - if ((MCU_FSM->MCU_FSM_WAKEUP_STATUS_REG) & BIT(5)) - { - watchdog_reset++; - } -#endif // SLI_SI91X_MCU_INTERFACE if (status != SL_STATUS_OK) { return status; @@ -449,7 +428,7 @@ static sl_status_t wfx_rsi_init(void) return status; } #else // For SoC -#if SL_ICD_ENABLED +#if CHIP_CONFIG_ENABLE_ICD_SERVER uint8_t xtal_enable = 1; status = sl_si91x_m4_ta_secure_handshake(SL_SI91X_ENABLE_XTAL, 1, &xtal_enable, 0, NULL); if (status != SL_STATUS_OK) @@ -457,7 +436,7 @@ static sl_status_t wfx_rsi_init(void) SILABS_LOG("Failed to bring m4_ta_secure_handshake: 0x%lx\r\n", status); return status; } -#endif /* SL_ICD_ENABLED */ +#endif /* CHIP_CONFIG_ENABLE_ICD_SERVER */ #endif /* SLI_SI91X_MCU_INTERFACE */ sl_wifi_firmware_version_t version = { 0 }; @@ -477,7 +456,7 @@ static sl_status_t wfx_rsi_init(void) return status; } -#ifdef TINYCRYPT_PRIMITIVES +#ifdef SLI_SI91X_MCU_INTERFACE const uint32_t trngKey[TRNGKEY_SIZE] = { 0x16157E2B, 0xA6D2AE28, 0x8815F7AB, 0x3C4FCF09 }; // To check the Entropy of TRNG and verify TRNG functioning. @@ -495,7 +474,7 @@ static sl_status_t wfx_rsi_init(void) SILABS_LOG("TRNG Key Programming Failed"); return status; } -#endif // TINYCRYPT_PRIMITIVES +#endif // SLI_SI91X_MCU_INTERFACE wfx_rsi.events = xEventGroupCreateStatic(&rsiDriverEventGroup); wfx_rsi.dev_state |= WFX_RSI_ST_DEV_READY; @@ -520,12 +499,13 @@ sl_status_t scan_callback_handler(sl_wifi_event_t event, sl_wifi_scan_result_t * { if (SL_WIFI_CHECK_IF_EVENT_FAILED(event)) { - callback_status = *(sl_status_t *) scan_result; + callback_status = *(sl_status_t *) scan_result; + SILABS_LOG("scan_callback_handler: failed: 0x%X", callback_status); scan_results_complete = true; #if WIFI_ENABLE_SECURITY_WPA3_TRANSITION wfx_rsi.sec.security = WFX_SEC_WPA3; #else - wfx_rsi.sec.security = WFX_SEC_WPA2; + wfx_rsi.sec.security = WFX_SEC_WPA2; #endif /* WIFI_ENABLE_SECURITY_WPA3_TRANSITION */ osSemaphoreRelease(sScanSemaphore); @@ -541,9 +521,9 @@ sl_status_t scan_callback_handler(sl_wifi_event_t event, sl_wifi_scan_result_t * break; case SL_WIFI_WPA: case SL_WIFI_WPA_ENTERPRISE: - case SL_WIFI_WPA_WPA2_MIXED: wfx_rsi.sec.security = WFX_SEC_WPA; break; + case SL_WIFI_WPA_WPA2_MIXED: case SL_WIFI_WPA2: case SL_WIFI_WPA2_ENTERPRISE: wfx_rsi.sec.security = WFX_SEC_WPA2; @@ -556,7 +536,7 @@ sl_status_t scan_callback_handler(sl_wifi_event_t event, sl_wifi_scan_result_t * case SL_WIFI_WPA3: wfx_rsi.sec.security = WFX_SEC_WPA3; #else - wfx_rsi.sec.security = WFX_SEC_WPA2; + wfx_rsi.sec.security = WFX_SEC_WPA2; #endif /* WIFI_ENABLE_SECURITY_WPA3_TRANSITION */ break; default: @@ -661,14 +641,18 @@ static sl_status_t wfx_rsi_do_join(void) connect_security_mode = SL_WIFI_WEP; break; case WFX_SEC_WPA: - case WFX_SEC_WPA2: connect_security_mode = SL_WIFI_WPA_WPA2_MIXED; break; + case WFX_SEC_WPA2: #if WIFI_ENABLE_SECURITY_WPA3_TRANSITION + connect_security_mode = SL_WIFI_WPA3_TRANSITION; + break; case WFX_SEC_WPA3: connect_security_mode = SL_WIFI_WPA3_TRANSITION; +#else + connect_security_mode = SL_WIFI_WPA_WPA2_MIXED; +#endif // WIFI_ENABLE_SECURITY_WPA3_TRANSITION break; -#endif /*WIFI_ENABLE_SECURITY_WPA3_TRANSITION*/ case WFX_SEC_NONE: connect_security_mode = SL_WIFI_OPEN; break; @@ -695,14 +679,14 @@ static sl_status_t wfx_rsi_do_join(void) sl_wifi_set_join_callback(join_callback_handler, NULL); -#if SL_ICD_ENABLED +#if CHIP_CONFIG_ENABLE_ICD_SERVER // Setting the listen interval to 0 which will set it to DTIM interval sl_wifi_listen_interval_t sleep_interval = { .listen_interval = 0 }; status = sl_wifi_set_listen_interval(SL_WIFI_CLIENT_INTERFACE, sleep_interval); sl_wifi_advanced_client_configuration_t client_config = { .max_retry_attempts = 5 }; sl_wifi_set_advanced_client_configuration(SL_WIFI_CLIENT_INTERFACE, &client_config); -#endif // SL_ICD_ENABLED +#endif // CHIP_CONFIG_ENABLE_ICD_SERVER /* Try to connect Wifi with given Credentials * untill there is a success or maximum number of tries allowed */ @@ -1006,47 +990,3 @@ void wfx_dhcp_got_ipv4(uint32_t ip) wfx_rsi.dev_state |= WFX_RSI_ST_STA_READY; } #endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */ - -/******************************************************************************************** - * @fn void wfx_rsi_pkt_add_data(void *p, uint8_t *buf, uint16_t len, uint16_t off) - * @brief - * add the data into packet - * @param[in] p: - * @param[in] buf: - * @param[in] len: - * @param[in] off: - * @return - * None - **********************************************************************************************/ -void wfx_rsi_pkt_add_data(void * p, uint8_t * buf, uint16_t len, uint16_t off) -{ - sl_si91x_packet_t * pkt; - pkt = (sl_si91x_packet_t *) p; - memcpy(((char *) pkt->data) + off, buf, len); -} - -#if !EXP_BOARD -/******************************************************************************************** - * @fn int32_t wfx_rsi_send_data(void *p, uint16_t len) - * @brief - * Driver send a data - * @param[in] p: - * @param[in] len: - * @return - * None - **********************************************************************************************/ -int32_t wfx_rsi_send_data(void * p, uint16_t len) -{ - int32_t status; - sl_wifi_buffer_t * buffer; - buffer = (sl_wifi_buffer_t *) p; - - if (sl_si91x_driver_send_data_packet(SI91X_WLAN_CMD_QUEUE, buffer, RSI_SEND_RAW_DATA_RESPONSE_WAIT_TIME)) - { - SILABS_LOG("*ERR*EN-RSI:Send fail"); - return ERR_IF; - } - return status; -} - -#endif diff --git a/examples/platform/silabs/display/lcd.cpp b/examples/platform/silabs/display/lcd.cpp index bf40cd0f6d543b..80cd5a1774bbad 100644 --- a/examples/platform/silabs/display/lcd.cpp +++ b/examples/platform/silabs/display/lcd.cpp @@ -26,7 +26,7 @@ #include "glib.h" #if (SLI_SI91X_MCU_INTERFACE) -#include "rsi_chip.h" +#include "sl_memlcd.h" #endif #ifdef QR_CODE_ENABLED @@ -67,10 +67,7 @@ CHIP_ERROR SilabsLCD::Init(uint8_t * name, bool initialState) /* Enable the memory lcd */ #if (SLI_SI91X_MCU_INTERFACE) - RSI_NPSSGPIO_InputBufferEn(SL_BOARD_ENABLE_DISPLAY_PIN, 1U); - RSI_NPSSGPIO_SetPinMux(SL_BOARD_ENABLE_DISPLAY_PIN, 0); - RSI_NPSSGPIO_SetDir(SL_BOARD_ENABLE_DISPLAY_PIN, 0); - RSI_NPSSGPIO_SetPin(SL_BOARD_ENABLE_DISPLAY_PIN, 1U); + sl_memlcd_display_enable(); #else status = sl_board_enable_display(); if (status != SL_STATUS_OK) diff --git a/src/platform/silabs/CHIPMem-Platform.cpp b/src/platform/silabs/CHIPMem-Platform.cpp index 2a6c372804b998..cf6552dd64b43b 100644 --- a/src/platform/silabs/CHIPMem-Platform.cpp +++ b/src/platform/silabs/CHIPMem-Platform.cpp @@ -147,7 +147,7 @@ bool MemoryInternalCheckPointer(const void * p, size_t min_size) } // namespace Platform } // namespace chip -extern "C" __WEAK void memMonitoringTrackAlloc(void * ptr, size_t size) {} -extern "C" __WEAK void memMonitoringTrackFree(void * ptr, size_t size) {} +extern "C" __attribute__((weak)) void memMonitoringTrackAlloc(void * ptr, size_t size) {} +extern "C" __attribute__((weak)) void memMonitoringTrackFree(void * ptr, size_t size) {} #endif // CHIP_CONFIG_MEMORY_MGMT_PLATFORM diff --git a/src/platform/silabs/SiWx917/wifi/ethernetif.cpp b/src/platform/silabs/SiWx917/wifi/ethernetif.cpp index 8570fc4b9a4fb3..25bd9cee03e5f8 100644 --- a/src/platform/silabs/SiWx917/wifi/ethernetif.cpp +++ b/src/platform/silabs/SiWx917/wifi/ethernetif.cpp @@ -35,6 +35,7 @@ extern "C" { #include "sl_wifi_callback_framework.h" #include "sl_wifi_constants.h" #include "sl_wifi_types.h" +#include "sl_wifi.h" #ifdef __cplusplus } #endif @@ -45,8 +46,6 @@ extern "C" { #include "netif/etharp.h" #include "silabs_utils.h" -#include - StaticSemaphore_t xEthernetIfSemaBuffer; /***************************************************************************** @@ -132,14 +131,13 @@ static void low_level_input(struct netif * netif, uint8_t * b, uint16_t len) (memcmp(netif->hwaddr, dst_mac, netif->hwaddr_len) != 0)) { #ifdef WIFI_DEBUG_ENABLED - ChipLogProgress(DeviceLayer, "%s: DROP, [%02x:%02x:%02x:%02x:%02x:%02x]<-[%02x:%02x:%02x:%02x:%02x:%02x] type=%02x%02x", - __func__, + SILABS_LOG("%s: DROP, [%02x:%02x:%02x:%02x:%02x:%02x]<-[%02x:%02x:%02x:%02x:%02x:%02x] type=%02x%02x", __func__, - dst_mac[0], dst_mac[1], dst_mac[2], dst_mac[3], dst_mac[4], dst_mac[5], + dst_mac[0], dst_mac[1], dst_mac[2], dst_mac[3], dst_mac[4], dst_mac[5], - src_mac[0], src_mac[1], src_mac[2], src_mac[3], src_mac[4], src_mac[5], + src_mac[0], src_mac[1], src_mac[2], src_mac[3], src_mac[4], src_mac[5], - b[12], b[13]); + b[12], b[13]); #endif return; } @@ -155,15 +153,14 @@ static void low_level_input(struct netif * netif, uint8_t * b, uint16_t len) bufferoffset += q->len; } #ifdef WIFI_DEBUG_ENABLED - ChipLogProgress(DeviceLayer, - "%s: ACCEPT %d, [%02x:%02x:%02x:%02x:%02x:%02x]<-[%02x:%02x:%02x:%02x:%02x:%02x] type=%02x%02x", __func__, - bufferoffset, + SILABS_LOG("%s: ACCEPT %d, [%02x:%02x:%02x:%02x:%02x:%02x]<-[%02x:%02x:%02x:%02x:%02x:%02x] type=%02x%02x", __func__, + bufferoffset, - dst_mac[0], dst_mac[1], dst_mac[2], dst_mac[3], dst_mac[4], dst_mac[5], + dst_mac[0], dst_mac[1], dst_mac[2], dst_mac[3], dst_mac[4], dst_mac[5], - src_mac[0], src_mac[1], src_mac[2], src_mac[3], src_mac[4], src_mac[5], + src_mac[0], src_mac[1], src_mac[2], src_mac[3], src_mac[4], src_mac[5], - b[12], b[13]); + b[12], b[13]); #endif if (netif->input(p, netif) != ERR_OK) @@ -194,84 +191,12 @@ static SemaphoreHandle_t ethout_sem; ******************************************************************************/ static err_t low_level_output(struct netif * netif, struct pbuf * p) { - sl_wifi_buffer_t * buffer; - sl_si91x_packet_t * packet; - sl_status_t status = SL_STATUS_OK; - void * rsipkt; - struct pbuf * q; - uint16_t framelength = 0; - uint16_t datalength = 0; - -#ifdef WIFI_DEBUG_ENABLED - ChipLogProgress(DeviceLayer, "LWIP : low_level_output"); -#endif - if (xSemaphoreTake(ethout_sem, portMAX_DELAY) != pdTRUE) - { + UNUSED_PARAMETER(netif); + sl_status_t status; + status = sl_wifi_send_raw_data_frame(SL_WIFI_CLIENT_INTERFACE, (uint8_t *)p->payload, p->len); + if (status != SL_STATUS_OK) { return ERR_IF; } - /* Calculate total packet size */ - for (q = p, framelength = 0; q != NULL; q = q->next) - { - framelength += q->len; - } - if (framelength < LWIP_FRAME_ALIGNMENT) - { - framelength = LWIP_FRAME_ALIGNMENT; - } - - /* Confirm if packet is allocated */ - status = sl_si91x_allocate_command_buffer(&buffer, (void **) &packet, sizeof(sl_si91x_packet_t) + framelength, - SL_WIFI_ALLOCATE_COMMAND_BUFFER_WAIT_TIME_MS); - VERIFY_STATUS_AND_RETURN(status); - if (packet == NULL) - { - ChipLogProgress(DeviceLayer, "EN-RSI:No buf"); - xSemaphoreGive(ethout_sem); - return SL_STATUS_ALLOCATION_FAILED; - } - memset(packet->desc, 0, sizeof(packet->desc)); -#ifdef WIFI_DEBUG_ENABLED - ChipLogProgress(DeviceLayer, "EN-RSI: Output"); -#endif - if ((netif->flags & (NETIF_FLAG_LINK_UP | NETIF_FLAG_UP)) != (NETIF_FLAG_LINK_UP | NETIF_FLAG_UP)) - { - ChipLogProgress(DeviceLayer, "EN-RSI:NOT UP"); - xSemaphoreGive(ethout_sem); - return ERR_IF; - } -#ifdef WIFI_DEBUG_ENABLED - uint8_t * b = (uint8_t *) p->payload; - ChipLogProgress(DeviceLayer, "EN-RSI: Out [%02x:%02x:%02x:%02x:%02x:%02x][%02x:%02x:%02x:%02x:%02x:%02x]type=%02x%02x", b[0], - b[1], b[2], b[3], b[4], b[5], b[6], b[7], b[8], b[9], b[10], b[11], b[12], b[13]); -#endif - /* Generate the packet */ - for (q = p, datalength = 0; q != NULL; q = q->next) - { - wfx_rsi_pkt_add_data(packet, (uint8_t *) (q->payload), (uint16_t) q->len, datalength); - datalength += q->len; - } - if (datalength < LWIP_FRAME_ALIGNMENT) - { - /* Add junk data to the end for frame alignment if framelength is less than 60 */ - wfx_rsi_pkt_add_data(packet, (uint8_t *) (p->payload), LWIP_FRAME_ALIGNMENT - datalength, datalength); - } -#ifdef WIFI_DEBUG_ENABLED - ChipLogProgress(DeviceLayer, "EN-RSI: Sending %d", framelength); -#endif - packet->length = framelength & 0xFFF; - packet->command = RSI_SEND_RAW_DATA; - if (sl_si91x_driver_send_data_packet(SI91X_WLAN_CMD_QUEUE, buffer, 1000)) - { - ChipLogProgress(DeviceLayer, "*ERR*EN-RSI:Send fail"); - xSemaphoreGive(ethout_sem); - return ERR_IF; - } - /* - * forward the generated packet to RSI to - * send the data over wifi network - */ - xSemaphoreGive(ethout_sem); - return ERR_OK; } diff --git a/src/platform/silabs/SiWx917/wifi/wfx_host_events.h b/src/platform/silabs/SiWx917/wifi/wfx_host_events.h index 526e22c751a69f..e3f923894c24e6 100644 --- a/src/platform/silabs/SiWx917/wifi/wfx_host_events.h +++ b/src/platform/silabs/SiWx917/wifi/wfx_host_events.h @@ -246,19 +246,12 @@ void wfx_ip_changed_notify(int got_ip); #endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */ #if SL_ICD_ENABLED +uint32_t sl_app_sleep_ready(); sl_status_t wfx_power_save(rsi_power_save_profile_mode_t sl_si91x_ble_state, sl_si91x_performance_profile_t sl_si91x_wifi_state); void sl_button_on_change(uint8_t btn, uint8_t btnAction); #endif /* SL_ICD_ENABLED */ void wfx_ipv6_notify(int got_ip); - -/* RSI for LWIP */ -void wfx_rsi_pkt_add_data(void * p, uint8_t * buf, uint16_t len, uint16_t off); -int32_t wfx_rsi_send_data(void * p, uint16_t len); -sl_status_t sl_si91x_driver_send_data_packet(sl_si91x_queue_type_t queue_type, sl_wifi_buffer_t * buffer, uint32_t wait_time); -sl_status_t sl_si91x_allocate_command_buffer(sl_wifi_buffer_t ** host_buffer, void ** buffer, uint32_t requested_buffer_size, - uint32_t wait_duration_ms); - void wfx_retry_interval_handler(bool is_wifi_disconnection_event, uint16_t retryJoin); #ifdef __cplusplus diff --git a/src/platform/silabs/efr32/wifi/wfx_host_events.h b/src/platform/silabs/efr32/wifi/wfx_host_events.h index b7a7c936b8d6de..a7a2dc2ac34fa4 100644 --- a/src/platform/silabs/efr32/wifi/wfx_host_events.h +++ b/src/platform/silabs/efr32/wifi/wfx_host_events.h @@ -386,12 +386,6 @@ void sl_wfx_host_gpio_init(void); sl_status_t sl_wfx_host_process_event(sl_wfx_generic_message_t * event_payload); #endif -#if (SLI_SI91X_MCU_INTERFACE | EXP_BOARD) -void wfx_retry_interval_handler(bool is_wifi_disconnection_event, uint16_t retryJoin); -sl_status_t sl_si91x_driver_send_data_packet(sl_si91x_queue_type_t queue_type, sl_wifi_buffer_t * buffer, uint32_t wait_time); -sl_status_t sl_si91x_allocate_command_buffer(sl_wifi_buffer_t ** host_buffer, void ** buffer, uint32_t requested_buffer_size, - uint32_t wait_duration_ms); -#endif void wfx_retry_interval_handler(bool is_wifi_disconnection_event, uint16_t retryJoin); #ifdef __cplusplus diff --git a/third_party/openthread/platforms/efr32/BUILD.gn b/third_party/openthread/platforms/efr32/BUILD.gn index f8f2dd4ac6f072..f3f13c1f61ba20 100644 --- a/third_party/openthread/platforms/efr32/BUILD.gn +++ b/third_party/openthread/platforms/efr32/BUILD.gn @@ -31,8 +31,14 @@ config("openthread_efr32_config") { include_dirs = [ "${chip_root}/examples/platform/efr32", "${sdk_support_root}/matter/efr32/${silabs_family}/${silabs_board}", - "${sl_ot_efr32_root}", "${sl_ot_platform_abstraction}/include", + "${sl_ot_efr32_root}", + + #TODO TEST is this needed here if it is in efr32_sdk.gni!!!! + "${sl_ot_platform_abstraction}/rtos", + + #this is for sl_openthread_features_config.h. should use generated one per board + "${sl_ot_libs_path}/config", ] # temporarily disable check until gsdk pulls in a more recent version of openthread @@ -54,6 +60,9 @@ source_set("openthread_core_config_efr32") { source_set("libopenthread-efr32") { sources = [ "${openthread_root}/examples/apps/cli/cli_uart.cpp", + "${openthread_root}/examples/platforms/utils/link_metrics.cpp", + "${openthread_root}/examples/platforms/utils/mac_frame.cpp", + "${openthread_root}/examples/platforms/utils/settings_ram.c", "${sl_ot_efr32_root}/alarm.c", "${sl_ot_efr32_root}/crypto.c", "${sl_ot_efr32_root}/entropy.c", @@ -61,11 +70,17 @@ source_set("libopenthread-efr32") { "${sl_ot_efr32_root}/ieee802154-packet-utils.cpp", "${sl_ot_efr32_root}/misc.c", "${sl_ot_efr32_root}/radio.c", + "${sl_ot_efr32_root}/radio_coex.c", + "${sl_ot_efr32_root}/radio_extension.c", + "${sl_ot_efr32_root}/radio_power_manager.c", + "${sl_ot_efr32_root}/sl_gp_interface.c", "${sl_ot_efr32_root}/sleep.c", "${sl_ot_efr32_root}/soft_source_match_table.c", "${sl_ot_efr32_root}/system.c", ] + include_dirs = [ "${openthread_root}/examples/platforms/utils" ] + public_deps = [ ":openthread_core_config_efr32", "${openthread_root}/src/core:libopenthread_core_headers", diff --git a/third_party/silabs/BUILD.gn b/third_party/silabs/BUILD.gn index 2326a73ab09121..6095f5b9bc47a8 100644 --- a/third_party/silabs/BUILD.gn +++ b/third_party/silabs/BUILD.gn @@ -150,12 +150,16 @@ if (wifi_soc != true) { # CCP board "${openthread_root}/src/cli/cli_history.hpp", "${openthread_root}/src/cli/cli_joiner.cpp", "${openthread_root}/src/cli/cli_joiner.hpp", + "${openthread_root}/src/cli/cli_link_metrics.cpp", + "${openthread_root}/src/cli/cli_link_metrics.hpp", "${openthread_root}/src/cli/cli_mac_filter.cpp", "${openthread_root}/src/cli/cli_mac_filter.hpp", + "${openthread_root}/src/cli/cli_mdns.cpp", + "${openthread_root}/src/cli/cli_mdns.hpp", "${openthread_root}/src/cli/cli_network_data.cpp", "${openthread_root}/src/cli/cli_network_data.hpp", - "${openthread_root}/src/cli/cli_output.cpp", - "${openthread_root}/src/cli/cli_output.hpp", + "${openthread_root}/src/cli/cli_ping.cpp", + "${openthread_root}/src/cli/cli_ping.hpp", "${openthread_root}/src/cli/cli_srp_client.cpp", "${openthread_root}/src/cli/cli_srp_client.hpp", "${openthread_root}/src/cli/cli_srp_server.cpp", @@ -164,6 +168,8 @@ if (wifi_soc != true) { # CCP board "${openthread_root}/src/cli/cli_tcp.hpp", "${openthread_root}/src/cli/cli_udp.cpp", "${openthread_root}/src/cli/cli_udp.hpp", + "${openthread_root}/src/cli/cli_utils.cpp", + "${openthread_root}/src/cli/cli_utils.hpp", "${openthread_root}/src/cli/x509_cert_key.hpp", ] } @@ -197,6 +203,11 @@ if (wifi_soc != true) { # CCP board public_configs += [ "${openthread_root}:openthread_${XTD}_config" ] + if (silabs_family == "mgm24") { + # Locally set silabs_family to efr32mg24 as mgm24 doesn't have dedicated sl_ot_platform libs + silabs_family = "efr32mg24" + } + libs = [ "${sl_ot_libs_path}/libs/libsl_ot_stack_${XTD}_${COAP_API}${silabs_family}_gcc.a", "${sl_ot_libs_path}/libs/libsl_platform_${XTD}_dmp_${silabs_family}_gcc.a", diff --git a/third_party/silabs/SiWx917_sdk.gni b/third_party/silabs/SiWx917_sdk.gni index 59ab00534af208..2862f9bc9d09f6 100644 --- a/third_party/silabs/SiWx917_sdk.gni +++ b/third_party/silabs/SiWx917_sdk.gni @@ -141,6 +141,13 @@ template("siwx917_sdk") { "${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/hardware_drivers/led/config", "${wifi_sdk_root}/components/device/silabs/si91x/mcu/core/config", + # sl memory manager + "${efr32_sdk_root}/platform/service/memory_manager/inc", + "${efr32_sdk_root}/platform/service/memory_manager/src", + "${efr32_sdk_root}/platform/service/memory_manager/profiler/inc", + "${efr32_sdk_root}/platform/service/memory_manager/profiler/config", + "${efr32_sdk_root}/util/silicon_labs/silabs_core/memory_manager", + # OTA "${wifi_sdk_root}/components/device/silabs/si91x/wireless/firmware_upgrade", "${wifi_sdk_root}/components/device/silabs/si91x/mcu/hal/inc", @@ -225,6 +232,7 @@ template("siwx917_sdk") { "RADIO_CONFIG_DMP_SUPPORT=1", "configUSE_POSIX_ERRNO=1", "NVM3_LOCK_OVERRIDE=1", + "SL_MEMORY_POOL_LIGHT=1", ] if (silabs_log_enabled && chip_logging) { @@ -373,6 +381,7 @@ template("siwx917_sdk") { # si91x component "${efr32_sdk_root}/platform/CMSIS/RTOS2/Source/os_systick.c", "${efr32_sdk_root}/platform/common/src/sl_assert.c", + "${efr32_sdk_root}/platform/common/src/sl_core_cortexm.c", "${efr32_sdk_root}/platform/common/src/sl_slist.c", "${efr32_sdk_root}/platform/common/src/sli_cmsis_os2_ext_task_register.c", "${efr32_sdk_root}/util/third_party/freertos/cmsis/Source/cmsis_os2.c", @@ -410,7 +419,10 @@ template("siwx917_sdk") { "${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/cmsis_driver/UDMA.c", "${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/cmsis_driver/USART.c", "${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/peripheral_drivers/src/clock_update.c", + "${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/peripheral_drivers/src/rsi_crc.c", "${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/peripheral_drivers/src/rsi_egpio.c", + "${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/peripheral_drivers/src/rsi_spi.c", + "${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/peripheral_drivers/src/rsi_timers.c", "${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/peripheral_drivers/src/rsi_udma.c", "${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/peripheral_drivers/src/rsi_udma_wrapper.c", "${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/peripheral_drivers/src/rsi_usart.c", @@ -446,10 +458,12 @@ template("siwx917_sdk") { "${efr32_sdk_root}/platform/emlib/src/em_core.c", "${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_nvic.c", "${efr32_sdk_root}/platform/service/system/src/sl_system_init.c", + "${efr32_sdk_root}/platform/service/system/src/sl_system_kernel.c", "${efr32_sdk_root}/util/third_party/freertos/kernel/croutine.c", "${efr32_sdk_root}/util/third_party/freertos/kernel/event_groups.c", "${efr32_sdk_root}/util/third_party/freertos/kernel/list.c", "${efr32_sdk_root}/util/third_party/freertos/kernel/portable/GCC/ARM_CM4F/port.c", + "${efr32_sdk_root}/util/third_party/freertos/kernel/portable/MemMang/heap_3.c", "${efr32_sdk_root}/util/third_party/freertos/kernel/queue.c", "${efr32_sdk_root}/util/third_party/freertos/kernel/stream_buffer.c", "${efr32_sdk_root}/util/third_party/freertos/kernel/tasks.c", @@ -457,11 +471,22 @@ template("siwx917_sdk") { "${sdk_support_root}/matter/si91x/siwx917/BRD4338A/autogen/sl_event_handler.c", "${sdk_support_root}/matter/si91x/siwx917/BRD4338A/autogen/sl_si91x_button_instances.c", "${sdk_support_root}/matter/si91x/siwx917/BRD4338A/autogen/sl_si91x_led_instances.c", + "${sdk_support_root}/matter/si91x/siwx917/BRD4338A/autogen/sl_ulp_timer_init.c", "${sdk_support_root}/matter/si91x/siwx917/BRD4338A/support/hal/rsi_hal_mcu_m4.c", "${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/hardware_drivers/button/src/sl_si91x_button.c", "${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/hardware_drivers/led/src/sl_si91x_led.c", "${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/service/nvm3/src/sl_si91x_nvm3_hal_flash.c", + # sl memory manager + "${efr32_sdk_root}/platform/service/memory_manager/profiler/src/sli_memory_profiler_stubs.c", + "${efr32_sdk_root}/platform/service/memory_manager/src/sl_memory_manager.c", + "${efr32_sdk_root}/platform/service/memory_manager/src/sl_memory_manager_cpp.cpp", + "${efr32_sdk_root}/platform/service/memory_manager/src/sl_memory_manager_dynamic_reservation.c", + "${efr32_sdk_root}/platform/service/memory_manager/src/sl_memory_manager_pool.c", + "${efr32_sdk_root}/platform/service/memory_manager/src/sl_memory_manager_region.c", + "${efr32_sdk_root}/platform/service/memory_manager/src/sl_memory_manager_retarget.c", + "${efr32_sdk_root}/platform/service/memory_manager/src/sli_memory_manager_common.c", + # mbedtls "${chip_root}/third_party/mbedtls/repo/library/aes.c", "${chip_root}/third_party/mbedtls/repo/library/asn1parse.c", diff --git a/third_party/silabs/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index 60622f4c75e71e..9312538453ecfd 100644 --- a/third_party/silabs/efr32_sdk.gni +++ b/third_party/silabs/efr32_sdk.gni @@ -153,31 +153,45 @@ template("efr32_sdk") { "${efr32_sdk_root}/hardware/driver/configuration_over_swo/inc/", "${efr32_sdk_root}/platform/bootloader", "${efr32_sdk_root}/platform/bootloader/config", - "${efr32_sdk_root}/platform/bootloader/config/s2/btl_interface", + "${efr32_sdk_root}/platform/bootloader/config/btl_interface", "${efr32_sdk_root}/platform/bootloader/api", "${efr32_sdk_root}/platform/CMSIS/Core/Include", "${efr32_sdk_root}/platform/CMSIS/RTOS2/Include", "${efr32_sdk_root}/platform/common/inc", + "${efr32_sdk_root}/platform/driver/debug/inc", "${efr32_sdk_root}/platform/emdrv/common/inc", "${efr32_sdk_root}/platform/emdrv/gpiointerrupt/inc", "${efr32_sdk_root}/platform/emdrv/dmadrv/inc", "${efr32_sdk_root}/platform/emdrv/nvm3/inc", - "${efr32_sdk_root}/platform/emdrv/rtcdrv/inc", "${efr32_sdk_root}/platform/emlib/inc", "${efr32_sdk_root}/platform/halconfig/inc/hal-config", "${efr32_sdk_root}/platform/peripheral/inc", "${efr32_sdk_root}/platform/radio/rail_lib/common", "${efr32_sdk_root}/platform/radio/rail_lib/chip/efr32", - "${efr32_sdk_root}/platform/radio/rail_lib/chip/efr32/rf/common/cortex", "${efr32_sdk_root}/platform/radio/rail_lib/protocol/ieee802154", "${efr32_sdk_root}/platform/radio/rail_lib/protocol/ble", "${efr32_sdk_root}/platform/radio/rail_lib/plugin/pa-conversions", "${efr32_sdk_root}/platform/radio/rail_lib/plugin/rail_util_pti", "${efr32_sdk_root}/platform/radio/rail_lib/plugin/rail_util_power_manager_init", + "${efr32_sdk_root}/platform/security/sl_component/sl_mbedtls_support/config/", + "${efr32_sdk_root}/platform/security/sl_component/sl_mbedtls_support/config/preset", + "${efr32_sdk_root}/platform/security/sl_component/sl_mbedtls_support/inc", + "${efr32_sdk_root}/platform/security/sl_component/sl_protocol_crypto/src", + "${efr32_sdk_root}/platform/security/sl_component/sl_psa_driver/inc", + "${efr32_sdk_root}/platform/security/sl_component/se_manager/inc", + "${efr32_sdk_root}/platform/security/sl_component/se_manager/src/", + "${efr32_sdk_root}/platform/service/clock_manager/inc", "${efr32_sdk_root}/platform/service/device_init/inc", + "${efr32_sdk_root}/platform/service/device_manager/inc", "${efr32_sdk_root}/platform/service/hfxo_manager/inc", "${efr32_sdk_root}/platform/service/hfxo_manager/src", + "${efr32_sdk_root}/platform/service/interrupt_manager/inc/", + "${efr32_sdk_root}/platform/service/interrupt_manager/inc/arm/", "${efr32_sdk_root}/platform/service/iostream/inc", + "${efr32_sdk_root}/platform/service/memory_manager/inc", + "${efr32_sdk_root}/platform/service/memory_manager/src", + "${efr32_sdk_root}/platform/service/memory_manager/profiler/inc", + "${efr32_sdk_root}/platform/service/memory_manager/profiler/config", "${efr32_sdk_root}/platform/service/mpu/inc", "${efr32_sdk_root}/platform/service/power_manager/inc/", "${efr32_sdk_root}/platform/service/power_manager/src/", @@ -189,34 +203,29 @@ template("efr32_sdk") { "${efr32_sdk_root}/platform/middleware/glib/config", "${efr32_sdk_root}/platform/middleware/glib/glib", "${efr32_sdk_root}/platform/middleware/glib/dmd", - "${efr32_sdk_root}/platform/base/hal/plugin/psstore", - "${efr32_sdk_root}/platform/base/hal/plugin/antenna", "${efr32_sdk_root}/protocol/bluetooth/inc/", "${efr32_sdk_root}/protocol/bluetooth/bgstack/ll/inc", "${efr32_sdk_root}/util/plugin/plugin-common/fem-control", "${efr32_sdk_root}/util/silicon_labs/silabs_core/graphics", "${efr32_sdk_root}/util/silicon_labs/silabs_core/memory_manager", + "${efr32_sdk_root}/util/silicon_labs/silabs_core/queue", "${efr32_sdk_root}/util/third_party/mbedtls/include", "${efr32_sdk_root}/util/third_party/mbedtls/include/mbedtls", "${efr32_sdk_root}/util/third_party/mbedtls/include/psa", "${efr32_sdk_root}/util/third_party/mbedtls/library", - "${efr32_sdk_root}/platform/security/sl_component/sl_protocol_crypto/src", - "${efr32_sdk_root}/platform/security/sl_component/sl_mbedtls_support/config/", - "${efr32_sdk_root}/platform/security/sl_component/sl_mbedtls_support/config/preset", - "${efr32_sdk_root}/platform/security/sl_component/sl_psa_driver/inc", - "${efr32_sdk_root}/platform/security/sl_component/se_manager/inc", - "${efr32_sdk_root}/platform/security/sl_component/se_manager/src/", "${efr32_sdk_root}/util/third_party/freertos/cmsis/Include", "${efr32_sdk_root}/util/third_party/freertos/kernel/include", - "${efr32_sdk_root}/platform/driver/debug/inc", "${silabs_gen_folder}/config", "${silabs_gen_folder}/autogen", - # Use directory in matter support until gsdk files are updated - "${sdk_support_root}/platform/security/sl_component/sl_mbedtls_support/inc", - # Headers needed for Init no function will be called if OT is not used "${sl_ot_efr32_root}", + + #TODO TEST is this needed here!!!! + "${sl_ot_platform_abstraction}/rtos", + + # TODO this is for sl_openthread_features_config.h. should use generated one per board when sl_ot_abstraction is integrated + "${sl_ot_libs_path}/config", ] if (silabs_family == "efr32mg24") { @@ -287,25 +296,32 @@ template("efr32_sdk") { "NVM3_DEFAULT_NVM_SIZE=40960", "NVM3_DEFAULT_MAX_OBJECT_SIZE=4092", "KVS_MAX_ENTRIES=${kvs_max_entries}", - "EFR32_OPENTHREAD_API", - "PHY=EMBER_PHY_RAIL", - "CORTEXM3", + "CORTEXM3=1", "MICRO=EMBER_MICRO_CORTEXM3_EFR32", "PLAT=EMBER_PLATFORM_CORTEXM3", "${silabs_mcu}=1", "${silabs_board}=1", "SL_BOARD_NAME=${silabs_board}", "__HEAP_SIZE=0", + "__STACK_SIZE=0", "SL_THREADING_ALT=1", "SL_COMPONENT_CATALOG_PRESENT=1", + "SL_CODE_COMPONENT_CORE=core", + "SL_CODE_COMPONENT_PERIPHERAL_SYSRTC=hal_sysrtc", + "SL_CODE_COMPONENT_POWER_MANAGER=power_manager", + "SL_CODE_COMPONENT_SLEEPTIMER=sleeptimer", + "CMSIS_NVIC_VIRTUAL=1", + "CMSIS_NVIC_VIRTUAL_HEADER_FILE=\"cmsis_nvic_virtual.h\"", "PLATFORM_HEADER=\"platform-header.h\"", "USE_NVM3=1", "SL_RAIL_LIB_MULTIPROTOCOL_SUPPORT=1", "SL_RAIL_UTIL_PA_CONFIG_HEADER=", "RADIO_CONFIG_DMP_SUPPORT=1", "SL_MATTER_BLE_EXTENDED_ADV=${sl_matter_ble_extended_adv}", - - #"__STACK_SIZE=0", + "SL_MEMORY_POOL_LIGHT=1", + "SL_OPENTHREAD_STACK_FEATURES_CONFIG_FILE=\"sl_openthread_features_config.h\"", + "CIRCULAR_QUEUE_USE_LOCAL_CONFIG_HEADER=1", + "MATTER_INTEGRATION=1", ] if (silabs_log_enabled && chip_logging) { @@ -511,6 +527,7 @@ template("efr32_sdk") { "${efr32_sdk_root}/platform/radio/rail_lib/plugin/pa-conversions/efr32xg24/config", "${efr32_sdk_root}/platform/service/device_init/config/s2/", "${efr32_sdk_root}/platform/emdrv/spidrv/inc", + "${efr32_sdk_root}/platform/emdrv/dmadrv/inc/s2_signals", ] libs += [ @@ -521,9 +538,10 @@ template("efr32_sdk") { if (!chip_enable_ble_rs911x) { libs += [ - "${sdk_support_root}/protocol/bluetooth/bgcommon/lib/libbgcommon_efr32xg24_gcc_release.a", + "${sdk_support_root}/protocol/bluetooth/bgcommon/lib/build/gcc/cortex-m33/bgcommon/release/libbgcommon.a", "${sdk_support_root}/protocol/bluetooth/bgstack/ll/lib/libbluetooth_controller_efr32xg24_gcc_release.a", - "${sdk_support_root}/protocol/bluetooth/lib/libbluetooth_host_efr32xg24_gcc_release.a", + "${sdk_support_root}/protocol/bluetooth/build/gcc/cortex-m33/bt_host/release/libbt_host.a", + "${sdk_support_root}/protocol/bluetooth/build/gcc/cortex-m33/bt_host/hal/release/libbt_hal_series2.a", ] } @@ -542,12 +560,14 @@ template("efr32_sdk") { "${efr32_sdk_root}/platform/radio/rail_lib/plugin/pa-conversions/efr32xg24", "${efr32_sdk_root}/platform/radio/rail_lib/plugin/pa-conversions/efr32xg24/config", "${efr32_sdk_root}/platform/service/device_init/config/s2/", + "${efr32_sdk_root}/platform/emdrv/dmadrv/inc/s2_signals", ] libs += [ - "${sdk_support_root}/protocol/bluetooth/bgcommon/lib/libbgcommon_efr32xg24_gcc_release.a", + "${sdk_support_root}/protocol/bluetooth/bgcommon/lib/build/gcc/cortex-m33/bgcommon/release/libbgcommon.a", "${sdk_support_root}/protocol/bluetooth/bgstack/ll/lib/libbluetooth_controller_efr32xg24_gcc_release.a", - "${sdk_support_root}/protocol/bluetooth/lib/libbluetooth_host_efr32xg24_gcc_release.a", + "${sdk_support_root}/protocol/bluetooth/build/gcc/cortex-m33/bt_host/release/libbt_host.a", + "${sdk_support_root}/protocol/bluetooth/build/gcc/cortex-m33/bt_host/hal/release/libbt_hal_series2.a", "${sdk_support_root}/platform/radio/rail_lib/autogen/librail_release/librail_multiprotocol_module_efr32xg24_gcc_release.a", "${sdk_support_root}/platform/emdrv/nvm3/lib/libnvm3_CM33_gcc.a", "${sdk_support_root}/protocol/openthread/libs/libsl_openthread_efr32mg2x_gcc.a", @@ -618,6 +638,7 @@ template("efr32_sdk") { "${efr32_sdk_root}/platform/bootloader/api/btl_interface.c", "${efr32_sdk_root}/platform/bootloader/api/btl_interface_storage.c", "${efr32_sdk_root}/platform/bootloader/security/sha/crypto_sha.c", + "${efr32_sdk_root}/platform/common/src/sl_core_cortexm.c", "${efr32_sdk_root}/platform/common/src/sl_slist.c", "${efr32_sdk_root}/platform/common/src/sli_cmsis_os2_ext_task_register.c", "${efr32_sdk_root}/platform/emdrv/dmadrv/src/dmadrv.c", @@ -625,7 +646,6 @@ template("efr32_sdk") { "${efr32_sdk_root}/platform/emdrv/nvm3/src/nvm3_default.c", "${efr32_sdk_root}/platform/emdrv/nvm3/src/nvm3_hal_flash.c", "${efr32_sdk_root}/platform/emdrv/nvm3/src/nvm3_lock.c", - "${efr32_sdk_root}/platform/emlib/src/em_adc.c", "${efr32_sdk_root}/platform/emlib/src/em_cmu.c", "${efr32_sdk_root}/platform/emlib/src/em_core.c", "${efr32_sdk_root}/platform/emlib/src/em_crypto.c", @@ -639,11 +659,10 @@ template("efr32_sdk") { "${efr32_sdk_root}/platform/emlib/src/em_se.c", "${efr32_sdk_root}/platform/emlib/src/em_system.c", "${efr32_sdk_root}/platform/emlib/src/em_timer.c", - "${efr32_sdk_root}/platform/peripheral/src/peripheral_sysrtc.c", + "${efr32_sdk_root}/platform/peripheral/src/sl_hal_sysrtc.c", "${efr32_sdk_root}/platform/radio/rail_lib/plugin/pa-conversions/pa_conversions_efr32.c", "${efr32_sdk_root}/platform/radio/rail_lib/plugin/rail_util_power_manager_init/sl_rail_util_power_manager_init.c", "${efr32_sdk_root}/platform/radio/rail_lib/plugin/rail_util_pti/sl_rail_util_pti.c", - "${efr32_sdk_root}/platform/security/sl_component/sl_mbedtls_support/src/crypto_ecp.c", "${efr32_sdk_root}/platform/security/sl_component/sl_mbedtls_support/src/error.c", "${efr32_sdk_root}/platform/security/sl_component/sl_mbedtls_support/src/mbedtls_ccm.c", "${efr32_sdk_root}/platform/security/sl_component/sl_mbedtls_support/src/mbedtls_cmac.c", @@ -651,23 +670,34 @@ template("efr32_sdk") { "${efr32_sdk_root}/platform/security/sl_component/sl_mbedtls_support/src/mbedtls_sha.c", "${efr32_sdk_root}/platform/security/sl_component/sl_mbedtls_support/src/sl_entropy_hardware.c", "${efr32_sdk_root}/platform/security/sl_component/sl_mbedtls_support/src/sl_mbedtls.c", + "${efr32_sdk_root}/platform/security/sl_component/sl_mbedtls_support/src/sl_psa_crypto.c", "${efr32_sdk_root}/platform/security/sl_component/sl_mbedtls_support/src/sli_psa_crypto.c", + "${efr32_sdk_root}/platform/security/sl_component/sl_psa_driver/src/sl_psa_its_nvm3.c", "${efr32_sdk_root}/platform/security/sl_component/sl_psa_driver/src/sli_psa_driver_common.c", "${efr32_sdk_root}/platform/security/sl_component/sl_psa_driver/src/sli_psa_driver_init.c", "${efr32_sdk_root}/platform/security/sl_component/sl_psa_driver/src/sli_psa_trng.c", "${efr32_sdk_root}/platform/security/sl_component/sl_psa_driver/src/sli_se_driver_builtin_keys.c", "${efr32_sdk_root}/platform/security/sl_component/sl_psa_driver/src/sli_se_driver_signature.c", "${efr32_sdk_root}/platform/security/sl_component/sl_psa_driver/src/sli_se_version_dependencies.c", - "${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_lfrco.c", - "${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_nvic.c", + "${efr32_sdk_root}/platform/service/clock_manager/src/sl_clock_manager.c", + "${efr32_sdk_root}/platform/service/clock_manager/src/sl_clock_manager_init.c", + "${efr32_sdk_root}/platform/service/device_manager/src/sl_device_clock.c", + "${efr32_sdk_root}/platform/service/device_manager/src/sl_device_peripheral.c", "${efr32_sdk_root}/platform/service/hfxo_manager/src/sl_hfxo_manager.c", + "${efr32_sdk_root}/platform/service/interrupt_manager/src/sl_interrupt_manager_cortexm.c", "${efr32_sdk_root}/platform/service/iostream/src/sl_iostream.c", "${efr32_sdk_root}/platform/service/iostream/src/sl_iostream_rtt.c", + "${efr32_sdk_root}/platform/service/memory_manager/profiler/src/sli_memory_profiler_stubs.c", + "${efr32_sdk_root}/platform/service/memory_manager/src/sl_memory_manager.c", + "${efr32_sdk_root}/platform/service/memory_manager/src/sl_memory_manager_cpp.cpp", + "${efr32_sdk_root}/platform/service/memory_manager/src/sl_memory_manager_dynamic_reservation.c", + "${efr32_sdk_root}/platform/service/memory_manager/src/sl_memory_manager_pool.c", + "${efr32_sdk_root}/platform/service/memory_manager/src/sl_memory_manager_region.c", + "${efr32_sdk_root}/platform/service/memory_manager/src/sl_memory_manager_retarget.c", + "${efr32_sdk_root}/platform/service/memory_manager/src/sli_memory_manager_common.c", "${efr32_sdk_root}/platform/service/mpu/src/sl_mpu.c", "${efr32_sdk_root}/platform/service/power_manager/src/sl_power_manager.c", "${efr32_sdk_root}/platform/service/power_manager/src/sl_power_manager_debug.c", - "${efr32_sdk_root}/platform/service/power_manager/src/sl_power_manager_hal_s0_s1.c", - "${efr32_sdk_root}/platform/service/power_manager/src/sl_power_manager_hal_s2.c", "${efr32_sdk_root}/platform/service/sleeptimer/src/sl_sleeptimer.c", "${efr32_sdk_root}/platform/service/sleeptimer/src/sl_sleeptimer_hal_rtcc.c", "${efr32_sdk_root}/platform/service/system/src/sl_system_init.c", @@ -675,11 +705,12 @@ template("efr32_sdk") { "${efr32_sdk_root}/platform/service/udelay/src/sl_udelay.c", "${efr32_sdk_root}/platform/service/udelay/src/sl_udelay_armv6m_gcc.S", "${efr32_sdk_root}/util/plugin/security_manager/security_manager.c", - "${efr32_sdk_root}/util/silicon_labs/silabs_core/memory_manager/sl_malloc.c", + "${efr32_sdk_root}/util/silicon_labs/silabs_core/queue/circular_queue.c", "${efr32_sdk_root}/util/third_party/freertos/cmsis/Source/cmsis_os2.c", "${efr32_sdk_root}/util/third_party/freertos/kernel/croutine.c", "${efr32_sdk_root}/util/third_party/freertos/kernel/event_groups.c", "${efr32_sdk_root}/util/third_party/freertos/kernel/list.c", + "${efr32_sdk_root}/util/third_party/freertos/kernel/portable/MemMang/heap_3.c", "${efr32_sdk_root}/util/third_party/freertos/kernel/portable/SiliconLabs/tick_power_manager.c", "${efr32_sdk_root}/util/third_party/freertos/kernel/queue.c", "${efr32_sdk_root}/util/third_party/freertos/kernel/stream_buffer.c", @@ -718,7 +749,6 @@ template("efr32_sdk") { "${efr32_sdk_root}/util/third_party/mbedtls/library/psa_crypto_cipher.c", "${efr32_sdk_root}/util/third_party/mbedtls/library/psa_crypto_client.c", "${efr32_sdk_root}/util/third_party/mbedtls/library/psa_crypto_driver_wrappers_no_static.c", - "${efr32_sdk_root}/util/third_party/mbedtls/library/psa_crypto_ecp.c", "${efr32_sdk_root}/util/third_party/mbedtls/library/psa_crypto_hash.c", "${efr32_sdk_root}/util/third_party/mbedtls/library/psa_crypto_mac.c", "${efr32_sdk_root}/util/third_party/mbedtls/library/psa_crypto_rsa.c", @@ -747,12 +777,8 @@ template("efr32_sdk") { "${silabs_gen_folder}/autogen/gatt_db.c", "${silabs_gen_folder}/autogen/sl_bluetooth.c", "${silabs_gen_folder}/autogen/sl_board_default_init.c", - "${silabs_gen_folder}/autogen/sl_device_init_clocks.c", "${silabs_gen_folder}/autogen/sl_event_handler.c", "${silabs_gen_folder}/autogen/sl_iostream_handles.c", - - # Used file in matter_support until fix is pushed to gsdk - "${sdk_support_root}/platform/security/sl_component/sl_psa_driver/src/sl_psa_its_nvm3.c", ] if (enable_dic) { sources += [ @@ -765,11 +791,6 @@ template("efr32_sdk") { ] } - if (silabs_family != "mgm24") { - sources += - [ "${efr32_sdk_root}/platform/radio/rail_lib/hal/efr32/hal_efr.c" ] - } - if (use_wstk_buttons) { sources += [ "${efr32_sdk_root}/platform/driver/button/src/sl_button.c", @@ -803,6 +824,7 @@ template("efr32_sdk") { "${efr32_sdk_root}/protocol/bluetooth/src/sl_bt_stack_init.c", "${efr32_sdk_root}/protocol/bluetooth/src/sli_bt_advertiser_config.c", "${efr32_sdk_root}/protocol/bluetooth/src/sli_bt_connection_config.c", + "${efr32_sdk_root}/protocol/bluetooth/src/sli_bt_host_adaptation.c", ] } @@ -858,7 +880,6 @@ template("efr32_sdk") { "${efr32_sdk_root}/hardware/driver/memlcd/src/memlcd_usart/sl_memlcd_spi.c", "${efr32_sdk_root}/platform/emdrv/uartdrv/src/uartdrv.c", "${efr32_sdk_root}/platform/emlib/src/em_eusart.c", - "${efr32_sdk_root}/platform/emlib/src/em_leuart.c", "${efr32_sdk_root}/platform/emlib/src/em_usart.c", "${silabs_gen_folder}/autogen/sl_uartdrv_init.c", ] @@ -901,7 +922,6 @@ template("efr32_sdk") { "${efr32_sdk_root}/platform/Device/SiliconLabs/EFR32MG24/Source/startup_efr32mg24.c", "${efr32_sdk_root}/platform/Device/SiliconLabs/EFR32MG24/Source/system_efr32mg24.c", "${efr32_sdk_root}/platform/radio/rail_lib/plugin/pa-conversions/pa_curves_efr32.c", - "${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_hfxo_s2.c", ] } else if (silabs_family == "mgm24") { sources += [ @@ -909,7 +929,6 @@ template("efr32_sdk") { "${efr32_sdk_root}/platform/Device/SiliconLabs/MGM24/Source/system_mgm24.c", "${efr32_sdk_root}/platform/radio/rail_lib/plugin/fem_util/sl_fem_util.c", "${efr32_sdk_root}/platform/radio/rail_lib/plugin/rail_util_rssi/sl_rail_util_rssi.c", - "${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_hfxo_mgm24.c", ] } @@ -925,6 +944,7 @@ template("efr32_sdk") { "${efr32_sdk_root}/platform/security/sl_component/se_manager/src/sl_se_manager_key_handling.c", "${efr32_sdk_root}/platform/security/sl_component/se_manager/src/sl_se_manager_signature.c", "${efr32_sdk_root}/platform/security/sl_component/se_manager/src/sl_se_manager_util.c", + "${efr32_sdk_root}/platform/security/sl_component/se_manager/src/sli_se_manager_mailbox.c", "${efr32_sdk_root}/platform/security/sl_component/sl_mbedtls_support/src/se_aes.c", "${efr32_sdk_root}/platform/security/sl_component/sl_mbedtls_support/src/se_jpake.c", "${efr32_sdk_root}/platform/security/sl_component/sl_protocol_crypto/src/sli_protocol_crypto_radioaes.c", @@ -943,11 +963,13 @@ template("efr32_sdk") { "${efr32_sdk_root}/platform/security/sl_component/sl_psa_driver/src/sli_se_transparent_driver_hash.c", "${efr32_sdk_root}/platform/security/sl_component/sl_psa_driver/src/sli_se_transparent_driver_mac.c", "${efr32_sdk_root}/platform/security/sl_component/sl_psa_driver/src/sli_se_transparent_key_derivation.c", + "${efr32_sdk_root}/platform/service/clock_manager/src/sl_clock_manager_hal_s2.c", + "${efr32_sdk_root}/platform/service/clock_manager/src/sl_clock_manager_init_hal_s2.c", "${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_dcdc_s2.c", - "${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_dpll_s2.c", - "${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_emu_s2.c", - "${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_lfxo_s2.c", + "${efr32_sdk_root}/platform/service/device_manager/clocks/sl_device_clock_efr32xg24.c", + "${efr32_sdk_root}/platform/service/device_manager/devices/sl_device_peripheral_hal_efr32xg24.c", "${efr32_sdk_root}/platform/service/hfxo_manager/src/sl_hfxo_manager_hal_s2.c", + "${efr32_sdk_root}/platform/service/power_manager/src/sl_power_manager_hal_s2.c", "${efr32_sdk_root}/platform/service/sleeptimer/src/sl_sleeptimer_hal_sysrtc.c", "${efr32_sdk_root}/util/third_party/freertos/kernel/portable/GCC/ARM_CM33_NTZ/non_secure/port.c", "${efr32_sdk_root}/util/third_party/freertos/kernel/portable/GCC/ARM_CM33_NTZ/non_secure/portasm.c", From 580c50b697abe81b822138cda20bd194eed671cf Mon Sep 17 00:00:00 2001 From: Junior Martinez <67972863+jmartinez-silabs@users.noreply.github.com> Date: Mon, 24 Jun 2024 08:31:47 -0400 Subject: [PATCH 04/12] Workflow to use latest silabs docker image --- .github/workflows/examples-efr32.yaml | 2 +- .github/workflows/release_artifacts.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/examples-efr32.yaml b/.github/workflows/examples-efr32.yaml index 7dab3f0886f09e..eaaedd226e778b 100644 --- a/.github/workflows/examples-efr32.yaml +++ b/.github/workflows/examples-efr32.yaml @@ -40,7 +40,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: ghcr.io/project-chip/chip-build-efr32:54 + image: ghcr.io/project-chip/chip-build-efr32:56 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/release_artifacts.yaml b/.github/workflows/release_artifacts.yaml index 55041773007925..be862403037423 100644 --- a/.github/workflows/release_artifacts.yaml +++ b/.github/workflows/release_artifacts.yaml @@ -64,7 +64,7 @@ jobs: runs-on: ubuntu-latest container: - image: ghcr.io/project-chip/chip-build-efr32:54 + image: ghcr.io/project-chip/chip-build-efr32:56 steps: - name: Checkout uses: actions/checkout@v4 From c8de8f8258a7eb136be2e354d79f77aaf9c77840 Mon Sep 17 00:00:00 2001 From: Junior Martinez <67972863+jmartinez-silabs@users.noreply.github.com> Date: Tue, 25 Jun 2024 10:13:09 -0400 Subject: [PATCH 05/12] Fix to leverage csl on thread libs --- third_party/openthread/platforms/efr32/BUILD.gn | 6 ++---- third_party/silabs/BUILD.gn | 7 ++++++- third_party/silabs/efr32_sdk.gni | 9 +++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/third_party/openthread/platforms/efr32/BUILD.gn b/third_party/openthread/platforms/efr32/BUILD.gn index f3f13c1f61ba20..381c6407f2c7cd 100644 --- a/third_party/openthread/platforms/efr32/BUILD.gn +++ b/third_party/openthread/platforms/efr32/BUILD.gn @@ -29,15 +29,13 @@ config("openthread_efr32_config") { ] include_dirs = [ + "${sl_ot_efr32_root}", "${chip_root}/examples/platform/efr32", "${sdk_support_root}/matter/efr32/${silabs_family}/${silabs_board}", "${sl_ot_platform_abstraction}/include", - "${sl_ot_efr32_root}", - - #TODO TEST is this needed here if it is in efr32_sdk.gni!!!! "${sl_ot_platform_abstraction}/rtos", - #this is for sl_openthread_features_config.h. should use generated one per board + #TODO this is for sl_openthread_features_config.h. should use generated one per board when sl_ot_abstraction is integrated "${sl_ot_libs_path}/config", ] diff --git a/third_party/silabs/BUILD.gn b/third_party/silabs/BUILD.gn index 6095f5b9bc47a8..e7b9c78a95216b 100644 --- a/third_party/silabs/BUILD.gn +++ b/third_party/silabs/BUILD.gn @@ -126,8 +126,13 @@ if (wifi_soc != true) { # CCP board } source_set("ot-efr32-cert") { + sources = [ + "${openthread_root}/examples/platforms/utils/mac_frame.cpp", + "${openthread_root}/examples/platforms/utils/mac_frame.h", + ] + if (enable_openthread_cli) { - sources = [ + sources += [ "${openthread_root}/examples/apps/cli/cli_uart.cpp", "${openthread_root}/src/cli/cli.cpp", "${openthread_root}/src/cli/cli.hpp", diff --git a/third_party/silabs/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index 9312538453ecfd..6120da8ebc7373 100644 --- a/third_party/silabs/efr32_sdk.gni +++ b/third_party/silabs/efr32_sdk.gni @@ -65,9 +65,6 @@ declare_args() { silabs_log_enabled = true - # Enable Synchronized Sleepy End Device - enable_synchronized_sed = false - # Argument to enable IPv4 for wifi # aligning to match chip_inet_config_enable_ipv4 default configuration chip_enable_wifi_ipv4 = false @@ -99,6 +96,9 @@ declare_args() { sl_ot_platform_abstraction = "${efr32_sdk_root}/protocol/openthread/platform-abstraction" + # Enable Synchronized Sleepy End Device + enable_synchronized_sed = use_silabs_thread_lib + # board related pre-generated files path (default) sl_pre_gen_path = "${sdk_support_root}/matter/efr32/${silabs_family}/${silabs_board}/" @@ -221,9 +221,6 @@ template("efr32_sdk") { # Headers needed for Init no function will be called if OT is not used "${sl_ot_efr32_root}", - #TODO TEST is this needed here!!!! - "${sl_ot_platform_abstraction}/rtos", - # TODO this is for sl_openthread_features_config.h. should use generated one per board when sl_ot_abstraction is integrated "${sl_ot_libs_path}/config", ] From 8a7fa4cd0d136d0425a80254e7a5493215655bd3 Mon Sep 17 00:00:00 2001 From: Junior Martinez <67972863+jmartinez-silabs@users.noreply.github.com> Date: Tue, 25 Jun 2024 10:31:51 -0400 Subject: [PATCH 06/12] bump matter support submodule --- third_party/silabs/matter_support | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/silabs/matter_support b/third_party/silabs/matter_support index edbfeba723c9ff..a1fdd62cb16804 160000 --- a/third_party/silabs/matter_support +++ b/third_party/silabs/matter_support @@ -1 +1 @@ -Subproject commit edbfeba723c9ffdc93f57ad1eee85186b1643f25 +Subproject commit a1fdd62cb168049f946f7e1b5399c39353bcd7b4 From 8d42b91b050ee1da8638b4bf8836e5b763ae0899 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 25 Jun 2024 14:44:18 +0000 Subject: [PATCH 07/12] Restyled by clang-format --- src/platform/silabs/SiWx917/wifi/ethernetif.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/platform/silabs/SiWx917/wifi/ethernetif.cpp b/src/platform/silabs/SiWx917/wifi/ethernetif.cpp index 25bd9cee03e5f8..72725102d6da48 100644 --- a/src/platform/silabs/SiWx917/wifi/ethernetif.cpp +++ b/src/platform/silabs/SiWx917/wifi/ethernetif.cpp @@ -32,10 +32,10 @@ extern "C" { #include "sl_si91x_driver.h" #include "sl_si91x_host_interface.h" #include "sl_si91x_types.h" +#include "sl_wifi.h" #include "sl_wifi_callback_framework.h" #include "sl_wifi_constants.h" #include "sl_wifi_types.h" -#include "sl_wifi.h" #ifdef __cplusplus } #endif @@ -193,8 +193,9 @@ static err_t low_level_output(struct netif * netif, struct pbuf * p) { UNUSED_PARAMETER(netif); sl_status_t status; - status = sl_wifi_send_raw_data_frame(SL_WIFI_CLIENT_INTERFACE, (uint8_t *)p->payload, p->len); - if (status != SL_STATUS_OK) { + status = sl_wifi_send_raw_data_frame(SL_WIFI_CLIENT_INTERFACE, (uint8_t *) p->payload, p->len); + if (status != SL_STATUS_OK) + { return ERR_IF; } return ERR_OK; From f1646146e9c8563d5b16ce98ea7637197d29ff7d Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 25 Jun 2024 14:44:24 +0000 Subject: [PATCH 08/12] Restyled by autopep8 --- third_party/silabs/slc_gen/run_slc.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/third_party/silabs/slc_gen/run_slc.py b/third_party/silabs/slc_gen/run_slc.py index b3bad4355f85d8..22ef27b2c750e6 100644 --- a/third_party/silabs/slc_gen/run_slc.py +++ b/third_party/silabs/slc_gen/run_slc.py @@ -16,9 +16,11 @@ def asBoolean(valueToTest): def isMG24(partnumber): return ("EFR32MG24" in partnumber or "MGM240" in partnumber) + def isMG26(partnumber): return ("EFR32MG26" in partnumber) + root_path = sys.argv[1] silabs_board = str(sys.argv[2]).lower() disable_lcd = asBoolean(sys.argv[3]) From 360a4f17c46ebe1092217eacf43b45d915f232b6 Mon Sep 17 00:00:00 2001 From: Junior Martinez <67972863+jmartinez-silabs@users.noreply.github.com> Date: Tue, 25 Jun 2024 14:07:39 -0400 Subject: [PATCH 09/12] fix linking issue with thread FTD lib --- examples/light-switch-app/silabs/.gn | 2 +- .../efr32/project_include/OpenThreadConfig.h | 4 +-- third_party/silabs/BUILD.gn | 16 ++++++++++-- third_party/silabs/efr32_sdk.gni | 25 ++++++++++++------- 4 files changed, 33 insertions(+), 14 deletions(-) diff --git a/examples/light-switch-app/silabs/.gn b/examples/light-switch-app/silabs/.gn index b05216fc9d7eae..27aa6c766a17e6 100644 --- a/examples/light-switch-app/silabs/.gn +++ b/examples/light-switch-app/silabs/.gn @@ -23,7 +23,7 @@ check_system_includes = true default_args = { target_cpu = "arm" target_os = "freertos" - chip_openthread_ftd = true + chip_openthread_ftd = false import("//openthread.gni") } diff --git a/examples/platform/silabs/efr32/project_include/OpenThreadConfig.h b/examples/platform/silabs/efr32/project_include/OpenThreadConfig.h index d7492f4044f3fa..ed56c7a5785d8a 100644 --- a/examples/platform/silabs/efr32/project_include/OpenThreadConfig.h +++ b/examples/platform/silabs/efr32/project_include/OpenThreadConfig.h @@ -45,7 +45,7 @@ // Timeout after 2 missed checkin or 4 mins if sleep interval is too short. #define OPENTHREAD_CONFIG_MLE_CHILD_TIMEOUT_DEFAULT ((SL_MLE_TIMEOUT_s < 120) ? 240 : ((SL_MLE_TIMEOUT_s * 2) + 1)) -#if defined(SL_CSL_ENABLE) && SL_CSL_ENABLE +#if defined(SL_CSL_ENABLE) && SL_CSL_ENABLE || SL_CONFIG_OPENTHREAD_LIB #define OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE 1 #define OPENTHREAD_CONFIG_MAC_CSL_AUTO_SYNC_ENABLE 1 @@ -55,7 +55,7 @@ #define OPENTHREAD_CONFIG_CSL_TIMEOUT SL_CSL_TIMEOUT #define SL_OPENTHREAD_CSL_TX_UNCERTAINTY 200 -#endif // SL_CSL_ENABLE +#endif // SL_CSL_ENABLE || SL_CONFIG_OPENTHREAD_LIB #endif // SL_ICD_ENABLED diff --git a/third_party/silabs/BUILD.gn b/third_party/silabs/BUILD.gn index e7b9c78a95216b..962c44c351452f 100644 --- a/third_party/silabs/BUILD.gn +++ b/third_party/silabs/BUILD.gn @@ -66,8 +66,6 @@ if (wifi_soc != true) { # CCP board if (use_silabs_thread_lib) { config("libopenthread-platform_config") { include_dirs = [ "${openthread_root}/examples/platforms" ] - - defines = [ "SL_CONFIG_OPENTHREAD_LIB=1" ] } copy("copy_openthread_system") { @@ -198,6 +196,20 @@ if (wifi_soc != true) { # CCP board XTD = "ftd" if (!chip_openthread_ftd) { XTD = "mtd" + } else { + # additional files needs for ftd lib + sources += [ + "${openthread_root}/examples/platforms/utils/link_metrics.cpp", + "${openthread_root}/examples/platforms/utils/link_metrics.h", + "${openthread_root}/src/core/api/link_api.cpp", + "${openthread_root}/src/core/mac/mac.cpp", + "${openthread_root}/src/core/mac/mac_frame.cpp", + "${openthread_root}/src/core/mac/sub_mac.cpp", + "${openthread_root}/src/core/thread/mle.cpp", + "${sl_ot_platform_abstraction}/efr32/radio.c", + ] + + include_dirs = [ "${sl_ot_platform_abstraction}/include" ] } # Use silabs openthread library stack with or without coap api enabled diff --git a/third_party/silabs/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index 6120da8ebc7373..e26754deea9cab 100644 --- a/third_party/silabs/efr32_sdk.gni +++ b/third_party/silabs/efr32_sdk.gni @@ -65,6 +65,9 @@ declare_args() { silabs_log_enabled = true + # Enable Synchronized Sleepy End Device + enable_synchronized_sed = false + # Argument to enable IPv4 for wifi # aligning to match chip_inet_config_enable_ipv4 default configuration chip_enable_wifi_ipv4 = false @@ -96,9 +99,6 @@ declare_args() { sl_ot_platform_abstraction = "${efr32_sdk_root}/protocol/openthread/platform-abstraction" - # Enable Synchronized Sleepy End Device - enable_synchronized_sed = use_silabs_thread_lib - # board related pre-generated files path (default) sl_pre_gen_path = "${sdk_support_root}/matter/efr32/${silabs_family}/${silabs_board}/" @@ -317,6 +317,7 @@ template("efr32_sdk") { "SL_MATTER_BLE_EXTENDED_ADV=${sl_matter_ble_extended_adv}", "SL_MEMORY_POOL_LIGHT=1", "SL_OPENTHREAD_STACK_FEATURES_CONFIG_FILE=\"sl_openthread_features_config.h\"", + "SL_CSL_TIMEOUT=${sl_ot_csl_timeout_sec}", "CIRCULAR_QUEUE_USE_LOCAL_CONFIG_HEADER=1", "MATTER_INTEGRATION=1", ] @@ -327,11 +328,6 @@ template("efr32_sdk") { defines += [ "SILABS_LOG_ENABLED=0" ] } - # Temporary configuration to enable COAP specific configurations - if (use_thread_coap_lib) { - defines += [ "SL_USE_COAP_CONFIG=1" ] - } - if (sl_uart_log_output) { defines += [ "SILABS_LOG_OUT_UART=1", @@ -339,6 +335,18 @@ template("efr32_sdk") { ] } + if (use_silabs_thread_lib) { + defines += [ "SL_CONFIG_OPENTHREAD_LIB=1" ] + } else { + defines += [ "SL_CONFIG_OPENTHREAD_LIB=0" ] + } + + if (use_thread_coap_lib) { + defines += [ "SL_USE_COAP_CONFIG=1" ] + } else { + defines += [ "SL_USE_COAP_CONFIG=0" ] + } + if (chip_enable_ble_rs911x) { defines += [ "RSI_BLE_ENABLE=1", @@ -462,7 +470,6 @@ template("efr32_sdk") { defines += [ "CHIP_DEVICE_CONFIG_THREAD_SSED=1", "SL_CSL_ENABLE=1", - "SL_CSL_TIMEOUT=${sl_ot_csl_timeout_sec}", ] } } From bf405bea90bad2ae306d5d9fbe6278ddca41f4ed Mon Sep 17 00:00:00 2001 From: Junior Martinez <67972863+jmartinez-silabs@users.noreply.github.com> Date: Tue, 25 Jun 2024 14:13:39 -0400 Subject: [PATCH 10/12] clean up --- examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.cpp | 2 +- third_party/silabs/BUILD.gn | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.cpp b/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.cpp index 54b36b123794d4..c89c6768abe62c 100644 --- a/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.cpp +++ b/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.cpp @@ -78,7 +78,7 @@ extern "C" { #include "sl_si91x_trng.h" #define TRNGKEY_SIZE 4 #endif // SLI_SI91X_MCU_INTERFACE -} // extern "C" { +} WfxRsi_t wfx_rsi; diff --git a/third_party/silabs/BUILD.gn b/third_party/silabs/BUILD.gn index 962c44c351452f..915cf8ba2bf164 100644 --- a/third_party/silabs/BUILD.gn +++ b/third_party/silabs/BUILD.gn @@ -197,7 +197,7 @@ if (wifi_soc != true) { # CCP board if (!chip_openthread_ftd) { XTD = "mtd" } else { - # additional files needs for ftd lib + # additional files needed for ftd lib sources += [ "${openthread_root}/examples/platforms/utils/link_metrics.cpp", "${openthread_root}/examples/platforms/utils/link_metrics.h", From d0ce054990bfd4d2d16faa88f4de5fb38efc4978 Mon Sep 17 00:00:00 2001 From: Junior Martinez <67972863+jmartinez-silabs@users.noreply.github.com> Date: Tue, 25 Jun 2024 16:25:40 -0400 Subject: [PATCH 11/12] fix wifi ncp builds --- .../efr32/rs911x/hal/rsi_hal_mcu_interrupt.c | 2 +- src/platform/silabs/efr32/wifi/ethernetif.cpp | 38 ++++++------------- third_party/silabs/efr32_sdk.gni | 1 + 3 files changed, 13 insertions(+), 28 deletions(-) diff --git a/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_interrupt.c b/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_interrupt.c index 079a5e0c9c32f4..1cb5ddf9206d65 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_interrupt.c +++ b/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_interrupt.c @@ -62,7 +62,7 @@ void rsi_gpio_irq_cb(uint8_t irqnum) if (irqnum != SL_WFX_HOST_PINOUT_SPI_IRQ) return; #if (SLI_SI91X_MCU_INTERFACE | EXP_BOARD) - sl_si91x_host_set_bus_event(NCP_HOST_BUS_RX_EVENT); + sl_si91x_host_set_bus_event(SL_SI91X_NCP_HOST_BUS_RX_EVENT); #else GPIO_IntClear(1 << SL_WFX_HOST_PINOUT_SPI_IRQ); if (call_back != NULL) diff --git a/src/platform/silabs/efr32/wifi/ethernetif.cpp b/src/platform/silabs/efr32/wifi/ethernetif.cpp index d07c14f61e2287..0388337939a3e2 100644 --- a/src/platform/silabs/efr32/wifi/ethernetif.cpp +++ b/src/platform/silabs/efr32/wifi/ethernetif.cpp @@ -40,6 +40,7 @@ extern "C" { #include "sl_si91x_driver.h" #include "sl_si91x_host_interface.h" #include "sl_si91x_types.h" +#include "sl_wifi.h" #include "sl_wifi_callback_framework.h" #include "sl_wifi_constants.h" #include "sl_wifi_types.h" @@ -347,12 +348,16 @@ static SemaphoreHandle_t ethout_sem; static err_t low_level_output(struct netif * netif, struct pbuf * p) { #if (SLI_SI91X_MCU_INTERFACE | EXP_BOARD) - sl_wifi_buffer_t * buffer; - sl_si91x_packet_t * packet; - sl_status_t status = SL_STATUS_OK; + UNUSED_PARAMETER(netif); + sl_status_t status; + status = sl_wifi_send_raw_data_frame(SL_WIFI_CLIENT_INTERFACE, (uint8_t *) p->payload, p->len); + if (status != SL_STATUS_OK) + { + return ERR_IF; + } + return ERR_OK; #else void * packet; -#endif struct pbuf * q; uint16_t framelength = 0; uint16_t datalength = 0; @@ -381,27 +386,14 @@ static err_t low_level_output(struct netif * netif, struct pbuf * p) xSemaphoreGive(ethout_sem); return ERR_IF; } - /* Confirm if packet is allocated */ -#if (SLI_SI91X_MCU_INTERFACE | EXP_BOARD) - status = sl_si91x_allocate_command_buffer(&buffer, (void **) &packet, sizeof(sl_si91x_packet_t) + framelength, - SL_WIFI_ALLOCATE_COMMAND_BUFFER_WAIT_TIME_MS); - VERIFY_STATUS_AND_RETURN(status); - if (packet == NULL) -#else // RS9116 packet = wfx_rsi_alloc_pkt(); if (!packet) -#endif // SLI_SI91X_MCU_INTERFACE { ChipLogProgress(DeviceLayer, "EN-RSI:No buf"); xSemaphoreGive(ethout_sem); -#if (SLI_SI91X_MCU_INTERFACE | EXP_BOARD) - return SL_STATUS_ALLOCATION_FAILED; - } - memset(packet->desc, 0, sizeof(packet->desc)); -#else // RS9116 return ERR_IF; } -#endif // SLI_SI91X_MCU_INTERFACE + #ifdef WIFI_DEBUG_ENABLED uint8_t * b = (uint8_t *) p->payload; ChipLogProgress(DeviceLayer, "EN-RSI: Out [%02x:%02x:%02x:%02x:%02x:%02x][%02x:%02x:%02x:%02x:%02x:%02x]type=%02x%02x", b[0], @@ -422,19 +414,10 @@ static err_t low_level_output(struct netif * netif, struct pbuf * p) ChipLogProgress(DeviceLayer, "EN-RSI: Sending %d", framelength); #endif - /* forward the generated packet to RSI to - * send the data over wifi network - */ -#if (SLI_SI91X_MCU_INTERFACE | EXP_BOARD) - packet->length = framelength & 0xFFF; - packet->command = RSI_SEND_RAW_DATA; - if (sl_si91x_driver_send_data_packet(SI91X_WLAN_CMD_QUEUE, buffer, 1000)) -#else /* forward the generated packet to RSI to * send the data over wifi network */ if (wfx_rsi_send_data(packet, datalength)) -#endif { ChipLogProgress(DeviceLayer, "*ERR*EN-RSI:Send fail"); xSemaphoreGive(ethout_sem); @@ -447,6 +430,7 @@ static err_t low_level_output(struct netif * netif, struct pbuf * p) xSemaphoreGive(ethout_sem); return ERR_OK; +#endif // RS9116 } #if (SLI_SI91X_MCU_INTERFACE | EXP_BOARD) diff --git a/third_party/silabs/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index e26754deea9cab..8ef09c80f3f214 100644 --- a/third_party/silabs/efr32_sdk.gni +++ b/third_party/silabs/efr32_sdk.gni @@ -531,6 +531,7 @@ template("efr32_sdk") { "${efr32_sdk_root}/platform/radio/rail_lib/plugin/pa-conversions/efr32xg24/config", "${efr32_sdk_root}/platform/service/device_init/config/s2/", "${efr32_sdk_root}/platform/emdrv/spidrv/inc", + "${efr32_sdk_root}/platform/emdrv/spidrv/config", "${efr32_sdk_root}/platform/emdrv/dmadrv/inc/s2_signals", ] From 47ea9cf41dbc009d52cb00c8d3ba9b545a94eaeb Mon Sep 17 00:00:00 2001 From: Junior Martinez <67972863+jmartinez-silabs@users.noreply.github.com> Date: Tue, 25 Jun 2024 21:38:01 -0400 Subject: [PATCH 12/12] update linker script for mgm24 and si917 --- .../silabs/ldscripts/SiWx917-common.ld | 51 ++-- examples/platform/silabs/ldscripts/mgm24.ld | 262 ++++++++---------- 2 files changed, 145 insertions(+), 168 deletions(-) diff --git a/examples/platform/silabs/ldscripts/SiWx917-common.ld b/examples/platform/silabs/ldscripts/SiWx917-common.ld index f23fecf8950d4c..fcc5c97de0a85b 100644 --- a/examples/platform/silabs/ldscripts/SiWx917-common.ld +++ b/examples/platform/silabs/ldscripts/SiWx917-common.ld @@ -39,8 +39,8 @@ SECTIONS .text : { KEEP(*(.isr_vector)) - KEEP(*(.reset_handler)) - *(EXCLUDE_FILE(*sl_si91x_bus.c.o *sl_si91x_driver.c.o *sli_si91x_multithreaded.c.o *rsi_hal_mcu_m4_ram.c.o *rsi_hal_mcu_m4_rom.c.o *rsi_deepsleep_soc.c.o *croutine.c.o *event_groups.c.o *list.c.o *queue.c.o *stream_buffer.c.o *tasks.c.o *timers.c.o *cmsis_os2.c.o *freertos_umm_malloc_host.c.o *malloc_buffers.c.o *sl_rsi_utility.c.o *port.c.o *heap_*.c.o *os_systick.c.o *sl_wifi_if.c.o *sl_si91x_m4_ps.c.o *sl_platform_wireless.c.o) .text*) + KEEP(*(.reset_handler)) + *(EXCLUDE_FILE(*sl_si91x_bus.o *sl_si91x_driver.o *sli_si91x_multithreaded.o *rsi_hal_mcu_m4_ram.o *rsi_hal_mcu_m4_rom.o *rsi_deepsleep_soc.o *croutine.o *event_groups.o *list.o *queue.o *stream_buffer.o *tasks.o *timers.o *cmsis_os2.o *freertos_umm_malloc_host.o *malloc_buffers.o *sl_rsi_utility.o *port.o *sl_sleeptimer.o *sl_sleeptimer_hal_si91x_sysrtc.o *rsi_sysrtc.o *sl_si91x_low_power_tickless_mode.o *heap_*.o *sl_core_cortexm.o) .text*) /* .ctors */ *crtbegin.o(.ctors) @@ -127,29 +127,30 @@ SECTIONS *(.rodata*) *(vtable) *(.data*) - *sl_si91x_bus.c.o(.text*) - *sl_si91x_driver.c.o(.text*) - *sli_si91x_multithreaded.c.o(.text*) - *rsi_hal_mcu_m4_ram.c.o(.text*) - *rsi_hal_mcu_m4_rom.c.o(.text*) - *rsi_deepsleep_soc.c.o(.text*) - *croutine.c.o(.text*) - *event_groups.c.o(.text*) - *list.c.o(.text*) - *queue.c.o(.text*) - *cmsis_os2.c.o(.text*) - *stream_buffer.c.o(.text*) - *tasks.c.o(.text*) - *timers.c.o(.text*) - *freertos_umm_malloc_host.c.o(.text*) - *malloc_buffers.c.o(.text*) - *sl_rsi_utility.c.o(.text*) - *port.c.o(.text*) - *heap_*.c.o(.text*) - *os_systick.c.o(.text*) - *sl_wifi_if.c.o(.text*) - *sl_si91x_m4_ps.c.o(.text*) - *sl_platform_wireless.c.o(.text*) + *sl_si91x_bus.o(.text*) + *sl_si91x_driver.o(.text*) + *sli_si91x_multithreaded.o(.text*) + *rsi_hal_mcu_m4_ram.o(.text*) + *rsi_hal_mcu_m4_rom.o(.text*) + *rsi_deepsleep_soc.o(.text*) + *croutine.o(.text*) + *event_groups.o(.text*) + *list.o(.text*) + *queue.o(.text*) + *cmsis_os2.o(.text*) + *stream_buffer.o(.text*) + *tasks.o(.text*) + *timers.o(.text*) + *freertos_umm_malloc_host.o(.text*) + *malloc_buffers.o(.text*) + *sl_rsi_utility.o(.text*) + *port.o(.text*) + *heap_*.o(.text*) + *sl_sleeptimer.o(.text*) + *sl_sleeptimer_hal_si91x_sysrtc.o(.text*) + *rsi_sysrtc.o(.text*) + *sl_si91x_low_power_tickless_mode.o(.text*) + *sl_core_cortexm.o(.text*) . = ALIGN(4); /* preinit data */ diff --git a/examples/platform/silabs/ldscripts/mgm24.ld b/examples/platform/silabs/ldscripts/mgm24.ld index a38794bbd7973d..16066c24195cec 100644 --- a/examples/platform/silabs/ldscripts/mgm24.ld +++ b/examples/platform/silabs/ldscripts/mgm24.ld @@ -1,43 +1,22 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ /***************************************************************************//** - * @file gcc_EFR32MG24.ld - * @brief GNU Linker Script for Cortex-M based device - * @version V2.2.0 - * @date 16. December 2020 - * Linker script for Silicon Labs EFR32MG24 devices + * GCC Linker script for Silicon Labs devices ******************************************************************************* * # License - * Copyright 2022 Silicon Laboratories, Inc. www.silabs.com + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com ******************************************************************************* * * SPDX-License-Identifier: Zlib - * + * * The licensor of this software is Silicon Laboratories Inc. - * + * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. - * + * * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely, subject to the following restrictions: - * + * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software * in a product, an acknowledgment in the product documentation would be @@ -48,52 +27,81 @@ * ******************************************************************************/ -MEMORY -{ - FLASH (rx) : ORIGIN = 0x08006000, LENGTH = 0x17A000 - RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x40000 -} - -/* Linker script to place sections and symbol values. Should be used together - * with other linker script that defines memory regions FLASH and RAM. - * It references following symbols, which must be defined in code: - * Reset_Handler : Entry of reset handler - * - * It defines following symbols, which code can use without definition: - * __exidx_start - * __exidx_end - * __copy_table_start__ - * __copy_table_end__ - * __zero_table_start__ - * __zero_table_end__ - * __etext - * __data_start__ - * __preinit_array_start - * __preinit_array_end - * __init_array_start - * __init_array_end - * __fini_array_start - * __fini_array_end - * __data_end__ - * __bss_start__ - * __bss_end__ - * __end__ - * end - * __HeapLimit - * __StackLimit - * __StackTop - * __stack - * __StackSeal (only if ARMv8-M stack sealing is used) - */ + MEMORY + { + FLASH (rx) : ORIGIN = 0x8006000, LENGTH = 0x178000 + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x40000 + } ENTRY(Reset_Handler) SECTIONS { - .text : + + .vectors : { + linker_vectors_begin = .; KEEP(*(.vectors)) - *(.text*) + linker_vectors_end = .; + + __Vectors_End = .; + __Vectors_Size = __Vectors_End - __Vectors; + __lma_ramfuncs_start__ = .; + } > FLASH + + .stack (NOLOAD): + { + . = ALIGN(8); + __StackLimit = .; + KEEP(*(.stack*)) + . = ALIGN(4); + __StackTop = .; + PROVIDE(__stack = __StackTop); + } > RAM + + + .noinit (NOLOAD): + { + *(.noinit*); + } > RAM + + .bss : + { + . = ALIGN(4); + __bss_start__ = .; + *(SORT_BY_ALIGNMENT(.bss*)) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; + } > RAM + + text_application_ram : + { + . = ALIGN(4); + __vma_ramfuncs_start__ = .; + __text_application_ram_start__ = .; + + *(text_application_ram) + + . = ALIGN(4); + __vma_ramfuncs_end__ = .; + __text_application_ram_end__ = .; + } > RAM AT > FLASH + + .rodata : + { + __lma_ramfuncs_end__ = .; + __rodata_start__ = .; + __rodata_end__ = .; + } > FLASH + + .text : + { + linker_code_begin = .; + *(SORT_BY_ALIGNMENT(.text*)) + *(SORT_BY_ALIGNMENT(text_*)) + . = ALIGN(32); + linker_code_end = .; KEEP(*(.init)) KEEP(*(.fini)) @@ -111,16 +119,11 @@ SECTIONS *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) *(SORT(.dtors.*)) *(.dtors) - - __code_classification_validator_start__ = .; - . = . + 0x20; - *(code_classification_validator) - . = ALIGN(32); - __code_classification_validator_end__ = .; - *(.rodata*) - KEEP(*(.eh_frame*)) + *(.rodata*) + *(.eh_frame*) } > FLASH + .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) @@ -142,6 +145,13 @@ SECTIONS LONG (__data_start__) LONG ((__data_end__ - __data_start__) / 4) + /* Add each additional data section here */ + /* + LONG (__etext2) + LONG (__data2_start__) + LONG ((__data2_end__ - __data2_start__) / 4) + */ + __copy_table_end__ = .; } > FLASH @@ -149,19 +159,23 @@ SECTIONS { . = ALIGN(4); __zero_table_start__ = .; + /* Add each additional bss section here */ + /* + LONG (__bss2_start__) + LONG ((__bss2_end__ - __bss2_start__) / 4) + */ + __zero_table_end__ = .; - __etext = ALIGN(4); + __etext = .; } > FLASH - .data : AT (__etext) + .data : { + . = ALIGN(4); __data_start__ = .; *(vtable) - *(.data*) - . = ALIGN (4); - PROVIDE (__ram_func_section_start = .); - *(.ram) - PROVIDE (__ram_func_section_end = .); + *(SORT_BY_ALIGNMENT(.data*)) + . = ALIGN(4); . = ALIGN(4); /* preinit data */ @@ -183,87 +197,49 @@ SECTIONS KEEP(*(.fini_array)) PROVIDE_HIDDEN (__fini_array_end = .); - KEEP(*(.jcr*)) . = ALIGN(4); /* All data end */ __data_end__ = .; - } > RAM - - .bss : - { - . = ALIGN(4); - __bss_start__ = .; - *(.bss) - *(.bss.*) - *(COMMON) - . = ALIGN(4); - __bss_end__ = .; - } > RAM AT > RAM - - __ramfuncs_start__ = .; - - __vma_ramfuncs_start__ = .; - __lma_ramfuncs_start__ = __etext + SIZEOF(.data); - - __text_application_ram_offset__ = . - __vma_ramfuncs_start__; - text_application_ram . : AT(__lma_ramfuncs_start__ + __text_application_ram_offset__) - { - . = ALIGN(4); - __text_application_ram_start__ = .; - *(text_application_ram) - . = ALIGN(4); - __text_application_ram_end__ = .; - } > RAM - - . = ALIGN(4); - __vma_ramfuncs_end__ = .; - __lma_ramfuncs_end__ = __lma_ramfuncs_start__ + __text_application_ram_offset__ + SIZEOF(text_application_ram); - - __ramfuncs_end__ = .; - - .heap (COPY): + } > RAM AT > FLASH + .memory_manager_heap (NOLOAD): { + . = ALIGN(8); __HeapBase = .; __end__ = .; end = __end__; _end = __end__; - KEEP(*(.heap*)) - __HeapLimit = .; + KEEP(*(.memory_manager_heap*)) + __HeapLimit = ORIGIN(RAM) + LENGTH(RAM); } > RAM - __main_flash_end__ = ORIGIN(FLASH) + LENGTH(FLASH); + __heap_size = __HeapLimit - __HeapBase; + __ram_end__ = 0x20000000 + 0x40000; + __main_flash_end__ = 0x8006000 + 0x178000; - /* .stack_dummy section doesn't contains any symbols. It is only - * used for linker to calculate size of stack sections, and assign - * values to stack symbols later */ - .stack_dummy (COPY): - { - KEEP(*(.stack*)) - /* KEEP(*(.stackseal*))*/ - } > RAM + /* This is where we handle flash storage blocks. We use dummy sections for finding the configured + * block sizes and then "place" them at the end of flash when the size is known. */ + .internal_storage (DSECT) : { + KEEP(*(.internal_storage*)) + } > FLASH - /* Set stack top to end of RAM, and stack limit move down by - * size of stack_dummy section */ - __StackTop = ORIGIN(RAM) + LENGTH(RAM); - __StackLimit = __StackTop - SIZEOF(.stack_dummy); - PROVIDE(__stack = __StackTop); - .nvm (DSECT) : { + .nvm (DSECT) : { KEEP(*(.simee*)) } > FLASH - /* Last page of flash is reserved for the manufacturing token space */ - linker_nvm_end = __main_flash_end__ - 8192; + __ramfuncs_start__ = __vma_ramfuncs_start__; + __ramfuncs_end__ = __vma_ramfuncs_end__; + + linker_nvm_end = __main_flash_end__; linker_nvm_begin = linker_nvm_end - SIZEOF(.nvm); - linker_nvm_size = SIZEOF(.nvm); + linker_storage_end = linker_nvm_begin; __nvm3Base = linker_nvm_begin; - __attestation_credentials_base = linker_nvm_end; - /* Check if data + heap + stack exceeds RAM limit */ - /*ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")*/ - ASSERT( (linker_nvm_begin + SIZEOF(.nvm)) <= __main_flash_end__, "NVM3 is excessing the flash size !") + linker_storage_begin = linker_storage_end - SIZEOF(.internal_storage); + ASSERT((linker_storage_begin >= (__etext + SIZEOF(.data))), "FLASH memory overflowed !") + - /* Check if FLASH usage exceeds FLASH size */ - ASSERT( LENGTH(FLASH) >= (__etext + SIZEOF(.data)), "FLASH memory overflowed !") + app_flash_end = 0x8006000 + 0x178000; + ASSERT( (linker_nvm_begin + SIZEOF(.nvm)) <= app_flash_end, "NVM3 is excessing the flash size !") }