Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
Announcements
Need Forum Guidance? Click here

Search our FPGA Knowledge Articles here.
19220 Discussions

FPGA2HPS SDRAM Bridge Appears to Be Working but data is Zeros

Altera_Forum
Honored Contributor II
834 Views

I'm using Q 17.1 I have tried this on numerous Evaluation boards -- but will describe it for the Macnica Sodia. 

 

This same code scheme worked with the Helio Evaluation board which used an older GSRD as the starting point a few years back. 

 

I start with the Golden Design Quartus project AND the SD Card image. 

 

I add a custom IP where the firmware is responsible for writing data to SD RAM memory (On signal tap we can see that the data is getting written to the specified location). 

 

I create new *.rbf and new *.dtb to link the custom Linux device driver properly. 

I also create a new preloader and u-boot - but this doesn't make any difference it I use the original GOLDEN u-boot and preloader or the ones created for this specific project.  

 

The custom Linux device driver for this IP kmallocs two buffers and uses this address to set up the firmware IP. It then creates virtual addresses for user space for the "copy_to_user" in the read function. 

 

Linux indicates -- ALL THE BRIDGES ARE ENABLED and I actually have the FPGA configured from the EPCQ and can see from the LEDs that it is configured BEFORE u-boot starts. SIGNAL TAP indicates that the data is being moved by the firmware. 

 

BUT - when the device driver does the "copy_to_user" from the virtualAddress the user space code buffer is ALL ZEROS. 

 

ANY ADVISE WOULD BE GREATLY APPRECIATED !!!
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
87 Views

SOLVED !!!!! 

 

I switched my allocation of the memory buffers to: 

 

 

static char * dmakbuf1; "kbuf" 

static char * dmakbuf2; 

 

static dma_addr_t handle; 

static dma_addr_t handle2; 

static size_t size = (1024 * PAGE_SIZE); 

 

 

dmakbuf1 = dma_alloc_coherent(NULL, size, &handle, GFP_KERNEL); 

if ( dmakbuf1 == NULL ) printk( KERN_ALERT "dma_alloc_coherent FAILED !!!! BUF1 \n" ); 

dmakbuf2 = dma_alloc_coherent(NULL, size, &handle2, GFP_KERNEL); 

if ( dmakbuf2 == NULL ) printk( KERN_ALERT "dma_alloc_coherent FAILED !!!! BUF2 \n" ); 

 

 

THE RETURN VALUES == "handle" the physical address is what I give to the FIRMWARE 

and the "dmakbuf" is what the user space code needs (NO ioremap) 

 

Hope this helps someone else.
Reply