Find corruption on internal Flash MK22FX512VLH12

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Find corruption on internal Flash MK22FX512VLH12

ソリューションへジャンプ
1,520件の閲覧回数
ralf1694
Contributor III

Hi community.

I must write data on the internal flash, without disable the interrupts.

But I found this:

         Interruption of an erase or program command can lead to corruption of the flash contents. Interruptions could include

         reset, loss of power, or a conflict with code running on processor.

My problem is, when I read the corrupt data from internal flash, I get a Bus Error.

Is there a way to find corrupt data on the internal flash or a way that no corruption accures?

0 件の賞賛
返信
1 解決策
1,358件の閲覧回数
mjbcswitzerland
Specialist V

Hi

Corrupted flash (this tends to be valid for second generation parts but not for all) causes a fault exception to be generated when read. It is necessary to erase the sector (or possibly the complete flash) to recover the Flash operation.

To detect the corruption you can use the fault exception itself - read all locations of Flash to see whether it is generated or not and stop further checking once an exception occurs.

Regards

Mark

元の投稿で解決策を見る

0 件の賞賛
返信
3 返答(返信)
1,358件の閲覧回数
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Oliver Schmid:

Just like Mark suggested, you can use the fault to detect a corrupted flash. There is also the option of using the Program Check command to compare your expected data vs actual stored data.

To avoid flash corruption, it is actually recommended to disable interrupts. You could also copy interrupt vectors to RAM and relocate the interrupt handler codes to a different flash block (not the one being written/erased) or to RAM memory, for all of those interrupts that are likely to trigger while the flash operation is performed.

I hope this helps!

Best regards,

Jorge Gonzalez

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛
返信
1,358件の閲覧回数
ralf1694
Contributor III

Thanks for your help:)

I implement the Bus Fault ISR and when I read the corrupt data I am in the ISR :smileyhappy:

But I have another question. When my Bus Fault ISR is empty, then I jump back to the read flash command which caused the fault. Then I read the same flash address and jump in the ISR again and after ISR back to the read command. After the 4th or 5th read from the corrupt data, I can read the data from flash and no Bus Fault occurs. Why?

Is there a way to execute the next line of the routine after the Bus Fault ISR jump back?

     -read corrupt data

     - isr

     -jump back to routine

     -next line to execute is the line after read command which caused the fault

0 件の賞賛
返信
1,359件の閲覧回数
mjbcswitzerland
Specialist V

Hi

Corrupted flash (this tends to be valid for second generation parts but not for all) causes a fault exception to be generated when read. It is necessary to erase the sector (or possibly the complete flash) to recover the Flash operation.

To detect the corruption you can use the fault exception itself - read all locations of Flash to see whether it is generated or not and stop further checking once an exception occurs.

Regards

Mark

0 件の賞賛
返信