Forum Discussion

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

How can I start different programs from flash.

How can I start different programs from flash.

Dependend on a configuration structure in flash I want to start different

programs from flash.

the reset vector in SOPC Builder should always point to address 0x000000

in flash.

it then starts a self made factory programmed bootloader at 0x000000,

,which itself should be able to start different programs from flash,

eg. program 1 at 0x100000 (in flash), program 2 at 0x200000 (in flash)

till now I'm able to receive serial S-Records and write them into flash

I had a look at the altera bootloader, and I think the programs are stored

in flash in a special format:

from bootloader.S# | dvb2004: Each "program record" looks like so:# | 4 bytes Length L# | 4 bytes Address A

How can I convert the .elf files to S-Record files with different address

regions in flash ?

Each program should have the altera booltloader in front, which copies the

program to the sram.

How can I make a jump to the different programs (from c-code), perhaps

small assembler routine.

thanks

4 Replies

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

    elf2flash Converts an .elf executable file to a .flash file for programming into flash memory.

    Or try

    page 1–6 of the

    Nios II Flash Programmer User Guide

    it's in the install, or on the web.

    You acn always do searched in pdf docs (not FIND - a SEARCH). This allows you to search all pdf docs for a word (in this case elf). THen you can expand the findings and see which one you want to look at.

    Tell me if this helps.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I want to update the software over a serial HDLC link.

    My own bootloader at address 0x0000 in flash is not allowed

    to be overwritten. This bootloader is a normal C-program with drivers for

    HDLC etc.

    Therefore it's not possible to use the NIOS II Flash programmer.

    My own bootloader can receive files in S-RECORD format.

    to download a program in another flash region,

    I changed the address of the normal .flash file

    (Resetvector from SOPC was 0x000000(flash) and compiler settings

    are "program memory (.text) = ext ram")

    with

    "nios2-elf-objcopy -I srec -O srec --srec-forceS3 --srec-len 32

    --change-addresses 0x200000 ext_flash.flash ext2_flash.flash"

    My bootloader stored the program, which should normally be at flash address

    0x000000, at flash address 0x200000.

    Then i made a simple

    asm("call 0x200000");

    in my bootloader program and the new program seams to start ok.

    It seems that the small altera bootloader in front of the program

    is not disturbed by the address shift ???

    I don't know if this is a good solution for making software updates and if it

    works correctly in every case ?

    Also how can I make the asm call variable ?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Your objcopy solution to relocation is a great idea; a really innovative solution to multi-boot. It will continue to work just fine in the future because the boot-loader is fully relocateable.

    As for parameterizing your 'asm("call 0x200000");' statement, take a look in the GNU documentation included with the kit under "Assembler Instructions with C Expression Operands". Just about any permutation of "take the value of a C variable and manipulate it in assembly" is covered there.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I changed the static asm call to

    void (*pBoot)(void); // declare function pointer

    int startadd; // declare startaddress as integer

    ..

    ..

    startadd=0x200000;

    pBoot=(void*)startadd;

    pBoot(); // jump to new altera bootloader in flash

    and this seems to work.

    hope to get some more opinions or better solutions for updating software.