views:

148

answers:

3

I am looking for recommendations for a tool that will let me construct a binary image out of a series of smaller images.

I have an embedded system with a flash ROM that I program using a single image. That image consists of a series of smaller objects (data, compiled code, etc) placed at specific offsets. The build system I inherited uses a disturbing amalgam of old 16-bit DOS utilities to hack the image together. I was hoping to find a modern tool that would do the job in a less arcane (and less bug-prone) manner.

The tool needs to be able to run from a config file. That is, I specify that file A.bin needs to be placed at offset 4KB, file B.bin needs to be placed at offset 16KB, etc etc in a configuration file so that the tool does not require repeated manual command-line invocations. This is mainly because we have another system that will be auto-generating these config files.

The tool also needs to be open source (or at a minimum, cross-platform). We have developers using Windows and automated build systems using Linux and the tool would need to work on both.

I have debated hacking together my own utility in C, but before I went through all the trouble developing and debugging I wanted to ask and see if someone knew of a tool that was already out there that I missed.

Edit: Cygwin-related tools are unfortunately not an option for us. One of our critical build tools will crash if it is run on a system with Cygwin installed (I think it uses a specific, older cygwin DLL but that's an entirely different fiasco unto itself).

+1  A: 

dd would be definitively your best friend.

Use cygwin for windows users.

Kornel Kisielewicz
I thought about `dd` initially, but I would have to call `dd` once for each component added to the binary image. Given the nature of the build system I've inherited, a tool that build the entire ROM image with a single invocation would be highly preferable.
bta
Write a shell, python, ruby, or perl script that takes multiple arguments and repeatedly calls dd?
Sam Post
Cygwin just to run dd!? A sledgehammer and nut situation methinks! ;-) Only if you already have Cygwin installed I suggest; otherwise use http://unxutils.sourceforge.net/
Clifford
+2  A: 

I usually write my own, but via Jack Ganssle's Embedded Muse newsletter No. 184 I came across http://srecord.sourceforge.net/ which will do just about anything with almost any type of binary image file (despite its name it handles far more formats than just Motorola S-Records, including raw binaries). It may save you some time.

Clifford
I'll second that recommendation. `Srecord` is a very useful tool for this sort of thing. I've used it on several projects; much better than what was done previously, which was to write a custom tool in C/C++.
Craig McQueen
Thanks for the recommendation. `Srecord` seems to be a very flexible utility indeed. It's not 100% of what we need, but I should be able to add in the remaining functionality fairly easily (much better than building my own from scratch).
bta
A: 

The Elfweaver utility that is distributed with OKL4 may be appropriate for you. From the manual: "Elfweaver is a tool that may be used to manipulate ELF files. Elfweaver is written as a Python 2.3 application that only uses cross-platform libraries. Therefore Elfweaver should run on Linux, Mac-OS X and Windows. The main functionality of Elfweaver is that it allows the user to merge multiple ELF files into a single ELF file" http://wiki.ok-labs.com/downloads/release-3.0/okl4-ref-manual-3.0.pdf

If you think that looks suitable, you can get the tool along with the okl4 source code from the OKL4 website.

inertial