cancel
Showing results for 
Search instead for 
Did you mean: 

AN2475 once again ...

robosoft
Associate II
Posted on January 19, 2009 at 22:39

AN2475 once again ...

6 REPLIES 6
robosoft
Associate II
Posted on May 17, 2011 at 09:57

Hi,

I am trying to download a bin file using the bootlader from AN2475 with KEIL tools. My device is a STR912FA44 revision 'H'.

As UART0 is not present I changed the code to use UART1.

When compiling the project and loading it in the device using ULINK, the program doesn't even start! It hangs at random places and enters the abort_handler interrupt.

I modified the FMI_Clk to 48MHz with succes, the program starts.

However when I download a small bin file (12K) programming fails after receiving 9 blocks with a 'verification error'. It seems that the data is not programmed correctly into flash.

I found out that the data that has to be programmed on 0x82000 fails, reading from 0x82000 gives 0xFFFF (erased). So a block of 8K can be written ? (Do I write in the 32K bank ?)

Receiving the file without writing it to flash is no problem.

Did somebody succeed to download a bin file using this bootloader ?

Luc Vercruysse

[ This message was edited by: robosoft.ontwikkeling on 15-01-2009 10:51 ]

kais2
Associate
Posted on May 17, 2011 at 09:57

Hi,

It should work when changing the level of optimization

As I remember I’ve encountered an issue like this.

May this help.

robosoft
Associate II
Posted on May 17, 2011 at 09:57

Thanks for response. I have tried all optimizations..no result.

Things go wrong when I want to write to flash on locations above the first 8K (starting from 0x2000).

A program that fits in 8K can be downloaded and started. However, I write programs larger than 8K ;)

roger8
Associate II
Posted on May 17, 2011 at 09:57

I know why this is.

There are #define errors in the code.

What it is doing is running from bank 0 which is 512K (or 256).

At 0x80000 the 32K bank 1 resides.

Now when you run the program it only erases the first sector which is 8K.

There is some confusion as it the source thinks it is actually erasing a 64K sector.

You need to do an erase at 0x80000 + 0x2000 and so on....

Then you will have erased all sectors of the 32K bank 1.

You can then download to bank 1 - a max code size of 32K.

When you jump to new application it swaps around the banks so your d/l app will reside at 0x000.

You need to make sure your main app does not try and swap the banks around in init.s.

I have swapped the banks around using a switch accessed by jlink commander so that I have a (default) bootloader running in the 32K bank 1 - this allows me to d/l a much bigger main app.

I am using some bits of AN2475.

It now works for me but I have to work out how to handle the exceptions and reset (which starts up the smaller bootloader) - bootloader will probably check to see if theres a valid main app and run it after a timeout.

robosoft
Associate II
Posted on May 17, 2011 at 09:57

Indeed, my bootloader was running in the 512K block. It seems to be impossible to program it in BANK1 using ulink with the settings from the application note. When I use Rlink (raisonance) it works.

Now I am able to program BANK0 from by bootloader, even large programs.

There is still one problem, when the 'mainprogram' (the program I download with bootloader) uses interrupts, this mainprogram cannot be started from bootloader. I have to find out what's going wrong here.

 

I have used several processors. Not one of them gives so much problems !!

 

I have already spend weeks to solve problems!

 

I thought the code from an application note is supposed to be plug and play.

 

The bootloader from AN2475 does not run without modifications. For example a stack of 0x400 bytes is defined in the Keil project. the used stack is maximum 0x512 byes !!

 

I tried to use the raisonance project, i cannot even build it !

 

 

I do already know witch processor I will not use in future projects !

 

mark9
Associate II
Posted on May 17, 2011 at 09:57

I've gotten fed up the STR912 many times as well, but I think a lot of that has to do with the ARM core and not so much with the micro. That said, the flash banking scheme of the STR912 is horribly implemented and that causes a lot of problems.

You might want to modify your main boot code as follows to disable the PFQ/BC

LDR R0, = SCU_BASE_Address

LDR R1, = 0x0196 ;was 0x0191

STR R1, [R0, #SCU_SCR0_OFST]

I've found that this causes a problem if you use interrupts in your bootloader. Otherwise, the IRQ address of your main program never gets called -- it is still calling the cached IRQ address of the bootloader. This was extremely frustrating and it is not mentioned anywhere in the app. note.

In your main code, you can reenable the PFQ/BC from C code.

-Mark

ps I feel your pain about the other demo code from ST regarding the STR912. Very poor quality... Some of it should be posted on the web as examples of how not to write code.