@@ -63,6 +63,9 @@ void SystemCoreClockUpdate(void)
6363 case OSCILLATORS_PLL_CURRENTFREQ_CURRENTFREQ_CK128M :
6464 SystemCoreClock = 128000000ul ;
6565 break ;
66+ case OSCILLATORS_PLL_CURRENTFREQ_CURRENTFREQ_CK256M :
67+ SystemCoreClock = 256000000ul ;
68+ break ;
6669 }
6770}
6871
@@ -87,6 +90,10 @@ void SystemInit(void)
8790 #endif
8891
8992 #if !defined(NRF_TRUSTZONE_NONSECURE ) && defined(__ARM_FEATURE_CMSE )
93+ /* Dummy-read KMU to starts its boot preparations. This operation should be at
94+ the beginning of SystemInit to allow KMU to run to completion during the function call */
95+ NRF_KMU -> STATUS ;
96+
9097 #ifndef NRF_SKIP_TAMPC_SETUP
9198 nrf7120_handle_approtect ();
9299 #endif
@@ -177,6 +184,19 @@ void SystemInit(void)
177184 #endif
178185
179186 #if !defined(NRF_SKIP_RESET_FLPR )
187+ // Poll the SPU until the VPR goes NS before we move onto polling the NS VPR address
188+ // Acquire the APB Slave index from the VPR_00 address (instead of hardcoding 12 into the index)
189+ uint8_t flpr_apb_slave_index = ((NRF_VPR00_S_BASE & 0x0003F000 ) >> 12 ); // 12 = 0xC
190+
191+ // Wait until the VPR has been set to NS
192+ while (
193+ (((NRF_SPU00 -> PERIPH [flpr_apb_slave_index ].PERM & SPU_PERIPH_PERM_DMASEC_Msk ) >> SPU_PERIPH_PERM_DMASEC_Pos ) != SPU_PERIPH_PERM_DMASEC_NonSecure ) &&
194+ (((NRF_SPU00 -> PERIPH [flpr_apb_slave_index ].PERM & SPU_PERIPH_PERM_SECATTR_Msk ) >> SPU_PERIPH_PERM_SECATTR_Pos ) != SPU_PERIPH_PERM_SECATTR_NonSecure )
195+ ) {}
196+
197+ // Wait until the FLPR is WFI (in sleep state) before resetting it. If the VPR is in RUNNING, do not proceed
198+ while (((NRF_VPR00_NS -> VPRSTATUS & VPR_VPRSTATUS_CPUSTATUS_Msk ) >> VPR_VPRSTATUS_CPUSTATUS_Pos ) == VPR_VPRSTATUS_CPUSTATUS_RUNNING ){}
199+
180200 // Assert a sync reset in FLPR
181201 NRF_VPR00_NS -> DEBUGIF .DMCONTROL = (VPR_DEBUGIF_DMCONTROL_NDMRESET_Active << VPR_DEBUGIF_DMCONTROL_NDMRESET_Pos ) | (VPR_DEBUGIF_DMCONTROL_DMACTIVE_Enabled << VPR_DEBUGIF_DMCONTROL_DMACTIVE_Pos );
182202
@@ -193,6 +213,14 @@ void SystemInit(void)
193213 NRF_GLITCHDET_S -> CONFIG = (GLITCHDET_CONFIG_ENABLE_Disable << GLITCHDET_CONFIG_ENABLE_Pos );
194214 #endif
195215 #endif
216+
217+ #if !defined(NRF_TRUSTZONE_NONSECURE ) && defined(__ARM_FEATURE_CMSE ) && !defined (NRF_SKIP_KMU_WAIT_FOR_READY )
218+ /* KMU is ready by now, but to be sure allow it to run to completion */
219+ while (NRF_KMU -> STATUS == KMU_STATUS_STATUS_Busy )
220+ {
221+ }
222+ #endif
223+
196224 #endif
197225}
198226
0 commit comments