Created
January 15, 2024 01:16
-
-
Save tridge/ce95c276bdb28896f7184656220ce131 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void check_ecc_errors(void) | |
{ | |
auto *dma = dmaStreamAlloc(STM32_DMA_STREAM_ID(1, 1), 0, nullptr, nullptr); | |
uint32_t buf[32]; | |
uint32_t ofs = 0; | |
while (ofs < BOARD_FLASH_SIZE*1024 && FLASH->SR1 == 0 && FLASH->SR2 == 0) { | |
__disable_fault_irq(); | |
dmaStartMemCopy(dma, | |
STM32_DMA_CR_PL(0) | STM32_DMA_CR_PSIZE_BYTE | | |
STM32_DMA_CR_MSIZE_BYTE, | |
ofs+(uint8_t*)FLASH_BASE, buf, sizeof(buf)); | |
dmaWaitCompletion(dma); | |
__enable_fault_irq(); | |
ofs += sizeof(buf); | |
} | |
dmaStreamFree(dma); | |
if (ofs < BOARD_FLASH_SIZE*1024) { | |
// we must have ECC errors in flash | |
flash_set_keep_unlocked(true); | |
for (uint32_t i=0; i<num_pages; i++) { | |
stm32_flash_erasepage(flash_base_page+i); | |
} | |
flash_set_keep_unlocked(false); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment