zangman / de10-nano

Absolute beginner's guide to the de10-nano
Apache License 2.0
182 stars 43 forks source link

U-boot instructions for SDRAM interactions #29

Open GustavoDLRA opened 4 months ago

GustavoDLRA commented 4 months ago

Hello! I was working in the FPGA - SDRAM Communication project. All was going fine up to the part of the U-boot programming. In instruction # 4: """ Now we load the rbf file into memory and then flash the FPGA with it. The reason we do this is because the FPGA design has some configuration bits on the bridge that get enabled when we flash it. However, this needs to be done when the sdram bridge is in reset mode and when it is not being used by the HPS. Hence it needs to be done in u-boot.

fatload mmc 0:1 0x2000000 sdr.rbf fpga load 0 0x2000000 0x700000 """

the fpga load instruction does not work. I was able to load my rbf file appropiately (The rbf file was generated based on the given instructions starting from the barebones project from the prior project): => fatload mmc 0:1 0x2000000 soc_system.rbf 2081456 bytes read in 106 ms (18.7 MiB/s)

But, when trying to do the fpga load part, I get the following error:

=> fpga load 0 0x2000000 0x1FC2B0 Command 'load' failed: Error -6

I was wondering why I happened to get different project sizes than those presented in the guide. I tried to adjust the hex part to reflect the size of the rbf, but still I wasn't able to progress. Thank you for your responses.

Andy2No commented 4 months ago

@GustavoDLRA perhaps it's due to the format of the .rbf file? In the process of converting the image to .rbf, you have to set a format, e.g. Passive Parallel x16, which is what the instructions show here:

https://github.com/zangman/de10-nano/blob/master/docs/Flash-FPGA-from-HPS-running-Linux.md#create-a-blink-design

I'm fairly sure there's only one format that will work with U-boot, and I haven't personally verified that those instructions are correct, so it may be worth trying others.

Using robseb/rsYocto (which is a similar system to the Zangman one) it's possible to load an FPGA image after the system has booted, from the linux command line (bash, IIRC), or from a script. I'm not sure if the Zangman system allows that, but it's another option for you to try:

https://github.com/robseb/rsyocto

I have tried that and I seem to remember it's possible to load different formats of .rbf that way. I didn't try loading them in U-boot.

I was able to send .rbf files to the microSD card via the USB-serial connection on both robseb/rsYocto and Zangman (using the Zmodem protocol in Teraterm with the rz command in linux), but to do it on Zangman I had to install the lrzsz package first. The version I needed for Debian was lrzsz_0.12.21-10_armhf.deb

To install that, I placed it on the FAT partition of the microSD card then mounted that to copy the file. I had to umount it afterwards to avoid Windows giving a warning message and wanting to scan it for errrors, afterwards. I can give more details if you want them, but I think if you want to try loading a .rbf from linux, rather than u-boot, you may need to use robseb/rsYocto instead.

The way I was trying .rbf images was to just let U-boot load whatever was on the card, then loading my own image from the command line, or from a script that ran automatically when it booted up, overwriting the one from U-boot. Provided that the device tree is the same, or at least the parts of it that you want to use are the same, there's no need to change the device tree.

GustavoDLRA commented 4 months ago

Thank you so much. I'm gonna try these things and report back later.

Thanks again