I am new to the Flash Plug in feature. I have found that in the .\Keil\ARM\Flash, there are a lot ".FLM" and ".FLX" files. It turns out they are flash plugins. I would like to use the tool to write my SPI Flash which connects to the SPI1 of a STM32F105 CPU. By the way, what is the differences between the ".FLM" and ".FLX"? I have noticed they are all renamed ELF files.
I modified the official STM32F10x_M25P64 project to suit my hardware. The "STM32F10X_W25Q32.FLM" has been successfully generated and copied into the Flash folder.
Question 1: I have noticed that the external Flash could be assigned an address. In my case, the 4M external Flash occupies the space from 0xc000000. Then how to store content in this space? I figure it only could save resource, since the STM32F10x CPU could not execute code from SPI Flash. Am I right?
Question 2:If I just want to save a ".hex" file(with address in it) or a ".bin" file(without address) into this region, how to do it?
Maybe there already exists well document to these questions. If someone could give me a hint, it would be very helpful.
A1: On a STM32F1 Series a SPI Flash device can only be used to store data. There is no way to executed directly code from this flash. To store content to that flash, you may use a JTAG Debug Unit such as ULINK and add the flash algorithm. www.keil.com/.../ulink2_su_flash_prg.htm
In case that you want to use the Flash from the application program you may use the embedded file system. You need to add a suitable driver http://www.keil.com/pack/doc/mw/FileSystem/html/nor_usage.html
A2: most likely you want to program an external file using a utility. Then this may help http://www.keil.com/support/docs/3061.htm
Thank you, Reinhard Keil.
The flash algorithm I modified from the official one works fine for me. I use the __attribute__ directive to declare a constant string absolutely addressed and it got correctly flashed into the external SPI flash.
I have two additional questions to seek your or others' help.
Question 1: In the Flash Download configuration tab, there is a group box to set RAM for Algorithm. Why not the algorithm just use all the RAM available? Would the RAM assigned here will be reserved for any further feature? I have noticed that after I added the external Flash Algorithm, the default 0x800 RAM setting is not enough and I must increase it so the algorithms would be loaded and executed successfully.
Question 2: Unfortunately, my currently debug tool is not ULINK. So I guessed that the algorithm I modified would just work in the Keil MDK environment. I would like to complete the ".hex" file programming task within MDK's capability. I have learned from this website that there already existed a command line method to program the output ".axf" to flash. Like this:
C:\Keil\UV4\UV4 -f Programming.UVPROJ -o Prg_Output.txt
So, 2.1 Is it possible to create a uVision project which has a sole source input as ".hex" file and a transliterated ".axf" output? 2.2 Could "fromelf.exe" or "fcarm.exe" complete my task? 2.3 Could ".lin" or ".sct" scripts lend me a hand?
Thanks.
The SPI FLASH won't have an address directly accessible by the STM32, but you can specify a virtual range in which it lives, and have your flashing code understand that range/region associates with the SPI FLASH's internal address space. You use the scatter file to define and direct resources into this virtual space as the linker creates the output .ELF(AXF) and .HEX
You'll want to make sure you access this content indirectly.
You could also create data for this region outside the linker, for example a tool you create for generating resource or file system images that can be downloaded into the SPI memory.
The plug-in needs RAM to be loaded into, and RAM space for the data it is being asked to deliver to FLASH. If your RAM needs are higher, you can adjust the settings, often parts within the family have less RAM, so generally it's better to go with, and code for, the most conservative numbers.
Thank you, Westonsupermare Pier.
I finally solved the problem via this approach:
1. I write a PC program to convert the binary resource into ".c" source file. The binary data is organized as C-Array. 2. I create a uVision project and add the aforesaid ".c" file as the sole source. 3. I modified the generated scatter file, removing the execution relevant directives. Then a resource only ".axf" has been generated. 4. Because I have absolutely assigned the address in the ".c" file, it now could be downloaded into the external SPI flash via my modified ".FLM" algorithm.
It seems a quick and dirty solution. If anyone has better solutions please kindly post here.