2011-04-20 06:35 AM
Remote Firmware Upgrade ... any help?
2011-05-17 05:32 AM
Hi, You need to study IAP application note AN2557. Most of what you need is explained there.
2011-05-17 05:32 AM
You'll need to write a small bootloader, with a SPI driver, and the flashing code. You'll pull the data out of the SPI chip in a similar fashion to the way you put data there in the first place, and then write data to the flash within the STM32 at least 16-bits at a time.
Personally, I've used GSM to pull a firmware over the air using HTTP, storing the new copy in a high region of the STM32's flash memory, and had the part reboot and reprogram the application portion of my device. I would concur with Trevor. First learn how others do it, then reimplement it in a manner suitable for your project. I would also suggests reviewing the flash programming manual/app note. ST maintains a list of consultants that can do these kinds of things.2011-05-17 05:32 AM
Thank you Trevor & Clive for your fast response.
actually, I did 2 small applications:when I run the code it start with app1 and turns LED1, jumping successfully to app2 and turns LED2.
what I want to do is:
at address 0x0800 0000: I will implement my bootloader to check for the ReadyFlag.
My question is how to do what is written in read.
(I'll start reading Trevor's reference and see if I can do something) Thanks & sorry for bothering you.2011-05-17 05:32 AM
The ''Copy'' you talk about is a two step process, you must read data from your SPI device, and then you must write it to the flash memory in the STM32. Before you can write to the flash, you must erase pages of flash first. You must implement code to do this.
Now typically, you'd have a flash routine that can take a block of data in RAM, and write that into FLASH. If the available space is short you might do this repetitively in 32 or 128 byte blocks. This could also be done by reading 16-bits at a time from an SPI flash device as a source, but probably not very efficiently. Earlier versions of the ST Firmware library (on IAR/Keil installs) has example code for interfacing with the SPI bus. Learn how to read from your SPI device. Learn how to program the STM32 flash. Combine this knowledge.2011-05-17 05:32 AM
Which SPI flash are you using? When you refer to ''flag'' what exactly is this? I do something very similar. I have a firmware header which contains a magic number in the first few bytes. This makes it very quick for my bootloader to check if firmware is ''waiting'' in SPI flash to be loaded to STM32 flash i.e. if the first few bytes are the magic number I continue to validate firmware in SPI flash and then load it to STM32 flash if valid (header CRC used to validate). Once loaded to STM32 flash (and CRC checked) I zero the firmware header in SPI flash (and thus the magic number is now invalid) and jump to the new application code.
2011-05-17 05:32 AM
Back ...
clive .. thank you for your support. Now I can read from SPI whatever I need & write it to STM32 Flash after erasing pages.Now .. I want to read data I've wrote in STM32 Flash for validation .. How can I perfom a read operation from flash?Trevor .. I'm using M25PE20 SPI Flash.
& the flag I'm talking about is to determine whether I need to do my upgrade and start the copy process or just boot from my current firmware. (flag = 1 if I have the image ready in SPI and the time&date occured for the upgrade process). Regarding you firmware header, I may use your method or use the optional bytes in the STM32 flash. May be I can ask you how to read data from STM32 flash? Thank you for your kind support. Best Regards,2011-05-17 05:32 AM
''how to read data from STM32 flash?''
You just read it! Set a pointer to the address you want to read, and read it!
2011-05-17 05:32 AM
Thank you Andrew.
I just found a post from Clive: ------ Reading is just like any other memory, set a pointer to it and read, nothing magic. u32 *mem = (u32 *)0x08002000; printf(''%08X\n'', *mem); Thank you all for your assisstence .. I'll see what I can do :)2011-05-17 05:32 AM
@saf I was wondering more where this ''flag'' exists? In RAM, battery backed RAM, flash, SPI flash etc. ?