Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12690 Discussions

elf2flash and bootloader questions

Altera_Forum
Honored Contributor II
1,650 Views

I'm trying (so far in vain) to get RedBoot to run from flash. The ROMRAM startup version of RedBoot works fine when loaded into RAM via JTAG, but the ROM startup version of RedBoot doesn't run when programmed into flash. Other stand-alone programs seem to work fine when programmed in flash. 

 

I see that the instructions mention some proprietary tool called elf2flash. It appears to be used instead of the standard Gnu binutils programs to generate an srec file. There also seems to be a "bootloader" srec file involved. I can find no detailed documentation on either elf2flash or the mysterious external bootloader which appears to be available only as an srec file.[list][*]What exactly does "elf2flash" do?[*]Why can't "objcopy" be used like all other normal eCos targets?[*]What is the external bootloader .srec file for? 

[*]Why would a ROM-resident bootloader like RedBoot require a second bootloader? 

[/list]
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
643 Views

Hi grante, 

 

> I can find no detailed documentation on either elf2flash or the mysterious external bootloader 

> which appears to be available only as an srec file. 

 

You need to read the "Nios II Software Developer’s Handbook." 

 

> * What exactly does "elf2flash" do? 

 

See the handbook for details ... but basically what it says: it converts the elf to a flash file. 

Very simply: it creates a record for each loadable section, throws in the bootloader if necessary, 

and outputs the srec for the flash programmer. 

 

> * Why can't "objcopy" be used like all other normal eCos targets? 

 

It can -- just run it from the command line. 

 

> * What is the external bootloader .srec file for? 

 

Read chapter 4 in the handbook ... the section "Memory Usage." 

 

> * Why would a ROM-resident bootloader like RedBoot require a second bootloader? 

 

It doesn't -- you can use objcopy and bin2flash (if you want to use the flash programmer). 

 

Regards, 

--Scott
0 Kudos
Altera_Forum
Honored Contributor II
643 Views

Firstly, thanks for the resonse.  

 

>> I can find no detailed documentation on either elf2flash or 

>> the mysterious external bootloader which appears to be 

>> available only as an srec file. 

>You need to read the "Nios II Software Developer’s 

>Handbook."  

 

I have. The copy I have is document number NII5V2-6.0. 

 

>> * What exactly does "elf2flash" do? 

>See the handbook for details ... 

 

What details? There's exactly one mention of elf2flash in the 

handbook with a single phrase saying that it"converts an 

.elf executable file to a .flash file for programming into 

flash memory"

 

>but basically what it says: it converts the elf to a flash 

>file. Very simply: it creates a record for each loadable 

>section, throws in the bootloader if necessary, and outputs the 

>srec for the flash programmer. 

 

Thanks, I had deduced that, but I was looking for exact 

descriptions of what each parameter does, where the bootloader 

is "thrown in", etc.  

 

>> * Why can't "objcopy" be used like all other normal eCos targets? 

>It can -- just run it from the command line. 

 

Then why was elf2flash written? Just for obsfucation value? 

 

>> * What is the external bootloader .srec file for? 

>Read chapter 4 in the handbook ... the section "Memory Usage." 

 

I did. And I just searched it again: the string "bootloader" 

doesn't appear even once in the handbook. Chapter 4 is 

about using the HIOS2 HAL system library. I'm not using the 

HAL libarary, I'm using eCos. 

 

Am I reading the wrong handbook? 

 

>> * Why would a ROM-resident bootloader like RedBoot require 

>> a second bootloader? 

>It doesn't -- you can use objcopy and bin2flash (if you want to 

>use the flash programmer). 

 

If it's not required, why is program_flash adding it to the 

srec file?
0 Kudos
Altera_Forum
Honored Contributor II
643 Views

Grant, 

 

> Thanks, I had deduced that, but I was looking for exact 

> descriptions of what each parameter does, where the bootloader 

> is "thrown in", etc.  

 

Fair enough, my bad ... it's in the "Nios II Flash Programmer User Guide", not 

the "Nios II Software Developer’s Handbook." My most sincere apologies. 

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

elf2flash 

The elf2flash utility takes a software executable file in .elf format, and 

translates it to an S-record file suitable for programming into flash 

memory. 

elf2flash also inserts a boot copier into the flash file, if needed. elf2flash 

inserts the boot copier code before the application code under the 

following conditions: 

&#9632; The CPU&#39;s reset address falls within the address range of the flash 

memory being programmed. 

&#9632; The executable code is linked to a memory location outside of the 

flash memory being programmed. 

If elf2flash inserts a boot copier, it also translates the application code .elf 

file to a boot record for use by the boot copier. This boot record contains 

all of the application code, but is not executable. After reset, the boot 

copier reads the boot record from flash memory and copies the 

application code to the correct linked address, and then branches to the 

newly-copied application code.[/b] 

--- Quote End ---  

 

 

> Then why was elf2flash written? Just for obsfucation value? 

 

Sorry, I can&#39;t answer that ... but it&#39;s awful handy when using 

the flash programmer ;-) 

 

> I did. And I just searched it again: the string "bootloader" 

> doesn&#39;t appear even once in the handbook.  

 

> Am I reading the wrong handbook? 

 

Yes, again, my apologies ... search for "boot copier" in the flash programmer&#39;s 

manual. 

 

Regards, 

--Scott
0 Kudos
Altera_Forum
Honored Contributor II
643 Views

> I can find no detailed documentation on either elf2flash or the mysterious 

> external bootloader which appears to be available only as an srec file. 

 

I forgot ... you can review the bootloader code -- look in: 

 

$SOPC_KIT_NIOS2\components\altera_nios2\sdk\src\boot_loader_sources 

 

Regards, 

--Scott
0 Kudos
Reply