1273 - How can I generate an Intel Hex, or an SREC file from the LatticeMico32 ELF file?

1273 - How can I generate an Intel Hex, or an SREC file from the LatticeMico32 ELF file?

The LatticeMico32 C/C++ Software Project Environment (SPE) menu allows the compiled C/C++ code to be deployed to on-chip Embedded Block RAM (EBR), or to parallel Flash memory. There is a command line tool that is run in the background that extracts the data from the ELF output. The program is called lm32-elf-objcopy. The lm32-elf-objcopy executable is capable of translating the ELF format into multiple different forms. The objcopy executable is a component of the GNU binutils package. It is documented as part of the GNU binutils toolset. Some example commands:
  • Create an Intel Hex image of the LM32 ELF data
    lm32-elf-objcopy -I elf32-lm32 -O ihex yourcode.elf yourcode.mcs
  • Create a SREC image
    lm32-elf-objcopy -I elf32-lm32 -O srec yourcode.elf yourcode.s0
  • Extract just the boot segment and store it as binary
    lm32-elf-objcopy -I elf32-lm32 -O binary --only-section .boot yourcode.elf yourboot.bin
Use the --info switch to get information about the supported memory formats, and use --help to get general command line assistance.