LPC55xx (Mass) Flash erase with IAP

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

LPC55xx (Mass) Flash erase with IAP

ソリューションへジャンプ
717件の閲覧回数
janpieterderuit
Contributor IV

Hi,

I'm using LPC5526 with SDK v2.8.0 with Eclipse IDE (2020-06)  (so not MCUXpresso).

I'm trying to do a runtime mass erase of the flash.

I get the mass erase working with the FLASH_Erase API, specifying the full flash area to erase.
But (obviously) the controller is not capable of doing anything afterwards.

I would like to at least do a FLASH_VerifyErase afterwards.

So I implemented a function in RAM (see https://mcu-things.com/blog/ramfunc-gcc/), calling the IAP ROM functions directly (which I figured should work):

__attribute__((long_call, noinline, section(".ramfunc"))) void MassErase(void) {
   flash_config_t flInst;
   UINT32 flashBlockBase = 0;
   UINT32 flashTotalSize = 0;

   if (FLASH_API_TREE->flash_init(&flInst) == kStatus_FLASH_Success) {

      FLASH_API_TREE->flash_get_property(&flInst, kFLASH_PropertyPflashBlockBaseAddr, &flashBlockBase);
      FLASH_API_TREE->flash_get_property(&flInst, kFLASH_PropertyPflashTotalSize, &flashTotalSize);

      if (FLASH_API_TREE->flash_erase(&flInst, flashBlockBase, flashTotalSize, kFLASH_ApiEraseKey) {
         if (FLASH_API_TREE->flash_verify_erase(&flInst, flashBlockBase, flashTotalSize) == kStatus_FLASH_Success) {
            // Mass erase successfull
         }
      }
   }
}

I verified code is running in RAM.

flash_init returns success and flash_get_property returns correct data, so ROM API calls seems to work OK.

Also flash_erase works (in the end Flash is erased), but I still get a SIGTRAP before flash_verify_erase can be executed.

Any idea what I can be doing wrong?

ラベル(1)
タグ(2)
0 件の賞賛
1 解決策
716件の閲覧回数
janpieterderuit
Contributor IV

Ah, I just tried a 'step into' the flash_erase function with the debugger, and turned up in an interrupt routine.

Disabling all interrupts fixed the issue.
I can now verify Flash erasure (and anything else) from RAM.

元の投稿で解決策を見る

0 件の賞賛
1 返信
717件の閲覧回数
janpieterderuit
Contributor IV

Ah, I just tried a 'step into' the flash_erase function with the debugger, and turned up in an interrupt routine.

Disabling all interrupts fixed the issue.
I can now verify Flash erasure (and anything else) from RAM.

0 件の賞賛