UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Visitor jesuabi.lc
Visitor
273 Views
Registered: ‎06-27-2018

Use AXI DMA to read on-chip RAM in RedPitaya V1.1

HI everyone

 

I've been asked to use a RedPitaya system to read data from a file and send it out trough the digital I/O on my board as a digital sequence.

I wrote a C code, and put some IP blocks together on Vivado, wrote a file with random 32 bit values and run all the system together with Linux using Putty. The results were...expected but disapointing, the sequences got out correctly from the digital I/O...but pretty slowly, at a 100 khz frequency.
Before that I was able to pull out  4 digital sequences at full clock speed (125 Mhz), writing 4 registers manually, and using a shift register code I wrote on VHDL.

I'm using an AXI_GPIO to write the values that my C code reads from the SD card, I've been reading about using AXI DMA, but I don't really understad how does it works.

My idea now is to read the values from SD card, write them on the RAM and then send it directly to the PL

Here is my Block Diagram and my C code for you tu analyze

BD_RP.png

 

And here is my C code:

#include <stdio.h>
#include <stdint.h>
#include <unistd.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
  int fd;
  long N_val=0;
  void *cfg;
  char *name = "/dev/mem";
  char filename[30];
  

  if (argc == 2) 
    {
  		strcpy(filename,argv[1]);
  		printf("abriendo ''%s''...\n",filename);
  	}
  else 
  	{
 		printf("Número de argumentos erroneos");
 		return 0;
	}
	
  if((fd = open(name, O_RDWR)) < 0)
  	{
    	perror("open");
    	return 1;
  	}

  cfg = mmap(0, sysconf(_SC_PAGESIZE), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x42000000);
	
  FILE *file=fopen(filename,"r");
  
  if ( file != NULL )
    {
      	char line [ 65535 ]; /* or other suitable maximum line size */
	      while ( fgets ( line, sizeof line, file ) != NULL ) /* read a line */
	      {
	         *((uint16_t *)(cfg)) = atof(line); 
	      }
	    N_val=N_val++;
	    fclose ( file );
    }
  else
    {
      	perror ( filename ); /* why didn't the file open? */
    }

  printf("Numero de valores: %li\n", N_val);
  
  *((uint16_t *)(cfg)) = 0; 

  munmap(cfg, sysconf(_SC_PAGESIZE));
  return 0;
}
0 Kudos
2 Replies
Xilinx Employee
Xilinx Employee
207 Views
Registered: ‎10-04-2016

Re: Use AXI DMA to read on-chip RAM in RedPitaya V1.1

Hi @jesuabi.lc,

I'm not sure what your question is. It sounds like you are interested in using AXI DMA, so I thought I would point out a few resources to get started.

The Product Guide is here:

https://www.xilinx.com/products/intellectual-property/axi_dma.html

Example code and bare metal drivers are here:

https://github.com/Xilinx/embeddedsw/tree/master/XilinxProcessorIPLib/drivers/axidma

Regards,

Deanna

-------------------------------------------------------------------------
Don’t forget to reply, kudo, and accept as solution.
-------------------------------------------------------------------------
0 Kudos
Visitor jesuabi.lc
Visitor
204 Views
Registered: ‎06-27-2018

Re: Use AXI DMA to read on-chip RAM in RedPitaya V1.1

Hi Demarco

I wonder if someone could help me improve my current desing using AXI_DMA, because I really don't know what to do about the data transfer between my RedPitaya's SD Card, the DDR memory, the PS and the PL.

Thanks for the documentation, but I'm really new at all this SoC things.

0 Kudos