Thanks for all that information, I will apply it to my project.
I am using this project:
https://github.com/bvlc/caffe The idea is that the FPGA module performs what the im2col function does (
https://github.com/bvlc/caffe/blob/master/src/caffe/util/im2col.cpp), translate an input image into a vector so later it can be used to perform some basic matrix operation.
I found that the input data (const Dtype* data_im) is some RAM allocated using malloc (CaffeMallocHost() in caffe,
https://github.com/bvlc/caffe/blob/master/include/caffe/syncedmem.hpp), so the idea is to change the CaffeMallocHost function to allocate memory which can be used later by the FPGA module to perform the im2col custom function, so I will need the physical address of that buffer already allocated by CaffeMallocHost().
I read that the dma_sync_single_for_device/cpu is required to sync the data, i.e., flush and invalidate the data cache, so the data is up to date when the CPU or DMA need to handle it.
So the function user_peripheral_mmap gets called when the mmap is called from the user space application? If so, what is the physical address we need to pass to the mmap function in the user app?
Also in the github link you provided to me, there is a file named as devicetree.template, what is the meaning of "reg = <0x40000000 0x20000>", The DE1-SoC has 1GB DDR3 SDRAM.
can you provide to me a sample code for a user app trying to allocate memory using the approach you are giving me please.
Thanks for all you time yxi95! I appreciate it!