@@ -53,6 +53,9 @@ extern "C" {
5353#define SL_LED_TURN_OFF (x ) sl_simple_led_turn_off(const_cast <sl_led_t *>(x))
5454#define SL_LED_TOGGLE (x ) sl_simple_led_toggle(const_cast <sl_led_t *>(x))
5555
56+ #if defined(SL_PROVISION_GENERATOR) && defined(SL_TRUSTZONE_NONSECURE)
57+ #include " gfw_tz_secure.h"
58+ #endif
5659#endif // (defined(SL_MATTER_RGB_LED_ENABLED) && SL_MATTER_RGB_LED_ENABLED == 1)
5760}
5861
@@ -155,26 +158,29 @@ void SilabsPlatform::SoftwareReset()
155158
156159CHIP_ERROR SilabsPlatform::FlashInit ()
157160{
158- #if defined(SL_TRUSTZONE_NONSECURE)
159- return CHIP_ERROR_NOT_IMPLEMENTED ;
161+ #if defined(SL_PROVISION_GENERATOR) && defined( SL_TRUSTZONE_NONSECURE)
162+ return GFW_Flash_Init () ? CHIP_ERROR_INTERNAL : CHIP_NO_ERROR ;
160163#elif defined(_SILICON_LABS_32B_SERIES_2)
161164 MSC_Init ();
165+ return CHIP_NO_ERROR;
162166#elif defined(_SILICON_LABS_32B_SERIES_3)
163167 sl_status_t status;
164168 status = sl_se_init ();
165169 VerifyOrReturnError (status == SL_STATUS_OK, CHIP_ERROR (status));
166170 status = sl_se_init_command_context (&cmd_ctx);
167171 VerifyOrReturnError (status == SL_STATUS_OK, CHIP_ERROR (status));
168- #endif
169172 return CHIP_NO_ERROR;
173+ #else
174+ return CHIP_ERROR_NOT_IMPLEMENTED;
175+ #endif
170176}
171177
172178CHIP_ERROR SilabsPlatform::FlashErasePage (uint32_t addr)
173179{
174- #if defined(SL_TRUSTZONE_NONSECURE)
175- return CHIP_ERROR_NOT_IMPLEMENTED ;
180+ #if defined(SL_PROVISION_GENERATOR) && defined( SL_TRUSTZONE_NONSECURE)
181+ return GFW_Flash_ErasePage (addr) ? CHIP_ERROR_INTERNAL : CHIP_NO_ERROR ;
176182#elif defined(_SILICON_LABS_32B_SERIES_2)
177- MSC_ErasePage ((uint32_t *) addr);
183+ return MSC_ErasePage ((uint32_t *) addr) ? CHIP_ERROR_INTERNAL : CHIP_NO_ERROR ;
178184#elif defined(_SILICON_LABS_32B_SERIES_3)
179185 sl_status_t status;
180186 uint32_t * data_start = NULL ;
@@ -185,16 +191,18 @@ CHIP_ERROR SilabsPlatform::FlashErasePage(uint32_t addr)
185191 VerifyOrReturnError (GENERIC_ADDRESS (addr) > GENERIC_ADDRESS ((uint32_t ) data_start), CHIP_ERROR_INVALID_ADDRESS);
186192 status = sl_se_data_region_erase (&cmd_ctx, (void *) addr, 1 ); // Erase one page
187193 VerifyOrReturnError (status == SL_STATUS_OK, CHIP_ERROR (status));
188- #endif
189194 return CHIP_NO_ERROR;
195+ #else
196+ return CHIP_ERROR_NOT_IMPLEMENTED;
197+ #endif
190198}
191199
192200CHIP_ERROR SilabsPlatform::FlashWritePage (uint32_t addr, const uint8_t * data, size_t size)
193201{
194- #if defined(SL_TRUSTZONE_NONSECURE)
195- return CHIP_ERROR_NOT_IMPLEMENTED ;
202+ #if defined(SL_PROVISION_GENERATOR) && defined( SL_TRUSTZONE_NONSECURE)
203+ return GFW_Flash_WriteWord (addr, data, size) ? CHIP_ERROR_INTERNAL : CHIP_NO_ERROR ;
196204#elif defined(_SILICON_LABS_32B_SERIES_2)
197- MSC_WriteWord ((uint32_t *) addr, data, size);
205+ return MSC_WriteWord ((uint32_t *) addr, data, size) ? CHIP_ERROR_INTERNAL : CHIP_NO_ERROR ;
198206#elif defined(_SILICON_LABS_32B_SERIES_3)
199207 sl_status_t status;
200208 uint32_t * data_start = NULL ;
@@ -205,8 +213,10 @@ CHIP_ERROR SilabsPlatform::FlashWritePage(uint32_t addr, const uint8_t * data, s
205213 VerifyOrReturnError (GENERIC_ADDRESS (addr) > GENERIC_ADDRESS ((uint32_t ) data_start), CHIP_ERROR_INVALID_ADDRESS);
206214 status = sl_se_data_region_write (&cmd_ctx, (void *) addr, data, size);
207215 VerifyOrReturnError (status == SL_STATUS_OK, CHIP_ERROR (status));
208- #endif
209216 return CHIP_NO_ERROR;
217+ #else
218+ return CHIP_ERROR_NOT_IMPLEMENTED;
219+ #endif
210220}
211221
212222#ifdef ENABLE_WSTK_LEDS
0 commit comments