cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F427 firmware upgrade process

hiharsh
Associate II
Posted on March 19, 2014 at 16:17

Hi All,

I would like to get started on firmware upgrade process. I have a following questions on the same.

1) My target board (STM32F427) has 1MB of flash, and 256 KB of external ram. At present, we run program from flash (we selected the option while creating a project using GreenHill tools).

The image size on STM32F427 is around 700KB. I would like to upgrade the STM32F427 software using RS232 as well as using USB.

What are the things I will have to worry about? Do I must have bootloader? and Do I need to modify the bootloader and implement the flash_erase/flash_write utilities in the same?  Do I need to worry about any other things which I might have missed?

Is there any document that would provide me insight to this? I think this must be pretty standard procedure since most of you are using the STM32 for a while.

#firmware-update #boot-loader
18 REPLIES 18
Posted on October 22, 2014 at 20:33

Well let's hope nobody dies,

// Image payloaded in FLASH is compiled with following mapping
// IROM 0x20000000..0x20003FFF [0x4000]
// IRAM 0x20004000..0x2001FFFF [0x1C000]
// Make sure IRAM (heap, stack, etc) for Boot Loader is not in 0x20000000..0x20003FFF region
#define RAM_ADDR 0x20000000
#define FLASH_ADDR 0x0801C000
#define FLASH_SIZE 0x00004000
typedef int (*pFunction)(void);
void RamCode(void)
{
uint32_t *Ram = (uint32_t *)RAM_ADDR;
pFunction RunCode;
memcpy(Ram, (void *)FLASH_ADDR, FLASH_SIZE); // Copy code
RunCode = (pFunction)Ram[1]; // ResetHandler (PC in second vector)
RunCode(); // sourcer32@gmail.com
}

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
umamahesh
Associate II
Posted on October 24, 2014 at 15:37

Clive,

Sorry to trouble again. Following where tried

 In Start_xxx.s for bootloader project, following section is added

LDR R0, =0x20000000 ; RAM Base

LDR SP,[R0, #0]

LDR R0,[R0, #4]

BX R0

the target settings for bootloader,

IROM1 -> 0x8000000 Size->0x30000

IRAM1-> 0x20004000 Size->0x2B000

Compiled size of bootloader for generating hex  is 157KB

For Application,

Normal KEIL generated start_xxx.s is added

the target settings for Application,

IROM1 -> 0x8000000 Size->0x30000(tried with IROM1->0x20000000,Size->0x3FFF)

IRAM1-> 0x20004000 Size->0x2B000

Compiled size of Application for generating hex is 155KB

So while doing memcpy() it goes to HardFault Error with FORCED enabled. Could you please tell me where I am going wrong.

Posted on October 24, 2014 at 17:17

Could you please tell me where I am going wrong.

a) Sounds bigger than 16KB

b) Not compiled for the appropriate address

Suggest you start by doing simpler examples which you understand and can debug.

Right now you're trying to integrate code I've never seen, on a chip that isn't defined, using a procedure that's not been thoroughly explained.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
umamahesh
Associate II
Posted on October 25, 2014 at 06:50

Clive, Sorry its typo error at couple of address mentioned earlier

In Start_xxx.s for bootloader project, following section is added

LDR R0, =0x20004000 ; RAM Base(As you have asked to use the range from 0x20000000 to 0x20003FFF by bootloader or Application)

LDR SP,[R0, #0]

LDR R0,[R0, #4]

BX R0

Typo error for Application start address

the target settings for Application,

IROM1 -> 0x81C0000 Size->0x40000(tried with IROM1->0x20000000,Size->0x3FFF)

IRAM1-> 0x20004000 Size->0x2B000

Compiled size of Application for generating hex is 155KB

Posted on October 25, 2014 at 15:05

Ok, so 50-60 KB not 16 KB

Why does this need to be in RAM? If in RAM what address?

If in RAM then not compiled/linked for a FLASH address.

The boot loader's IRAM address should not conflict with address to which you are copying data, otherwise you will overwrite the loaders stack and variables.

The Application image, if it's going to be copied to RAM needs to be compiled/linked for the RAM ADDRESS where you're copying it.

Does the Application start with the standard vector table for the interrupts it uses? Do you understand the format/content of the vector table?
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
umamahesh
Associate II
Posted on October 27, 2014 at 14:05

Hi Clive

Please look my comments below

Posted on October 27, 2014 at 16:54

It is the requirement to copy the application to RAM through bootloader. Whatever code you posted similar way I manually copy from Flash to RAM and verify CRC. If CRC is passed then I need to jump to application. I am stuck for jumping it, IROM and IRAM address I configure in KEIL getting failed. It goes to Hard fault error.

You really don't seem to be getting this, do the people above you setting the requirements have a better understanding of the problem, and explain the system details? Assume I have no idea what your application structure is, or how to get to executable code. All I know is what you've shared on the thread.

What Address and Size does this requirement state?

It likely faults because what you're pointing too isn't in a Cortex-Mx vector table format, it's not jumping to executable code and you haven't adequately described, or understand, the format it is in.

You need to be thinking about ''What am I jumping too exactly?''

In your logic after memcpy(); Retcode()-> goes to hardfault exception;

You don't understand what you're jumping to, and you've not provided any detail or disassembly to permit anything to be identified. If you had built a simple example like I'd recommended earlier, along the lines of the IAP examples, you'd be further along in your understanding of what will and will not work.

''Does the Application start with the standard vector table for the interrupts it uses? Do you understand the format/content of the vector table?''

 

As of now I have split Flash contents as follows

 

Bootloader: 0x8000000 size:0x30000; IRAM1: 0x2000e900 size:0x19000

 

Application: 0x81C0000 size:0x40000;IRAM1:0x2000e900 size:0x19000

 

I'm not sure that addresses my questions. I going to assume your Application has some proprietary format which isn't compatible the standard vector table model. There is a difference between compiling/linking code to run at a specific address, and placing a binary blob of code in some other location, and then copying it to it's final destination. The code NEEDS to be built to execute at 0x20000000 if that is where it is being copied.

I will not copy bootloader to RAM it will reside in Flash.

And I'm not telling you to copy the bootloader to RAM. I'm telling you that you shouldn't copy the Application over the RAM where the bootloader's stack and variables are situated. The ''Bootloader: 0x8000000 size:0x30000; IRAM1: 0x2000e900 size:0x19000'' is thus OK

Need some references to proceed since what ever range I give it is getting failed. If application need to copied to RAM, should it be compiled for RAM? i.e., should I give IROM1 start and size of RAM address(0x20000000...)

The Application's IROM should be 0x20000000[0xE900],  provided it has a structure that's compatible with Cortex-Mx execution.

Do you have any colleagues with Cortex-Mx experience?

Can I suggest you review the IAP (In Application Programming) examples.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
umamahesh
Associate II
Posted on October 28, 2014 at 09:29

Clive,

Thanks for immediate suggestions.Please check my comments

The Application's IROM should be 0x20000000[0xE900], provided it has a structure that's compatible with Cortex-Mx execution.

This configuration was done but unable to port using ULINK Pro, it says No Algorithm for the following address.Right now trying to jump within Flash(i.e., Bootrom to Application within Flash)

Am I missing any assembly rountines to be developed in start_xxx.s  to branch it to Application address.

Posted on October 28, 2014 at 17:54

This configuration was done but unable to port using ULINK Pro, it says No Algorithm for the following address.

Yes, you'll need to use the Debugger Scripting to load code into RAM, flash algorithms only work for FLASH targets.

You need to merge the Boot Loader and Application images to write them into flash, or you'll need to take the application output as a binary, and write it into your flash holding location with a tool like the ST-LINK utilities, or provide basic functionality in your Boot Loader to write the Application image into flash.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..