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: 
Visitor raha_2181
Visitor
1,366 Views
Registered: ‎08-05-2018

reset cpu1 from cpu0 -- AMP zynq

Jump to solution

Hi,

I have a problem to reset cpu1 from cpu0,

I use standalode bsp v6, and here is the code I use in application project of cpu0 to reset cpu1:

 

#define A9_CPU_RST_CTRL           (XSLCR_BASEADDR + 0x244)

#define A9_RST1_MASK              0x00000002

#define A9_CLKSTOP1_MASK          0x00000020

 

#define XSLCR_LOCK_ADDR           (XSLCR_BASEADDR + 0x4)

#define XSLCR_LOCK_CODE           0x0000767B

 

#define CPU1_CATCH                0xFFFFFFF0

 

Xil_Out32(XSLCR_UNLOCK_ADDR, XSLCR_UNLOCK_CODE);

 

RegVal = Xil_In32(A9_CPU_RST_CTRL);

 

RegVal |= A9_RST1_MASK;

Xil_Out32(A9_CPU_RST_CTRL, RegVal);

 

RegVal |= A9_CLKSTOP1_MASK;

Xil_Out32(A9_CPU_RST_CTRL, RegVal);

 

RegVal &= ~A9_RST1_MASK;

Xil_Out32(A9_CPU_RST_CTRL, RegVal);

 

RegVal &= ~A9_CLKSTOP1_MASK;

Xil_Out32(A9_CPU_RST_CTRL, RegVal);

 

Xil_Out32(XSLCR_LOCK_ADDR, XSLCR_LOCK_CODE);

 

Xil_Out32(CPU1_CATCH, APP_CPU1_ADDR);

 

dmb();

sev();

 

After trying this part of code, cpu1 stuck at wfe loop as follows:

 

00000130:   and     r1, r1, #15

00000134:   cmp     r1, #0

00000138:   beq     +60     ; addr=0x0000017c

0000013c:    wfe

00000140:    b       -12     ; addr=0x0000013c

 

I would really appreciate if anybody can help with the instruction to reset cpu1.

 

Thanks,

-- raha

0 Kudos
1 Solution

Accepted Solutions
Visitor raha_2181
Visitor
1,223 Views
Registered: ‎08-05-2018

Re: reset cpu1 from cpu0 -- AMP zynq

Jump to solution

I've added #include "xparameters.h" at the beginning of asm_vectors.s and it seems the problem solved.

I used the following lines as they are in the asm_vectors.s of xapp1079:

 

#if XPAR_CPU_ID==0

    _cpu0_catch:

        .word   OKToRun

    _cpu1_catch:

        .word   EndlessLoop0

#elif XPAR_CPU_ID==1

    _cpu0_catch:

        .word   EndlessLoop0

    _cpu1_catch:

        .word   OKToRun

#endif

 

The definition of XPAR_CPU_ID can be found in "xparameters.h" and I suppose the problem was that it was hidden to asm_vectors.s while I didn't face any error.

0 Kudos
6 Replies
Visitor raha_2181
Visitor
1,364 Views
Registered: ‎08-05-2018

Re: reset cpu1 from cpu0 -- AMP zynq

Jump to solution

I use VIVADO 2015.1 and SDK 2015.1, on Microzed with zynq7010 and as I said standalone bsp v6. 

0 Kudos
Voyager
Voyager
1,320 Views
Registered: ‎04-13-2015

Re: reset cpu1 from cpu0 -- AMP zynq

Jump to solution

@raha_2181

 

The good news: you succeeded at resetting CPU #1.

It is stuck there because it's running from the boot ROM and waiting for the address to go to.

Write in 0xFFFFFFF0 the address you want CPU #1 to start executing.

Make sure CPU #1 start address is aligned on 16 bytes otherwise it will remain in that section of the boot ROM

0 Kudos
Visitor raha_2181
Visitor
1,296 Views
Registered: ‎08-05-2018

Re: reset cpu1 from cpu0 -- AMP zynq

Jump to solution

Hi ,

Thanks for the response!

So I got to reset CPU1!!

I do write the starting address of CPU1, mentioned at the beginning of the CPU1.elf as start address 0x02000000 to 0xFFFFFFF0 in the command Xil_Out32(CPU1_CATCH, APP_CPU1_ADDR);

 

CPU1_CATCH is 0xFFFFFFF0 and

APP_CPU1_ADDR is 0x02000000

 

- I tried ''the address writing command'' both before and after reset commands.

- and the address 0x02000000 is aligned on 16 bytes based on your point I suppose..

 

So, what's wrong that CPU1 cannot read its starting address?

 

thanks for the help,

--raha

0 Kudos
Xilinx Employee
Xilinx Employee
1,275 Views
Registered: ‎02-01-2008

Re: reset cpu1 from cpu0 -- AMP zynq

Jump to solution

You issue looks like cpu1 is starting to run the bsp for cpu0 and there is a wfe loop in the beginning of boot.S that checks if the bsp was created for cpu0 or cpu1. If it is for the wrong cpu, then it will sit in a wfe loop.

 

Also, the wfe loop at the top of OCM is setup during boot of the PS. Stroking cpu1 reset will not use the top wfe loop.

 

Instead, resetting cpu1 will cause it to jump to the reset vector at 0. So you either need to modify Boot.S such that if cpu1 is detected, then jump to cpu1's program at 0x02000000 (by the looks of your setup).

 

Later versions of xapp1079 used this mechanism. A slightly modified boot.S and asm_vectors.S allowed both cpu0 and cpu1 to use the same reset vector at 0, and then once in the BSP (boot.s), the cpu # was detected, and then the cpu would jump to an address indexed at the end of the vector table. This way, you could rewrite the fixed offset from the vector table with your starting address of 0x02000000 for cpu1.

 

Search wiki.xilinx.com for xapp1079 and you will find the version that does this reset. Look at the BSP's asm_vectors.S and boot.S files for the changes that you would want to add to your BSP.

0 Kudos
Visitor raha_2181
Visitor
1,230 Views
Registered: ‎08-05-2018

Re: reset cpu1 from cpu0 -- AMP zynq

Jump to solution

Dear johnmcd,

Thank you for your response. I do use the instruction in xapp1079. I changed the boot.s to add the following lines for boot:

_boot:

 

       mrc p15,0,r1,c0,c0,5

       and r1, r1, #0xf

       cmp r1, #0

       bne NotCpu0

 

       ldr r0, =_cpu0_catch

       b cpuxCont

 

NotCpu0:

    cmp r1, #1

    bne EndlessLoop0

    ldr r0, =_cpu1_catch

    b cpuxCont

also I've added the following lines to asm_vectors.s:

#if XPAR_CPU_ID==0

    _cpu0_catch:

        .word   OKToRun

    _cpu1_catch:

        .word   EndlessLoop0

#elif XPAR_CPU_ID==1

    _cpu0_catch:

        .word   EndlessLoop0

    _cpu1_catch:

        .word   OKToRun

#endif

However, it didn't work until I changed the code as follows:  (I changed both EndlessLoop0 to OkToRun)

#if XPAR_CPU_ID==0

    _cpu0_catch:

        .word   OKToRun

    _cpu1_catch:

        .word   OKToRun

#elif XPAR_CPU_ID==1

    _cpu0_catch:

        .word   OKToRun

    _cpu1_catch:

        .word   OKToRun

#endif

 

By writing the starting address of CPU#1 to 0x00000024 as stated in xapp1079 I got CPU#1 to work after reset.

But with no EndlessLoop0 command.   

Do you know what makes the unmodified asm_vectors.s to not to work properly?

 

Thanks for your help,

--raha

0 Kudos
Visitor raha_2181
Visitor
1,224 Views
Registered: ‎08-05-2018

Re: reset cpu1 from cpu0 -- AMP zynq

Jump to solution

I've added #include "xparameters.h" at the beginning of asm_vectors.s and it seems the problem solved.

I used the following lines as they are in the asm_vectors.s of xapp1079:

 

#if XPAR_CPU_ID==0

    _cpu0_catch:

        .word   OKToRun

    _cpu1_catch:

        .word   EndlessLoop0

#elif XPAR_CPU_ID==1

    _cpu0_catch:

        .word   EndlessLoop0

    _cpu1_catch:

        .word   OKToRun

#endif

 

The definition of XPAR_CPU_ID can be found in "xparameters.h" and I suppose the problem was that it was hidden to asm_vectors.s while I didn't face any error.

0 Kudos