cancel
Showing results for 
Search instead for 
Did you mean: 

Bootloader: Main App not running after system reset

gajeronline
Associate II
Posted on April 12, 2007 at 09:15

Bootloader: Main App not running after system reset

14 REPLIES 14
najoua
Associate II
Posted on May 17, 2011 at 09:39

Hello Gager,

I suppose that you are using the IAP via UART provided by ST.

If this is the case, so the behavior you are observing is normal and considered as a limitation.

Please find below the root cause of the observed behavior:

----------------------------------------------------------

As you know, in the STR91x, there are two types of reset generated internally, defined as System Reset (such as the Hardware reset using a push button) and Global Reset (such as Power On reset).

A global reset sets all the registers to their reset values whereas a system reset sets all registers to their reset values EXCEPT the Clock control register (SCU_CLKCNTR), PLL configuration register (SCU_PLLCONF), System status register (SCU_SYSSTATUS) and the FMI Bank address and Bank size registers.

When the Bank0 and the Bank1 are hardware remapped using CAPS tool, the FMI bank addresses become 0x80000 for Bank0 (Non Boot bank) and 0x00 for Bank1 (Boot bank).

As you know, before jumping to the user application, software remapping of Bank0 and Bank1 at 0x00 and 0x80000, respectively, is performed. Apparently, if a hardware reset is applied, the FMI Bank address and Bank size registers will keep the last values (corresponding to this software remapping), i.e. Bank1 base address is 0x80000 and Bank0 base address is 0x00. Consequently, a boot from bank1, where the IAP driver is loaded, is not possible: the IAP driver will not be executed: neither the IAP menu will be displayed on the HyperTerminal (even the Joystick button is at ‘Right’ position) nor a jump to the user application will be performed.

At this moment, a Power On reset should be used to reset the FMI Bank address and Bank size registers in order to be able to boot from the Bank1 to re-execute the IAP driver.

This analysis can be confirmed by the following:

If the software remapping is suppressed from the IAP software and simply a jump to address 0x80000 is performed to execute the user application, there is no problem and the driver behaves normally when a Hardware Reset is applied.

Just to remind: The software remapping of Bank0 at address 0x00 and Bank1 at address 0x80000 in the IAP driver is mandatory because the user application may use interrupts.

Hope this was clear.

Please let me know if you have further questions.

Regards,

Najoua.

gajeronline
Associate II
Posted on May 17, 2011 at 09:39

Hi,

When My Bootloader jump to MainApp, MainApp works fine, but when i use ResetButton MainApp don't starting and I must switching power off/power on on My DevBoard.

MLCK is 25 Mhz.

gajeronline
Associate II
Posted on May 17, 2011 at 09:39

Hmm.

Yes I know about limitation in STR9, I read errata.

But my App still hang-off after I use ResetButton.

After ResetButton CPU don't jump in IAP and don't jump in MyApp section.

I use ST project AN2475, and this project also don't work correctly and after I use ResetButton CPU hang-off

najoua
Associate II
Posted on May 17, 2011 at 09:39

Hello again gajer,

I think there is a misunderstanding.

The limitation I am speaking about is not mentioned in the STR91x erratasheet. This limitation is STR91x IAP driver related: the fact of having a problem with IAP when pressing the Reset push button is normal (explanation is described in my previous answer) and a Power On Reset should be applied instead of a Hardware Reset when using IAP driver.

Please let me know if the explanation was no clear enough.

Regards,

Najoua.

gajeronline
Associate II
Posted on May 17, 2011 at 09:39

>> At this moment, a Power On reset should be used to reset the

>> FMI Bank address and Bank size registers in order to be able

>> to boot from the Bank1 to re-execute the IAP driver.

OK, but I don't want to boot from Bank 1 to execute IAP driver when pressing ResetButton, I want to boot from Bank 0 after reset.

1. I PowerOn my development board, MCU boot from bank 1 (this work)

2. Bootloader in bank 1 remap memory bank and start application in bank 0 this work)

// function running from RAM

void StartUserApplication(void) __attribute__((section(''.fast'')));

void StartUserApplication(void)

{

void (*StartApp)(void);

FMI->BBSR = 0x4;

FMI->NBBSR = 0x2;

FMI->BBADR = 0x80000 >> 2;

FMI->NBBADR = 0x00000 >> 2;

FMI->CR |= 0x18;

StartApp = (void *) 0x0;

StartApp();

}

3. When I pressing Reset Button or when i use Watchdog reset my development board hang-off (why ?)

When I pressing Reset when bootloader is running, then bootloader start again.

But when I pressing Reset (or use watchodog reset) after bank remap, when application in bank 0 is running, development board hang-off (grrr why ?)

kind regards gajer.

najoua
Associate II
Posted on May 17, 2011 at 09:39

>Because after software (or watchod) reset FMI register ''do not change''

>then after reset, CPU jump to address 0x00 whitch means, run >application from bank 0 because bank 0 is software remaping from address >0x80000 to address 0x00.

--> There is one thing to be verified: Verifiy if FMI registers:

** do not change at all after a system reset and they keep the last values(corresponding the the software remapping). In this case, the application in Bank0 should execute without problems even after a hardware reset.

OR

** are modified without keeping the last values corresponding to the software remapping (and are not reset to their default values corresponding to the hardware remapping using CAPS).

I will check this point and keep you informed.

Best regards,

Najoua.

[ This message was edited by: Najoua on 14-03-2007 11:46 ]

najoua
Associate II
Posted on May 17, 2011 at 09:39

Hello gajer,

As I told you, this is a normal behavior.

You said that ''you want to boot from Bank 0 after reset'' but this is not possible using the IAP driver provided by ST.

The IAP driver is located in Bank1 hardware remapped at address 0x00 using CAPS tool.

The IAP driver main program has the following structure:

void main(void)

{

/* If Joystick position is 'Right' */

if (Push_Button_Read() == 0x60)

{

/* Execute the IAP driver in order to re-program the Flash */

}

else

{

/* Keep the user application running */

}

while (1);

}

So, to be able to run the user application located in Bank0 after reset, a boot from Bank1 (and not from bank0) is MANDATORY because the jump to the user application in Bank0 is done from Bank1.

After software remapping, using a hardware reset, a Boot from Bank1 is not possible(as I had already explained) ,that's why the user application in Bank0 will not be executed after a hardware reset: a Power On reset should be applied to recover the FMI Bank address and Bank size registers' values(Bank1 and Bank0 mapped respectively at 0x00 and 0x80000 respectively).

If your application doesn't use interrupts, the software remapping of both Banks is unuseful and a jump to address 0x80000 should be performed.The 'void StartUserApplication(void)' routine becomes:

void StartUserApplication(void)

{

void (*StartApp)(void);

StartApp = (void *) 0x80000;

StartApp();

}

In this case, the behavior will be normal, i.e the user application will be executed successfully after applying a Hardware reset.

Just a remark:

Are you using the STR91x IAP driver provided by ST. I noticed that you are using different routine name 'StartUserApplication' instead of 'Execute_STR9Application' etc...

Hope this answers your question.

Kind regards,

Najoua.

[ This message was edited by: Najoua on 14-03-2007 10:05 ]

gajeronline
Associate II
Posted on May 17, 2011 at 09:39

ok, I'm to agree with you.

but after software remaping where jumps CPU after software or watchodog reset ?. In my opinion after this reset CPU jumps to address 0x00.

Because after software (or watchod) reset FMI register do not change then after reset, CPU jump to address 0x00 whitch means, run application from bank 0 because bank 0 is software remaping from address 0x80000 to address 0x00.

another way, what sense has bootloader when my application can't start after watchog reset (or button reset)

gajeronline
Associate II
Posted on May 17, 2011 at 09:39

thanks, i will be waiting for any sugestion and workaround.

It's very important for me (and my project).

Best regards

gajer