From 2e5c6eb7a7e93442998ee7dd2b447f7dfd4bdf8a Mon Sep 17 00:00:00 2001 From: Josuah Demangeon Date: Fri, 11 Aug 2023 16:46:52 +0200 Subject: [PATCH] platforms/crosslink_nx_evn: add SPI flash support --- litex_boards/targets/lattice_crosslink_nx_evn.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/litex_boards/targets/lattice_crosslink_nx_evn.py b/litex_boards/targets/lattice_crosslink_nx_evn.py index 4775f1b..eda48c0 100755 --- a/litex_boards/targets/lattice_crosslink_nx_evn.py +++ b/litex_boards/targets/lattice_crosslink_nx_evn.py @@ -68,6 +68,7 @@ class BaseSoC(SoCCore): } def __init__(self, sys_clk_freq=75e6, device="LIFCL-40-9BG400C", toolchain="radiant", with_led_chaser = True, + with_spi_flash = False, **kwargs): platform = lattice_crosslink_nx_evn.Platform(device=device, toolchain=toolchain) @@ -97,6 +98,12 @@ class BaseSoC(SoCCore): if debug_uart: self.add_uartbone() + # SPI Flash -------------------------------------------------------------------------------- + if with_spi_flash: + from litespi.modules import MX25L12833F + from litespi.opcodes import SpiNorFlashOpCodes as Codes + self.add_spi_flash(mode="4x", clk_freq=100_000, module=MX25L12833F(Codes.READ_4_4_4), with_master=True) + # Build -------------------------------------------------------------------------------------------- @@ -109,12 +116,14 @@ def main(): parser.add_target_argument("--programmer", default="radiant", help="Programmer (radiant or ecpprog).") parser.add_target_argument("--address", default=0x0, help="Flash address to program bitstream at.") parser.add_target_argument("--prog-target", default="direct", help="Programming Target (direct or flash).") + parser.add_target_argument("--with-spi-flash", action="store_true", help="Enable SPI Flash (MMAPed).") args = parser.parse_args() soc = BaseSoC( sys_clk_freq = args.sys_clk_freq, device = args.device, toolchain = args.toolchain, + with_spi_flash = args.with_spi_flash, **parser.soc_argdict ) builder = Builder(soc, **parser.builder_argdict)