Forum Discussion

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

Quick nios2-flash-programmer question

Hi.

Does anyone know if its possible to program multiple software (elf / flash) applications into a single flash device, where each program is located at a different address? If so, how may this be done?

I saw another thread asking this very question, but the answer was to use the --offset tag with elf2flash, however, this tag does not seem to be supported anymore (was it ever?).

Thanks a bunch,

Kevin

(P.S. Does anyone else have issues with the 'search' tool on this forum? It never returns decent results)

2 Replies

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

    two possibilities done with script files (not from ide)

    nios2 .flash files are srec files

    1.

    a) use elf2flash to generate flash-file from elf-file

    http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/cool.gif use nios2-elf-objcopy to change address of srec file

    2.

    a) use elf2flash to generate flash-file from elf-file

    http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/cool.gif use nios2-elf-objcopy to generate binary file from flash-file

    c) use bin2flash to generate again flash-file at new offset

    sample script for 1.

    SRCNAME=hello_world_0

    FLASH_OFFSET=0x100000 # where program is stored in flash

    SRC_FILE=./src/$SRCNAME.elf

    DST_FILE=./flash_files/$SRCNAME.flash

    DST_FILE_OFF="./flash_files/"$SRCNAME"_"$FLASH_OFFSET".flash"

    echo ----------------------------------------------------------------------------

    echo "START elf2flash"

    FLASHBASE=0x000000 # BASEADDRESS OF FLASH

    FLASHEND=0x7FFFFF

    RESETADDRESS=0x000000

    FLASH_ID=U1

    BOOTLOADER=boot_loader_cfi.srec # BOOTLOADER

    echo "ELF FILE : "$SRC_FILE

    echo "FLASH FILE : "$DST_FILE

    echo "BOOTLOADER : "$BOOTLOADER

    echo "FLASH ID : "$FLASH_ID

    echo "FLASH BASE ADD : "$FLASHBASE

    echo "FLASH END ADD : "$FLASHEND

    echo "RESET ADD : "$RESETADDRESS

    elf2flash --input=$SRC_FILE --output=$DST_FILE --base=$FLASHBASE --end=$FLASHEND --boot=$BOOTLOADER --reset=$RESETADDRESS --flash=$FLASH_ID --verbose

    echo ----------------------------------------------------------------------------

    echo "START objcopy"

    echo "INPUT FLASH FILE : "$DST_FILE

    echo "OUTPUT FLASH FILE : "$DST_FILE_OFF

    echo "OFFSET IN FLASH : "$FLASH_OFFSET

    nios2-elf-objcopy -v -I srec -O srec --srec-forceS3 --srec-len 32 --change-addresses $FLASH_OFFSET $DST_FILE $DST_FILE_OFF

    echo ----------------------------------------------------------------------------

    echo "START quartus_programmer"

    BOARD_CONF_FILE=b12dal03_fpga.sof # PATH TO FLASH PROGRAMMER BOARD FILE

    JTAG_DEVICE=2 # NO OF DEVICE in JTAG_CHAIN

    echo "BOARD_CONF_FILE: "$BOARD_CONF_FILE

    echo "JTAG-DEVICE : "$JTAG_DEVICE

    quartus_pgm --cable="USB-Blaster [USB-0]" --mode=JTAG --operation="p;$BOARD_CONF_FILE@$JTAG_DEVICE"

    echo ----------------------------------------------------------------------------

    FLASH_FILE=$DST_FILE_OFF

    BASEFLASH=0x00000000 # BASEADDRESS OF FLASH

    echo "START nios2-flash-programmer"

    echo "FLASH FILE : "$FLASH_FILE

    echo "JTAG-DEVICE : "$JTAG_DEVICE

    echo "FLASH BASE ADD : "$BASEFLASH

    nios2-flash-programmer --debug --device=$JTAG_DEVICE --accept-bad-sysid --base=$BASEFLASH $FLASH_FILE
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Wowha! How did I miss all of those GNU tools?! Bonus! Thanks a bunch,

    Kevin

    --- Quote Start ---

    originally posted by fischer@Aug 10 2006, 03:43 PM

    two possibilities done with script files (not from ide)

    nios2 .flash files are srec files

    1.

    a) use elf2flash to generate flash-file from elf-file

    http://forum.niosforum.com/work2/style_emoticons/<#emo_dir#>/cool.gif use nios2-elf-objcopy to change address of srec file

    2.

    a) use elf2flash to generate flash-file from elf-file

    http://forum.niosforum.com/work2/style_emoticons/<#emo_dir#>/cool.gif use nios2-elf-objcopy to generate binary file from flash-file

    c) use bin2flash to generate again flash-file at new offset

    sample script for 1.

    srcname=hello_world_0

    flash_offset=0x100000 # where program is stored in flash

    src_file=./src/$srcname.elf

    dst_file=./flash_files/$srcname.flash

    dst_file_off="./flash_files/"$srcname"_"$flash_offset".flash"

    echo ----------------------------------------------------------------------------

    echo "start elf2flash"

    flashbase=0x000000 # baseaddress of flash

    flashend=0x7fffff

    resetaddress=0x000000

    flash_id=u1

    bootloader=boot_loader_cfi.srec # bootloader

    echo "elf file : "$src_file

    echo "flash file : "$dst_file

    echo "bootloader : "$bootloader

    echo "flash id : "$flash_id

    echo "flash base add : "$flashbase

    echo "flash end add : "$flashend

    echo "reset add : "$resetaddress

    elf2flash --input=$src_file --output=$dst_file --base=$flashbase --end=$flashend --boot=$bootloader --reset=$resetaddress --flash=$flash_id --verbose

    echo ----------------------------------------------------------------------------

    echo "start objcopy"

    echo "input flash file : "$dst_file

    echo "output flash file : "$dst_file_off

    echo "offset in flash : "$flash_offset

    nios2-elf-objcopy -v -i srec -o srec --srec-forces3 --srec-len 32 --change-addresses $flash_offset $dst_file $dst_file_off

    echo ----------------------------------------------------------------------------

    echo "start quartus_programmer"

    board_conf_file=b12dal03_fpga.sof # path to flash programmer board file

    jtag_device=2 # no of device in jtag_chain

    echo "board_conf_file: "$board_conf_file

    echo "jtag-device : "$jtag_device

    quartus_pgm --cable="usb-blaster [usb-0]" --mode=jtag --operation="p;$board_conf_file@$jtag_device"

    echo ----------------------------------------------------------------------------

    flash_file=$dst_file_off

    baseflash=0x00000000 # baseaddress of flash

    echo "start nios2-flash-programmer"

    echo "flash file : "$flash_file

    echo "jtag-device : "$jtag_device

    echo "flash base add : "$baseflash

    nios2-flash-programmer --debug --device=$jtag_device --accept-bad-sysid --base=$baseflash $flash_file

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

    --- quote end ---

    --- Quote End ---