Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add image-flash, gateware-flash, etc support for pano_logic_g2 target. #420

Merged
merged 5 commits into from
May 15, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions Makefile
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,23 @@ FIRMWARE_FBI=$(FIRMWARE_FILEBASE).fbi
endif
endif

ifeq ($(FIRMWARE),linux)
# Linux Image component files - kernel+emulator+dts+rootfs
define fbi_rule
$(1): $(subst .fbi,,$(1))
endef

OVERRIDE_FIRMWARE=--override-firmware=none
BUILDROOT_IMAGES = third_party/buildroot/output/images
KERNEL_FBI = $(BUILDROOT_IMAGES)/Image.fbi
ROOTFS_FBI = $(BUILDROOT_IMAGES)/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_FILE): $(GATEWARE_FILEBASE).bin $(BIOS_FILE) $(FIRMWARE_FBI)
$(PYTHON) mkimage.py \
$(MISOC_EXTRA_CMDLINE) $(LITEX_EXTRA_CMDLINE) $(MAKE_LITEX_EXTRA_CMDLINE) \
Expand Down Expand Up @@ -315,13 +332,21 @@ 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

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))
52 changes: 41 additions & 11 deletions targets/pano_logic_g2/Makefile.mk
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,56 @@ COMM_PORT ?= /dev/ttyUSB0
BAUD ?= 115200

# 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

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

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

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

firmware-flash-$(PLATFORM):
@echo "Unsupported"
@false

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

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

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 "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 Down
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.