Showing results for 
Show  only  | Search instead for 
Did you mean: 
Registered: ‎08-14-2014

Petalinux AMP FreeRTOS cannot reset SPI properly




  I have been running PetaLinux AMP with FreeRTOS on CPU1 on a ZC706 for a while.  I was able to customize the rpmsg interface and I am passing messages between Linux and FreeRTOS with no problem.  Now I need to interface with Analog Devices' AD9361 card with AMP running FreeRTOS on the second core.  When I boot up FreeRTOS on CPU1, after I intialize the Trace Buffers and remoteproc, I need to reset the AD9361 and read  the product ID hrough SPI0.  Unfortunately, I am not able to read the SPI register correctly.  After resetting SPI0, I don't see it in the RESET state.  The status returned when reading the SPI register is always 0.  The same code I used in FreeRTOS to initialize the SPI and AD9361 works fine when it is running in CPU0 alone, or with both CPU0 and CPU1 running as bare-metal.  I have also tried the Peripheral Test code from the XSDK templates, but it failed with SPI the same way (That is, running Linux on CPU0, and the Peripheral Test FreeRTOS on CPU1).  I have added the SPI and AD9361 interfaces in the resouce section in remoteproc.c, but that does not seem to make any difference.  Does anyone have the experience or insight to why FreeRTOS running on CPU1 cannot read the SPI register?


Thanks in advance,



Tags (3)
0 Kudos
4 Replies
Registered: ‎08-14-2014


I have actually resolved this problem on my own.  I needed to add the spi node in the device tree script.  Unfortunately, the SDK device tree generator does not seem to work properly - the generated device tree blob does not work.  I have to manually add to the device tree script the following for enablig the SPI:


                            spi0 = &ps7_spi_0;


and the node


                            ps7_spi_0: ps7-spi@e0006000 {

                                   bus-num = <1>;

                                   clock-names = "ref_clk", "aper_clk";

                                   clocks = <&clkc 25>, <&clck 34>;

                                   compatible = "xlnx,ps7-spi-1.00.a";

                                   interrupt-parent = <&ps7_scugic_0>;

                                   interrupts = <0 26 4>;

                                   num-chip-select = <4>;

                                   reg = <0xe0006000 0x1000>;



Note the bus-num field is essential.


I am running Petalinux on CPU0 and FreeRTOS on CPU1, with FreeRTOS interfacing with an AD9361 card over the SPI.



0 Kudos
Registered: ‎05-16-2015

Hi Twong,


I'm facing the same issue as you.


Con CPU0 I have linux running, on the CPU1 I have my bare metal application.

I would lilke to be able to use the SPI0/1 from the bare metal application.


If I try to read the Spi0 register it is always zero (peek 0xE0006000).

This even after I try to set this register to its default value via: poke 0xE0006000 0x00020000


Due to this reason, the SPI self test fails.


Could you please add more information on what you did?



Thank you in advance.



0 Kudos
Registered: ‎05-16-2015



just got around this, it seems that the linux is not turning on the peripheral's clocks at bootup.

here the code to make it work:

APER_CLK_CTRL |= (1<<14) | (1<<15);
SPI_CLK_CTRL = 0x00000503; //Spi clock divider set to 5, SPI1 & 0 clock enable

0 Kudos
Registered: ‎01-09-2019

I am facing  the same issu on Peta Linux 2018.2

Kindly help


0 Kudos