8

I am building a binary for ARM using GCC and Crossworks. I have a secondary binary image that needs to be loaded to another IC during start up.

I like to integrate this binary to my tool-chain, in other words, I make this binary part of my image and every time I build this binary gets integrated into the final binary file that will be loaded to the CPU. What is the best practice for this?

Thx

Ktc
  • 2,226
  • 3
  • 26
  • 48

1 Answers1

3

You can use objcopy to transform the binary image into an object file. The object file will contain symbols that can be accessed from C code. Then tell GCC to link the object file in and you can access the symbols in the object file using extern in order to load the data into the other IC.

Here is a good tutorial on how to link in a binary blob including how to file out the options you need to pass to objcopy using objdump.

And of course the objcopy man page and the objdump man page.

embedded.kyle
  • 8,411
  • 2
  • 26
  • 44
  • super answer.. it took me total of 5 mins to make this work.. – Ktc Jul 03 '12 at 03:27
  • Additional question. The obj file is working well however the toolchain places it in RAM which is becoming a problem due to size of the file. How can I force this object to be placed at Flash? – Ktc Jul 06 '12 at 08:27
  • solved it.. basically, objcopy -I binary -O elf32-littlearm -B arm --rename-section .data=.rodata,alloc,load,readonly,data,contents fpga.bin fpga.o this makes the whole thing .rodata and linker places correctly to the flash. – Ktc Jul 06 '12 at 09:57
  • `objcopy` has a massive number of options. It can probably do anything you want. It just requires a lot of staring at that man page. Thanks for sharing your solution as I'm sure that will be a common question for people looking to do what you're doing. – embedded.kyle Jul 06 '12 at 12:42