LPC4367/LPC4337: IAP-command "Chip_IAP_SetBootFlashBank()" somehow only validates but does not invalidate

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC4367/LPC4337: IAP-command "Chip_IAP_SetBootFlashBank()" somehow only validates but does not invalidate

2,187 Views
mario_goeckel_e
Contributor I

if an Application, started from Bank A, sets via IAP-command "Chip_IAP_SetBootFlashBank(..B)" flashbank B to get the active one, the Bootloader (after a reset) does start Flashbank A again as Flashbank A has not been invalidated (with 00000000 from 0x1A000001C on) while Flashbank B (with valid 4-Byte Checksum at 0x1B000001C (calculated out of Vector-Tables 0 to 6)) has been validated only. I expected the Bootloader to start Flashbank B

Here is a code-snippet of my application, started from Bank A, for setting B to get the active one. What am I missing?:

__disable_irq();

ret_code = Chip_IAP_SetBootFlashBank(IAP_FLASH_BANK_B);

if (ret_code != IAP_CMD_SUCCESS){

   DEBUGOUT("Command failed to execute, return code is: %x\r\n", ret_code);

}

__enable_irq();/* Re-enable interrupt mode */ NVIC_SystemReset();

Labels (1)
0 Kudos
Reply
6 Replies

1,844 Views
1g0rb
Contributor I

It's an old thread but I had the same issue recently so just to update it if anyone else needs it as it took me quite some time to figure it out.

Alterative to doing hard-reset (for example if it's not accessible or if it has to be done in firmware) is to switch to deep powerdown mode and for example use RTC to wake the MCU immediately. Wake from deep powerdown will correctly initialize everything just like the hard reset would do (and which soft-reset doesn't do).

0 Kudos
Reply

2,040 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Mario Göckel,

Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
According to your statement, the flash bank switch fails even if ret_code is  IAP_CMD_SUCCESS after executing the Chip_IAP_SetBootFlashBank(IAP_FLASH_BANK_B) function, is it right? And MCU always boot from the Flash bank A?
So I'd like to suggest you check the POW bit in the FLASHCFGA and FLASHCFGB registers for confirming, please give a try.


Have a great day,
TIC

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

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply

2,040 Views
mario_goeckel_e
Contributor I

Hello,

thanks for you fast response first of all!

My statement “Chip_IAP_SetBootFlashBank()" somehow only validates but does not invalidate” was wrong.

I guess the missing invalidation of Bank A was due to the Debugger of Segger Embedded Studio preferring Bank A ..

So “Chip_IAP_SetBootFlashBank()" does correctly validate the requested bank and does invalidate the other one

After further investigations I found out, that I need to do a soft-reset AND also hard-reset to get the bootloader starting the requested Bank

Szenario: starting-point is an Application, started from Bank A, which sets Bank B with Chip_IAP_SetBootFlashBank(..B).

When reading the 4byte-signature at 0x01C is see that Bank A was correctly invalidated and Bank B was correctly validated.

..but when I perform a soft-reset with “NVIC_SystemReset()” the bootloader starts Bank A unexpectedly.

And only after performing also a hard-reset after the soft-reset, the bootloader finally starts the requested Bank B.

So after setting the requested Bank, I have to perform a soft-reset and additionally a hard-reset..

So what has to be done using only a soft-reset to get the bootloader starting the requested Bank?

Best regards

Mario Göckel

Von: jeremyzhou <admin@community.nxp.com>

Gesendet: Donnerstag, 23. Mai 2019 04:49

An: Goeckel, Mario (ext) (SHS PV R&D-PE MDGC) <mario.goeckel.ext@siemens-healthineers.com>

Betreff: Re: - Re: LPC4367/LPC4337: IAP-command "Chip_IAP_SetBootFlashBank()" somehow only validates but does not invalidate

NXP Community <https://community.freescale.com/resources/statics/1000/35400-NXP-Community-Email-banner-600x75.jpg>

Re: LPC4367/LPC4337: IAP-command "Chip_IAP_SetBootFlashBank()" somehow only validates but does not invalidate

reply from jeremyzhou<https://community.nxp.com/people/jeremyzhou?et=watches.email.thread> in LPC Microcontrollers - View the full discussion<https://community.nxp.com/message/1155270?commentID=1155270&et=watches.email.thread#comment-1155270>

0 Kudos
Reply

2,039 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Mario Göckel,

In my testing, it needs the hardware reset to force the MCU to boot the active Flash bank after executing Set active boot flash bank command.
Hope this is clear.

Have a great day,
TIC

 

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

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply

2,041 Views
mario_goeckel_e
Contributor I

Thanks,

yes definitely, it’s working fine after performing a hard-reset.

Sorry, i couldn’t find the time yet to inform you about my proceedings.

Regards

Mario

Von: jeremyzhou <admin@community.nxp.com>

Gesendet: Mittwoch, 29. Mai 2019 06:38

An: Goeckel, Mario (ext) (SHS PV R&D-PE MDGC) <mario.goeckel.ext@siemens-healthineers.com>

Betreff: Re: - Re: LPC4367/LPC4337: IAP-command "Chip_IAP_SetBootFlashBank()" somehow only validates but does not invalidate

NXP Community <https://community.freescale.com/resources/statics/1000/35400-NXP-Community-Email-banner-600x75.jpg>

Re: LPC4367/LPC4337: IAP-command "Chip_IAP_SetBootFlashBank()" somehow only validates but does not invalidate

reply from jeremyzhou<https://community.nxp.com/people/jeremyzhou?et=watches.email.thread> in LPC Microcontrollers - View the full discussion<https://community.nxp.com/message/1157432?commentID=1157432&et=watches.email.thread#comment-1157432>

0 Kudos
Reply

2,041 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Mario Göckel,

Thanks for your reply.

According to your reply, it seems that the soft-reset is incapable of force the MCU boot from the Flash bank B, only hardware reset resource (likes the external reset pin, POR, etc ) can make it, is it right?
If yes, I'll like to test it by myself to replicate this phenomenon.
Have a great day,
TIC

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

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply