Skip to content

Commit

Permalink
Merge pull request #420 from skiphansen/pano_make_flash_support
Browse files Browse the repository at this point in the history
Add image-flash, gateware-flash, etc support for pano_logic_g2 target.
  • Loading branch information
mateusz-holenko authored May 15, 2020
2 parents a3d3477 + 1c7e6c0 commit a7221b7
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 27 deletions.
22 changes: 15 additions & 7 deletions Makefile
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ ifeq ($(shell [ $(JOBS) -gt 1 ] && echo true),true)
export MAKEFLAGS="-j $(JOBS) -l $(JOBS)"
endif

TARGET_BUILD_DIR = build/$(FULL_PLATFORM)_$(TARGET)_$(FULL_CPU)/
TARGET_BUILD_DIR = build/$(FULL_PLATFORM)_$(TARGET)_$(FULL_CPU)

GATEWARE_FILEBASE = $(TARGET_BUILD_DIR)/gateware/top
BIOS_FILE = $(TARGET_BUILD_DIR)/software/bios/bios.bin
Expand Down Expand Up @@ -207,8 +207,8 @@ ifeq ($(FIRMWARE),clear)
OVERRIDE_FIRMWARE=--override-firmware=clear
FIRMWARE_FBI=
else
OVERRIDE_FIRMWARE=--override-firmware=$(FIRMWARE_FILEBASE).fbi
FIRMWARE_FBI=$(FIRMWARE_FILEBASE).fbi
OVERRIDE_FIRMWARE?=--override-firmware=$(FIRMWARE_FILEBASE).fbi
FIRMWARE_FBI?=$(FIRMWARE_FILEBASE).fbi
endif
endif

Expand Down Expand Up @@ -315,20 +315,28 @@ endif
$(FIRMWARE_FILEBASE).bin: firmware-cmd
@true

$(FIRMWARE_FILEBASE).fbi: $(FIRMWARE_FILEBASE).bin

ifeq ($(CPU_ENDIANNESS), little)
$(PYTHON) -m litex.soc.software.mkmscimg -f --little $< -o $@
MKMSCIMG = $(PYTHON) -m litex.soc.software.mkmscimg --little
else
$(PYTHON) -m litex.soc.software.mkmscimg -f $< -o $@
MKMSCIMG = $(PYTHON) -m litex.soc.software.mkmscimg
endif

$(FIRMWARE_FILEBASE).fbi: $(FIRMWARE_FILEBASE).bin
@echo "making $< -> $@"
$(MKMSCIMG) -f $< -o $@

%.fbi: %
@echo "making $< -> $@"
$(MKMSCIMG) -f $< -o $@

firmware: $(FIRMWARE_FILEBASE).bin
@true

firmware-load: firmware firmware-load-$(PLATFORM)
@true

firmware-flash: firmware firmware-flash-$(PLATFORM)
firmware-flash: firmware $(FIRMWARE_FBI) firmware-flash-$(PLATFORM)
@true

firmware-flash-py: firmware
Expand Down
45 changes: 38 additions & 7 deletions platforms/pano_logic_g2.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# can be found here https://github.com/tomverbeure/panologic-g2

from litex.build.generic_platform import *
from litex.build.xilinx import XilinxPlatform, iMPACT
from litex.build.xilinx import XilinxPlatform, XC3SProg

# IOs ----------------------------------------------------------------------------------------------

Expand Down Expand Up @@ -182,33 +182,57 @@
Subsignal("rx", Pins("C17"), IOStandard("LVCMOS33"))
)

# this is needed since make.py calls prog.set_flash_proxy_dir forcing
# proxys to be in ./third_party/flash_proxies but a special proxy is needed for
# the Pano logic device and it has not been accepted by https://github.com/quartiq/bscan_spi_bitstreams
# yet.

class PanoXC3SProg(XC3SProg):
def __init__(self, cable, flash_proxy_basename=None, position=0):
super(PanoXC3SProg,self).__init__(cable, flash_proxy_basename, position)

def flash(self, address, data_file):
proxy_dir = os.path.realpath("./targets/pano_logic_g2/flash_proxies")
super(PanoXC3SProg,self).set_flash_proxy_dir(proxy_dir)
super(PanoXC3SProg,self).flash(address, data_file)

# Platform -----------------------------------------------------------------------------------------

class Platform(XilinxPlatform):
name = "pano logic g2"
default_clk_name = "clk125"
default_clk_period = 1e9/125e6

# actual .bit file size rounded up to next flash erase boundary
gateware_size = 0x420000
flavor = os.environ.get('FIRMWARE', 'firmware')
if flavor == 'linux':
# leave room for emulator and DTS file in the .bit file partition
gateware_size = 0x410000
else:
# actual .bit file size rounded up to next flash erase boundary
gateware_size = 0x440000

# Micron M25P128
spiflash_model = "m25p128"
spiflash_read_dummy_bits = 8
spiflash_clock_div = 4
spiflash_total_size = int((128/8)*1024*1024) # 128Mbit/16Mbyte
spiflash_page_size = 256
spiflash_sector_size = 0x20000
spiflash_sector_size = 0x40000

def __init__(self, programmer="impact", device="xc6slx150", uart_connection="dvi"):
def __init__(self, programmer="xc3sprog", device="xc6slx150", uart_connection="dvi"):
if uart_connection == 'dvi':
_io.append(_dvi_serial)
elif uart_connection == 'hdmi':
_io.append(_hdmi_serial)
else:
raise ValueError("Unsupported uart_connection \"{}\", available \"dvi\", \"hdmi\"".format(uart_connection))

if device != "xc6slx150" and device != "xc6slx100":
raise ValueError("Invalid device \"{}\"".format(device))
self.device = device

XilinxPlatform.__init__(self, device+"-2-fgg484", _io)
self.toolchain.bitgen_opt += " -g Compress -g ConfigRate:26"
self.programmer = programmer

self.add_platform_command("""CONFIG VCCAUX="2.5";""")
Expand All @@ -217,7 +241,14 @@ def do_finalize(self, fragment, *args, **kwargs):
pass

def create_programmer(self):
if self.programmer == "impact":
return iMPACT()
cable_type = os.getenv('CABLE',default='jtaghs2')

if self.device == "xc6slx150-2-fgg484":
proxy = "bscan_spi_xc6slx150_pano.bit"
elif self.device == "xc6slx100-2-fgg484":
proxy = "bscan_spi_xc6slx100_pano.bit"

if self.programmer == "xc3sprog":
return PanoXC3SProg(cable_type, proxy)
else:
raise ValueError("{} programmer is not supported".format(self.programmer))
77 changes: 67 additions & 10 deletions targets/pano_logic_g2/Makefile.mk
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,83 @@ TARGET ?= $(DEFAULT_TARGET)
COMM_PORT ?= /dev/ttyUSB0
BAUD ?= 115200

ifeq ($(FIRMWARE),linux)


OVERRIDE_FIRMWARE=--override-firmware=none
define fbi_rule
$(1): $(subst .fbi,,$(1))
endef

TARGET_BUILD_DIR = build/$(FULL_PLATFORM)_$(TARGET)_$(FULL_CPU)
FIRMWARE_DIR = $(TARGET_BUILD_DIR)/software/$(FIRMWARE)

KERNEL_FBI = $(FIRMWARE_DIR)/firmware.bin.fbi
ROOTFS_FBI = $(FIRMWARE_DIR)/riscv32-rootfs.cpio.fbi
EMULATOR_FBI = $(TARGET_BUILD_DIR)/emulator/emulator.bin.fbi
DTB_FBI = $(FIRMWARE_DIR)/rv32.dtb.fbi
FIRMWARE_FBI = $(KERNEL_FBI) $(ROOTFS_FBI) $(EMULATOR_FBI) $(DTB_FBI)

$(foreach file,$(FIRMWARE_FBI),$(eval $(call fbi_rule,$(file))))
endif

# Image
image-flash-$(PLATFORM):
@echo "Unsupported"
@false
image-flash-$(PLATFORM): gateware-flash-$(PLATFORM) firmware-flash-$(PLATFORM)

# Gateware
gateware-load-$(PLATFORM):
@echo "Unsupported"
@false
./load.py ise

gateware-flash-$(PLATFORM):
@echo "Unsupported"
@false
ifeq ($(FIRMWARE),linux)
GATEWARE_BIN = $(TARGET_BUILD_DIR)/gateware+emulator+dtb.bin

# note: emulator and DTB are flashed with gateware to save flash space
$(GATEWARE_BIN): $(GATEWARE_FILEBASE).bin $(DTB_FBI) $(EMULATOR_FBI)
dd if=$(GATEWARE_FILEBASE).bin of=$@ bs=4259840 conv=sync
dd if=$(DTB_FBI) bs=16K conv=sync >> $@
cat $(EMULATOR_FBI) >> $@

# note: emulator and DTB are flashed with gateware to save flash space
gateware-flash-$(PLATFORM): $(GATEWARE_BIN)
ifeq ($(DUMMY_FLASH),)
@echo "Flashing $(notdir( $(GATEWARE_BIN))) @ 0"
$(PYTHON) flash.py --mode=other --other-file $(GATEWARE_BIN) --address 0
endif
@true
else
gateware-flash-$(PLATFORM): gateware-flash-py
endif

# Firmware
firmware-load-$(PLATFORM):
flterm --port=$(COMM_PORT) --kernel=$(FIRMWARE_FILEBASE).bin --speed=$(BAUD)


rootfs-flash-$(PLATFORM):
ifeq ($(DUMMY_FLASH),)
@echo "Flashing roots @ 0x9c0000"
$(PYTHON) flash.py --mode=other --other-file $(ROOTFS_FBI) --address 10223616
endif

kernel-flash-$(PLATFORM):
ifeq ($(DUMMY_FLASH),)
@echo "Flashing kernel @ 0x440000"
$(PYTHON) flash.py --mode=other --other-file $(KERNEL_FBI) --address 4456448
endif

ifeq ($(FIRMWARE),linux)
firmware-flash-$(PLATFORM): $(FIRMWARE_FBI) kernel-flash-$(PLATFORM) rootfs-flash-$(PLATFORM)
else
ifeq ($(FIRMWARE),micropython)
MICROPYTHON_FBI = $(TARGET_BUILD_DIR)/software/micropython/firmware.fbi

firmware-flash-$(PLATFORM):
@echo "Unsupported"
@false
@echo "Flashing micropython @ 0x440000"
$(PYTHON) flash.py --mode=other --other-file $(MICROPYTHON_FBI) --address 4456448
else
firmware-flash-$(PLATFORM): firmware-flash-py
endif
endif

firmware-connect-$(PLATFORM):
flterm --port=$(COMM_PORT) --speed=$(BAUD)
Expand All @@ -48,3 +104,4 @@ help-$(PLATFORM):
reset-$(PLATFORM):
@echo "Unsupported"
@false

6 changes: 3 additions & 3 deletions targets/pano_logic_g2/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ def __init__(self, platform, **kwargs):
self.flash_boot_address = self.mem_map["spiflash"]+platform.gateware_size
self.add_constant("FLASH_BOOT_ADDRESS", self.flash_boot_address)
self.add_constant("DEVICE_TREE_IMAGE_FLASH_OFFSET",0x00000000)
self.add_constant("EMULATOR_IMAGE_FLASH_OFFSET",0x20000)
self.add_constant("KERNEL_IMAGE_FLASH_OFFSET",0x40000)
self.add_constant("ROOTFS_IMAGE_FLASH_OFFSET",0x5c0000)
self.add_constant("EMULATOR_IMAGE_FLASH_OFFSET",0x4000)
self.add_constant("KERNEL_IMAGE_FLASH_OFFSET",0x30000)
self.add_constant("ROOTFS_IMAGE_FLASH_OFFSET",0x5b0000)

# Take Ethernet Phy out of reset for SYSCLK of 125 Mhz
gmii_rst_n = platform.request("gmii_rst_n")
Expand Down
Binary file not shown.
Binary file not shown.

0 comments on commit a7221b7

Please sign in to comment.