Skip to main content
TheRaprus
Associate III
Mar 30, 2024 8:48 AM UTC
Solved

Flash Memory access when >512k

Hi to everybody.

I'm struggling to figure out this issue: I got a "NMI_Handler" error...

uint32_t *p = (uint32_t*)0x08080000UL;
uint32_t val = *p; //here jump to NMI_Handler

If I put the addr to 0x08070000UL (e.g.) no probelm.

I'm using a STM32H562RGTX with 1MB of flash. I know that a 2MB need a back swtich... But why in 1MB?
How I can handle this?

Thanks in advance.

This topic has been closed for replies.
Tesla DeLorean
Tesla DeLoreanBest answer
Guru
Mar 30, 2024 5:54 PM UTC

Make sure the Flash has valid content written to it. Blank memory may fault due to lack of valid ECC data.

Not sure if this a feature that can be turned off.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..

7 replies

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
Mar 30, 2024 5:54 PM UTC

Make sure the Flash has valid content written to it. Blank memory may fault due to lack of valid ECC data.

Not sure if this a feature that can be turned off.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
TheRaprus
TheRaprusAuthor
Associate III
Mar 30, 2024 6:08 PM UTC

Thanks Tesla DL.

I tried with full chip erase, then execute again the test, and now it work wo NMI interrupt. So you're right.

Now the question should be: How I can detect if the flash (in any point) is not corrupted? Because tn that case the only way is reset the uC in the nmi ISR and handle it.

STOne-32
ST Technical Moderator
Mar 30, 2024 8:36 PM UTC

Dear @TheRaprus , @Tesla DeLorean ,

 

This NMI protection is thanks to our Flash ECC that as it detects a non Written Memory and so ECC is not initialized . So it protects the CPU to jump to non valid Address , such is EMC etc.

Hope it helps you .

ST1 

Pavel A.
Mar 30, 2024 7:22 PM UTC

@TheRaprus Your question is equivalent to this: if/when the program detects the flash corruption, what can it do, besides of endlessly restarting or shutting down?

 

Tesla DeLorean
Guru
Mar 30, 2024 10:32 PM UTC

It could output an error, perhaps indicating the address or current registers, advance the PC address on the stack frame, and return.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
TheRaprus
TheRaprusAuthor
Associate III
Mar 31, 2024 5:26 AM UTC

@Pavel A. @STOne-32 @Tesla DeLorean 

Yep! The situation is in a custom bootloader (I'm doing a porting from a M4 solution).

If the bootloader check the CRC32's application in flash it simply remain in bootloader and don't jump. What Is necessary is doing the same thing with ECC. There is also a bitmap image to display, and this can open different perspective.

In my code I'm using the function
"HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t FlashAddress, uint32_t DataAddress)"
where DataAddress "shall be 32-bit aligned". I'm not checking it, and this is probably the cause.

I'll keep this issue open, and in the next days I want use this mistake to find a solution - starting from TeslaDL's last post - And I'll write here (if any :grinning_face_with_sweat:)

Thanks for help!