Project

General

Profile

How to access FPGA internal memory through AXI slave interface protocol

Added by Bill Lee over 10 years ago

Hi,

I have implemented a logic and loaded into cyclone V FPGA. Before that, I did run simulation to access a memory, which was generated by Megafunctions Wizard and is inside of FPGA. After I loaded the image of my design, I need to first check if I can access the FPGA internal memory from the commend line of a termianl emulator window. I used the "memtool" command, which I learned from critical link's design example about accesing external SDRAM, to write data to the address of 0xc000_0000 (FPGA region address space). Then, I try to read out the content from the same address as I wrote. However, It hung after I typed in the read commend by using "memtool".

The read command: "memtool -32 0xc0000000 32" It returns all ZEROs for 32 locations
The write command: "memtool -32 0xc0000000=0x1111" It returns "Writing 32-bit value 0x1111 to address 0xc0000000"
The read command: "memtool -32 0xc0000000 32" It hangs with "Re" showing on the terminal window.

Please help me on this issue or point me to a example or right way to do it.

Thanks in advance.
-Steve


Replies (10)

RE: How to access FPGA internal memory through AXI slave interface protocol - Added by Michael Williamson over 10 years ago

Which AXI crossbar interface are you using? The hps2fpga bridge or the lightweight bridge? Did you make a new preloader?

Ref: http://www.altera.com/literature/hb/cyclone-v/cv_54005.pdf

You must ensure that you are enabling the bridge prior to issuing a read-request or the bridge will stall.

Ref: http://www.rocketboards.org/foswiki/Documentation/GSRDProgrammingFPGA

RE: How to access FPGA internal memory through AXI slave interface protocol - Added by Bill Lee over 10 years ago

Thanks for your reply.

I am currently intend to use hps2fpga bridge only in my design. And I just copy the generated rbf file into SD card and loaded it into FPGA by using "cat file.rbf > /dev/fpga0". By refering to the 2nd link from your reply, 3 ways to do the FPGA configuration. It can be from Preloader (now only for QSPI, can not from SDMMC currently), U-Boot, or Linux. I am not sure if my way can enabling the h2f bridge.

I also, try to check the enable status through linux commands. I got the following responses when I did that.
First Login as root
"cat /sys/class/fpga/fpga0/status" - It returns "configuration phase"
"cat /sys/class/fpga-bridge/hps2fpga/enable" - it returns "cat: can't open '/sys/class/fpga-bridge/hps2fpga/enable': No such file or directory"
"cat file.rbf > /dev/fpga0"
"cat /sys/class/fpga/fpga0/status" - It returns "user mode"
So, is there any way to check if the bridge is enable or not?

Thanks again.

RE: How to access FPGA internal memory through AXI slave interface protocol - Added by Michael Williamson over 10 years ago

If you can't see the enable file then the driver for the device isn't compiled in or the device tree blob doesn't instantiate it. You typically don't want to enable the bridge until the FPGA is loaded.

Can you attach your full boot log or do a "dmesg > foo.txt" and post that?

Can you list what is present in /sys/class/fpga-bridge?

Also, can you attach your .config in your kernel build area or the /proc/config.gz file?

What device tree blob are you using?

-Mike

RE: How to access FPGA internal memory through AXI slave interface protocol - Added by Bill Lee over 10 years ago

Hi Mike,

I attached 2 files as you indicated in your previous reply. One is boot.log and another one is foo.txt.

Let me describe my intention and building flow to you.
1. I have a function need to be implemented in FPGA with HPS be able to access to the function through hps2fpga bridge.
2. I was told that I just need to generate a raw binary file of the design and copy it over to the SD card without regenerating u-boot and preloader. So, I just went through Quartus and Qsys process to generate a .sof file. After I converted it into a .rbf file, I copy the rbf file into the SD card under /home/root directory, and use the default u-boot and preloader in the SD card which came with development kit.
3. I put back the SD card to the dev. board. Power on, log in, and type "cat file.rbf > /dev/fpga0". That's all I do.

Please take a look the attached files and let me know if anything missing.

Thanks.

RE: How to access FPGA internal memory through AXI slave interface protocol - Added by Michael Williamson over 10 years ago

Hi Bill,

It looks like you are using version 3.8 of the kernel. Version 3.8 does not have the FPGA bridge drivers that provide the sysfs layers.

I believe we are now shipping DevKits that use a 3.12 version of the kernel as the baseline, which includes the sysfs fpga-bridge drivers you are trying to use.

I am looking for a copy of the SD card image on our support wiki and don't see it and need to chase down the right folks to get the reference image published (or you can build the kernel and run it yourself if you are comfortable with this approach).

The other way to enable the bridge would be to use memtool and check / take the bridge out of reset, something like the command below (after you load the FPGA). That might be a "quick fix" with the 3.8 kernel.

memtool -32 0xFFD05000=0x06

Sorry for the delay.

-Mike

RE: How to access FPGA internal memory through AXI slave interface protocol - Added by Bill Lee over 10 years ago

Mike,

I think you meant "memtool -32 0xFFD0501C=0x06" for brgmodrst register. The reset value of the register somehow shows "0x00000000". So, I set it to 0x7, then 0x6, to make sure the hps2fpga bridge get reset and release the reset.

We purchased the dev. kit last year. That may be the reason why the kernel version is out of date. I would prefer that I can get a up-to-date version of the SD card image from you. Please let me know when you found the new image.

By the way, if I use memtool to access fpga address space, what the address range should be? Can I use "memtool -32 0xc0000000 1" to access the first location of the FPGA region?

Thanks again,

RE: How to access FPGA internal memory through AXI slave interface protocol - Added by Alexander Block over 10 years ago

Information on how to make an SD card based upon the current Development Kit SD card image (Rev 1B) can be found on this wiki page (https://support.criticallink.com/redmine/projects/mityarm-5cs/wiki/Building_SD_Card_Image) in the "Development Kit SD Card Image" section.

-Alex

RE: How to access FPGA internal memory through AXI slave interface protocol - Added by Bill Lee over 10 years ago

Hi,

I downloaded the sd_image_mitysom_5csx_rev1B.zip, and extracted out the .bin file. Then I typed "sudo dd if=sd_image_mitysom_5csx_rev1B.bin of=/dev/sdb bs=1M" into a brand new 8GB MicroSDHC sd card. Next, I typed "sync" as instructed in the ../wiki/Building_SD_Card_Image/ session. After that, I plug the sd card in the sd card slot of the dev. board. As usual, I brought up the terminal window with the setting of "baud rate=57600; data=8bits; parity=0; stopbits=1; flowcontrol=0". But the terminal showed unrecognize characters on the screen. Do I need to load in any other files in the SD card?

Thanks,

RE: How to access FPGA internal memory through AXI slave interface protocol - Added by Adam Dziedzic over 10 years ago

Hi Bill,

Sorry for the confusion. The latest image updated the Baud Rate to 115.2kbps to be consistent with the rest of the Critical Link modules.

- Adam

    (1-10/10)
    Go to top
    Add picture from clipboard (Maximum size: 1 GB)