Forum Discussion

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

NIOS II Command Shell

How to program/download .flash file into flash memory using NIOS II 9.0 Command Shell with serial cable?

4 Replies

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

    1) In case with the "serial cable", you are refering to a USB-Blaster Cable, than you can use the Nios IDE software to download your software in the flash memory.

    2) Some development boards, such as these from TerasIC have a software utility by which you can download whatever file from your PC onto the memories on your board.

    3) You can of course also make a small Nios-II processor that takes input from your serial cable via a UART and fills the information in the Flash memory.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    What is need to type in to IDE command shell to download the flash file to my flash memory. I had tried nios2_flash_programmer, but it says command not found. Is there an example to run like "Hello World"?

    [NiosII EDS]? ....... nios2-flash-programmer.....

    Can the flash file be download with the use of serial port rather through the USB Blaster cable?

    I had tried using flash programmer in the IDE with just the .flash file into flash memory, but it does seem to work. What option should be used for .flash file into flash memory?

    It would be helpful if I have the ability to download using Nios II Command Shell and using Nios II IDE methods.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I use the NiosII Command Shell to program my FPGA This happend in 6 steps using the simple script (prog.sh).

    The arguments are the .SOF file and .ELF file.

    E.g: "sh prog.sh my_top.sof my_software.elf"

    Below following the script code:

    (try that matters to you and take care with the values wich i used for base address, sysid, ...)

    # !/bin/bash

    # ######################################

    #

    # Gravacao do XXXX na flash do PCI Kit

    #

    #

    echo

    echo "------------------------------------------------"

    echo " XXXXXXX"

    echo

    echo " Script para gravacao da logica e software do "

    echo " projeto XXXXXXXXXXXx na flash do PCI Kit "

    echo

    echo " XXXXXX, Built Tue Nov 17 2009"

    echo

    echo "------------------------------------------------"

    sof_file=$1

    elf_file=$2

    echo

    echo

    echo " ARQUIVO SOF: $1"

    echo " ARQUIVO ELF: $2"

    echo

    echo " Gravacao em 6 passos..."

    echo

    echo

    echo

    echo " 1# Creating .flash file for the FPGA configuration"

    echo

    "$SOPC_KIT_NIOS2/bin/sof2flash" --epcs --input="$sof_file" --output="NEW_TOP.flash"

    echo

    echo "2# Programming flash with the FPGA configuration"

    echo

    "$SOPC_KIT_NIOS2/bin/nios2-flash-programmer" --epcs --base=0x04001000 --cable='USB-Blaster [USB-0]' --sidp=0x04030000 --id=1624645854 --timestamp=1258370507 --accept-bad-sysid --instance=0 "NEW_TOP.flash"

    echo

    echo "3# Creating .flash file for the project "

    echo

    "$SOPC_KIT_NIOS2/bin/elf2flash" --epcs --after="NEW_TOP.flash" --input="$elf_file" --output="epcs_flash_controller.flash"

    echo

    echo "4# Programming flash with the project"

    echo

    "$SOPC_KIT_NIOS2/bin/nios2-flash-programmer" --epcs --base=0x04001000 --cable='USB-Blaster [USB-0]' --sidp=0x04030000 --id=1624645854 --timestamp=1258370507 --accept-bad-sysid --instance=0 "epcs_flash_controller.flash"

    echo

    echo "5# Creating .flash file for the datafile"

    echo

    "$SOPC_KIT_NIOS2/bin/bin2flash" --base=0x04001000 --location=0xFF0000 --input="$elf_file" --output="NEW_SOFTWARE.flash"

    echo

    echo "6# Programming flash with the datafile"

    echo

    "$SOPC_KIT_NIOS2/bin/nios2-flash-programmer" --epcs --base=0x04001000 --cable='USB-Blaster [USB-0]' --sidp=0x04030000 --id=1624645854 --timestamp=1258370507 --accept-bad-sysid --instance=0 "NEW_SOFTWARE.flash"

    echo

    echo

    echo "============================="

    echo " FIM DA GRAVACAO!!!"

    echo "verifique se houve erros"

    echo "============================="

    echo

    echo "Obs: Pressione o botao RECONFIGURE na placa PCI"

    echo " ou desligue/ligue para iniciar o sistema."

    echo

    echo

    # the end