Hardware flash write protection¶
The hardware flash write protection driver (
fprotect) can be used to protect flash areas from writing.
The driver uses a hardware peripheral (BPROT, ACL, or SPU, depending on the chip model) to protect the area.
The protection is irreversible until a reset occurs.
The following example shows how to protect
PM_B0_SIZE bytes of the flash area starting from
int err = fprotect_area(PM_B0_ADDRESS, PM_B0_SIZE);
API for write protection of flash areas using Hardware peripheral.
fprotect_area(u32_t start, size_t length)¶
Protect flash area against writes.
start: Start of range to protect.
length: Length in bytes of range to protect.
- Return Value
0: On success.
-EINVAL: If any of the argument are incorrect.
-ENOSPC: If function is called too many times. Applies to devices where there is a limited number of configuration registers which are used for all address ranges.