Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
#endif

#ifdef SL_PROVISION_GENERATOR
#if !defined(SL_TRUSTZONE_NONSECURE)
extern void setNvm3End(uint32_t addr);
#endif
#elif !SL_MATTER_GN_BUILD
#include <sl_matter_provision_config.h>
#endif
Expand Down Expand Up @@ -165,7 +167,7 @@ CHIP_ERROR Storage::Initialize(uint32_t flash_addr, uint32_t flash_size)
base_addr = (flash_addr + flash_size - FLASH_PAGE_SIZE);
#endif // SLI_SI91X_MCU_INTERFACE
chip::DeviceLayer::Silabs::GetPlatform().FlashInit();
#ifdef SL_PROVISION_GENERATOR
#if defined(SL_PROVISION_GENERATOR) && !defined(SL_TRUSTZONE_NONSECURE)
setNvm3End(base_addr);
#endif
}
Expand Down
32 changes: 21 additions & 11 deletions src/platform/silabs/platformAbstraction/GsdkSpam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ extern "C" {

#endif // (defined(SL_MATTER_RGB_LED_ENABLED) && SL_MATTER_RGB_LED_ENABLED == 1)
}
#endif
Copy link
Contributor

@Sarthak-Shaha sarthak shaha (Sarthak-Shaha) Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#endif
#endif //ENABLE_WSTK_LEDS

nit


#if defined(SL_PROVISION_GENERATOR) && defined(SL_TRUSTZONE_NONSECURE)
#include "gfw_tz_secure.h"
#endif

#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT
Expand Down Expand Up @@ -155,26 +158,29 @@ void SilabsPlatform::SoftwareReset()

CHIP_ERROR SilabsPlatform::FlashInit()
{
#if defined(SL_TRUSTZONE_NONSECURE)
return CHIP_ERROR_NOT_IMPLEMENTED;
#if defined(SL_PROVISION_GENERATOR) && defined(SL_TRUSTZONE_NONSECURE)
return GFW_Flash_Init() ? CHIP_ERROR_INTERNAL : CHIP_NO_ERROR;
#elif defined(_SILICON_LABS_32B_SERIES_2)
MSC_Init();
return CHIP_NO_ERROR;
#elif defined(_SILICON_LABS_32B_SERIES_3)
sl_status_t status;
status = sl_se_init();
VerifyOrReturnError(status == SL_STATUS_OK, CHIP_ERROR(status));
status = sl_se_init_command_context(&cmd_ctx);
VerifyOrReturnError(status == SL_STATUS_OK, CHIP_ERROR(status));
#endif
return CHIP_NO_ERROR;
#else
return CHIP_ERROR_NOT_IMPLEMENTED;
#endif
Copy link
Contributor

@Sarthak-Shaha sarthak shaha (Sarthak-Shaha) Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#endif
#endif //defined(SL_PROVISION_GENERATOR) && defined(SL_TRUSTZONE_NONSECURE)

nit

}

CHIP_ERROR SilabsPlatform::FlashErasePage(uint32_t addr)
{
#if defined(SL_TRUSTZONE_NONSECURE)
return CHIP_ERROR_NOT_IMPLEMENTED;
#if defined(SL_PROVISION_GENERATOR) && defined(SL_TRUSTZONE_NONSECURE)
return GFW_Flash_ErasePage(addr) ? CHIP_ERROR_INTERNAL : CHIP_NO_ERROR;
#elif defined(_SILICON_LABS_32B_SERIES_2)
MSC_ErasePage((uint32_t *) addr);
return MSC_ErasePage((uint32_t *) addr) ? CHIP_ERROR_INTERNAL : CHIP_NO_ERROR;
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return value logic appears inverted. MSC_ErasePage typically returns 0 (msc_Return_OK) on success, so a successful call would incorrectly return CHIP_ERROR_INTERNAL. The ternary condition should be inverted to match the GFW pattern or the MSC function's actual return convention should be verified.

Copilot uses AI. Check for mistakes.
#elif defined(_SILICON_LABS_32B_SERIES_3)
sl_status_t status;
uint32_t * data_start = NULL;
Expand All @@ -185,16 +191,18 @@ CHIP_ERROR SilabsPlatform::FlashErasePage(uint32_t addr)
VerifyOrReturnError(GENERIC_ADDRESS(addr) > GENERIC_ADDRESS((uint32_t) data_start), CHIP_ERROR_INVALID_ADDRESS);
status = sl_se_data_region_erase(&cmd_ctx, (void *) addr, 1); // Erase one page
VerifyOrReturnError(status == SL_STATUS_OK, CHIP_ERROR(status));
#endif
return CHIP_NO_ERROR;
#else
return CHIP_ERROR_NOT_IMPLEMENTED;
#endif
}

CHIP_ERROR SilabsPlatform::FlashWritePage(uint32_t addr, const uint8_t * data, size_t size)
{
#if defined(SL_TRUSTZONE_NONSECURE)
return CHIP_ERROR_NOT_IMPLEMENTED;
#if defined(SL_PROVISION_GENERATOR) && defined(SL_TRUSTZONE_NONSECURE)
return GFW_Flash_WriteWord(addr, data, size) ? CHIP_ERROR_INTERNAL : CHIP_NO_ERROR;
#elif defined(_SILICON_LABS_32B_SERIES_2)
MSC_WriteWord((uint32_t *) addr, data, size);
return MSC_WriteWord((uint32_t *) addr, data, size) ? CHIP_ERROR_INTERNAL : CHIP_NO_ERROR;
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return value logic appears inverted. MSC_WriteWord typically returns 0 (msc_Return_OK) on success, so a successful call would incorrectly return CHIP_ERROR_INTERNAL. The ternary condition should be inverted to match the GFW pattern or the MSC function's actual return convention should be verified.

Copilot uses AI. Check for mistakes.
#elif defined(_SILICON_LABS_32B_SERIES_3)
sl_status_t status;
uint32_t * data_start = NULL;
Expand All @@ -205,8 +213,10 @@ CHIP_ERROR SilabsPlatform::FlashWritePage(uint32_t addr, const uint8_t * data, s
VerifyOrReturnError(GENERIC_ADDRESS(addr) > GENERIC_ADDRESS((uint32_t) data_start), CHIP_ERROR_INVALID_ADDRESS);
status = sl_se_data_region_write(&cmd_ctx, (void *) addr, data, size);
VerifyOrReturnError(status == SL_STATUS_OK, CHIP_ERROR(status));
#endif
return CHIP_NO_ERROR;
#else
return CHIP_ERROR_NOT_IMPLEMENTED;
#endif

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#endif
#endif //#if defined(SL_PROVISION_GENERATOR) && defined(SL_TRUSTZONE_NONSECURE)

nit

}

#ifdef ENABLE_WSTK_LEDS
Expand Down
Loading