Aligment error (PGAERR) on FLASH write. Error UNDEFINSTR joins the party
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-12-13 12:02 PM
I dont know why this error happens. It is aligned as 0x0800F800.
Not only this, but i get a hardfault (UNDEFINSTR) error too, while printing the above error with the following:
printf("Error writeFLASHDoubleWord FLASH->SR: %02X", READ_REG(FLASH->SR));
Solved! Go to Solution.
- Labels:
-
STM32G4 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-12-13 12:42 PM
You are spot on. I did not think about how big a page actually is ;-).
I put it now at the end to not get a problem again. But i found out, that after erasing pages, my writing does not work anymore. If i comment out the erase, i can write the flash. How can the erase prevent me from writin?
 
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-12-13 12:20 PM
You can read FLASH->SR directly, and its not at 0x800F800
Your error is coming from something else. Decompose the Hard Fault, presenting those registers and the machine instructions that are faulting, so it might be more apparent what the actual issue is.
The printf() doesn't look intrinsically wrong. Are you perhaps deleting the code/data that relate to the instruction, the library, the string?
A double word would need to be on an 8-byte boundary, and the content properly erased.
Going to need better presentation and context to understand why this is failing.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-12-13 12:42 PM
You are spot on. I did not think about how big a page actually is ;-).
I put it now at the end to not get a problem again. But i found out, that after erasing pages, my writing does not work anymore. If i comment out the erase, i can write the flash. How can the erase prevent me from writin?
 
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-12-13 2:10 PM
>>How can the erase prevent me from writing?
It didn't complete yet?
There's some pending error?
Hard to tell anything from screen shot code fragment. Need to see output and sequences from an instrumented process. Best not to single-step in debugger, or dwell on the peripheral view. Print out info about the stages, and the register in hex at each point. Decimal not helpful.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-12-13 2:46 PM
I dont do single step as i know of the problems.
But i found my problem: i did not clear PER and PNB after erase, which gave me troubles. After findind out you can write some flash without erase, i went like this. But it seems that it does not work any kind of predictable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-12-13 3:58 PM - edited ‎2023-12-13 3:59 PM
On these devices after erase every 64-bit cell can be written just once and in addition one can always invalidate the cell by writing zeros to it. All of it is explained in the reference manual.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-12-14 12:00 AM
I was having some memory about invalidating, but could not find the part in the manual again...
But with playing around with it, i can truly confirm that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-12-14 4:25 PM
RM0440 Rev 7 section 5.3.7 tells it in the second sentence...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-12-14 5:02 PM
No, i think it was somewhere else. It is in general the case: with addresses that you have not programmed before, you can only write 0x0.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-12-14 5:46 PM
What "no"? I showed where it is written. If it's also written in some other place... so what? And how many times un how many places it must be written for you to finally read it? Zero is the only value that can be written to addresses that have been programmed previously!
