Forum Discussion

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

cyclone iii nios boot from epcs

cyclone iii nios boot from epcs:

i use nios_flash_programmer to burn fpga+nios to epcs64 ,but do not boot from epcs,i use memtes

to Test EPCS Serial Flash

first time :

----------------------------------

Memory Test Main Menu

----------------------------------

a: Test RAM

b: Test Flash

c: Test EPCS Serial Flash

q: Exit

----------------------------------

Select Choice (a-c): [Followed by <enter>]

Enter the name of the EPCS flash device to be opened,

or just press <enter> to open "/dev/epcs_controller"

> -ERROR: Could not open /d

Press enter to continue...

then stop run again :

----------------------------------

Memory Test Main Menu

----------------------------------

a: Test RAM

b: Test Flash

c: Test EPCS Serial Flash

q: Exit

----------------------------------

Select Choice (a-c): [Followed by <enter>]c

Enter the name of the EPCS flash device to be opened,

or just press <enter> to open "/dev/epcs_controller"

>

-Successfully opened /dev/epcs_controller

-Region 0 contains 128 blocks.

-Checking Region 0 for erased blocks.

-Block 11, at address 0xB0000 identified.

-Would you like to test this block? (y/n)

My qustion is :

1:my hardware is ok ?

2:why do not boot from epcs?

Thanks.

16 Replies

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

    You don't need to know the NIOS app's offset.

    If you've placed the NIOS app right after FPGA image, then the EPCS bootloader will detect the FPGA image, calculate the size of the image, skip it and start executing the NIOS application.

    That's why you have to set the reset vector to the offset 0x0000 of your EPCS Controller (that's where the bootloader is located).

    More details can be found from the following Altera documents:

    - Embedded Peripherals IP User Guide (the section "EPCS Serial Flash Controller Core")

    - Application note 458 "Alternative Nios II Boot Methods"

    Regards,

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

    Correct !

    In fact the FPGA Image is read byte after another so inside the EPCS some kind of actual adresspoint is set and incremented, after the last FPGA image byte, this pointer points to the first byte of the application software and the boot loader can fetch again one byte after another continuing the data stream.

    So just ensure that your application is directly after the fpga image.

    This means whenever you change your application, you need to assemble to complete EPCS image again.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Gotcha..

    I have a little twist...

    Trying to program a .pof on the epcs directly, so in quartus I open the Convert Programming File window. select the fpga sof file, and then add (nios) Hex data immediately after (absolute addressing)

    However, the nios ide outputs an elf and strangely enough it also outputs a file called, "epcs_controller_boot_rom.flash".

    So to generate a hex file that could be used as an input to make an epcs pof file...

    if I do this:

    nios2-elf-objcopy --input-target srec --output-target ihex input.elf output.hex

    it produces a hex file that apparently exceeds the epcs capacity when added after the sof file.

    if I do this:

    nios2-elf-objcopy --input-target srec --output-target ihex epcs_controller_boot_rom.flash output.hex

    Quartus complains that data in hex file overlaps between data blocks at address 1 and address 0.

    However, if I do this:

    1) sof2flash --verbose --compress --epcs --input=input.sof --output fpga.flash

    2) elf2flash --verbose --epcs --after=fpga.flash --input=input.elf --output=app.flash

    3) nios2-elf-objcopy --input-target srec --output-target ihex app.flash output.hex

    Then it fits and I can program it, but at power-on, the nios does not appear to be running (no blinking led). Interestingly, the nCS on the epcs is continuously toggling. I would expect it to be active only during config/boot and then to stay high.

    So long story short, how do you create a epcs .pof file that has the fpga image and nios code??
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi Happy420,

    In SOPC builder (or Qsys), you have added a "epcs_flash_controller" module. This module has a ROM memory in which the "epcs_controller_boot_rom.flash" is stored. This memory contains some code given by altera to load your nios program from the epcs to the processor RAM memory. You don't need to change anything on it. Just tell your processor to start from this memory with the processor's reset_vector set on the epcs_flash_controller.

    To store your program in the epcs, you could try this method I use : http://www.alteraforum.com/forum/showpost.php?p=127299&postcount=2

    For your problem with the nCS pin continuously toggling, It could be that you only have write the nios program in the epcs, but not the VHDL.

    The second ligne creates a flash file with the elf file at an offset the size of the vhdl.flash file. So in your hex file, you have only the nios code beginning at a non zero address.

    You could check if CONF_DONE pin rise or not.

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

    Thanks, I think it's closer! The fpga logic is definitely being booted correctly from the epcs ( have it toggling an i/o), but the nios code doesn't execute at all ( a different i/o).

    The reset vector in the sopc is pointing to the epcs controller peripheral (no offset), and the Nios IDE is setup to have everything run in external sram. If I power-on and allow the epcs to boot the fpga logic, and then I just download the nios code using the ide afterwards, then the nios program also works fine. So it seems it's only the nios portion (either flashed in the epcs or with the bootloader) that has the problem.

    As a test for now, I am flashing both the fpga logic and the nios via the Nios IDE. The tool doesn't have any option to specifically specify the use of "epcs_controller_boot_rom.flash"... so I simply check the box to flash the software project and the FPGA configuration data (pointing to the sof file). During programming I see perform 2 flashes (each with checksum/verify/erase/programming):

    "$SOPC_KIT_NIOS2/bin/nios2-flash-programmer" --epcs --base=0x04121800 --cable='U

    SB-Blaster [USB-0]' --sidp=0x041220b8 --id=519100584 --timestamp=1322097713 "FpgaLogic.flash"

    and

    # Programming flash with the project

    "$SOPC_KIT_NIOS2/bin/nios2-flash-programmer" --epcs --base=0x04121800 --cable='U

    SB-Blaster [USB-0]' --sidp=0x041220b8 --id=519100584 --timestamp=1322097713 "ep

    cs_controller.flash"

    I get no errors when flashing, yet only the fpga logic works on power-on. What can I check for?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi Happy420,

    Could you tell us how is the epcs_controller.flash created ? Actually you don't have to do anything with the epcs_controller_boot_rom.flash, it's already included in the VHDL.

    I just want to exclude any confusing between your code which you have to write in the epcs and the small rom bootloader.

    Regards