Coder Social home page Coder Social logo

raw FLASH option needed about openfpgaloader HOT 73 OPEN

emard avatar emard commented on September 23, 2024
raw FLASH option needed

from openfpgaloader.

Comments (73)

trabucayre avatar trabucayre commented on September 23, 2024

Hi,
all prerequisites are present (-o / --offset to provides base address and I've fixed a bug in spiFlash the last week) but this option was only tested with cyc1000 board.
So, I need to create a design to check behaviour before unlocking this feature (for ECP5 in a first time).
Currently since erase is done by sector it's a 64k offset. But I must improving erase and flash algorithm to handle smallest size as possible.
In fact this feature is in my ASAP todolist.
Thank to motivate me to hurry about that ;)

from openfpgaloader.

emard avatar emard commented on September 23, 2024

There should not be any hurry. Of course my primary interest
should be ecp5-ft231x :) but I can also test and report what
happens on ft4232 based boards with ecp5-85, artix7-100, and cyclone5-49

from openfpgaloader.

trabucayre avatar trabucayre commented on September 23, 2024

In fact the interface is not a problem. If it's work with one of them, it will work with all.
I need to enable this feature FPGA per FPGA since flash access is a bit different for each vendor:

  • flash access is tranparent for anlogic eagle_s20 and ECP5 (it's only mandatory to write a specific instruction before)
  • one bitstream must be loaded in RAM to provide a bridge for xilinx and cyclone devices. An in this situation it's mandatory to have as much as bitstream as FPGA model (artix, spartan6/7, cyclone 10/5) and size. Bitstreams are available for artix A35t and A50t).
  • for the specific case of cyc1000 I use the second interface of FT2232 (interface B) to emulate SPI (bitstream is just connexion between pins on the Ftdi side and pins on the Flash side). I must updating this to have jtag<->SPI interface like for xilinx FPGA.

In a first time, I focus to ecp5 (colorlight and ecp5_evn).

from openfpgaloader.

emard avatar emard commented on September 23, 2024

I kinde understand everything mentioned.
I have a board with ecp5 and 256-mbit flash, the one with 4-byte
address and openFPGALoader works while I know it uses only
3-byte legacy addresses. That's great

I know for every artix anc cyclone, a different jtag-spi passthru
bitstream must be prepared. Not only this but there's more, cyclone5
or MAX10 i htink have some internal flash that is used to initialize
BRAM content so the programmer needs to handle this thing also.

from openfpgaloader.

trabucayre avatar trabucayre commented on September 23, 2024

I know I need to improve spiFlash support to handle both 4 and 3-bytes address.

For artix and spartan7 se same implementation may be used (@Fatsie has added spartan7 support). For altera I need to first reworks the passthru to use jtag <-> spi instead.

With FPGAs with internal flash it's a bit more easy because in most case the flash is only dedicated for bitstream and it's not possible to add something else.

I have locally unlocked the ability to flash a raw data, a read after write show correct data but I'have a problem with my test design. I'm waiting to fix this before updating lattice support.

from openfpgaloader.

emard avatar emard commented on September 23, 2024

from openfpgaloader.

trabucayre avatar trabucayre commented on September 23, 2024

Yesterday I'have fixed my design for my ECP5_EVN:

  • an riscV is written at the beginning of the FLASH
  • the CPU firmware is written at 0x200000
    After fixing some issue it's works -> openFPGALoader is able for ECP5 to write something everywhere in flash \o/
    Now it's time to cleanup openFPGALoader and the design before pushing it.

for ECP5 you have to known file format: bit and mcs.

  • mcs is written in flash
  • bit is loaded in RAM if -m (or nothing) and written in flash if -f

For the jtagofspi, xc3sprog bitstreams are not compatible. I use a piece of HDL I've written. But to support new xilinx FPGA you have just to update the Makefile and add corresponding xdc file.

from openfpgaloader.

emard avatar emard commented on September 23, 2024

from openfpgaloader.

trabucayre avatar trabucayre commented on September 23, 2024

It's true for read back mainly because it's possible to check write task. In fact I've already this (to read back content just after write) to verify the read everywhere.
If I have artix's details I'm able to update the Makefile to produce required bitstream if you want.
For gzip, as mentionned here, It's not clear for me if it's for storage or to increase write speed task.

from openfpgaloader.

emard avatar emard commented on September 23, 2024

from openfpgaloader.

emard avatar emard commented on September 23, 2024

I was experimenting with esp32 micropython programmer
using xc3sprog bscan and got it working, it uploads bscan7.bit.gz
first and then writes the flash. It first reads a flash block, compares
with to-be-written block content and decides if it must erase or write or
nothing, thus reducing flash wear and working faster.

Sometimes (about 1 in 20), after uploading bscan7,
flash write fails on first block (erase, write, verify
retried 3 times and give up).

If you need some inspiration or reference, here it is:

https://github.com/emard/esp32ecp5/tree/master/rbp

BTW is there spioverjtag source for altera?

from openfpgaloader.

trabucayre avatar trabucayre commented on September 23, 2024

Okay I will seeing this. Thanks
In fact I have written my spiOverJtag in early time of this project. Maybe I must move to xc3sprog version. I will compare both.
For altera I need to find where I have stored this (but It has no real interest since it use interfaceB of the ft2232, and consequently limited to cyc1000). My idea is to rewrite this (or adapt the xc3sprog passthru) to use the JTAG interface.

I've updated the repository with support for writing raw data at an arbitrary offset (readback is currently missing).
My test design is an adaptation to picosoc

from openfpgaloader.

emard avatar emard commented on September 23, 2024

from openfpgaloader.

trabucayre avatar trabucayre commented on September 23, 2024

My bridge has nothing to do with that of xc3sprog. This why both are incompatible.
If you read xilinx_spiOverJtag this piece of code just adapts JTAG signals to SPI.
I need to compare both speed to move to xc3sprog bridge.

from openfpgaloader.

emard avatar emard commented on September 23, 2024

from openfpgaloader.

trabucayre avatar trabucayre commented on September 23, 2024

Sorry for delay.
I've updated xilinx support to write raw data in arbitrary address (tested again with picosoc) and added bitstream for xc7a100 device. If you can try it.
ASAP I must compare for bridge to see if I need to move to xc3sprog version. But usually SPI communication is quite small (for tx there are no overhead, for rx with a delay of one bit I need to read one byte more and reconstruct byte).

from openfpgaloader.

emard avatar emard commented on September 23, 2024

from openfpgaloader.

trabucayre avatar trabucayre commented on September 23, 2024

OK. No problem. It's not hurry at all.
Currently, openFPGALoader use only 64K erase block. (I know it's sometime overkill and the algorithm needs to be improved).

from openfpgaloader.

emard avatar emard commented on September 23, 2024

from openfpgaloader.

trabucayre avatar trabucayre commented on September 23, 2024

To write a bitstream in flash you need to convert the bit to mcs.
In fact I've not tried to write a bit to flash (If it so, i'll update openFPGALoader to allows this)

from openfpgaloader.

emard avatar emard commented on September 23, 2024

from openfpgaloader.

emard avatar emard commented on September 23, 2024

from openfpgaloader.

trabucayre avatar trabucayre commented on September 23, 2024

I've tried with a .bit: It didn't work in flash.
lattice .bit and xilinx .bit are not same...
Lattice .bit contains instructions to drive the FPGA in configuration phase.
I suspect this is not true for xilinx .bit file this is why it's mandatory to use mcs (maybe .bin)
In openFPGALoader, xilinx class don't use -f and -m.
if file is .mcs -> FLASH
if file is .bit -> RAM
if file is xxx -> FLASH with a sanity checking about offset
It's true this mean a file with .bit can't be written at an offset > 0x00

from openfpgaloader.

emard avatar emard commented on September 23, 2024

from openfpgaloader.

emard avatar emard commented on September 23, 2024

from openfpgaloader.

emard avatar emard commented on September 23, 2024

So I renamed bit file to xxx and this seems to work and pass verify
only I'd like to be able to flash raw binary exactly at offset 0,
currently it accepts other offsets than 0.
I edited the source and removing checking for address 0,
have written *.bit raw bitstream there and it works!

./openFPGALoader --cable ft4232 -o 0 /tmp/artix7.xxx
load program
Flash SRAM: [===================================================] 100.000008%
Done
parsing 3825900

file length 30607200
Parse file DONE
Detail:
Jedec ID : 01
memory type : 60
memory capacity : 19
EDID + CFD length : ff
EDID : ffff
CFD :
Erasing: [==================================================] 100.000000%
Done
Writing: [===================================================] 100.000008%
Done

from openfpgaloader.

emard avatar emard commented on September 23, 2024

I can test something similar (same cable ft4232 and 32MB spansion flash)
with cyclone5, part 5CEBA4F23C7N

from openfpgaloader.

trabucayre avatar trabucayre commented on September 23, 2024

After comparing .bit file from xilinx and mcs file from xilinx too, it's true the .bit file should work with the flash. I need to redo my tests, I'have missed something, but not now I'm not at home and hav'nt my arty with me.
For .mcs produces by using objcopy, I suppose my implementation don't cover all possible type... I've added this in my (long) TODO list.
For rawData at offset 0x0, I've (it's maybe an error) forbid this behavior considering only a valid bitstream could be write in this area.
I have never tested with CycloneV, I need to redo bridge (currently cyc1000 only). For SRAM you need to use a svf file. .sof file is just not documented, quartus do a magic thing before sending bitstream data...

from openfpgaloader.

emard avatar emard commented on September 23, 2024

from openfpgaloader.

trabucayre avatar trabucayre commented on September 23, 2024

I've redo test and now it's possible to write a .bit in flash (In fact my previous tests have failed due to an inconscient in parser...)
Yes sof are too difficult... Tried to analyse this file but fails...

from openfpgaloader.

emard avatar emard commented on September 23, 2024

from openfpgaloader.

trabucayre avatar trabucayre commented on September 23, 2024

I've planned to study .rbf. This format is used by Linux, for cycloneV Soc, to program the FPGA. I suppose this filetype is more or less documented (at least enough to be usable).
If it's possible to use them, it's maybe better (or simplier) than using .svf

from openfpgaloader.

emard avatar emard commented on September 23, 2024

Is altera (cyclone-5 + epc flash = 5CEBA4F23C7 + EPCS64) supported?
I see there's some code to load bridge and read/write flash.

there's possible misspelling at sram write, it prints message
"Flash SRAM" maybe it should print message "Write SRAM".

from openfpgaloader.

trabucayre avatar trabucayre commented on September 23, 2024

altera cycloneV are supported to write SPI flash.
This model must be added in spiOverJtag. Have you a ref board? I could update accordingly.

from openfpgaloader.

emard avatar emard commented on September 23, 2024

from openfpgaloader.

trabucayre avatar trabucayre commented on September 23, 2024

Thanks.
rbf are a bit large :-/ (and it's not possible to use compression since jtag+real time uncompress is not supported by cyclone devices)
Before adding this file to openFPGALoader repo could you try:

  1. download this bridge into spiOverJtag directory.
  2. add in src/part.hpp idcode for your device
  3. make install
  4. use openFPGALoader -c ft4232 --fpga-part 5ce423 -f yourRBF.rbf

Thanks

from openfpgaloader.

emard avatar emard commented on September 23, 2024

from openfpgaloader.

trabucayre avatar trabucayre commented on September 23, 2024

spiOverjtag naming is a bit strange, i'm agree. I've assumed only size and package are required (maybe I need to do a deep check).
First dump seems good. openFPGALoader has correctly loaded bridge into RAM and you use the correct (as far I know) command to produce the rbf file.
SVF is not working here, because It will be loaded into SRAM
For the second dump it's like chip is not connected or something like this.
Need to try in my side (maybe something in spiflash update has broken that...)

from openfpgaloader.

emard avatar emard commented on September 23, 2024

from openfpgaloader.

trabucayre avatar trabucayre commented on September 23, 2024

It's really weird. I have tried by two of my intel FPGAs (cycloneV and cyclone IV) sucessfully...
If you dump flash it's the same as rbf content? (maybe with bit reversal) ?

from openfpgaloader.

emard avatar emard commented on September 23, 2024

from openfpgaloader.

trabucayre avatar trabucayre commented on September 23, 2024

Most of devices with SPI flash have dump flash support. Seems doc must be updated to highlight that :)

from openfpgaloader.

emard avatar emard commented on September 23, 2024

from openfpgaloader.

trabucayre avatar trabucayre commented on September 23, 2024

My fault... Wrong method signature...
Fixed

from openfpgaloader.

emard avatar emard commented on September 23, 2024

from openfpgaloader.

emard avatar emard commented on September 23, 2024

from openfpgaloader.

trabucayre avatar trabucayre commented on September 23, 2024

rbf is handle as a raw data so flash's content must match rbf's content. Its may be required to add byte reversal when storage to have exactly original file content.

I've updated spiFlashdb with W25Q64 device.

from openfpgaloader.

emard avatar emard commented on September 23, 2024

from openfpgaloader.

trabucayre avatar trabucayre commented on September 23, 2024

byte reversal is not required before calling openFPGALoader. It is done, if required, before writing to flash. With all my intel's FPGAs rbf are working.
Byte reversal may be required after a dump to compare original rbf with the dump.

from openfpgaloader.

emard avatar emard commented on September 23, 2024

from openfpgaloader.

trabucayre avatar trabucayre commented on September 23, 2024

A bitstream is always reversed. A raw data file is written in natural order.
Oups I have a typo in previous messages byte -> bit so LSB become MSB and MSB become LSB

from openfpgaloader.

emard avatar emard commented on September 23, 2024

from openfpgaloader.

trabucayre avatar trabucayre commented on September 23, 2024

Need to compare jic and rbf (maybe I've already done that but don't remember -> documentation page for file format is required). It's weird tried many time successfully (but not with your board/device)
Same for spiOverJtag with all intel based board it's okay (but again not with this device) -> have to check aliexpress for something similar to your board.
Thanks

from openfpgaloader.

emard avatar emard commented on September 23, 2024

If there's source for spioverjtag, I can compile and
try to change something to see if I can fix it

maybe not the same chip but similar and very good board
and with good price should be "mister".

from openfpgaloader.

trabucayre avatar trabucayre commented on September 23, 2024

source is available, I just have to push entry for your device.
"mister" uses the de10nano? I have one of them. chip id is correctly read but further steps are not working (I suspect dual or quad access between FPGAs and chip).

from openfpgaloader.

emard avatar emard commented on September 23, 2024

from openfpgaloader.

emard avatar emard commented on September 23, 2024

from openfpgaloader.

trabucayre avatar trabucayre commented on September 23, 2024

I have de10nano, de0nanoSo and de1Soc.
I have produce a jic file from sof -> it's quite similar to rbf with an header. Need to check why some small diff.
Having to load something into RAM before using spiOverJtag is really strange, currently I don't see why. Need to investigate.
Using an rbf into flash it not always possible (You can't use one in compress mode -> real time decompression isn't supported by the FPGA in JTAG mode).

from openfpgaloader.

emard avatar emard commented on September 23, 2024

from openfpgaloader.

trabucayre avatar trabucayre commented on September 23, 2024

for svf the compression is, as far I know, not used.
I've started a parser for jic
But it's clear I can't reproduce your issue (and it's a situation I don't like). I need to check everything... I, definitively, have to find a board with same hardware.

from openfpgaloader.

emard avatar emard commented on September 23, 2024

from openfpgaloader.

emard avatar emard commented on September 23, 2024

from openfpgaloader.

trabucayre avatar trabucayre commented on September 23, 2024

Tried with my de10nano -> success...
flash id is read successfully...
Ok I'm unable to program chip for an unknown reason -> maybe with the clip I will be able to dump transaction with a logic analyzer.

from openfpgaloader.

emard avatar emard commented on September 23, 2024

from openfpgaloader.

emard avatar emard commented on September 23, 2024

from openfpgaloader.

trabucayre avatar trabucayre commented on September 23, 2024

it's maybe time to open an dedicated issue, this thread become very long :-)
My board is currently in AS mode (but I have tried all modes)
I can't set holdn and wpn since I use intel IP (serial flash loader).
I need to finalize my jic parser and to integrate this. But it's really weird, I have flashed many rbf this morning to verify behaviour with cylone10, cycloneIV and cycloneV (not socfpga) without any problem. Maybe something with quad/dual/single mode?

from openfpgaloader.

emard avatar emard commented on September 23, 2024

from openfpgaloader.

Mecrisp avatar Mecrisp commented on September 23, 2024

I am trying to write a raw binary file, too, but despite the -o option given, openFPGALoader does not accept random data. Do I need to provide additional options to enable this?

openFPGALoader --board=ulx3s -f -o 0x200000 LICENSE -v

write to flash
Jtag probe limited to 3MHz
Jtag frequency : requested 6000000Hz -> real 3000000Hz
ret 0
found 1 devices
index 0:
        idcode 0x41113043
        manufacturer lattice
        model  LFE5U-85
        family ECP5
        irlength 8
File type : LICENSE
Error: Failed to claim FPGA device: incompatible file format

openFPGALoader -V
openFPGALoader v0.5.0

from openfpgaloader.

emard avatar emard commented on September 23, 2024

from openfpgaloader.

trabucayre avatar trabucayre commented on September 23, 2024

@Mecrisp Good catch! file type are deduced from extension, but without extension, and without --file-type, openFPGALoader is unable to decide what to do. It's now fixed in master branch.
@emard true. It's a solution to avoid this error.

Thanks to all

from openfpgaloader.

Mecrisp avatar Mecrisp commented on September 23, 2024

Thank you for the quick solution - specifying the file type did the trick. Idea: Would be great if the help text could include the possible "file-type-specifiers". I tried with --file-type raw intuitively before, but that wasn't accepted.

This did the trick with the version already installed, will update later:
openFPGALoader --board=ulx3s -f -o 0x200000 LICENSE -v --file-type bin

from openfpgaloader.

emard avatar emard commented on September 23, 2024

from openfpgaloader.

trabucayre avatar trabucayre commented on September 23, 2024

@emard exactly (and done this morning).
I have relaxed constrains about filetype:

  • known format are treated using corresponding parser
  • unknown format are allowed only if the file is wrtten in flash

now if you use:

openFPGALoader --board=ulx3s -f -o 0x200000 LICENSE -v --file-type bin

or

openFPGALoader --board=ulx3s -f -o 0x200000 LICENSE -v --file-type raw

or

openFPGALoader --board=ulx3s -f -o 0x200000 LICENSE -v 

Result (and behaviour) is same (or I have introduce a bug ;-) )

@Mecrisp it's true: message must be more explicit and more informative

from openfpgaloader.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.