Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

How do I create .hex or .flash files in IDE?

Hi,

I am trying to get the IDE to automatically create a .hex or .flash file each time I build my project in the IDE.

I have searched the altera docs and think that what I need is the "mem_init.mk", but the docs don't explain how to use/enable it.

Does anyone know how to do it?

Thanks

Cliff

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    hi,

    use the nios II command shell and sof2flash/elf2flash/nios2-elf-objcopy programs. options depend on your needs.

    # 1) Convert SOF to Flash

    sof2flash --input=filename.sof --output=hwimage.flash --epcs --verbose# 2) Convert ELF to Flash

    elf2flash --input=../filename.elf --output=swimage.flash --epcs --after=hwimage.flash --verbose# 3) Concatenate

    cp hwimage.flash hw_sw.flash

    cat swimage.flash >> hw_sw.flash

    # 4) Create HexFile

    nios2-elf-objcopy -I srec -O ihex hw_sw.flash hw_sw.hex

    i use it in a tcl script and run it with nios II shell.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    The application Makefile has a 'mem_init_install' target that uses the BSP mem_init.mk.

    Here is the help target from a Nios II application project Makefile for reference

    help :

    @$(ECHO) "Summary of Makefile targets"

    @$(ECHO) " Build targets:"

    @$(ECHO) " all (default) - Application and all libraries (including BSP)"

    @$(ECHO) " bsp - Just the BSP"

    @$(ECHO) " libs - All libraries (including BSP)"

    @$(ECHO) " flash - All flash files"

    @$(ECHO) " mem_init_generate - All memory initialization files"

    @$(ECHO) " mem_init_install - All memory initialization files (copy files to Quartus II project)"

    @$(ECHO) " Clean targets:"

    @$(ECHO) " clean_all - Application and all libraries (including BSP)"

    @$(ECHO) " clean - Just the application"

    @$(ECHO) " clean_bsp - Just the BSP"

    @$(ECHO) " clean_libs - All libraries (including BSP)"

    @$(ECHO) " Run targets:"

    @$(ECHO) " download-elf - Download and run your elf executable"

    @$(ECHO) " program-flash - Program flash contents to the board"