-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
step22 - fails for Gatemate flash programming or flash reading #2
Comments
Hi, Debugging it with gtkwave revealed that MISO is Z all the time. It took a while to see it, but in my case the CCF file declared both MOSI and MISO as output?! Changing MISO to Pin_in certainly helps, but still doesn't solve it. |
Hi g3grau, Thank you very much for sharing your experience and attempts to solve the flash reading. A second person trying is very helpful! Sadly I have not made any progress myself yet. I need to give it another try on one of the coming weekends. Solving step22 is key to progress further. Next I want to try and connect a logic analyzer to the J3 pin header. Per schematic, J3 is directly connecting to the Flash IC SPI lines. Recording the SPI protocol and decode the state would be great. There is a discussion post for the ARTY board on BrunoLevy/learn-fpga#108 that also struggles with the Flash in the same step. |
I just connected a scope and got surprised. For comparison I just loaded the design from step21 .. there CS#, MOSI and MISO are 1 as expected. More spooky ... I added some reg in the main design for non-blocking assignment of the SPI signals to them, and then assign that to the 3 free LED (I think I do not yet understand this bidirectional IO). It doesn't change anything in the simulation, but suddenly the scope shows the expected signals on CS# and MISO! The program still doesn't run 100%, my printf statements are nuts, but maybe I made something wrong with memory size and stack pointer (I tried to increase RAM 4x). Apart from the direction fixing in gatemate-e1.ccf for SPIFLASH_MISO, this should be my relevant change. `module SOC ( MappedSPIFlash SPIFlash( ` |
After fixing an error in my memory sizing I could read the first 4 bytes .. but the memory address does not increase. |
Well..?! I really don't know why it works now and how exactly it fails in the other cases (not only the Flash access, also the code execution seems broken in that case), but now I get the full demo at maybe 3Fps :-) |
👏 Congratulations! This is awesome. Thank you very much for the hard work, and documenting progress inside the comments! I am still processing changes from the files in your gist, so I can update the step22 files. My first quick attempt failed, so I better double-check. I may need to ask a question if I get stuck... What is the pin assignment you had in your .ccf file? I fixed mine to:
Meanwhile I was getting a handle on basic SPI protocol analysis for the E1 board's flash operation. I took down my notes for it in a gist at Gatemate E1 Board - SPI Flash Programming and Boot Operation. In a nutshell, openFPGA programs the flash at 6.25MHz by using repeat PP "page program" commands to write the bitstream data in 256 byte chunks. For the E1 FPGA boot from flash, a single FASTREAD operation is done at 33MHz after checking the flash access with a couple of RDID commands. Getting over step22 is great! |
It would be awesome if I would understand the issue :-D It's a workaround but not a fix yet. The design can run at 30MHz (I switched the power mode to speed), but more seems to be not possible due to the SPI clock limit (fast should allow 80MHz after configuring it with an initially slower clock) and a timing issue in the design (PR reports 28MHz max). I didn't check if my RAM increase may be the bottleneck. Yes, the ccf looks good. We have to remember that dual/quad would require inout... |
Awesome! Yes it works for me too! Your changes made all the difference. This is great. Big thanks for solving it! Your debug code that routes the SPI signals to the upper LED's was neat. I could see if the SPI starts, and if there is MISO traffic coming back from the flash. The major fix was to set the right signal directions. module SOC (
input CLK, // system clock
input RESET, // reset button
output [7:0] LEDS, // system LEDs
input RXD, // UART receive
output TXD, // UART transmit
output SPIFLASH_CLK, // SPI flash clock
output SPIFLASH_CS_N, // SPI flash chip select (active low)
output SPIFLASH_MOSI, // SPI flash MOSI output
input SPIFLASH_MISO // SPI flash MISO input
); I just updated the repo with 3968362, and now the final two steps 23/24 are waiting for another day. |
Great! Just to be sure: your demo starts with a yellow "Oxygene" string? I had variants which seem to start somewhere else. I tried your variant (with reg in the interface), that also worked for me. It it is still kind of unstable. E.g. it only works if I comment out my debug block. Changing the clock back from 30 to 10MHz also breaks it again. As an analog designer I know this kind of side effects, but here I didn't expect it :-D The SOC_pr.log tells me that it should run up to 21 MHz. The opposite is true...no output at CPU_FREQ 10 but works fine at 30 :-S I'll double check again with your repo update, maybe I just changed too much ;) I just noticed that you started step23 and ran into an issue "program doesn't run" .. which may also be this kind of timing issue I have with step22? Did you try changing the clock? |
Hello, I'm struggling also. |
@g3grau: what was the solution to the wrong libgcc. I'm trying to use the riscv64-unknown-linux-gnu-gcc and I'm struggling with the compiler flags |
Hi,
|
That's an interesting note. I tried to get a data logger working with a lot of headache this spring, but at some point I gave up on the Hyperram complexity and lack of deeper knowledge how to use DDR interfaces, multiphase clocks or timing constraints in this environment. I got it working (with inout) using a Verilog interface from Kevin M. Hubbard (which is much slower than the theoretical possible throughput, but at least it works). I think a "full speed" reference implementation of this hyperram interface would provide a great insight how to use these tools on an advanced level. |
Hello g3grau, With best regards |
In step22, the application expects the app image data to be uploaded into the flash memory at a 1M offset. This step currently fails due to issues with SPI flash access. The issue is that no output is visible on the serial line. This can have several possible root causes:
(A) Selected wrong flash read mode for spi_flash.v. 4 modes are defined:
So far, I unsuccessfully tried 1. and 4.
(B) Using the wrong openFPGALoader flash offset value
openFPGALoader only understands an offset provided in bytes. I am using
openFPGALoader -b gatemate_evb_spi -o 1048576 data/scene1.dat
, assuming the 1M offset calculates with 1024.(C) It is the first time that I am using the
+uCIO
flag for the Gatemate place and route tool 'p_r', trying to directly access the flash from the FPGA.(D) A pin swap is another common cause (e.g. MOSI->MISO), hopefully it's that simple.
The make output example below shows the successful flash execution, but the program output does not show :-(
The text was updated successfully, but these errors were encountered: