| | 1 | = Binary converter = |
| | 2 | |
| | 3 | There is a tool in DSX python library called elf2blob. It uses objcopy to repackage an elf image to a blob. |
| | 4 | |
| | 5 | It is useful for concatenating different sections to a single image. |
| | 6 | |
| | 7 | It supports: |
| | 8 | * Any binutils-supported target for input |
| | 9 | * Binary blob, Intel-HEX, and MIF output |
| | 10 | |
| | 11 | == Usage == |
| | 12 | |
| | 13 | If you have your python path correctly set up (See DsxInstall), you can call {{{python -m bintools.elf2blob}}}. |
| | 14 | |
| | 15 | {{{ |
| | 16 | $ python -m bintools.elf2blob --help |
| | 17 | Usage: elf2blob.py [options] |
| | 18 | |
| | 19 | Options: |
| | 20 | -h, --help show this help message and exit |
| | 21 | -c OBJCOPY, --objcopy=OBJCOPY |
| | 22 | Use given objcopy |
| | 23 | -s SECTIONS, --section=SECTIONS |
| | 24 | Add section:byte_offset to output file |
| | 25 | -O OUT_FMT, --output-format=OUT_FMT |
| | 26 | Output file type (binary, hex or mif) |
| | 27 | -o OUTPUT, --output=OUTPUT |
| | 28 | Output file name |
| | 29 | -w WIDTH, --width=WIDTH |
| | 30 | MIF word width |
| | 31 | -S SIZE, --size=SIZE Blob size (bytes) |
| | 32 | $ |
| | 33 | }}} |
| | 34 | |
| | 35 | `-s`:: |
| | 36 | May be given more than once to add many sections |
| | 37 | |
| | 38 | == Example == |
| | 39 | |
| | 40 | Let's create a blob: |
| | 41 | * to initialize an 8-KiB altera ram (MIF output), in file named `sram.mif`, |
| | 42 | * from a mips binary named `kernel-soclib-mips32el.out`, |
| | 43 | * with: |
| | 44 | * .boot at 0 |
| | 45 | * .excep at 0x20 |
| | 46 | * .text at 0x1400 |
| | 47 | |
| | 48 | {{{ |
| | 49 | $ python -m bintools.elf2blob \ |
| | 50 | -c mipsel-unknown-elf-objcopy \ |
| | 51 | -s .boot:0 -s .excep:0x20 -s .text:0x1400 \ |
| | 52 | -O mif -o sram.mif \ |
| | 53 | kernel-soclib-mips32el.out |
| | 54 | $ |
| | 55 | }}} |
| | 56 | |