cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Observer
Observer
10,858 Views
Registered: ‎07-30-2015

AMP load CPU1 from Linux running on CPU0

Jump to solution

I have a Petalinux system setup with MAXCPUS=1, and with maximum memory a half of available memory.

On the free half of memory I want to run a bare metal application.

Not as described in XAPP1078, I want to be able to choose the elf file by linux terminal, and give some command

to copy the file in the free half of ram and give another command to run CPU1 with the bare metal application just loaded.

in XAPP1078 it is the FSBL to do everything, but I need to have the runtime control of which file is uploaded and run bu CPU1. Is it possible to use the DMA in the PS to do that, in some way ? Is the DMA able to access the full memory even Linux can see only a half of the hole memory ?

 

0 Kudos
1 Solution

Accepted Solutions
Highlighted
Xilinx Employee
Xilinx Employee
19,900 Views
Registered: ‎02-01-2008

Re: AMP load CPU1 from Linux running on CPU0

Jump to solution

Just to clarify, the bootrom forces CPU1 to the WFE loop which is located around 0xffffff80 and that WFE loop monitors address 0xfffffffc to determine where CPU1 will jump to. The bootrom initially writes the beginning address of the wfe loop to 0xfffffffc.

 

You are correct that Linux is used to change the contents of 0xfffffffc which will cause the CPU1 wfe loop to jump to the new address that was written into 0xfffffffc.

 

You could change the order of startup by writing your new starting address to 0xfffffffc either in the source of the FSBL, using a small bin file that gets loaded to 0xfffffffc via the FSBL, or even in u-boot. But, you have to be carefull of what shared resources will be used by CPU1. By waiting until Linux is running, then writing to 0xfffffffc, Linux will have already initialized the shared resources.

View solution in original post

0 Kudos
13 Replies
Highlighted
Xilinx Employee
Xilinx Employee
10,812 Views
Registered: ‎02-01-2008

Re: AMP load CPU1 from Linux running on CPU0

Jump to solution

I suggest you look at using OpenAmp. Linux will startup in SMP mode, and then you can tell cpu1 to start running it's own application. OpenAmp uses remoteProc for this startup process uses rpmsg to enable messaging between Linux and cpu1's application.

0 Kudos
Highlighted
Observer
Observer
10,790 Views
Registered: ‎07-30-2015

Re: AMP load CPU1 from Linux running on CPU0

Jump to solution

Yes, this might be a good solution, thanks for the hint.

Anyway, I looked at Open amp yet but everything seems very tricky, and that framework seems not supported by Xilinx but only by a community. The framework then is not integrated in SDK and petalinux, and there is not much documentation. So I decided to switch to XAPP1078 which is well documented, at least for 2014.2 version (even if I am using 2015.2 and I am experiencing some problems..)

I think that Zynq has a very great potential for developing such AMP applications, because they allow a separation between security critical tasks (which can be done by bare metal apps), and Linux operating system (which is not certified for safe applications, but offer a lot of possibilities).

0 Kudos
Highlighted
Observer
Observer
10,786 Views
Registered: ‎06-09-2014

Re: AMP load CPU1 from Linux running on CPU0

Jump to solution

I have been running the XAPP 1078 using 2015.2 for a couple of months now on a z7020 Microzed. There are a couple of changes that need to be made though for it to work. Using the BSP from the Wiki for 2014.4, here are the steps it took for me to get everything working:

 

All of this has been tested on a MicroZed z7020.

 

  1. Duplicate the 2015.2 BSP and modify the files as described in the Documents folder of the Updated Design Files for Vivado 2014.4 found on the Wiki. (I have also attached below the BSP I have been using. Note these changes have not been validated by Xilinx, but are basically the same changes that Xilinx approved for 2014.4 & 2014.2).
  2. Before building Linux (using Petalinux - petalinux-build), the following changes need to be made in the device tree for the FPGA and the Ethernet to work:
        • "./subsystems/linux/configs/device-tree/pcw.dtsi" modify
          fclk-enable = <0x0>;
           to 
          fclk-enable = <0xf>;
            • This change should enable the fabric clock.
        • "./subsystems/linux/configs/device-tree/system-top.dts" Add the following at the end of the file:
        • &gem0 {
                  phy-handle = <&phy0>;
                  phy-mode = "rgmii-id";
                  mdio {
                          #address-cells = <1>;
                          #size-cells = <0>;
                          phy0: phy@0 {
                                  compatible = "marvell,88e1510";
                                  device_type = "ethernet-phy";
                                  reg = <0x0>;
                                  marvell,reg-init = <3 16 0xff00 0x1e 3 17 0xfff0 0x00>;
                          };
                  };
          };
          • This should fix the Ethernet.

With these fixes and following the 2014.4 Documentation, you should be able to get the XAPP 1078 working in 2015.2. I will update this post if I remember any other changes that had to be made.

 

Ryan

0 Kudos
Highlighted
Observer
Observer
10,770 Views
Registered: ‎07-30-2015

Re: AMP load CPU1 from Linux running on CPU0

Jump to solution

Thank you very much Ryan !!!!  This helps me a lot...

For the "fclk-enable" I discovered recently that Petalinux-2015.2.1-final version fixes it... so maybe it is worth to get updated to that version...

 

Max

 

0 Kudos
Highlighted
Observer
Observer
10,762 Views
Registered: ‎06-09-2014

Re: AMP load CPU1 from Linux running on CPU0

Jump to solution

Thanks, I will look into upgrading. I didn't realize they released an update. 

0 Kudos
Highlighted
Observer
Observer
10,697 Views
Registered: ‎07-30-2015

Re: AMP load CPU1 from Linux running on CPU0

Jump to solution

Ryan,

 

did you use the modified FSBL as described in the XAPP, or the FSBL released with 2015.2 ?

For the XAPP xilinx released a modified FSBL, but it seems that it is not necessary to use that because the 2015.2 FSBL managed the multiple ELF files yet. But I dont'understand how to implement the trampoline mechanism to launch CPU1 using the new FSBL.

 

Max

0 Kudos
Highlighted
Observer
Observer
10,689 Views
Registered: ‎06-09-2014

Re: AMP load CPU1 from Linux running on CPU0

Jump to solution

I have only used the standard FSBL that comes with 2015.2. Our product does not require the CPU1 application until Linux Boots, so we have not explored starting CPU1 from the FSBL or U-Boot. 

 

My best guess would be to write the starting address of the CPU1 program to the L2 Register specified in the XAPP immediately before the FSBL passes off to U-boot. (Similar to poking the register via Linux, but instead, doing it in the FSBL). If I remeber correctly, the FSBL puts CPU1 in a WFE loop checking this register for the next address to jump to.

 

If I have time, I'll look at it also, but due to my schedule, I probably won't have time for a while. If you do get it working, please let me know as it might be useful down the road.

 

Ryan 

0 Kudos
Highlighted
Observer
Observer
10,679 Views
Registered: ‎07-30-2015

Re: AMP load CPU1 from Linux running on CPU0

Jump to solution

Ryan, thanks for your quick reply..

 

Yesterday I browsed in the forum  and found a very intresting thread explaining very well how the trampoline works.

The thread is:

https://forums.xilinx.com/t5/Embedded-Development-Tools/using-both-CPU-cores-on-Zynq/td-p/264788/page/4

 

It seems that CPU1 is not started by FSBL if you use Linux, but from Linux itself. It is  Linux that forces CPU1 to the WFE loop at address 0xfffffffc. So, when using Linux on CPU0, the correct way to start CPU1 is to write the CPU1 application entry  address in the address 0xfffffff0.

I tested it and it works..

 

Max

 

 

0 Kudos
Highlighted
Xilinx Employee
Xilinx Employee
19,901 Views
Registered: ‎02-01-2008

Re: AMP load CPU1 from Linux running on CPU0

Jump to solution

Just to clarify, the bootrom forces CPU1 to the WFE loop which is located around 0xffffff80 and that WFE loop monitors address 0xfffffffc to determine where CPU1 will jump to. The bootrom initially writes the beginning address of the wfe loop to 0xfffffffc.

 

You are correct that Linux is used to change the contents of 0xfffffffc which will cause the CPU1 wfe loop to jump to the new address that was written into 0xfffffffc.

 

You could change the order of startup by writing your new starting address to 0xfffffffc either in the source of the FSBL, using a small bin file that gets loaded to 0xfffffffc via the FSBL, or even in u-boot. But, you have to be carefull of what shared resources will be used by CPU1. By waiting until Linux is running, then writing to 0xfffffffc, Linux will have already initialized the shared resources.

View solution in original post

0 Kudos
Highlighted
Participant
Participant
6,510 Views
Registered: ‎10-27-2013

Re: AMP load CPU1 from Linux running on CPU0

Jump to solution

John 

 

I too am having trouble getting cpu1 to wakeup using the latest linux-xlnx and SDK 2015.4. 

 

Maybe I should be using OpenAMP? 

Is there a XAPP or HOWTO that can show how to use OpenAMP and remoteproc instead of unreliable XAPP1078 AMP on cpu1.

 

     Stan Schekall 

 

0 Kudos
Highlighted
Xilinx Employee
Xilinx Employee
6,495 Views
Registered: ‎09-10-2008

Re: AMP load CPU1 from Linux running on CPU0

Jump to solution

Hi Stan,

 

Starting with 2015.4 there is a getting started guide so that the app note should not be needed (but it's good information to have).

 

http://www.xilinx.com/support/documentation/sw_manuals/ug1186-zynq-openamp-gsg.pdf

 

I've been using this guide on Zynq Ultrascale+ MPSOC but I have not tried it all on Zynq 7000 yet.

 

It does use Petalinux so if you're rolling your own kernel then you might need to do a bit more on your own.

 

Thanks

John

 

 

0 Kudos
Highlighted
Contributor
Contributor
3,977 Views
Registered: ‎05-16-2014

Re: AMP load CPU1 from Linux running on CPU0

Jump to solution

Hi ,  do you have maked some progress about  AMP  ,  I am using  the  vavado2016.2 ,  and   don't  konw  how  to  modified the  BPS of  CUP1. Can  you  help  me  ,and  give me  your   E-mail Address  or  QQ .  I think  the  2016.2  is  different from the  2014.4  on  the  xilinx wiki .

0 Kudos
Highlighted
Visitor
Visitor
3,622 Views
Registered: ‎12-23-2016

Re: AMP load CPU1 from Linux running on CPU0

Jump to solution

Hello John,

 

When you talk about changing the starting address you mean in the app_cp1's linker script?

 

Regards

 

Alberto

0 Kudos