Skip to content

Commit 0d57cfe

Browse files
committed
Set MANW bit of NVMCTRL to 1 at startup (default is 0).
This prevents accidental overwrites of the bootloader if a NULL pointer is used for writing by mistake.
1 parent c608786 commit 0d57cfe

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
SAMD CORE 1.6.5
2+
3+
* Set NVMCTRL.MANW bit to 1 (default is 0). This prevents accidental writes on program memory.
4+
15
SAMD CORE 1.6.4 2016.02.19
26

37
* Fixed Wire address setup when running as slave.

cores/arduino/startup.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,4 +223,9 @@ void SystemInit( void )
223223
linearity |= ((*((uint32_t *) ADC_FUSES_LINEARITY_1_ADDR) & ADC_FUSES_LINEARITY_1_Msk) >> ADC_FUSES_LINEARITY_1_Pos) << 5;
224224

225225
ADC->CALIB.reg = ADC_CALIB_BIAS_CAL(bias) | ADC_CALIB_LINEARITY_CAL(linearity);
226+
227+
/*
228+
* 9) Disable automatic NVM write operations
229+
*/
230+
NVMCTRL->CTRLB.bit.MANW = 1;
226231
}

0 commit comments

Comments
 (0)