wiki:UsefulTools

Binary converter

There is a tool in DSX python library called elf2blob. It uses objcopy to repackage an elf image to a blob.

It is useful for concatenating different sections to a single image.

It supports:

  • Any binutils-supported target for input
  • Binary blob, Intel-HEX, and MIF output

Usage

If you have your python path correctly set up (See DsxInstall), you can call python -m bintools.elf2blob.

$ python -m bintools.elf2blob --help
Usage: elf2blob.py [options]

Options:
  -h, --help            show this help message and exit
  -c OBJCOPY, --objcopy=OBJCOPY
                        Use given objcopy
  -s SECTIONS, --section=SECTIONS
                        Add section:byte_offset to output file
  -O OUT_FMT, --output-format=OUT_FMT
                        Output file type (binary, hex or mif)
  -o OUTPUT, --output=OUTPUT
                        Output file name
  -w WIDTH, --width=WIDTH
                        MIF word width
  -S SIZE, --size=SIZE  Blob size (bytes)
$
-s
May be given more than once to add many sections

Example

Let's create a blob:

  • to initialize an 8-KiB altera ram (MIF output), in file named sram.mif,
  • from a mips binary named kernel-soclib-mips32el.out,
  • with:
    • .boot at 0
    • .excep at 0x20
    • .text at 0x1400
$ python -m bintools.elf2blob \
    -c mipsel-unknown-elf-objcopy \
    -s .boot:0 -s .excep:0x20 -s .text:0x1400 \
    -O mif -o sram.mif \
    kernel-soclib-mips32el.out
$ 
Last modified 14 years ago Last modified on May 12, 2010, 5:20:11 PM