Forum Discussion

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

Is there a way to combine sof and elf files ?

Hi,

I am trying to download my sof and elf in a multiprocessor Nios system. I know that it can be done separately (convert sof to flash and then the elf to flash and then use the command line), but

1. is it possible to just load the elf inside the sof and then place this sof in the flash ??

2. I have read at a few places that using the elf2hex can help as then its possible to use this hex as a memory initialization file but I cant seem to find it in the Altera documentation. Has anyone done something similar before ?

Any suggestions are welcome.

Thanks !

17 Replies

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

    Actually my requirement is to combine the .elf with the .sof

    And now i have made my .hex(NIOS exe) as a memory initialization file to a onchip rom..and set the reset address of nios to this memory

    I followed the instructions given above , but could not succed
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    There wasn't any error, the onchip-memory(rom) was not getting initialized.

    I solved the problem now.I had set that particular module which has the onchip-memory(rom) as DESIGN PARTITION then.so it was not compiling the newly added changes.

    Now it is working obsolutely fine after i deselected the SET AS DESIGN PARTITION option for that module and the nios is executing from the onchip -ROM
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi

    I am trying to do the same thing by following the instructions of this post.

    However, in my case, only the sof file works and the elf file is not working.

    I'm wondering if I miss anything and hope someone could kindly help me.

    I have a simple project which controls two leds.

    After the sof file is downloaded, the second led is on.

    If the elf file is working on the NiosII CPU, the first led blinks.

    I cannot see the led blink after I download sof file which initializes the on-chip memory with the hex file converted from elf.

    Here are some detailed steps:

    1. The reset vector of NiosII CPU is already set in the on-chip memory.

    (Please see my attached qsys file)

    2. The "Enable non-default initialization file" option is checked. The initialization file is "my_nios2_mem" which locates in the root of my project.

    3. The "my_nios2_mem.hex" is generated from elf file with the following command:

    bash-3.1$ elf2hex --input=sof_elf_epcs_niosii.elf --output=my_nios2_mem.hex --base=0x00000000 --end=0x0003ffff --width=32
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Check that the correct .hex file is placed in the Quartus project folder and that Quartus finds it when you recompile the project. Unfortunately if it doesn't find the file it won't generate an error but just a warning (maybe a critical warning, I don't remember) so it can be easy to miss.

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

    Hi Daixiwen

    Thanks for your reply.

    If the hex file cannot be found, there will be a critical warning as you remember.

    I had this critical warning in the beginning and I have solved it already.

    So I believe Quartus II can find the hex file.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    IIRC Quartus has a tool that can let you look into single port internal FPGA memory blocks. Maybe you can use it to check that the CPU's RAM has the correct image and not just an empty one.