Topic : Flash Bank2 Erase Problem

Forum : ARM

Original Post
Post Information Post
April 15, 2011 - 11:22am
Guest

Hi!

I try to erase Bank2 using this code:

//Pages = 0x08080000;//bank2 start adress
FLASH_UnlockBank2();
FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR);
FLASH_Status1 = FLASH_EraseAllBank2Pages();
// FLASH_Status1 = FLASH_ErasePage(Pages);

But FLASH_Status1 returns always FLASH_TIMEOUT

I can erase bank1 pages succesfully but i couldnt do it for bank2

can you help me?

Best Regards

Replies
Post Information Post
+1
0
-1
April 15, 2011 - 12:15pm
Raisonance Support Team

Hi,

I did not spend any time experimenting with your example, but there is one point that you have to take care of: The debugger requires specific access to the Flash, so it may corrupt the accesses you are doing.
One thing to try is to execute your code with debug mode deactivated, and check whether it works better.

One other thing to do is to have a look at the ST library examples, and dig in them to get some working code to experiment with.

Best Regards,

+1
0
-1
April 15, 2011 - 2:43pm
Guest

I didnt use debug mode
I send usart1 some data so i can see what is Flash_status
but it is still same I see always 0xCC on usart1 :S
FLASH_UnlockBank2();
FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR);
FLASH_Status1 = FLASH_EraseAllBank2Pages();
// FLASH_Status1 = FLASH_ErasePage(Pages);

if(FLASH_Status1 == FLASH_ERROR_PG)
USART1_Tx(0xAA);
if(FLASH_Status1 == FLASH_ERROR_WRP)
USART1_Tx(0xBB);
if(FLASH_Status1 == FLASH_TIMEOUT)
USART1_Tx(0xCC);
if(FLASH_Status1 == FLASH_COMPLETE)
USART1_Tx(0xDD);

+1
0
-1
April 16, 2011 - 10:16am
Guest

Hi!

I clear bank2 flags using

FLASH_ClearFlag(FLASH_FLAG_BANK2_EOP | FLASH_FLAG_BANK2_PGERR | FLASH_FLAG_BANK2_WRPRTERR);

Now it works (:

but stm's example use only this code to clear flags this is only related with bank1
"FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR);"

Best Regards

+1
0
-1
April 18, 2011 - 8:22am
Raisonance Support Team

Great news Mehlicicek,

Thanks for sharing this information with us!

+1
0
-1
April 18, 2011 - 3:06pm
Guest

I tested to write or erase but it is not stable you have to use no optimization or -o3 level to to write or erase flash correctly
it writes but it goes flash time_out
I send my project maybe you can find solution
Best Regards

+1
0
-1
April 18, 2011 - 6:31pm
Raisonance Support Team

Hi,

We received your project. Thanks.

This looks like a known bug in the GCC compiler. Please try the followng change, in order to see if it is indeed the same problem:
In file "stm32f10x_flash.c", declare as volatile the "status" variables of the two "FLASH_WaitForLastBank...Operation" functions:

FLASH_Status FLASH_WaitForLastBank1Operation(uint32_t Timeout)
{
volatile FLASH_Status status = FLASH_COMPLETE;

...

FLASH_Status FLASH_WaitForLastBank2Operation(uint32_t Timeout)
{
volatile FLASH_Status status = FLASH_COMPLETE;

...

Tell us if it fixes the problem or not.

This bug is known and fixed, but the fix will only be available with the next release of the GCC compiler for ARM. The date of this release is not defined yet.
In the meantime the above workaround is the best solution. (or disabling optimization on file "stm32f10x_flash.c".)

If the modification above does not solve the problem, we will look deeper into it. However, note that the fact that the same code works with other compilers does NOT prove that there is a bug in this compiler: Depending on the way the compilers optimize, they might output different code from the same source, and if the code is not written with all necessary guards, it might "work" (whatever that means) with one compiler and not another, with the two compilers still being correct. The ST lib code used to be quite bad on these issues. Now it is much better but there might still remain some undettected problems.

Best Regards,

Vincent

+1
0
-1
April 19, 2011 - 3:25pm
Guest

Hi!

It worked when i used volatile
I look forward for next release of the compiler.
I hope it doesnt take much time
Thank you

+1
0
-1
April 20, 2011 - 1:35pm
Guest

Hi!
I see new version of gcc
http://gcc.gnu.org
GCC 4.4.6
April 16, 2011 new

how can i run new version of compiler with ride7?
if i download and copy to Program Files\Raisonance\Ride\arm-gcc\arm-none-eabi directory is it work ?

Best Regards

+1
0
-1
April 26, 2011 - 10:07am
Raisonance Support Team

Hi,

Unfortunatelly it's not so simple. I recommend you keep the workaround until the new release.

Best Regards,

Vincent