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++

nios2-elf-objcopy BUG??

Altera_Forum
Honored Contributor II
1,485 Views

we are using nios2-elf-objcopy.exe to produce hex file after building a project. 

in ihex file 03 record, that points to program entry point, should be MSB. 

for example we are have 0x00020000 as base address of RAM. 

after project building process has complete we are call objcopy: 

nios2-elf-objcopy.exe -O ihex debug\project.elf project.hex 

program entry point is 0x0000201C8 (proofed in debugger and we are have boot address in another memory). 

objcopy it produce an ihex file and set program entry point with 03 record type to address 0x200001C8 

this is produced string: 

:04000003200001C810  

 

WHY???  

 

it should be  

:04000003000201C82E 

 

does it bug in objcopy or in elf file?
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
671 Views

Hi m_fox, 

 

> this is produced string: 

> :04000003200001C810 

> WHY??? 

 

Because it is the correct format for intel-hex. The address is specified 

as CS:IP (code segment register value:instruction pointer register value). 

Together they form a 20-bit segmented address. 

 

> it should be 

> :04000003000201C82E 

 

No, this would generate the linear address 000_01e8. The first two bytes "2000" 

represent bits [19:4], the second two are bits [16:0] ... the two values are 

added together in the proper bit positions. Basically, the correct values 

are added like this: 

 

20000 (CS) 

001c8 (IP) 

-------------- 

201c8 (20-bit linear) 

 

> does it bug in objcopy or in elf file? 

 

No, it is not a bug. 

 

Regards, 

--Scott
0 Kudos
Altera_Forum
Honored Contributor II
671 Views

hello, 

thanks a lot for explain. 

so, in other words, to get linear address we are should do following calculations: 

:04000003XXXXYYYY 

 

(XXXX<<4) + YYYY 

 

is it correct? 

 

but it&#39;s funny, why objcopy sometimes generates records 05 and sometimes 03?
0 Kudos
Altera_Forum
Honored Contributor II
671 Views

Hi m_fox, 

 

> (XXXX<<4) + YYYY 

> is it correct? 

 

Yes. 

 

> but it&#39;s funny, why objcopy sometimes generates records 05 and sometimes 03? 

 

I don&#39;t know why this happens -- record type 05 (start linear address) is certainly 

more appropriate for Nios (and virtually everything other than x86 in real mode). 

But from a practical point-of-view, it probably doesn&#39;t matter -- since device 

programmers don&#39;t use the start records. 

 

Regards, 

--Scott
0 Kudos
Reply