How to reserve DDR3 memory region for FPGA direct access?


#1

I have a system design that FPGA will generate data, and update to DDR3 of HPS. then notify (interrupts ) HPS. and HPS start to transmit data into PC via Ethernet.

I have few questions of software design in this architecture, please help me to find the solution.

Questions:

  1. How to reserve DDR3 memory region in Linux OS ? (Linux OS will not use this segment of memory).
  2. How to access reserved DDR3 memory region in Linux Application or Linux kernel ?

Thanks in advance.


#2

when creating your u-boot.scr

add the line:
setenv mmcboot ‘setenv bootargs console=ttyS0,115200 mem=512M root=${mmcroot} rw rootwait;bootz ${loadaddr} - ${fdtaddr}’

which will allow 512M for Linux (leaving everything else for FPGA)

accessing is a bit more involved (& I’m still figuring it out myself )


#3

hi!!
and also try
memmap=512M$1024M (begining at 1024M for example)
take a look at memmap
https://www.kernel.org/doc/Documentation/kernel-parameters.txt

"
memmap=nn[KMG]$ss[KMG]
[KNL,ACPI] Mark specific memory as reserved.
Region of memory to be reserved is from ss to ss+nn.
Example: Exclude memory from 0x18690000-0x1869ffff
memmap=64K$0x18690000
or
memmap=0x10000$0x18690000
"
or you can also try reserved-memory in your device tree
in kernel /Documentation/devicetree/bindings/reserved-memory.txt

And to access
mmap

bye


#4

Hi,
I planned a similarly architecture in my application and will start to implement them now.
To write the data from FPGA, I can use the upper 512M from my 1GB RAM, when I set the parameter mem=512M in the u-boot script…? Is this true?
Have someone any good idea or solution to read the data (from Linux) which are located in the ddr memory? It should be also possible to process the data and write them back from the HPS. (In a further step, the data should be transmitted over Ethernet)


#5

Where is the u-boot-scr file located? Can you elaborate on the steps required? Does only the uboot and perhaps preloader get modified to achieve this, and linux will inherit the reservation? Or do we have to rebuild linux?


#6

hi!
you just create a u-boot.txt file with the kernel parameters
like this:

setenv mmcboot "setenv bootargs console=ttyS0,115200 root=${mmcroot} mem=1020M memmap=4M$1020M rw rootwait;bootz ${loadaddr} - ${fdtaddr}"
run mmcload;
run mmcboot;

Create the u-boot.scr
~/cv_soc_devkit_ghrd/software/spl_bsp/uboot-socfpga/tools/mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n “My script” -d u-boot.txt u-boot.scr
(refer http://rocketboards.org/foswiki/view/Documentation/GSRD131ProgrammingFPGA#GSRD_FPGA_Configuration)

Copy it to the fat partition.

For more information
http://blackfin.uclinux.org/doku.php?id=reduce_kernel_memory_footprint&s[]=kernel&s[]=memory

And you dont have to rebuild linux!
bye


#7

Any other Ideas??? or way to do this!!??


#8

Hi,
You can also use a reserved-memory node in your dts file.

Take a look here

Regards,
Fred.


#9

I have tried to reserve memory region in u-boot.scr.

And access reserved memory region in Linux application using mmap(), It seems work.

You can see note of my testing.
download: (1) https://mega.nz/#!a95W1IID!j4LAx0PI-G9Nk7DTh7nsXNv68ziDtmeKtGIsuw0s-Kc
(2) https://mega.nz/#!apgRXYDR!O5QjjIbOaUofs1eCGZzo9nEp45olSP7Xf7aM4OXnWgk


#10

I’ve started a design where FPGA uses own DMA to read/write to DDRAM attached to HPS. The tricky part seems to be reserve and found out physical memory adress for a buffer allocated in the app. I’m not reserving memory but instead allocate buffer then figuring out it’s physical adress and provide this to DMA (I’m using Scatter Gather DMA). With small amounts of memory it works but I haven’t tested yet what happens with large buffers (beyond page size). Translation to physical adress is described in following link but it’s more a hack than a portable solution.

https://shanetully.com/2014/12/translating-virtual-addresses-to-physcial-addresses-in-user-space/

Just discovered that this translation of virtual adress to physical doesn’t work in user space for me reliably. Sometimes it works but sometimes not!. So I switched to reserving memory and map this from /dev/mem by mmap.


#11

Hi,

Can please tell me how can I use the reserved-memory on a driver?
I have set a node as shown in the link you provided, but after that how can I request or use that memory in my device driver? I need to map that area in my driver.

Regards,
Alex


#12

Hi,

is there a tutorial witch addresses the driver implementation and the hardware part inside the FPGA?

Regards,
Sebastian


#13

Hello there, the link to the kernel-parameters text is broken, probably moved somewhere else?

I have dug out what I think is the same section on the html based documentation from the kernel for version 4.10:

https://www.kernel.org/doc/html/v4.10/admin-guide/kernel-parameters.html?highlight=kernel%20parameters


#14

Hi…i am a new user here. As per my knowledge the tricky part seems to be reserve and found out physical memory adress for a buffer allocated in the app. I’m not reserving memory but instead allocate buffer then figuring out it’s physical adress and provide this to DMA. With small amounts of memory it works but I haven’t tested yet what happens with large buffers .

pcb assembly