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

Spiflash fixes for issues exposed by sys_clk = 200MHz and L2 cache #1881

Merged
merged 9 commits into from
Feb 1, 2024

Conversation

AndrewD
Copy link
Collaborator

@AndrewD AndrewD commented Feb 1, 2024

This is a set of several changes to fix various issues identified when debugging why the mmap
spiflash data read with the bios did not match the data written with openfpgaloader.

Example boot with the fixes on a Efinix Ti60 based design:

litex> reboot

        __   _ __      _  __
       / /  (_) /____ | |/_/
      / /__/ / __/ -_)>  <
     /____/_/\__/\__/_/|_|
   Build your hardware, easily!

 (c) Copyright 2012-2024 Enjoy-Digital
 (c) Copyright 2007-2015 M-Labs

 BIOS built on Feb  1 2024 15:12:36
 BIOS CRC passed (0adc116a)

 LiteX git sha1: 8678b7af

--=============== SoC ==================--
CPU:            VexRiscv SMP-LINUX @ 200MHz
BUS:            WISHBONE 32-bit @ 4GiB
CSR:            32-bit data
ROM:            128.0KiB
SRAM:           8.0KiB
FLASH:          16.0MiB
MAIN-RAM:       32.0MiB

--========== Initialization ============--
Ethernet init...
Memtest at 0x40000000 (2.0MiB)...
  Write: 0x40000000-0x40200000 2.0MiB     
   Read: 0x40000000-0x40200000 2.0MiB     
Memtest OK
Memspeed at 0x40000000 (Sequential, 2.0MiB)...
  Write speed: 87.9MiB/s
   Read speed: 49.2MiB/s

Initializing W25Q128JV SPI Flash @0x01000000...
[ID: ff ef 60 18]Enabling Quad mode...
Testing against CRC32: 0bc9f423
[DIV: 3] 0bc9f423
[DIV: 2] 0bc9f423
[DIV: 1] 0bc9f423
[DIV: 0] 5b89d331
SPI Flash clk configured to 50 MHz
Memspeed at 0x1000000 (Sequential, 4.0KiB)...
   Read speed: 19.2MiB/s
Memspeed at 0x1000000 (Random, 4.0KiB)...
   Read speed: 6.4MiB/s

Andrew Dennison added 9 commits February 1, 2024 14:37
require both phy and flash support to enable QUAD/QPI capability.

Many flash devices support 4x read but may be on a 1x phy
Ensure default_divisor is set to desired default - 1 as required by LiteSPIClkGen
Calculate actual PHY_CLK based on default_divisor
This is safer than defaulting to sys_clock / 2 if sys_clock > 100MHz
clk_freq tuning will result in a faster clock if supported by hardware.
Correct CRC was always calculated, regardless of divisor, as the
test flash block was in the L2 cache. This resulted in the minimum
divisor being used and incorrect flash reads with 200MHz sys_clock.
Same CRC was always reported if the memory region was in the cache...
Noticed when manually testing spiflash divisor.
many openfpgaloader args have a name with '-' as per normal convention.

This kwarg now works: file_type="raw"
@enjoy-digital enjoy-digital merged commit be23467 into enjoy-digital:master Feb 1, 2024
1 check passed
@enjoy-digital
Copy link
Owner

Thanks @AndrewD!

@AndrewD AndrewD deleted the spiflash_fixes branch February 5, 2024 00:07
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

Successfully merging this pull request may close these issues.

None yet

2 participants