修复Flash操作返回失败,及log_end_add返回块首址造成无法写log。

pull/42/head
LAPTOP-ORSGE5M9\lyy 7 years ago
parent 0504880003
commit 7b08609404

@ -143,13 +143,16 @@ EfErrCode ef_port_write(uint32_t addr, const uint32_t *buf, size_t size) {
FLASH_ClearFlag(FLASH_FLAG_BSY | FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR); FLASH_ClearFlag(FLASH_FLAG_BSY | FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR);
for (i = 0; i < size; i += 4, buf++, addr += 4) { for (i = 0; i < size; i += 4, buf++, addr += 4) {
/* write data */ /* write data */
FLASH_ProgramWord(addr, *buf); read_data = *(uint32_t *)addr;
read_data = *(uint32_t *)addr; if (read_data != *buf) {
/* check data */ FLASH_ProgramWord(addr, *buf);
if (read_data != *buf) { read_data = *(uint32_t *)addr;
result = EF_WRITE_ERR; /* check data */
break; if (read_data != *buf) {
} result = EF_WRITE_ERR;
break;
}
}
} }
FLASH_Lock(); FLASH_Lock();

@ -239,7 +239,7 @@ static uint32_t find_sec_using_end_addr(uint32_t addr) {
return sector_start + EF_ERASE_MIN_SIZE - continue_ff; return sector_start + EF_ERASE_MIN_SIZE - continue_ff;
} else { } else {
/* all sector not has continuous 0xFF, so the sector is full */ /* all sector not has continuous 0xFF, so the sector is full */
return sector_start + EF_ERASE_MIN_SIZE; return sector_start + EF_ERASE_MIN_SIZE+LOG_SECTOR_HEADER_SIZE;
} }
} }

Loading…
Cancel
Save