cancel
Showing results for 
Search instead for 
Did you mean: 

Program arbitrary data to on chip flash

hbarta2
Associate III
Posted on February 06, 2017 at 17:23

Is there an easy way to programarbitrary date to on chip flash? We're using IAR Workbench and an ST-LINK/V2   JTAG debugger. I've done some looking in the IAR documentation and not found anything (but that doesn't mean it is not there.)

We need to flash a disk file to a specified location in the on chip flash (outside of the area where our code loads.)

Thanks!

11 REPLIES 11
David SIORPAES
ST Employee
Posted on February 06, 2017 at 17:29

Here's how to do it with IAR: 

https://www.iar.com/support/tech-notes/general/programming-binary-files-into-flash-within-ewarm/

 
Posted on February 06, 2017 at 17:36

The ST-LINK Utilities also permit the loading of data (.BIN) to arbitrary locations. One could convert a file to .HEX with simple tools, like SRECORD

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on February 06, 2017 at 17:35

Hi David,

Thanks for the reply. I forgot to mention that I had already seen that and was hoping for an easier option.

thanks,

hank

Posted on February 06, 2017 at 17:38

The Keil debugger command line has LOAD / SAVE commands

Your firmware could also implement the ability to send a file and write it to memory.

The other alternative is to create a C array from the file, compile that and have the linker place it in a specific section/address of the micro.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on February 06, 2017 at 17:46

1) We're not using Keil.

2) I've offered to do this. It will be needed eventually when we do not have access to JTAG. Right now we don't know what access we will have.

3) I'm using this technique to include the data in the program that uses it.

I'm downloading the

ST-LINK Utilities to see  what I can do with that. It seems likely to be the lowest friction strategy at this point.

thanks,

hank

Posted on February 06, 2017 at 18:10

Yes, those documents look pretty daunting at first... in the end it's really a matter of adding one line of code to the ICF script and a simple linker option.

Another alternative with IAR would be to use the 'location' pragma to place your data to a specific address, e.g.:

♯ pragma location=0x08004000

const char buffer[] = 'Hi There';

You could use 'xxd -i' to produce a C array from your data file. 

Jeroen3
Senior
Posted on February 06, 2017 at 19:20

You can use bin2c and put it in the 'run before' box. Sure IAR has something like that?

https://sourceforge.net/projects/bin2c/

 

Just create a linker configuration and tell the downloader to skip all but that region.

Posted on February 06, 2017 at 19:27

I think that's the trick. It still requires that I change the file extension to .BIN but that's minimal 'post processing' And I may even be able to override that in the process that builds the data file. It faithfully burns the file to on chip flash.

thanks,

hank

Posted on February 06, 2017 at 19:32

Hi Jeroen3,

IAR does have a process to do that which they describe in 12 steps at

https://www.iar.com/contentassets/554f673197f74bfa9059dd4094d61bee/instructions-how-to-flash-one-bin-file-with-ewarm.pdf

. (Hmmm I wonder if 12 steps is a coincidence. If my reference puzzles you, google '12 step program.'  ) I'm looking for something simpler.