openpiton icon indicating copy to clipboard operation
openpiton copied to clipboard

VCU118 hangs at loading Linux from SD Card

Open khoatm98 opened this issue 1 year ago • 19 comments

Hi everyone, I tried to get this project worked on VCU118.

I tried to implement the workaround solution in https://github.com/PrincetonUniversity/openpiton/issues/65 but it still does not work. I also tried to modify the clock divider on sd card and modify the VADJ.

The system always get stuck at sd initialized! initializing SD... sd initialized! copying block 0 of 1 blocks (0 %) z5309218568739_edc8d4f09ab8847a278c646cd7de1d2d z5309219218443_82c686608fe69018191fa7e82ef348b0 z5309218542440_752060b85f2149fd8c3dacc7feb28e6a

Is there anything else that I need to check? Thank you very much.

khoatm98 avatar Apr 02 '24 11:04 khoatm98

Sorry, this issue is redundant.

khoatm98 avatar Apr 05 '24 04:04 khoatm98

This is the first week of our teaching quarter so I wasn't keeping up. Did you figure it out?

Jbalkind avatar Apr 05 '24 04:04 Jbalkind

Yes, it seems like the connection is not stable all the time, we need to reset the CPU several times until it can read data from SD card.

khoatm98 avatar Apr 05 '24 04:04 khoatm98

That is frustrating. Unfortunately we don't have a vcu118 of our own. Ultimately I think Xilinx's decision to deprioritise low speed I/O on ultrascale+ seems to make this kind of issue inevitable. I do wonder whether further reducing the SD frequency might help?

Jbalkind avatar Apr 05 '24 04:04 Jbalkind

I will try reducing SD frequency and let you you the result asap. By the way, currently I also want to try the solution booting without SD card mentioned in https://groups.google.com/g/openpiton/c/STQLcZMDOeI/m/wZUfb2z3AgAJ as a work around solution.

khoatm98 avatar Apr 05 '24 05:04 khoatm98

Hi @Jbalkind,

I tried to reduce the clock frequency for SD but the result still remains the same. I tried booting Linux by pitonstream and it works fine. However, in both cases (loading from SD card and by pitonstream), I could only get few information printed out the console and the program could never boot up successfully. I also tried the ariane image on the website as well as rebuilding one myself.

I wonder if you have any experience about this situation.

Thank you, Khoa. screen.txt

khoatm98 avatar Apr 05 '24 16:04 khoatm98

I would recommend against using UART for Linux boot. It's pretty likely that there could be a data corruption over the course of loading the whole bitstream. Perhaps you could try JTAG? There is a bscane2 config in the RTL that you could set up and try loading the kernel image using openocd and gdb. It's a lot faster and more reliable than UART.

Jbalkind avatar Apr 08 '24 17:04 Jbalkind

Thank you @Jbalkind ,

I will try it this week and let you know the result.

khoatm98 avatar Apr 08 '24 17:04 khoatm98

Hi @Jbalkind ,

Now, I have been trying Openocd but the result is not optimistic. I checked the schematic and the Bscane2 module is already there. I want to confirm that whether it is necessary to connect our host machine to the FPGA board via GPIO pins or we can just use the micro-USB port labeled with JTAG.

image

Thank you.

khoatm98 avatar Apr 10 '24 04:04 khoatm98

I believe bscane2 is on the regular JTAG chain with the micro usb

Jbalkind avatar Apr 10 '24 04:04 Jbalkind

I would recommend against using UART for Linux boot. It's pretty likely that there could be a data corruption over the course of loading the whole bitstream. Perhaps you could try JTAG? There is a bscane2 config in the RTL that you could set up and try loading the kernel image using openocd and gdb. It's a lot faster and more reliable than UART.

Hello!

I have a similar issue. I would prefer to use only the UART and pitonstream instead of GDB. How can I write the bbl.bin to RAM? If I use pitonstream then uart boot should be enabled. This chooses the baremetal bootROM. So should I change this to use the linux bootrom without copying from SD card? @khoatm98 How did you managed to pitonstream the linux image?

Thanks!

jimaandro avatar May 28 '24 12:05 jimaandro

hi @jimaandro Yes I can use UART for linux boost but I could take a while (~10minutes). Just use your bbl (place it at openpiton/piton/verif/diag) as a prebuild image and run pitonstream script to download the image to FPGA board. For this, you would need to comment the line that is used to copy data from SD card to RAM in bootroom source and regenerate bitstream. However, it works but i don't recommend to do it this way. You can use openOCD to donwload the image instead.

khoatm98 avatar May 28 '24 17:05 khoatm98

hi @jimaandro Yes I can use UART for linux boost but I could take a while (~10minutes). Just use your bbl (place it at openpiton/piton/verif/diag) as a prebuild image and run pitonstream script to download the image to FPGA board. For this, you would need to comment the line that is used to copy data from SD card to RAM in bootroom source and regenerate bitstream. However, it works but i don't recommend to do it this way. You can use openOCD to donwload the image instead.

Thanks for the reply! I will try both ways to download the bbl. So if I use pitonstream, I understand that you used the Linux Bootrom without loading from SD. So did you set uart_boot_en to 0 (if it's 1 then baremetal bootrom is used) or did you just change the verilog code to always use the Linux Bootrom and keep the uart_boot_en =1 ?

jimaandro avatar May 28 '24 19:05 jimaandro

Hi @jimaandro ,

Actually you should set uart_boot_en =1 because we load the linux image in the same way as we do with baremetal image. Ahh, for this, you don't need to change the verilog file as well. Sorry for misinforming you, I just remember from now.

khoatm98 avatar May 29 '24 06:05 khoatm98

Hello @khoatm98 Thanks! If you are using OpenOCD, where do you copy the bbl.bin? I suppose 0x80000000 is the correct address, but this doesn't work for me. And after you copy the bbl to RAM, do you just continue or do you set $pc = something and then continue ?

jimaandro avatar May 29 '24 08:05 jimaandro

Hello @khoatm98 Thanks! If you are using OpenOCD, where do you copy the bbl.bin? I suppose 0x80000000 is the correct address, but this doesn't work for me. And after you copy the bbl to RAM, do you just continue or do you set $pc = something and then continue ?

Hello @khoatm98 Actually I found what I need to do in GDB. My question now is did you used the BSCAN module in the project or did you connect the JTAG pins to FPGA pins in XDC file?

jimaandro avatar Jun 01 '24 09:06 jimaandro

Hi @jimaandro , I'm not sure, but I think if you want to use openOCD, then you need to integrate Xilin BSCAN module. I did use it since my current project does not require.

khoatm98 avatar Jun 03 '24 04:06 khoatm98

I believe bscane2 is on the regular JTAG chain with the micro usb

Hello, I have managed to connect to Debug module with jtag using openOCD. I didn't used BSCANE2 module because this is already in the design. I am using VCU128. So I hust connected the jtag pins to uart0 like rocket-chip and for trst I used a VIO for manually reset. I can download the image without any issue, but when I examine the memory I see that some instructions where written in worng position. Is this a JTAG issue?

jimaandro avatar Jul 18 '24 11:07 jimaandro

My guess is this could just be an endianness issue. Usually when we are using PCIe-based DMA, we also end up changing the endianness of the file before performing the DMA. Can you see exactly how the bytes are misarranged? Two common issues:

  1. byte-in-word endianness (can be changed with --reverse-bytes=8 in objcopy)
  2. word-in-cacheline endianness (can be changed with --reverse-bytes=64 in objcopy then potentially also the same as 1.)

Jbalkind avatar Jul 21 '24 21:07 Jbalkind