Skip to content

Commit 4cf156f

Browse files
Generator Firnware (GFW) TrustZone support.
1 parent 2b2249e commit 4cf156f

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

examples/platform/silabs/provision/ProvisionStorageDefault.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#include <psa/crypto.h>
4141
#endif
4242

43-
#ifdef SL_PROVISION_GENERATOR
43+
#if defined(SL_PROVISION_GENERATOR) && !defined(SL_TRUSTZONE_NONSECURE)
4444
extern void setNvm3End(uint32_t addr);
4545
#elif !SL_MATTER_GN_BUILD
4646
#include <sl_matter_provision_config.h>
@@ -165,7 +165,7 @@ CHIP_ERROR Storage::Initialize(uint32_t flash_addr, uint32_t flash_size)
165165
base_addr = (flash_addr + flash_size - FLASH_PAGE_SIZE);
166166
#endif // SLI_SI91X_MCU_INTERFACE
167167
chip::DeviceLayer::Silabs::GetPlatform().FlashInit();
168-
#ifdef SL_PROVISION_GENERATOR
168+
#if defined(SL_PROVISION_GENERATOR) && !defined(SL_TRUSTZONE_NONSECURE)
169169
setNvm3End(base_addr);
170170
#endif
171171
}

src/platform/silabs/platformAbstraction/GsdkSpam.cpp

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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

156159
CHIP_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

172178
CHIP_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

192200
CHIP_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

Comments
 (0)