Project Home
Project Home
Source Code
Source Code
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Convert ELF to Bin?: (5 Items)
   
Convert ELF to Bin?  
Hey all,

I would like to convert my kernel image cwc.ifs to a binary file that is executable starting at instruction 0. The mkrec
 utility simply encodes whatever you give it in S-record format, but it does no conversion of the object, so what I end 
up with is an Elf file encoded as a bunch of S-records. When I TFTP this to my target, the Elf file gets placed in flash
, Elf header and all. What I really want is to convert Elf to Bin, then encode the Bin in S-record format.

"Building Embedded Systems" mentions using objcopy to do this conversion, but the standard objcopy that comes with Linux
 builds an image that won't boot (even though objcopy claims to understand big-endian Elf). Do I need a special cross-
objcopy that understands PPC opcodes? Which objcopy are you guys using? Can anyone recommend something that will run 
under Linux & handle PPC object code?

Thanks,
-Jon
Re: Convert ELF to Bin?  
The normal image doesn't have an entry point as offset 0 - you want to
use raw.boot - the first instruction will find and jump to the entry point
of the startup.

change

[virtual=ppc,elf]

to

[virtual=ppc,raw]

in your build file.

Cheers,

Colin

Jonathan Juniman wrote:
> Hey all,
> 
> I would like to convert my kernel image cwc.ifs to a binary file that is 
> executable starting at instruction 0. The mkrec utility simply encodes 
> whatever you give it in S-record format, but it does no conversion of 
> the object, so what I end up with is an Elf file encoded as a bunch of 
> S-records. When I TFTP this to my target, the Elf file gets placed in 
> flash, Elf header and all. What I really want is to convert Elf to Bin, 
> then encode the Bin in S-record format.
> 
> "Building Embedded Systems" mentions using objcopy to do this 
> conversion, but the standard objcopy that comes with Linux builds an 
> image that won't boot (even though objcopy claims to understand 
> big-endian Elf). Do I need a special cross-objcopy that understands PPC 
> opcodes? Which objcopy are you guys using? Can anyone recommend 
> something that will run under Linux & handle PPC object code?
> 
> Thanks,
> -Jon
> 
> 
> _______________________________________________
> General
> http://community.qnx.com/sf/go/post7501
> 

-- 
cburgess@qnx.com
Re: Convert ELF to Bin?  
OK, before, the line in my build file said:
[virtual=ppcbe,elf +compress]

So I would let it build an Elf file, then convert to S-record with mkrec. For some reason, mkrec prepended two bytes of 
garbage 0x90 0x90 to the start of the Elf image. But no matter. I could get the entry point out of the Elf header, then 
boot it by copying from flashaddr+2 to RAM, and jumping to the known entry point. This works.

So now I changed the build file to:
[virtual=ppcbe,raw +compress]

When I run it through mkrec, it still prepends 0x90 0x90 to the image. I TFTPed it to the board and tried it both ways: 
copying from flashaddr+2 to RAM (to strip the garbage bytes), and copying from flashaddr to RAM (to leave the garbage 
bytes). The image won't boot either way.

Do I need some tech support help on this one?
Re: Convert ELF to Bin?  
Never mind, it works. The manufacturer's BIOS has some quirk where the boot-up never works the first time after you've 
flashed it. This did the trick! Thanks!
Re: Convert ELF to Bin?  
Cool :-)

Jonathan Juniman wrote:
> Never mind, it works. The manufacturer's BIOS has some quirk where the 
> boot-up never works the first time after you've flashed it. This did the 
> trick! Thanks!
> 
> _______________________________________________
> General
> http://community.qnx.com/sf/go/post7513
> 

-- 
cburgess@qnx.com