UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Participant n5ac
Participant
3,972 Views
Registered: ‎10-29-2008

Jump to address / set PC problem

In a bootloader I wrote, I have the following lines of C code to boot my final application that I have loaded in DRAM at 0x88000000:

 

typedef int (*FUNPTR) ();

#define PROGRAM_START (FUNPTR)0x88000000

 

....

 

FUNPTR boot = PROGRAM_START;

xil_printf("Booting ... 0x%08x\r\n",boot);

boot();

 

 

They compile to the following (disassembled with mb-objdump):

 

     bac: b9f4fdd0 brlid r15, -560 // 97c <jtagOff>

     bb0: 80000000 or r0, r0, r0

     bb4: 30a01e70 addik r5, r0, 7792

     bb8: b0008800 imm -30720

     bbc: 30c00000 addik r6, r0, 0

     bc0: b9f40270 brlid r15, 624 // e30 <xil_printf>

     bc4: 80000000 or r0, r0, r0

     bc8: b0008800 imm -30720

     bcc: b9f40000 brlid r15, 0

     bd0: 80000000 or r0, r0, r0

     bd4: e9e10000 lwi r15, r1, 0

     bd8: ea61001c lwi r19, r1, 28

     bdc: eac10020 lwi r22, r1, 32

     be0: eae10024 lwi r23, r1, 36

     be4: eb010028 lwi r24, r1, 40

     be8: eb21002c lwi r25, r1, 44

     bec: 10600000 addk r3, r0, r0

     bf0: b60f0008 rtsd r15, 8

     bf4: 30210030 addik r1, r1, 48

 

 

But when I run my program, it doesn't seem to start -- it seems to start somewhere in the middle of the software which confused me.  I loaded up XMD and stepped across these instructions and found this:

 

XMD% stp

     BC8:   B0008800  imm      -30720

     BCC:   B9F40000  brlid    r15, 0

     BD0:   80000000  Or       r0 , r0 , r0


XMD% stp

88000BCC:   10A80000  addk     r5 , r8 , r0


XMD%

 

Apparently, the compiler has coded a relative branch instead of a jump instruction so instead of going to 0x88000000 where my program starts, it is going to 0x88000BCC in the middle.

 

Have I coded the C wrong?  Is this a compiler bug (doubtful)...?

 

Steve 

Message Edited by n5ac on 03-21-2010 08:39 PM
0 Kudos
4 Replies
Participant n5ac
Participant
3,968 Views
Registered: ‎10-29-2008

Re: Jump to address / set PC problem

Incidentally, this code (from XAPP482):

 

 

#define PROG_START_ADDR 0x88000000

int (*func_ptr) ();

 
....
 

xil_printf("Booting ... \r\n");

func_ptr = PROG_START_ADDR; // jump to start execution code

func_ptr();


 

works, but produces a compiler warning:

 

 

../src/system.c: In function 'main':

../src/system.c:184: warning: assignment makes pointer from integer without a cast


 

so a response isn't urgent, but it is still perplexing... 

 

Steve 

0 Kudos
Participant elaa82
Participant
3,958 Views
Registered: ‎02-13-2010

Re: Jump to address / set PC problem

i had same problem like u.

 

but i solved it by doing this

 

1) load ur elf/srec image file (not boot loader) to flash memory (u can do by using sdk. device configuration -> program flash memory)
2) enter flash base addr, scratch memory address (prog_start_addr) and enable create boot loader option from program flash memory window.
3) program flash
4) run ur last created bootloader (no need to change bootloader code). This will copy ur image file to dram and will start run from it.
5) check ur linker script also. (project of image file - code section, data section and heap stack section (shoud be link with dram). Except .boot of data section, this should be link with bram)
i confused u?
Thanks and Regards,
Elaa
0 Kudos
Participant elaa82
Participant
3,957 Views
Registered: ‎02-13-2010

Re: Jump to address / set PC problem

warning will be avoid by doing this. 

func_ptr = (int (*) (void)) (PROG_START_ADDR); // jump to start execution code

Thanks

Elaa

0 Kudos
Explorer
Explorer
3,939 Views
Registered: ‎01-25-2008

Re: Jump to address / set PC problem

Or Try:

 

 

void (*pAddx)(); //Set the address pAddx = (void (*)())0x88000000; //Call (*pAddx)();

 

Regards

 

 

 

Lachlan Grogan
CEO, SIL3 Pty Ltd
Melbourne, Australia
http://sil3.com.au
0 Kudos