1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-26 06:53:52 +01:00

cpu/sam0_common: flashpage: disable cache while writing

fix errata 2.14.1: NVM Read Corruption
This commit is contained in:
Benjamin Valentin 2024-11-26 14:02:08 +01:00
parent b69d060e35
commit 1320d97e89

View File

@ -73,7 +73,12 @@ static unsigned _unlock(void)
PAC1->WPCLR.reg = PAC1_WPROT_DEFAULT_VAL;
#endif
/* NVM reads could be corrupted when mixing NVM reads with Page Buffer writes. */
return irq_disable();
#ifdef NVMCTRL_CTRLA_CACHEDIS1
_NVMCTRL->CTRLA.reg |= NVMCTRL_CTRLA_CACHEDIS0
| NVMCTRL_CTRLA_CACHEDIS1;
#endif
}
static void _lock(unsigned state)
@ -87,6 +92,11 @@ static void _lock(unsigned state)
PAC1->WPSET.reg = PAC1_WPROT_DEFAULT_VAL;
#endif
#ifdef NVMCTRL_CTRLA_CACHEDIS1
_NVMCTRL->CTRLA.reg &= ~NVMCTRL_CTRLA_CACHEDIS0
& ~NVMCTRL_CTRLA_CACHEDIS1;
#endif
/* cached flash contents may have changed - invalidate cache */
#ifdef CMCC
CMCC->MAINT0.reg |= CMCC_MAINT0_INVALL;