Put two files into one

Maybe the question is a little bit weird, but I do need to solve it.

I have two boot loaders, say bootA and bootB. Each of them can be ran in the flash rom on my walnut board. I need to put these two boot loader into one file and load this file to the flash rom (I have a very special reason for doing this. This would be a long story and irrelavant to the topic so I just skip talking about it). Now what I want to do is, using bootA to boot up the board and then jump to bootB before loading the linux image. The bootA provides a jump capibility so I can indicate the address of the bootB and start to execute bootB from the given address. The bootB is the one used to load linux image.

For me it seems simply concatenating two boot loaders should work (please correct me if I am wrong). e.g. the commond in DOS: copy bootA+bootB bootTogether

bootTogether is the file I would put to the flash. My question is, is there anyway to indicate the offset of the bootB within the bootTogether? For example, if bootA is 100kb and bootB is 300kb. How to align the bootB in the bootTogether so the offset of the bootB is

512kb? What's the command to realize it in linux?

Thanks! Frank

Reply to
Loading thread data ...

Hi Frank,

Are you able to configure bootB that the system is already configured?

You could search for a magic string in bootB which has a fixed offset in bootB. Then you would know the beginning. Or you could patch a word in bootTogether with the offset of bootB in bootTogether. Requires 1/4h of C coding for a new "cat" command.

But I think the best way is KISS by merging the features you need of bootA to bootB.


Markus Pietrek

(Remove _nospam from email address before replying)
Reply to
Markus Pietrek

That would be copy /b bootA+bootB bootTogether probably (unless things have changed)

Here's something that should work both in Linux and in Cygwin: $ len=`wc -c bootA` $ dd if=/dev/zero of=bootPad count=1 bs=$len $ cat bootA bootPad bootB > bootTogether

Or just write a little C program.

Reply to
Dan Kegel

After I use "copy /b bootA+B bootTogether" to get the bootTogether (or the corresponding command in linux), I need to change bootTogether to elf format. But when I use command: objcopy -O elf-powerpc32 bootTogether bootTogether.frm

An error message shows that "bootTogether: File format is not unrecognized". So how to change a bin file to an elf file?


Reply to

Well, you should make sure that ALL symbols end up in their proper place as well...This is a bootloader right - forget all about elf-format. You need to us custom linker scripts to get all variables in proper locations (read in RAM memory). I assume that bootA is running in flash only (using no RAM only cpu registers) and bootB is the 'in ram' piece of loader, correct ?

You should have a look at the [1] blob bootloader, they have two loader scripts + Makefile that you may use as some inspiration, (src/blob/rest-ld-script.in , start-ld-script)

If you need a more complicated example have a look at the linux kernel link script (arch/i386/vmlinux.lds).

You don't ! You don't have a linux kernel to execute it in the raw startup mode.

No probs. Devlin.

NSA disclaimer: This message does not contain any of the words: BOMB, 
WHITEHOUSE, TERRORISM or PRESIDENT so you may stop reading right here.
Reply to
Devlin Doe

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.