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?



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.

  • \$\begingroup\$ super answer.. it took me total of 5 mins to make this work.. \$\endgroup\$
    – Ktc
    Jul 3 '12 at 3:27
  • \$\begingroup\$ 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? \$\endgroup\$
    – Ktc
    Jul 6 '12 at 8:27
  • \$\begingroup\$ 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. \$\endgroup\$
    – Ktc
    Jul 6 '12 at 9:57
  • \$\begingroup\$ 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. \$\endgroup\$ Jul 6 '12 at 12:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.