don't let openblt erase itself #6290

This commit is contained in:
rusefillc 2024-03-31 04:55:48 -04:00 committed by rusefillc
parent b0154825a6
commit 9401aecd0c
1 changed files with 10 additions and 0 deletions

View File

@ -19,12 +19,22 @@ blt_addr FlashGetUserProgBaseAddress() {
}
blt_bool FlashWrite(blt_addr addr, blt_int32u len, blt_int8u *data) {
// don't allow overwriting the bootloader
if (addr < FlashGetUserProgBaseAddress()) {
return BLT_FALSE;
}
return (FLASH_RETURN_SUCCESS == intFlashWrite(addr, (const char*)data, len)) ? BLT_TRUE : BLT_FALSE;
return BLT_TRUE;
}
blt_bool FlashErase(blt_addr addr, blt_int32u len) {
// don't allow erasing the bootloader
if (addr < FlashGetUserProgBaseAddress()) {
return BLT_FALSE;
}
if (!intFlashIsErased(addr, len)) {
return (FLASH_RETURN_SUCCESS == intFlashErase(addr, len)) ? BLT_TRUE : BLT_FALSE;
}