Jump to content
  • 0

Physically Contagious 4MB memory of DDR with Physical Base Address to communicate to PL


Saad Zia

Question

Dear Expert

I am working on Petalinux 2015.4 and Zedboard. I want to have a contagious 4 MB block of DDR to communicate with PL and have the physical address of the its Base.

-Can I have this much memory allocated?

-How can I get physical address of the memory?

Regards

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

The way I typically do this is reserve the first half of the DDR for the OS (in your case, Petalinux) and the other half for shared memory between CPU and FPGA.

 

You can do that in the device tree, in the bootargs line by adding "mem = 512M". This will cause the OS to only "see" the first 512MB of memory, and you can safely use the remaining DDR for shared memory.

In order to access it, you can either mmap it or create a generic-uio driver in the device tree. I recommend the latter. To do this, add the following to your device tree:

 

{
scratch_mem@20000000 {

#address-cells = <1>;

#size-cells = <1>;

reg = <0x20000000 0x20000000>;

compatible = "generic-uio";

interrupts = < 0 58 0 >;

interrupt-parent = <0x1>;

};

 

You will also have to modify your bootargs line in the device tree to enable generic-uio. For instance:

bootargs = "console=ttyPS0,115200 root=/dev/mmcblk0p2 rw earlyprintk rootfstype=ext4 rootwait mem=256M uio_pdrv_genirq.of_id=generic-uio";

 

I hope this helps ;)

Link to comment
Share on other sites

As far as I know, allocating physically contiguous memory from User space is not easily done, and usually requires a hack or to tie into a specific subsystem for what you are trying to accomplish (for example, using the DRM frame work to allocate framebuffer memory). If you are trying to allocate memory for a video framebuffer, I would highly recommend this guide for learning to do so: http://betteros.org/tut/graphics1.php .

If you are looking for just a general purpose way of allocating memory, I think you can do it from the device tree: https://www.kernel.org/doc/Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt 

 

Link to comment
Share on other sites

Dear @miguel_rodrigues, thank you for the reply, I was able to export UIO for mem= 256, Now I want to do the following: 

The size of ZedBoards Ram is 512 mb, What I am gonna go is mem= 508 so that I have enough space for my buffer.

Now for this, what should be address of scratch_mem@20000000, i.e. what should be replaced by 20000000?

And what will be the physical base address of my 4MBs?

Link to comment
Share on other sites

I change scratch_mem to following:

scratch_mem@1fc00000 {
        #address-cells = <1>;
        #size-cells = <1>;
        reg = <0x1fc00000 0x400000>;
        compatible = "generic-uio";
        interrupts = < 0 58 0 >;
        interrupt-parent = <0x1>;
    };

Is this correct approach?

Link to comment
Share on other sites

Yes, that is the correct approach.

 

However, I would note that for the Zybo I had to modify the fdt_high and initrd_high from 0x20000000 to 0x10000000 in u-boot. This is because the DDR in Zybo has 512MB, like the Zedboard. This issue was noted right away as Linux started crashing.

 

The way I did this was build everything from scratch, but maybe it is possible to modify these variables in a u-boot command prompt.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...