0

there is a hex file from a C project. I want to download this hex file on LPC1768's flash with some raw data which I use it in the code on runtime ( for initializing data in the code ). I know when I write it on the board, in the run time, LPC1768 copies data from flash on the memory.

problem 1: how to download raw data with hex file, with jflash?

problem 2: how can I find where the raw data copied on the memory, to use it in the runtime?

Babak
  • 176
  • 1
  • 4
  • 18

3 Answers3

1

This seems similar to me to the questions:

Include binary file with GNU ld linker script

linking arbitrary data using GCC ARM toolchain

You can convert your raw data to an object file and then link it with your code to produce a hex file containing both which you then upload as usual. The linker will define special symbols that tell you where your data starts and ends in the memory. Check the links above for more info and an example.

Community
  • 1
  • 1
11temp
  • 21
  • 2
  • is there any way to do this without linker( download hex file and binary data with jtag seperately)? – Babak Aug 05 '13 at 07:06
  • 1
    Well, you could write a simple program which would append your data to the hex file at a chosen empty address range and then upload such a hex file. The format of the hex file is pretty simple http://en.wikipedia.org/wiki/Intel_HEX Other then that I don't know. – 11temp Aug 05 '13 at 21:11
  • You have to specify what address the data will end up in memory when you append it to your hex file, just make sure it is an empty range and valid for your microcontroler. Once the hex file is uploaded you can access the data at that address. – 11temp Aug 06 '13 at 11:28
0

You can convert binary data to C, for example with bin2c. Then just add the generated C code to your project.

The generated code will looke like this:

const unsigned char binary_data[] = {
    0x4D, 0x5A, 0x90, 0x00, //...
}

It will end up as read-only data in flash, which does not get copied into RAM unless you use an unusual linker skript.

The generation of the C code from a binary can be automated in a Makefile. I've seen this in the OpenOCD project for example.

Turbo J
  • 7,563
  • 1
  • 23
  • 43
0

you may considered using Flash Magic to download the hex file into flash memory. It only downloads the hex. you may not be able to debug the code, though.

Are you trying to reverse engineer something??

madD7
  • 823
  • 10
  • 23