elftosb2 loads virtual addresses instead of physical

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

elftosb2 loads virtual addresses instead of physical

Jump to solution
1,600 Views
PetriLaakso
Contributor II

Hello everyone!

I have a problem with elftosb2 as it constructs .sb image with instructions to load virtual addresses instead of physical.

I have elf binary for which "readelf -e" reports:

...

Section Headers:

  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al

  [ 0]                   NULL            00000000 000000 000000 00      0   0  0

  [ 1] .start            PROGBITS        40000000 008000 0000ec 00  AX  0   0  4

  [ 2] .text             PROGBITS        c00000ec 0080ec 14f5c4 00  AX  0   0 128

...cut...

Program Headers:

  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align

  LOAD           0x008000 0x40000000 0x40000000 0x000ec 0x000ec R E 0x8000

  LOAD           0x0080ec 0xc00000ec 0x400000ec 0x14f6c4 0x14f6c4 R E 0x8000

  LOAD           0x158000 0xc0150000 0x40150000 0xcb040 0xdacf4 RW  0x8000


I'd like to SB image to load code to PhysAddresses, instead of Virt.


Snipplet from the .bd:

// Load kernel to DRAM.
load kernel;

jump kernel;

And output from the elftosb:


$ nbelftosb -V -c bootimx23.bd -z -o bootimx23.sb

Boot Section 0x00000000:

  LOAD | adr=0x00000000 | len=0x00001008 | crc=0xa9094f19 | flg=0x00000000

  LOAD | adr=0x00001008 | len=0x00000064 | crc=0xf3c1ca49 | flg=0x00000000

  FILL | adr=0x0000106c | len=0x0000000c | ptn=0x00000000

  CALL | adr=0x000001a8 | arg=0x00000000 | flg=0x00000000

  LOAD | adr=0x40000000 | len=0x000000ec | crc=0x5e621393 | flg=0x00000000

  LOAD | adr=0xc00000ec | len=0x0014f5c4 | crc=0x42e999c0 | flg=0x00000000

  LOAD | adr=0xc014f6b0 | len=0x0000003c | crc=0xa8b3e4a6 | flg=0x00000000

  LOAD | adr=0xc014f6ec | len=0x0000000c | crc=0x7a350852 | flg=0x00000000

  LOAD | adr=0xc014f6f8 | len=0x0000004c | crc=0xa2ae784a | flg=0x00000000

  LOAD | adr=0xc014f744 | len=0x00000004 | crc=0x02b0032f | flg=0x00000000

  LOAD | adr=0xc014f748 | len=0x00000038 | crc=0x7186ee9b | flg=0x00000000

  LOAD | adr=0xc014f780 | len=0x00000010 | crc=0xa5cac6ee | flg=0x00000000

  LOAD | adr=0xc014f790 | len=0x00000020 | crc=0x29c7ba54 | flg=0x00000000

  LOAD | adr=0xc0150000 | len=0x000cb040 | crc=0x8446f74b | flg=0x00000000

  FILL | adr=0xc021b040 | len=0x0000fcb4 | ptn=0x00000000

  JUMP | adr=0x40000000 | arg=0x00000000 | flg=0x00000000

As you can see, elftosb2 load to Virtual. I'd like to have it to load using ELF binary's physcall address to do the loads.

Is it possible? Is it known issue? I've read the fine manual and I didn't find anything which relates this problem.


Best regards

Petri Laakso


0 Kudos
Reply
1 Solution
1,247 Views
PetriLaakso
Contributor II

I solved this problem by copying elf binary's data using objcopy and loading resulting raw. Something like:

sources {

        # elf(3) binary.

        boot_prep="./boot";

        # objcopy(1) generated .bin

        kernel="./kernel.bin";

}

section (0) {

        // Initialize power, clocks and DRAM.

        load boot_prep;

        call boot_prep;

        // Load kernel to DRAM.

        load kernel > 0x40000000;

        jump 0x40000000;

}


View solution in original post

0 Kudos
Reply
3 Replies
1,247 Views
jimmychan
NXP TechSupport
NXP TechSupport

what BSP are you using? what board are you using?

0 Kudos
Reply
1,247 Views
PetriLaakso
Contributor II

i.MX23 OLinuXino and vanilla elftosb compiled from the source.

So, the question is, am I able to instruct elftosb to use ELF binary's physical addresses, instead of virtual?

I'd like to load all sections to starting from 0x40000000, as it is DRAM address space.

There is nothing physically or rather, virtually mapped to 0xc0000000 :-(


0 Kudos
Reply
1,248 Views
PetriLaakso
Contributor II

I solved this problem by copying elf binary's data using objcopy and loading resulting raw. Something like:

sources {

        # elf(3) binary.

        boot_prep="./boot";

        # objcopy(1) generated .bin

        kernel="./kernel.bin";

}

section (0) {

        // Initialize power, clocks and DRAM.

        load boot_prep;

        call boot_prep;

        // Load kernel to DRAM.

        load kernel > 0x40000000;

        jump 0x40000000;

}


0 Kudos
Reply