Fix for errata 168 in SDK 2.1.4

Hi,

I am using the SDK 2.1.1 and I will upgrade to 2.1.4 since errata 160 is fixed there.

Reading the errata document here, the anomaly 168 is fixed in SDK 2.5.1. Unfortunately i cannot upgrade now to that version.

The workaround is also presented in the link above.

SCB->SCR |= SCB_SCR_SEVONPEND_Msk;
__disable_irq();
__WFE(); // or __WFI();
__nop();__nop();__nop();__nop();__nop();__nop();__nop();__nop(); // 8 NOPs
__enable_irq();

I had a look how the fix is implemented in 2.5.1 and basically it is through the macro SOC_ON_EXIT_CPU_IDLE in the file soc_cpu_idle.h, then invoked in the assembler file cpu_idle.S in the function arch_cpu_idle

I dont see in this fix the line SCB->SCR |= SCB_SCR_SEVONPEND_Msk; 

Question 1: is that ok ? Why is that missing ? Is it performed somewhere else ?

The other topic regards the implementation of this fix in the SDK 2.1.4. According to the workaround, the following implementation should work (when code is not executed in RAM at 128 MHz)

.macro _sleep_if_allowed wait_instruction
#if defined(CONFIG_ARM_ON_ENTER_CPU_IDLE_HOOK)
	push	{r0, lr}
	bl	z_arm_on_enter_cpu_idle
	/* Skip the wait instruction if on_enter_cpu_idle() returns false. */
	cmp	r0, #0
	beq	_skip_\@
#endif /* CONFIG_ARM_ON_ENTER_CPU_IDLE_HOOK */

	/*
	 * Wait for all memory transactions to complete before entering low
	 * power state.
	 */
	dsb
	\wait_instruction

	/* Errata for Anomaly 168 */
	.rept 8
	nop;
	.endr
#if defined(CONFIG_ARM_ON_ENTER_CPU_IDLE_HOOK)
_skip_\@:
#if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE)
	pop	{r0, r1}
	mov	lr, r1
#else
	pop	{r0, lr}
#endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE */
#endif /* CONFIG_ARM_ON_ENTER_CPU_IDLE_HOOK */
.endm

Question 2: could i have your feedback about that please ? Is this implementation enough ?

Thanks in advance !

Kind regards

Riccardo

Parents Reply Children
Related