cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
marcoventurini
Adventurer
Adventurer
35,813 Views
Registered: ‎10-02-2014

Zynq + Petalinux reserve a DDR memory region

Jump to solution

Hi all,

 

I' working on a system where Petalinux and a custom AXI DMA share a common area of the DD3 memory.

 

I'm an experienced FPGA designer but i have no experince in linux sw development. ;)

 

The idea is that the PS writes that area of memory and then commands the FPGA to read it or viceversa.

I have already made it work with a bare metal application, now i have to try with linux.

 

So far i got a register interface(not mapped in the DDR address sapce) working with the UIO driver.

My system will have lik 128 Mbytes for linux and 384 of shared buffer.

 

The buffer must not be chached and must be accessible from userspace.

 

My first question is :

Should i limit the RAM size in the petalinux BSP? (by changing the main_memory_size override)

How do i write/read withpu cache ? is there some guide or some snippet like "write a word to address 0x10000000" ?

 

Thanks

 

Marco

 

 

 

 

 

0 Kudos
43 Replies
abbascit
Contributor
Contributor
3,867 Views
Registered: ‎12-30-2015
Hi David,

I could be when you try to perform DMA to ddr at that moment Linux is using that part of memory.

What i had done i built the Linux kernel with my own hardware design and developed DMA driver. Then I performed whole DMA transactions in Linux.

I also tried to do like you are doing but I didn’t got any success. So I decide to use Linux and developed kernel drivers.

Another thing Linux reads and writes to virtual addresses while bearmetal with DMA uses actual address. That could be the cause of problem.

Make sure you are reading acutal address space in Linux. You can also see the memory registers after written through DMA there was a option in xsdk.

It will give you more clues.

Regards
Abbas
0 Kudos
3,860 Views
Registered: ‎05-16-2015

The DMA is a shared resource.

If you don't have a clear hand shaking between to access it, you might run in to troubles?!.

Additionally, you might as well having caching issues.

 

I had caching issues while moving data between from one core to the other using the DDR (but no DMA transfer).

 

Hope this helps.

Regards 

0 Kudos
davirol
Observer
Observer
3,836 Views
Registered: ‎08-16-2017

Thanks @abbascit,giona.imperatori@phonak.com for the help. We'll try to figure out what can be happening.

 

Regards

 

 

0 Kudos
liwenz
Explorer
Explorer
1,934 Views
Registered: ‎10-09-2017

I'm trying the solution, but I wonder where  the dts file is. 

I add usb with changing ./project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi

It is  petalinux 2018.2, 

how to do "altering the devicetree in the boot partition"?

0 Kudos
m3atwad
Voyager
Voyager
1,572 Views
Registered: ‎05-25-2016

Has a working example of a device tree that reserves DDR memory space been posted?  This seems critically important and there is no clear detailed response from Xilinx.  This is a core pillar of the entire zynq platform.

Could someone from Xilinx please respond to the follow:

1. Example working device tree that reserves a DDR memory chunk

2. How did you select the memory region to ensure it doesn't interefere with other parts of linux?

3. What do the lines in the reserved-memory section of the device tree do/mean?

4. What else besides the device tree do we need to modify for the linux image build?

5. Are there any additional steps, flags etc.. involved in the petalinux build of this system?

6. Should we use UIO or mmap - there is a lot of confusion here.

This is too important to be this fragmented and confusing - someone from Xilinx needs to straighten out this approach with clear details!

I ran across this which may be helpful but still doesn't cover all the questions.

#1 may be covere by the below link - it looks like there is a write up on confluence that describes this process to some degree.

https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18841683/Linux+Reserved+Memory

0 Kudos
r.sarwar87
Participant
Participant
1,562 Views
Registered: ‎09-17-2018

The method of reserving memory from device tree is given in wiki:

https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18841683/Linux+Reserved+Memory

 

reserved-memory {
   #address-cells = <2>;
   #size-cells = <2>;
   ranges;
 
   reserved: buffer@0 {
      no-map;
      reg = <0x0 0x70000000 0x0 0x10000000>;
   };
};
 
reserved-driver@0 {
   compatible = "xlnx,reserved-memory";
   memory-region = <&reserved>;
};

1. The above lines will reserve 256 MB bettween 3.5 and 4 GB.

2. you can select any region you feel like. Linux will bypass it. It is called "reserved memory" after all :)

3. they reserve memory in between address range bla bla bla, and assigns a driver, if you want to use cma, etc.

4. nothing

5. no

6. depends on your application

 

most of your questions are things you should be able to answer yourself -> just compile, boot, and find out. 

 

0 Kudos
m3atwad
Voyager
Voyager
1,559 Views
Registered: ‎05-25-2016

Thanks for the direction

0 Kudos
m3atwad
Voyager
Voyager
1,518 Views
Registered: ‎05-25-2016

for current version of petalinux - should this node be added to the "system-user.dtsi" instead of the "system-top.dts"?

 

When I do a petalinux-build -x mrproper I see that all my device trees get deleted except for the /project-spec/meta-user/recipes-bsp/device-tree/files/systemuser.dtsi

0 Kudos
r.sarwar87
Participant
Participant
1,480 Views
Registered: ‎09-17-2018

depends on your workflow, xilinx will have you added to  /project-spec/meta-user/recipes-bsp/device-tree/files/...

 

    0 /include/ "system-conf.dtsi"
    1 / {
    2   chosen {
    3   ┊ xlnx,eeprom = &eeprom;
    4   };
+   5   reserved-memory {
+   6   ┊ ┊#address-cells = <2>;
+   7   ┊ ┊#size-cells = <2>;
+   8   ┊ ┊ranges;
+   9   ┊
+  10   ┊ ┊reserved: buffer@0 {
+  11   ┊ ┊ ┊ no-map;
+  12   ┊ ┊ ┊ reg = <0x0 0x5ff00000 0x0 0x20000000>;
+  13   ┊ ┊};
+  14   };
+  15   ┊
+  16   reserved-driver@0 {
+  17   ┊ ┊compatible = "xlnx,reserved-memory";
+  18   ┊ ┊memory-region = <&reserved>;
+  19   };
   20 };
   21 
   22 /* notes:
   23 serdes: // PHY TYP see: dt-bindings/phy/phy.h
   24 */
   25 
   26 /* default */
   27 &amba {
   28   ┊ zyxclmm_drm {
   29   ┊ ┊ ┊ ┊ ┊ compatible = "xlnx,zocl";
   30   ┊ ┊ ┊ ┊ ┊ status = "okay";
   31   ┊ ┊ ┊ ┊ ┊ reg = <0x0 0xA0000000 0x0 0x10000>;
   32   ┊ ┊ ┊ };
   33 };
   34 /* SD */

 

0 Kudos
m3atwad
Voyager
Voyager
1,459 Views
Registered: ‎05-25-2016

thansk @r.sarwar87 that is the correct place I think.  I now seem to have this up and running in 2019.1.  The wiki is outdated and the above mentioned device tree file should be used instead.

0 Kudos
Prasanna_K
Explorer
Explorer
932 Views
Registered: ‎07-24-2020

Hi, I Know its a old post but still i will try. I am also trying to achieve the same as you tried, may I know, how did you fix this?

0 Kudos
m3atwad
Voyager
Voyager
909 Views
Registered: ‎05-25-2016

@Prasanna_K did you use the example device tree above?  What does your device tree look like right now?

0 Kudos
Prasanna_K
Explorer
Explorer
842 Views
Registered: ‎07-24-2020

@m3atwad I have made manual entry of my device tree in system-user.dtsi and it looks like this,

memory {
device_type = "memory";
reg = <0x40000000 0x20000000>;
};

I am trying achieve, all memory request from the PS has to pass through my PL, instead of PS directly accessing DDR. That is why I have given the physical address of the PL as the memory address start address. Could you please guide me as to how to make the petalinux to write all the memory request to PL instead of DDR? 

NOTE: I have made this working in baremetal, just that I am new to petalinux, and am not able to figure out how to accomplish the same from the OS level.

 

0 Kudos
m3atwad
Voyager
Voyager
826 Views
Registered: ‎05-25-2016

@Prasanna_K I actually don't know how to do that.  I thought you were using PS DDR and just needed a reserved space.  I would continue reach out to someone more experience at Xilinx as you are trying to do.  I'm sorry I couldn't help

0 Kudos