Skip to content

Commit 35a5a29

Browse files
[SL-UP] Uart smaller log buffer (#515)
Co-authored-by: Mathieu Kardous <[email protected]>
1 parent ef40bdb commit 35a5a29

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

examples/platform/silabs/MatterConfig.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,9 @@ void ApplicationStart(void * unused)
210210
void SilabsMatterConfig::AppInit()
211211
{
212212
GetPlatform().Init();
213+
#ifdef HEAP_MONITORING
214+
DisplayMemoryUsage();
215+
#endif
213216
sMainTaskHandle = osThreadNew(ApplicationStart, nullptr, &kMainTaskAttr);
214217
ChipLogProgress(DeviceLayer, "Starting scheduler");
215218
VerifyOrDie(sMainTaskHandle); // We can't proceed if the Main Task creation failed.

examples/platform/silabs/MemMonitoring.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
*/
1818

1919
#include "MemMonitoring.h"
20-
2120
#include "AppConfig.h"
21+
#include "sl_memory_manager.h"
2222
#include <cmsis_os2.h>
2323
#include <platform/CHIPDeviceLayer.h>
2424
#include <sl_cmsis_os2_common.h>
@@ -43,6 +43,17 @@ size_t nbAllocSuccess = 0;
4343
size_t nbFreeSuccess = 0;
4444
size_t largestBlockAllocated = 0;
4545

46+
void DisplayMemoryUsage()
47+
{
48+
uint32_t totalHeap = static_cast<uint32_t>(sl_memory_get_total_heap_size());
49+
uint32_t usedHeap = static_cast<uint32_t>(sl_memory_get_used_heap_size());
50+
uint32_t highWatermark = static_cast<uint32_t>(sl_memory_get_heap_high_watermark());
51+
52+
SILABS_LOG("Total Heap Size %lu B", totalHeap);
53+
SILABS_LOG("Used Heap Size %lu B", usedHeap);
54+
SILABS_LOG("Heap High Watermark %lu B", highWatermark);
55+
}
56+
4657
void MemMonitoring::StartMonitor()
4758
{
4859
sMonitorThreadHandle = osThreadNew(MonitorTask, nullptr, &kMonitorTaskAttr);
@@ -58,6 +69,7 @@ void MemMonitoring::MonitorTask(void * pvParameter)
5869

5970
while (true)
6071
{
72+
DisplayMemoryUsage();
6173

6274
SILABS_LOG("=============================");
6375
SILABS_LOG(" ");
@@ -78,6 +90,9 @@ void MemMonitoring::MonitorTask(void * pvParameter)
7890
}
7991

8092
SILABS_LOG(" ");
93+
DisplayMemoryUsage();
94+
SILABS_LOG(" ");
95+
8196
SILABS_LOG("=============================");
8297
// run loop every 5 seconds
8398
osDelay(osKernelGetTickFreq() * 5);

examples/platform/silabs/MemMonitoring.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ namespace chip {
2424
namespace DeviceLayer {
2525
namespace Silabs {
2626

27+
void DisplayMemoryUsage();
28+
2729
class MemMonitoring
2830
{
2931
public:

examples/platform/silabs/uart.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ typedef struct
150150
} Fifo_t;
151151

152152
// uart transmit
153-
#if SILABS_LOG_OUT_UART
153+
#if SILABS_LOG_OUT_UART && !defined(SIMG301M113WIH)
154154
#define UART_MAX_QUEUE_SIZE 125
155155
#else
156156
#if (_SILICON_LABS_32B_SERIES < 3)

0 commit comments

Comments
 (0)