Forum Discussion

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

Booting Nios2 from custom NV-RAM

I tried this question on comp.arch.fpga newsgroup - no answer. Here is probably a better place to ask.

Preface:

When the Nios2 CPU reset vector points into Altera-provided CFI flash the SOPC Builder automatically adds following lines to the system ptf file:

WIZARD_SCRIPT_ARGUMENTS

{

MAKE

{

MACRO

{

FLASH_FLASHTARGET_ALT_SIM_PREFIX =

"$(FLASH_FLASHTARGET_TMP1:0=)";

FLASH_FLASHTARGET_TMP1 =

"$(ALT_SIM_OPTIMIZE:1=RUN_ON_HDL_SIMULATOR_ONLY_)";

}

MASTER cpu

{

MACRO

{

BOOT_COPIER = "boot_loader_cfi.srec";

CPU_CLASS = "altera_nios2";

CPU_RESET_ADDRESS = "0x0";

}

}

TARGET delete_placeholder_warning

{

flash

{

Command1 = "rm -f

$(SIMDIR)/contents_file_warning.txt";

Is_Phony = "1";

Target_File = "do_delete_placeholder_warning";

}

}

TARGET flashfiles

{

flash

{

Command1 = "@echo Post-processing to create $(notdir

$@)";

Command2 = "elf2flash --input=$(ELF) --flash=

--boot=$(shell

$(QUARTUS_ROOTDIR)/sopc_builder/bin/find_sopc_component_dir

$(CPU_CLASS) $(QUARTUS_PROJECT_DIR))/$(BOOT_COPIER)

--outfile=$(FLASH_FLASHTARGET_ALT_SIM_PREFIX)flash.flash

--sim_optimize=$(ALT_SIM_OPTIMIZE) --base=0x0 --end=0x1FFFFFF

--reset=$(CPU_RESET_ADDRESS) ";

Dependency = "$(ELF)";

Target_File =

"$(FLASH_FLASHTARGET_ALT_SIM_PREFIX)flash.flash";

}

}

TARGET sim

{

flash

{

Command1 = "if [ ! -d $(SIMDIR) ]; then mkdir

$(SIMDIR) ; fi";

Command2 = "@echo Hardware simulation is not enabled

for the target SOPC Builder system. Skipping creation of hardware

simulation model contents and simulation symbol files. \\(Note: This

does not affect the instruction set simulator.\\)";

Command3 = "touch $(SIMDIR)/dummy_file";

Dependency = "$(ELF)";

Target_File = "$(SIMDIR)/dummy_file";

}

}

}

}

Later on when Nios2 IDE discovers that the .text section has to be copied/relocated it adds the required commands to the makefile. That's nice because this way we never forget to run elf2flash utility at the end of the make process and at the same time could take full advantage from other aspects of automatic makefile generation in Nios2 IDE.

The Question:

How do I get the same functionality for custom non-volatile memory component that has NOR-flash compatible read interface?

The file class.ptf under "\kits\nios2_51\components\altera_avalon_cfi_flash" directory contains nothing resembling the required lines.

Of course, it is possible to manually edit either the system .ptf file or the makefile generated by IDE, but I prefer more version-control friendly solution.

3 Replies

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

    If you are using NVRAM instead of Flash you may place the component into SOPC builder as a normal RAM memory (the IDT SRAM for example). You will get a warning that the reset and exception address is pointing to a volatile memory, but you can ignore it.

    Than instead of writing the code into Flash, just download (Run) it into NVRAM. The code should stay there after a power up sequence. In the properties dialog for the project library you van select which part of the code should be placed into NVRAM (only .text or variables too, the stack? ...).

    If you would like to automate the process, subversion friendly, than modify the flash programmer script to use the nios2-download executable instead of the flash programmer.

    You may have to add some format conversions if you would like to use the Altera provided boot loader.

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

    --- Quote Start ---

    originally posted by iztok.jeras@Nov 15 2006, 02:30 PM

    if you are using nvram instead of flash you may place the component into sopc builder as a normal ram memory (the idt sram for example). you will get a warning that the reset and exception address is pointing to a volatile memory, but you can ignore it.

    than instead of writing the code into flash, just download (run) it into nvram. the code should stay there after a power up sequence. in the properties dialog for the project library you van select which part of the code should be placed into nvram (only .text or variables too, the stack? ...).

    if you would like to automate the process, subversion friendly, than modify the flash programmer script to use the nios2-download executable instead of the flash programmer.

    you may have to add some format conversions if you would like to use the altera provided boot loader.

    izi

    <div align='right'><{post_snapback}> (index.php?act=findpost&pid=19444)

    --- quote end ---

    --- Quote End ---

    I&#39;m not "using NVRAM instead of Flash". My NV-RAM _is_ Flash. I just don&#39;t like Altera-provided CFI flash component so I replaced it with my own.

    Now I want SOPC Builder/Nios2 IDE to automatically place proper conversion commands in my makefile in the same way it does for Altera&#39;s CFI flash component.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Than you may modify the Altera provided component to satisfy your needs (I do not know how to exactly do that, but you should probably know some scripting language). Or manually modify the .ptf file, it will not open gracefully in SOPC builder, but should be OK when you finish the hardware and focus on software.

    IzI