Skip to content
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

write to flash on GW5A is not yet supported #389

Open
chopin1998 opened this issue Oct 10, 2023 · 22 comments
Open

write to flash on GW5A is not yet supported #389

chopin1998 opened this issue Oct 10, 2023 · 22 comments

Comments

@chopin1998
Copy link

i got a tang mega 138k pro which use Gowin GW5AST 138 as main fpga chip,

but now openFPGALoader not supported to write its external flash, will support soon?

Thank you!

@trabucayre
Copy link
Owner

I will receive a mega in few days (or a week), will be able to work on adding external flash support.

@chopin1998
Copy link
Author

got your board ? ^_^

@trabucayre
Copy link
Owner

Yes! I have received my board and started to see how to access flash for this family. It's not really complex (a bit tricky) but I have first to review a PR for gowin devices.

@chopin1998
Copy link
Author

Good news! i’m a newbie on this, thanks for your help!

@chopin1998
Copy link
Author

chopin1998 commented Nov 20, 2023

i noticed that openFPGAloader support flash GW5A now! so happy!

but seems write to SRAM function bad now.... when Load a new fs file to SRAM, nothing happen, and READY led on board keeping ON, which should be off

here is log for SRAM upload

openFPGALoader -v ws2812_lcd_key.fs
No cable or board specified: using direct ft2232 interface
Jtag frequency : requested 6.00MHz -> real 6.00MHz
found 1 devices
index 0:
idcode 0x1081b
manufacturer Gowin
family GW5AST
model GW5AST-138
irlength 8
File type : fs
Parse file Parse ws2812_lcd_key.fs:
checksum 0xd735
Done
DONE
bitstream header infos
CRCCheck: ON
Compress: OFF
ConfDataLength: 21872
LoadingRate: 4629629
ProgramDoneBypass: OFF
SPIAddr: 00000000
SecurityBit: ON
idcode: 0001081b
before program sram: displayReadReg 00002622
Bad Command
Memory Erase
Reserved9
Non-JTAG configuration is active
Done Final
Erase SRAM before erase sram: displayReadReg 00004460
Memory Erase
Preamble
Non-JTAG configuration is active
Security Final
pollFlag: 40a0 (80)
pollFlag: 4080 (0)
pollFlag: 4080 (0)
pollFlag: 4080 (0)
pollFlag: 4080 (0)
pollFlag: 4080 (0)
pollFlag: 4080 (0)
pollFlag: a0 (20)
after erase sram: displayReadReg 000000a0
Memory Erase
System Edit Mode
pollFlag: 20 (0)
after erase sram: displayReadReg 00000020
Memory Erase
DONE
Load SRAM before write sram: displayReadReg 00000200
Reserved9
Load SRAM: [==================================================] 100.00%
Done
after write sram: displayReadReg 00002622
Bad Command
Memory Erase
Reserved9
Non-JTAG configuration is active
Done Final
DONE
after program sram: displayReadReg 00002622
Bad Command
Memory Erase
Reserved9
Non-JTAG configuration is active
Done Final

@trabucayre
Copy link
Owner

Currently SPI write is only supported for GW5A, not GW5AST (I don't know why but I have strange behaviour).
It's weird: I have tried yesterday with tangMega and not seen issue when trying to load SRAM, maybe device is in wrong state...
I have to investigate.

@trabucayre
Copy link
Owner

I have also to update status display: currently bit/function are displayed according to non GW5A(ST). For this family only GW5A-25 has the correct register decoding.

@chopin1998
Copy link
Author

Currently SPI write is only supported for GW5A, not GW5AST (I don't know why but I have strange behaviour). It's weird: I have tried yesterday with tangMega and not seen issue when trying to load SRAM, maybe device is in wrong state... I have to investigate.

but i can write flash on my mega138pro..

@trabucayre
Copy link
Owner

Ok. So I have to recheck everything. SPI flash is seen but not all the time, it fails to write and I'm able to load SRAM. it's more or less totally opposite situation.
Could you try with openFPGALoader --bulk-erase to see if after your able to load a bitstream (ie device is in wrong state due to an issue when bitstream was written).

@chopin1998
Copy link
Author

when device under wrong state, other write is not work, even with --bulk-erase, need to repower it.

@trabucayre
Copy link
Owner

I continue to search the reason to this regression. before this commit there is no issue, after yes.
I have some results but it's not really stable and OK/KO depends on bitstream written to the flash...

@wtjcn
Copy link

wtjcn commented Dec 10, 2023

I have the same problem, when load to sram of 138k, nothing happen

@trabucayre
Copy link
Owner

I try, as much as possible, to find why SRAM is not working. But I can't isolate the issue. It's a WIP.

@trabucayre
Copy link
Owner

A strange thing I observe: depending of the bitstream written in flash, loading to SRAM works or not.
If I have one of the @sipeed bitstream: SRAM fails. With LiteX bitstream: SRAM is working.
Maybe something wrong with the security option.

@trabucayre
Copy link
Owner

With my last commit I'm able to load a bitstream all the time (with a flash containing a bitstream where security bit is enable or not).
Could you confirm/infirm my tests ?
Thanks.

@chopin1998
Copy link
Author

c00l!!

now SRAM write ~100% work, thank thee very much!

flash write need twice, 1st time failed(need to wait), then 2rd time work fine

@trabucayre
Copy link
Owner

I have observed this issue too. I don't know why but bulk-erase works all the time.
Maybe the same trick must be applied on Flash side.

@wtjcn
Copy link

wtjcn commented Dec 12, 2023

for me, it not work.
when write sram, it show "Erase SRAM double eraseSRAM", progress to 100% and "DONE", but the board's LEDs light continue in old ways. Both litex and official led.fs .

@trabucayre
Copy link
Owner

litex and led.fs uses leds in a similar way. Could you try with litex and ws2812. I use this demo to have real distinct behavior when I have to switch.
But If after the load you have something (ie no errors) it's a good news.

@wtjcn
Copy link

wtjcn commented Dec 21, 2023

  1. I found I used linux's FT2232 driver, because it can give /dev/ttyUSB device, although it does not realy work on mega138k
  2. I run Gowin_USB_Cable_Installer.sh and then reboot, /dev/ttyUSB disappear, but Gowin's Programmer works well, both for SRAM and FLASH. In this condition, I use openFPGAloader, sram erase dose not work, and sram programming "DONE" but not work. Another small problem, openFPGAloader default use 6MHz jtag freq, Gowin's doc said it should not more than 2.5MHz, I change it to 2.5MHz but no change.

@trabucayre
Copy link
Owner

Hi,
after a long period of try it seems I'm able to write the flash: I have added delay after erase SRAM and after sending SPI mode instruction.
Could you confirm that?
Thanks!

@SeanGan233
Copy link

In version 0.12.1,Ubuntu , I also meet the problem: nothing happened after burning and READY led on board keeping ON, which should be off.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants