Skip to content

Commit

Permalink
make/soc_linux: add SPI SDCard support and enable it on Nexys4DDR/De1…
Browse files Browse the repository at this point in the history
…0Nano(MiSTer).

To boot Linux from the SDCard:

Use a FAT16 partition on SDCard and copy the images to it:
- Image from buildroot/Image.
- rootfs.cpio fom buildroot/rootfs.cpio.
- rv32.dtb from buildroot/rv32.dtb.
- emulator.bin emulator/emulator.bin.

Then use the spisdcardboot command of the LiteX bios.
  • Loading branch information
enjoy-digital committed Mar 19, 2020
1 parent 4f913ce commit 2d232e9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 4 additions & 2 deletions make.py
Expand Up @@ -132,7 +132,7 @@ def load(self):
class Nexys4DDR(Board):
def __init__(self):
from litex_boards.targets import nexys4ddr
Board.__init__(self, nexys4ddr.EthernetSoC, {"serial", "ethernet"})
Board.__init__(self, nexys4ddr.EthernetSoC, {"serial", "spisdcard", "ethernet"})

def load(self):
from litex.build.xilinx import VivadoProgrammer
Expand Down Expand Up @@ -246,7 +246,7 @@ def load(self):
class De10Nano(Board):
def __init__(self):
from litex_boards.targets import de10nano
Board.__init__(self, de10nano.MiSTerSDRAMSoC, {"serial", "leds", "switches"})
Board.__init__(self, de10nano.MiSTerSDRAMSoC, {"serial", "spisdcard", "leds", "switches"})

def load(self):
from litex.build.altera import USBBlaster
Expand Down Expand Up @@ -329,6 +329,8 @@ def main():
soc.add_spi_flash(dummy_cycles=board.SPIFLASH_DUMMY_CYCLES)
soc.add_constant("SPIFLASH_PAGE_SIZE", board.SPIFLASH_PAGE_SIZE)
soc.add_constant("SPIFLASH_SECTOR_SIZE", board.SPIFLASH_SECTOR_SIZE)
if "spisdcard" in board.soc_capabilities:
soc.add_spi_sdcard()
if "ethernet" in board.soc_capabilities:
soc.configure_ethernet(local_ip=args.local_ip, remote_ip=args.remote_ip)
if "leds" in board.soc_capabilities:
Expand Down
7 changes: 7 additions & 0 deletions soc_linux.py
Expand Up @@ -116,6 +116,13 @@ def add_spi_flash(self, dummy_cycles):
self.add_wb_slave(self.mem_map["spiflash"], self.spiflash.bus)
self.add_csr("spiflash")

def add_spi_sdcard(self, spisdcard_clk_freq=400e3):
spisdcard_pads = self.platform.request("spisdcard")
if hasattr(spisdcard_pads, "rst"):
self.comb += spisdcard_pads.rst.eq(0)
self.submodules.spisdcard = SPIMaster(spisdcard_pads, 8, self.clk_freq, spisdcard_clk_freq)
self.add_csr("spisdcard")

def add_leds(self):
self.submodules.leds = GPIOOut(Cat(platform_request_all(self.platform, "user_led")))
self.add_csr("leds")
Expand Down

0 comments on commit 2d232e9

Please sign in to comment.