Forum Discussion

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

Nios 5.1, elf2flash ignores base address?

I have just upgraded from Version 5 to Version 5.1

The generated command line is this:

elf2flash --input=LynxApp.elf --flash=IC2 --boot=c:/altera/kits/nios2_51/components/altera_nios2/boot_loader_cfi.srec --outfile=cfi_flash_0.flash --sim_optimize=0 --base=0x100000 --end=0x1FFFFF --reset=0x100000

If I create a text file called "flash" with the following contents and do "source flash" from the "Nios command line"....

elf2flash --input=LynxApp.elf --boot=c:/altera/kits/nios2_51/components/altera_nios2/boot_loader_cfi.srec --outfile=cfi_flash_0.flash --base=0x200000 --end=0x2FFFFF --reset=0x200000

...the same output is generated.

Thus S-records are produced such as

S325000000003A7001007400C0043A48019804F8FF9C1EFD3F983A2000003AE02E00062000008B

When they should be

S325001000003A7001007400C0043A48019804F8FF9C1EFD3F983A2000003AE02E00062000007B

Have I missed something, or is there something wrong with elf2flash? I note there are changes in elf2flash.jar

6 Replies

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

    Hi JasonDiplomat,

    > Have I missed something, or is there something wrong with elf2flash?

    You missed something -- you're specifying a boot copier -- so your elf sections

    get translated into boot records that follow the boot copier code.

    > S325000000003A700100 ...

    This is the boot copier code at offset 0 in your flash device.

    To get a better feel for what's going on, compare the outputs of the following:

    $ elf2flash --input=LynxApp.elf --flash=IC2

    --base=0x100000 --end=0x1FFFFF --reset=0x100000

    --output=boot.flash

    --boot=$SOPC_KIT_NIOS2/components/altera_nios2/boot_loader_cfi.srec

    $ elf2flash --input=LynxApp.elf --flash=IC2

    --base=0x100000 --end=0x1FFFFF --reset=0x100000

    --output=noboot.flash

    Regards,

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

    If I try the noboot example, I get an error "Boot copier file name required".

    The boot copier is required since I run the code in SRAM.

    What does bother me is the "IC2" reference, which I believe I had used as part of a board description in the previous Quartus version, but which is not visible now (there are no board descriptions showing in SOPC builder).
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    > If I try the noboot example, I get an error "Boot copier file name required".

    > The boot copier is required since I run the code in SRAM.

    ** Sigh **

    $ elf2flash --input=LynxApp.elf --base=0 --end=0x7fffffff --output=noboot.flash

    Regardless, I don't think elf2flash is broken ;-)

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

    $ elf2flash --input=LynxApp.elf --base=0 --end=0x7fffffff --output=noboot.flash

    This ^^^ produces a SREC file which addresses the SRAM - that's not what I need!

    I now don't believe elf2flash is broken either, since I've looked closer at the differences between the two versions. Which implies that something's being set in the ELF, which I'm currently unable to detect differences to the existing released version built with quartus/nios version 5.

    And I've just added a board description, just specifying the flash memory, and now SOPC builder complains that "onchip memory *** cannot operate with ."

    I'm just going to have to modify the flash programmer code to add the offset. This has been an expensive day.

    Is there any source code available for elf2flash so I can see how it performs the boot code merge?

    Do I need an "install.ptf" file?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    > This ^^^ produces a SREC file which addresses the SRAM - that's not what I need!

    Of course not! But ...

    > Have I missed something, or is there something wrong with elf2flash?

    ... your original question has been answered.

    Let&#39;s try another way. From my earlier post: <div class='quotetop'>QUOTE </div>

    --- Quote Start ---

    This is the boot copier code at offset 0 in your flash device.[/b]

    --- Quote End ---

    and, from the Nios II Flash Programmer User Guide, October 2005 (Emphasis added):<div class='quotetop'>QUOTE </div>

    --- Quote Start ---

    nios2-flash-programmer can use any S-record file as an input, provided

    that the addresses specified in the S-record file represent

    offsets from the beginning of flash memory .[/b]

    --- Quote End ---

    > I&#39;m just going to have to modify the flash programmer code to add the offset.

    You might want to grab another cup of coffee and mull it over a bit before

    doing this.

    Regards,

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

    Ahhh - you&#39;ve answered what my question should really have been (i.e. has Altera decided to change SREC addresses from absolute to relative).

    I don&#39;t use nios2-flash-programmer, I use my own handwritten one. I just needed to add a single line of code to fix it, and I&#39;m now happy in the knowledge that Altera aren&#39;t going to release a "fix" in a few weeks that would break it.