Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
871 Views

Linux access to non-Linux memory

I want to write large amounts of data into DDR using the FPGA. This works, and I can store data at the required rate. I want the ARM on the C5SOC chip to be able to process that data. 

 

I have tried various tacks, but the one that works (but slowly) is to configure Linux to only use 768MB, then use the FPGA to write to the last 256MB of the DDR memory, and get Linux to access it using: 

mmap(NULL, 0x10000000, (PROT_READ | PROT_WRITE), MAP_SHARED | MAP_LOCKED, fd, 0x30000000); 

 

The only problem with this, and it's a big one, is that it would seem access to this memory is painfully slow. If I copy it from there to a malloc'ed buffer in Linux and then process it, it works MUCH faster. This is all within the HPS DDR memory chips, so it's the same chip being accessed in both cases, but going through mmap is slow. I have been advised that there are better ways of doing this, but the person advising wasn't sure how. I've posted this question here, in the hope that some software people/Linux people will be able to advise how to access physical addresses quicker from within Linux. 

 

Given that any FPGA memory buffer accessed through the HPS2FPGA busses will necessarily run slowly because the only way I know of accessing them is via MMAP. Is there a better way? 

 

Cheers, 

Simon
0 Kudos
5 Replies
Altera_Forum
Honored Contributor I
26 Views

May be your "up" memory not cached ? 

You try malloc Linux memory, translate it start address to absolute from HPS and to relative FPGA AMBA address and write to ?
Altera_Forum
Honored Contributor I
26 Views

That would be ideal, but I have no idea how to translate a malloc'ed Linux address to an absolute HPS address! Any clues gratefully received.

Altera_Forum
Honored Contributor I
26 Views

I is not fanat of Linux, still know a function mmap() with file 'fd = open("/dev/mem", O_RDWR|O_SYNC)', that get any system region to be visible in process. May be reverce function ? Sources for investigation ? 

In any case, you may fill your malloc-ed region with unique string likewise "1@3$zxcv0(8&:LKJ", search it from FPGA and write to it all data :) 

P.S. Or search your string from HPS: map sequentially all absolute knowing DDR memory with mmap(), find string, unmap, map upper...
Altera_Forum
Honored Contributor I
26 Views

Reserving a chunk of physical memory (as you've done) is probably easiest. 

Does seem like you've got uncached access to the memory. 

You didn't say which device you've opened (for the mmap), there might be one that gives cached access. 

Otherwise you'll need to write a device driver and work out how to map the memory cached and then implement mmap().
Altera_Forum
Honored Contributor I
26 Views

Hi all, 

Please help me if you have able to access HPS DDR3 memory for your processing. 

My problem is: 

I have used malloc for reserve memory in DS-5 code.so I got one start address.now I pass the same to my DMA write start address .so DMA in qsys will start write data from that location. 

Now I want to read that location form DS-5 code. 

so I need to translate that address to read data from HPS DDR3 memory? if yes ,How? 

 

Thanks in advance.