Fill unused flash with invalid instruction

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

Fill unused flash with invalid instruction

1,318件の閲覧回数
riccardolalli
Contributor I

Hello everyone,

My binary images don't occupy the whole flash memory and they come with holes too, so I would like to fill them with some kind of value that makes the mcu reset if executed by accident.

It needs to work with S32K14x family, but if it works with S32K11x is a bonus.

I followed this thread https://community.nxp.com/thread/453969 but now I'm unsure about which value I should use.

I have found the UDF instruction to be a good candidate, but I don't understand the difference between its T1 (16bit) and T2 (32bit) encodings.

is the T1 version (0xDExx) ok for my purposes?

Are there any flaws with this approach?

Thank you very much,

Riccardo

0 件の賞賛
4 返答(返信)

1,103件の閲覧回数
danielmartynek
NXP TechSupport
NXP TechSupport

Hello Riccardo,

Have you considered using Memory Protection Unit?

Regards,

Daniel

0 件の賞賛

1,102件の閲覧回数
riccardolalli
Contributor I

Hello Daniel,

Thanks for the support.

I didn't think about MPU! However I was thinking of filling empty space with some data pattern because I also need to compute a checksum over the image so I thought I could kill two birds with one stone.

0 件の賞賛

1,102件の閲覧回数
danielmartynek
NXP TechSupport
NXP TechSupport

Hello Riccardo,

I don't think there is a standard for this.

But AN4779 EMC Design Tips for Kinetis E Family, Cortex M0+, recommends the undefined branch instruction that you are considering 0xDExx. 

Checking ARM®v7-M Architecture Reference Manual, I see that only Encoding T1 has the UNDEFINED variant of that instruction. I have tried that on S32K144, it seems to be working, it triggers CFSR[UNDEFINSTR].

pastedImage_2.png

If you don't use Supervisor Call, I think you can use __asm__("svc #0x00") as well.

pastedImage_3.png

pastedImage_1.png

And trigger SW reset from that exception instead of the fault exception. 

Regards,

Daniel

0 件の賞賛

1,102件の閲覧回数
riccardolalli
Contributor I

Thank you, I'll try both of them.

Regards,

Riccardo

0 件の賞賛