integration/soc/sdcard: cleanup emulator integration, fix sim.
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Tue, 7 Jul 2020 13:05:07 +0000 (15:05 +0200)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Tue, 7 Jul 2020 13:05:07 +0000 (15:05 +0200)
litex/soc/integration/soc.py
litex/soc/software/liblitesdcard/sdcard.c
litex/tools/litex_sim.py

index a92faa6a88e708ee6e5807af9cdf51477d113dc4..a8c40e09070ef049cc9c714540185e3285c5a73d 100644 (file)
@@ -1244,23 +1244,24 @@ class LiteXSoC(SoC):
         self.add_csr(name)
 
     # Add SDCard -----------------------------------------------------------------------------------
-    def add_sdcard(self, name="sdcard", with_emulator=False):
+    def add_sdcard(self, name="sdcard", use_emulator=False):
         # Imports
+        from litesdcard.emulator import SDEmulator
         from litesdcard.phy import SDPHY
         from litesdcard.core import SDCore
         from litesdcard.frontend.dma import SDBlock2MemDMA, SDMem2BlockDMA
 
         # Emulator / Pads
-        if with_emulator:
-            from litesdcard.emulator import SDEmulator
-            self.submodules.sdemulator = SDEmulator(self.platform)
-            sdcard_pads = self.sdemulator.pads
+        if use_emulator:
+            sdemulator = SDEmulator(self.platform)
+            self.submodules += sdemulator
+            sdcard_pads = sdemulator.pads
         else:
             sdcard_pads = self.platform.request(name)
 
         # Core
-        self.submodules.sdphy   = SDPHY(sdcard_pads, self.platform.device, self.clk_freq)
-        self.submodules.sdcore  = SDCore(self.sdphy)
+        self.submodules.sdphy  = SDPHY(sdcard_pads, self.platform.device, self.clk_freq)
+        self.submodules.sdcore = SDCore(self.sdphy)
         self.add_csr("sdphy")
         self.add_csr("sdcore")
 
index b0f875c04c06257329dfc228c071fdc51e37b02a..4361fe49af21ae92ceba177efb0fe74035a16acc 100644 (file)
@@ -562,7 +562,9 @@ sdcard_set_block_count(count);
 
        /* Flush CPU caches */
        flush_cpu_dcache();
+#ifdef CONFIG_L2_SIZE
        flush_l2_cache();
+#endif
 }
 
 void sdcard_write(uint32_t sector, uint32_t count, uint8_t* buf)
index 680fb4a3afaa77dd549efa7415f4eb4df4438bc6..4c33dbb72208669517e6df5c0274b4a2a20aca18 100755 (executable)
@@ -309,7 +309,7 @@ class SimSoC(SoCCore):
 
         # SDCard -----------------------------------------------------------------------------------
         if with_sdcard:
-            self.add_sdcard("sdcard", with_emulator=True)
+            self.add_sdcard("sdcard", use_emulator=True)
 
 # Build --------------------------------------------------------------------------------------------