From 51dd5277af322ca06ae68dc74d2debc5b83a7ae2 Mon Sep 17 00:00:00 2001 From: Andrew Dennison Date: Mon, 29 May 2023 15:03:38 +1000 Subject: [PATCH] soc/integration: support software_debug for add_spi_flash() --- litex/soc/integration/soc.py | 4 +++- litex/soc/software/liblitespi/spiflash.c | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/litex/soc/integration/soc.py b/litex/soc/integration/soc.py index 7a3f6eacb..a504d4757 100644 --- a/litex/soc/integration/soc.py +++ b/litex/soc/integration/soc.py @@ -1758,7 +1758,7 @@ class LiteXSoC(SoC): self.platform.add_false_path_constraints(self.crg.cd_sys.clk, eth_rx_clk, eth_tx_clk) # Add SPI Flash -------------------------------------------------------------------------------- - def add_spi_flash(self, name="spiflash", mode="4x", clk_freq=None, module=None, phy=None, rate="1:1", **kwargs): + def add_spi_flash(self, name="spiflash", mode="4x", clk_freq=None, module=None, phy=None, rate="1:1", software_debug=False, **kwargs): # Imports. from litespi import LiteSPI from litespi.phy.generic import LiteSPIPHY @@ -1792,6 +1792,8 @@ class LiteXSoC(SoC): self.add_constant(f"{name}_MODULE_QUAD_CAPABLE") if SpiNorFlashOpCodes.READ_4_4_4 in module.supported_opcodes: self.add_constant(f"{name}_MODULE_QPI_CAPABLE") + if software_debug: + self.add_constant(f"{name}_DEBUG") # Add SPI SDCard ------------------------------------------------------------------------------- def add_spi_sdcard(self, name="spisdcard", spi_clk_freq=400e3, with_tristate=False, software_debug=False): diff --git a/litex/soc/software/liblitespi/spiflash.c b/litex/soc/software/liblitespi/spiflash.c index 5bd827318..eb565c5ac 100644 --- a/litex/soc/software/liblitespi/spiflash.c +++ b/litex/soc/software/liblitespi/spiflash.c @@ -28,7 +28,7 @@ int spiflash_freq_init(void) crc = crc32((unsigned char *)SPIFLASH_BASE, SPI_FLASH_BLOCK_SIZE); crc_test = crc; -#if SPIFLASH_DEBUG +#ifdef SPIFLASH_DEBUG printf("Testing against CRC32: %08x\n\r", crc); #endif @@ -41,7 +41,7 @@ int spiflash_freq_init(void) while((crc == crc_test) && (lowest_div-- > 0)) { spiflash_phy_clk_divisor_write((uint32_t)lowest_div); crc_test = crc32((unsigned char *)SPIFLASH_BASE, SPI_FLASH_BLOCK_SIZE); -#if SPIFLASH_DEBUG +#ifdef SPIFLASH_DEBUG printf("[DIV: %d] %08x\n\r", lowest_div, crc_test); #endif } @@ -62,7 +62,7 @@ int spiflash_freq_init(void) void spiflash_dummy_bits_setup(unsigned int dummy_bits) { spiflash_core_mmap_dummy_bits_write((uint32_t)dummy_bits); -#if SPIFLASH_DEBUG +#ifdef SPIFLASH_DEBUG printf("Dummy bits set to: %d\n\r", spiflash_core_mmap_dummy_bits_read()); #endif }