Nios® V Processor Software Developer Handbook

ID 743810
Date 7/08/2024
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

16.2.2.1. elf2hex

Synopsis

elf2hex [OPTIONS] <ELF FILE> <HEX FILE>

Description

The elf2hex utility converts the software and data within an .elf file in the address range [base, end] into a .hex file that can be used as the initialization data for a memory component. The width option is to ensure that the resulting .hex file is formatted properly for its corresponding memory component.

This utility can also create lane files which are used to initialize multi-laned memory components. The maximum address span between base and end is 1 GByte (0x4000_0000).

Usage

#Generate hex file for OCM Memory initialization
elf2hex <elf input file> -b <On-chip memory start address> -w <On-chip memory data width in bits> -e <On-chip memory end address> -r 4 -o <hex output file>

Example: elf2hex software/app/build/hello.elf  -b 0x0 -w 32 -e 0x4FFFF -r 4 -o ram.hex
Table 55.  Options
Options Description
-b,--base <addr> Hex data base address
--big-endian-mem Force big-endian memory layout
--debug Debug mode
-e,--end <addr> Hex data end address
-h,--help Print this message
-i,--input <file> Input ELF file to process
-l,--create-lanes <value> 1 if lane files should be created
--little-endian-mem Force little-endian memory layout
--log <file> File for logging progress
--lower If you prefer your hex in lower case
--no-zero-fill No zero fill of empty sections
-o,--output <file> Output Hex file
-q,--quiet Only print errors
-r,--record <length> Output record length (--width in bytes)
-s,--silent Silent mode - same as quiet
-v,--verbose Lots of interesting information
-w,--width <value> Data width of the memory [ 8 | 16 | 32 | 39 | 64 | 128]