-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reading internal flash triggers HardFault #463
Comments
Hi! Thanks for reporting. The stm32h7b0 is a device with only 128KB of flash, divided into 16 sectors of 8KB each. You're trying to read from the last of those sectors. In theory that should be possible. Could you confirm:
|
I tried to erase the sector using: let (mut flash, _) = dp.FLASH.split();
let mut unlocked = flash.unlocked();
unlocked.erase_sector(15).unwrap(); The program reported the following error:
It seems that some of my write operations didn't complete, and then an ECC error occured. @richardeoin Does |
Assuming the flash is fine and just got interrupted while writing or
something, shouldn't a flash erase and write fix the ECC error?
…On Thu, Oct 12, 2023, 8:20 AM HaoboGu ***@***.***> wrote:
I tried to erase the sector using:
let (mut flash, _) = dp.FLASH.split();let mut unlocked = flash.unlocked();
unlocked.erase_sector(15).unwrap();
The program reported the following error:
panicked at boards/stm32h7/src/main.rs:101:35:
called `Result::unwrap()` on an `Err` value: EccDoubleDetection
It seems that some of my write operations didn't complete, and then an ECC
error occured.
@richardeoin <https://github.com/richardeoin> Does stm32h7xx-hal crate
provide any methods to fix flash ECC error?
—
Reply to this email directly, view it on GitHub
<#463 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAUS5FMRP2XU3WKH3HHWHGDX67VCRANCNFSM6AAAAAA534WUFU>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
I've reviewed my code. I use the following function to write the flash: fn write_record(&mut self, record: EepromRecord) {
match self
.storage
.write(STORAGE_START_ADDR + self.pos, &record.to_bytes())
{
Ok(_) => self.pos += 4,
Err(_) => error!("Failed to write record to storage"),
}
} after each write, the next write addr will be addr + 4. Is this right way to use the crate? I believe I didn't write much data(about 300 bytes). So I don't know is the flash still fine. Erasing the sector with |
Your report about USB is a separate issue. I've posted a fix in #464 |
Erasing the sector fixed the ECC error, closing this issue |
Hello, I'm using stm32h7b0 mcu and trying to emulate eeprom using mcu's flash and
stm32h7xx-hal::flash
. Here is my testing code for flash write/read:But the
read
function fails and the program jumps to HardFaultHere is the callstack:
The text was updated successfully, but these errors were encountered: