Forum Discussion

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

Update bitstream and kernel in flash from Linux : A clean way to generate binary file

Hi all,

I wish to update my entire system from a running Linux by changing Flash content : changing bitstream and kernel.

My flash is partitioned with 2 area : bitstream (4MB ) and kernel (4MB ).

My main issue is that using altera tools to convert sof2flash and elf2flash I do not have intermediary files : raw binary files that I can write to my flash using

cp <file> /dev/mtdX
I only get srec files that are not usable from Linux to Flash my external memory (as far as I know, but maybe there is a tool to write srec files from nios2-linux)

Ok I have already binary file : the .sof and my zImage but :

  • sof2flash adds (or remove) some headers and configure bitstream loading mode : in my case active parallel

  • elf2flash adds a bootloader before my zImage

So I need to pass through sof2flash and elf2flash. Unfortunately those software does not provide binary format of the generated files ....

So the most automated way I found is to :

  1. Flash my board using Altera tools (elf2flash, sof2flash and nios2-flash-programmer)

  2. Read back partitions from flash using
    nios2-flash-programmer -B <ADD>+<SIZE> -R zImage.tmp --base=0x08000000

  3. use srec_cat
    srec_cat -output zImage.bin -binary zImage.tmp

Doing this I have a zImage.bin adapted to my Flash with a bootloader inside.

I can also dump the flash from linux and then transfer it using ftp but I cannot automate the process easily.

Does someone has a better solution ??

Best regards

1 Reply

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

    You can use nios2-elf-objcopy on the SREC like so:

    
    elf2flash --base=0xc1000000 --end=0xc1FFFFFF --reset=0xc1540020 --input=zImage --output=zImage.flash --boot=/opt/altera/nios2eds/components/altera_nios2/boot_loader_cfi.srec && nios2-elf-objcopy -I srec -O binary zImage.flash /data/nios/nios2-linux/zImage.bin