MCS file parsing error.

Open
#588 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp

Research direction

The reporter bisected the failure to src/mcsParser.cpp after v0.13.1: MCS writes get a wrong end_addr (Spartan-3E verify fail at 0; Kintex-7 flash overflow) while BIT files still work. Diff that file against tags/v0.13.1, then trace how record addresses and length are accumulated into start/end for SPI flash. Confirm a fix by writing the same MCS with --verify on a matching part; no tests or extra files are named in the issue.

Written by the indexing model from the issue text.

Description

Wait for feedback

I am trying to write an MCS file to SPI flash on custom boards with Xilinx FPGA. Firmware size or verification errors occur. There are no errors when writing the original BIT file to the flash.

$ ./build/openFPGALoader -V
openFPGALoader v1.0.0

Write to the Spartan3e board. When writing MCS - end_addr: 00080000 and the check failed. If I write BIT - end_addr: 00030000

$ OPENFPGALOADER_SOJ_DIR=./spiOverJtag ./build/openFPGALoader -c digilent_hs2 --fpga-part xc3s250evq100 -f 1/fpga_xc3s.mcs --verify
empty
write to flash
Jtag frequency : requested 6.00MHz    -> real 6.00MHz   
Open file DONE
Parse file DONE
Use: ./spiOverJtag/spiOverJtag_xc3s250evq100.bit.gz
Load SRAM: [==================================================] 100.00%
Done
jtag_chain_len: 1
SOJ version: 1.000000
Detail: 
Jedec ID          : 20
memory type       : 20
memory capacity   : 12
flash chip unknown: use basic protection detection
start addr: 00000000, end_addr: 00080000
Erasing: [==================================================] 100.00%
Done
Writing: [==================================================] 100.00%
Done
Verifying write (May take time)
Reading: [==================================================] 100.00%
Fail
Verification failed at 0

$ OPENFPGALOADER_SOJ_DIR=./spiOverJtag ./build/openFPGALoader -c digilent_hs2 --fpga-part xc3s250evq100 -f 1/fpga_xc3s.bit --verify
empty
write to flash
Jtag frequency : requested 6.00MHz    -> real 6.00MHz   
Open file DONE
Parse file DONE
Use: ./spiOverJtag/spiOverJtag_xc3s250evq100.bit.gz
Load SRAM: [==================================================] 100.00%
Done
jtag_chain_len: 1
SOJ version: 1.000000
Detail: 
Jedec ID          : 20
memory type       : 20
memory capacity   : 12
flash chip unknown: use basic protection detection
start addr: 00000000, end_addr: 00030000
Erasing: [==================================================] 100.00%
Done
Writing: [==================================================] 100.00%
Done
Verifying write (May take time)
Reading: [==================================================] 100.00%
Done

Write to the Kintex7 board.

$ OPENFPGALOADER_SOJ_DIR=./spiOverJtag ./build/openFPGALoader -c digilent_hs2 --fpga-part xc7k410tffg900 -f 1/fpga_xc7t.mcs --verify
empty
write to flash
Jtag frequency : requested 6.00MHz    -> real 6.00MHz   
Open file DONE
Parse file DONE
Use: ./spiOverJtag/spiOverJtag_xc7k410tffg900.bit.gz
load program
Load SRAM: [==================================================] 100.00%
Done
Shift IR 35
ir: 1 isc_done 1 isc_ena 0 init 1 done 1
jtag_chain_len: 1
SOJ version: 2.000000
JEDEC ID: 0x20bb18
Detected: micron MT25/N25Q128_1_8V 256 sectors size: 128Mb
flash overflow

$ OPENFPGALOADER_SOJ_DIR=./spiOverJtag ./build/openFPGALoader -c digilent_hs2 --fpga-part xc7k410tffg900 -f 1/fpga_xc7t.bit --verify
empty
write to flash
Jtag frequency : requested 6.00MHz    -> real 6.00MHz   
Open file DONE
Parse file DONE
Use: ./spiOverJtag/spiOverJtag_xc7k410tffg900.bit.gz
load program
Load SRAM: [==================================================] 100.00%
Done
Shift IR 35
ir: 1 isc_done 1 isc_ena 0 init 1 done 1
jtag_chain_len: 1
SOJ version: 2.000000
JEDEC ID: 0x20bb18
Detected: micron MT25/N25Q128_1_8V 256 sectors size: 128Mb
00000000 00000000 00000000 00
start addr: 00000000, end_addr: 00680000
Erasing: [==================================================] 100.00%
Done
Writing: [==================================================] 100.00%
Done
Verifying write (May take time)
Reading: [==================================================] 100.00%
Done

When I restored src/mcsParser.cpp from release 0.13.1 and rebuild the project, then there are no errors and the MCS file is successfully written to flash.

$ git checkout tags/v0.13.1 src/mcsParser.cpp
Updated 1 path from 3378212

$ cmake --build build
[  1%] Building CXX object CMakeFiles/openFPGALoader.dir/src/mcsParser.cpp.o
[  3%] Linking CXX executable openFPGALoader
[100%] Built target openFPGALoader
[100%] Built target bit

$ OPENFPGALOADER_SOJ_DIR=./spiOverJtag ./build/openFPGALoader -c digilent_hs2 --fpga-part xc3s250evq100 -f 1/fpga_xc3s.mcs --verify
empty
write to flash
Jtag frequency : requested 6.00MHz    -> real 6.00MHz   
Open file DONE
Parse file DONE
Use: ./spiOverJtag/spiOverJtag_xc3s250evq100.bit.gz
Load SRAM: [==================================================] 100.00%
Done
jtag_chain_len: 1
SOJ version: 1.000000
Detail: 
Jedec ID          : 20
memory type       : 20
memory capacity   : 12
flash chip unknown: use basic protection detection
start addr: 00000000, end_addr: 00030000
Erasing: [==================================================] 100.00%
Done
Writing: [==================================================] 100.00%
Done
Verifying write (May take time)
Reading: [==================================================] 100.00%
Done

$ OPENFPGALOADER_SOJ_DIR=./spiOverJtag ./build/openFPGALoader -c digilent_hs2 --fpga-part xc7k410tffg900 -f 1/fpga_xc7t.mcs --verify
empty
write to flash
Jtag frequency : requested 6.00MHz    -> real 6.00MHz   
Open file DONE
Parse file DONE
Use: ./spiOverJtag/spiOverJtag_xc7k410tffg900.bit.gz
load program
Load SRAM: [==================================================] 100.00%
Done
Shift IR 35
ir: 1 isc_done 1 isc_ena 0 init 1 done 1
jtag_chain_len: 1
SOJ version: 2.000000
JEDEC ID: 0x20bb18
Detected: micron MT25/N25Q128_1_8V 256 sectors size: 128Mb
00000000 00000000 00000000 00
start addr: 00000000, end_addr: 00680000
Erasing: [==================================================] 100.00%
Done
Writing: [==================================================] 100.00%
Done
Verifying write (May take time)
Reading: [==================================================] 100.00%
Done

Best regards,
Pavel

Dominant language
C++
Stars
1.7k
Forks
396
Avg merge
2d 4h
Merged PRs (30d)
15

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from trabucayre/openFPGALoader

All issues in trabucayre/openFPGALoader

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.