From e5c91ba59fc66a5761170065594a538b62232926 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Mon, 30 Oct 2017 02:49:27 -0700 Subject: [PATCH 001/219] scripts: Working on script to build Linux. --- .gitignore | 1 + scripts/build-linux.sh | 79 ++++++++++++++++++++++++++++++++++++++++++ third_party/litex | 2 +- 3 files changed, 81 insertions(+), 1 deletion(-) create mode 100755 scripts/build-linux.sh diff --git a/.gitignore b/.gitignore index 6260aefc..f4a41106 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ build *.png third_party/qemu-litex third_party/micropython +third_party/linux diff --git a/scripts/build-linux.sh b/scripts/build-linux.sh new file mode 100755 index 00000000..56e612c2 --- /dev/null +++ b/scripts/build-linux.sh @@ -0,0 +1,79 @@ +#!/bin/bash + +if [ "$(whoami)" = "root" ] +then + echo "Running the script as root is not permitted" + exit 1 +fi + +CALLED=$_ +[[ "${BASH_SOURCE[0]}" != "${0}" ]] && SOURCED=1 || SOURCED=0 + +SCRIPT_SRC=$(realpath ${BASH_SOURCE[0]}) +SCRIPT_DIR=$(dirname $SCRIPT_SRC) +TOP_DIR=$(realpath $SCRIPT_DIR/..) + +if [ $SOURCED = 1 ]; then + echo "You must run this script, rather then try to source it." + echo "$SCRIPT_SRC" + return +fi + +if [ -z "$HDMI2USB_ENV" ]; then + echo "You appear to not be inside the HDMI2USB environment." + echo "Please enter environment with:" + echo " source scripts/enter-env.sh" + exit 1 +fi + +# Imports TARGET, PLATFORM, CPU and TARGET_BUILD_DIR from Makefile +export FIRMWARE=linux +eval $(make env) +make info + +set -x +set -e + +if [ "$CPU" != or1k ]; then + echo "Linux is only supported on or1k at the moment." + exit 1 +fi + +( + cd third_party/litex + git checkout or1k-linux +) + +make gateware + +# Install a toolchain with the newlib standard library +if ! $CPU-elf-newlib-gcc --version > /dev/null 2>&1; then + conda install gcc-$CPU-elf-newlib +fi + +# Get linux-litex is needed +LINUX_SRC_DIR=$TOP_DIR/third_party/linux +if [ ! -d "$LINUX_SRC_DIR" ]; then + ( + cd $(dirname $LINUX_SRC_DIR) + git clone https://github.com/mithro/linux-litex.git -b litex-minimal linux + cd $LINUX_SRC_DIR + wget "https://drive.google.com/a/mithis.com/uc?authuser=0&id=0B5VlNZ_Rvdw6d21LWXdHQlZuOVU&export=download" -O openrisc-rootfs.cpio + gzip openrisc-rootfs.cpio + ) +fi + +# Build linux-litex +export ARCH=openrisc +export CROSS_COMPILE=$CPU-elf-newlib- +( + cd $LINUX_SRC_DIR + make litex_defconfig + make -j32 + ls -l arch/openrisc/boot/vmlinux.bin + mkdir -p $(dirname $TOP_DIR/$FIRMWARE_FILEBASE) + cp arch/openrisc/boot/vmlinux.bin $TOP_DIR/$FIRMWARE_FILEBASE.bin +) + +make tftp +make gateware-load diff --git a/third_party/litex b/third_party/litex index 56ef2290..aa6dadf0 160000 --- a/third_party/litex +++ b/third_party/litex @@ -1 +1 @@ -Subproject commit 56ef22902926e5edfdb524a064804823fe449502 +Subproject commit aa6dadf0d843a856ea64288d387869efe0b0c255 From 2f0cc16e41179b66b5dacb809dc5d8e936346a5a Mon Sep 17 00:00:00 2001 From: Greg Darke Date: Sun, 5 Nov 2017 18:24:37 -0800 Subject: [PATCH 002/219] Make it possible to start an image in qemu as a user. By switching to usermode networking in qemu, because of this we no longer need to set up the tap interface, nor do we need to start tftpd as root. This change requires a fix to the netboot code in the bios, otherwise it will time out fetching the second block of the firmware (the second 512 bytes). --- scripts/build-qemu.sh | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/scripts/build-qemu.sh b/scripts/build-qemu.sh index 93f6294f..f9634d54 100755 --- a/scripts/build-qemu.sh +++ b/scripts/build-qemu.sh @@ -113,18 +113,25 @@ fi # Ethernet if grep -q ETHMAC_BASE $TARGET_BUILD_DIR/software/include/generated/csr.h; then - if [ ! -e /dev/net/tap0 ]; then - sudo true - echo "Need to bring up a tun device." - IPRANGE=192.168.100 - sudo openvpn --mktun --dev tap0 - sudo ifconfig tap0 $IPRANGE.100 up - sudo mknod /dev/net/tap0 c 10 200 - sudo chown $(whoami) /dev/net/tap0 - make tftpd_start - fi + # Make qemu emulate a network device + EXTRA_ARGS+=("-net nic") + + # Build/copy the image into the TFTP directory. make tftp - EXTRA_ARGS+=("-net nic -net tap,ifname=tap0,script=no,downscript=no") + + # Use the userspace network support. QEMU will pretend to be a + # machine a 192.168.100.100. Any connections to that IP will + # automatically be forwarded to the real localhost. + # + # Connections to real localhost on port 2223, will be + # forwarded to the expected guest ip (192.168.100.50) on port + # 23 (telnet). + EXTRA_ARGS+=("-net user,net=192.168.100.0/24,host=192.168.100.100,dhcpstart=192.168.100.50,tftp=$TOP_DIR/build/tftpd,hostfwd=tcp::2223-:23") + + # Make debugging the userspace networking easier, dump all + # packets to a file. + # FIXME: Make this optional. + EXTRA_ARGS+=("-net dump,file=/tmp/data.pcap") fi # Allow gdb connections From 2a5220c26d37ee329a83cb12393cf7bf8d74e6c2 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Fri, 17 Nov 2017 17:26:21 -0800 Subject: [PATCH 003/219] Remove gateware-load from scripts/build-linux.sh --- scripts/build-linux.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/build-linux.sh b/scripts/build-linux.sh index 56e612c2..2c768070 100755 --- a/scripts/build-linux.sh +++ b/scripts/build-linux.sh @@ -74,6 +74,3 @@ export CROSS_COMPILE=$CPU-elf-newlib- mkdir -p $(dirname $TOP_DIR/$FIRMWARE_FILEBASE) cp arch/openrisc/boot/vmlinux.bin $TOP_DIR/$FIRMWARE_FILEBASE.bin ) - -make tftp -make gateware-load From fd49a22a121fb1679d43178db95209b9b42dbb58 Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Sat, 18 Nov 2017 14:26:38 +1100 Subject: [PATCH 004/219] Make build-linux.sh only make gateware if it changes branch. --- scripts/build-linux.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/build-linux.sh b/scripts/build-linux.sh index 2c768070..0497387e 100755 --- a/scripts/build-linux.sh +++ b/scripts/build-linux.sh @@ -41,11 +41,13 @@ fi ( cd third_party/litex - git checkout or1k-linux + if [ "$(git rev-parse --abbrev-ref HEAD)" != "or1k-linux" ]; then + git checkout or1k-linux + cd ../.. + make gateware + fi ) -make gateware - # Install a toolchain with the newlib standard library if ! $CPU-elf-newlib-gcc --version > /dev/null 2>&1; then conda install gcc-$CPU-elf-newlib From 1a33aea3246557680aec3df6762af67dc447e466 Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Sat, 18 Nov 2017 15:01:40 +1100 Subject: [PATCH 005/219] Make build-qemu work on arch. --- Makefile | 2 +- scripts/build-qemu.sh | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8c937e05..8bcc4167 100644 --- a/Makefile +++ b/Makefile @@ -231,7 +231,7 @@ tftpd_start: sudo true @if command -v atftpd >/dev/null ; then \ echo "Starting aftpd"; \ - sudo atftpd --verbose --bind-address $(TFTP_IPRANGE).100 --daemon --logfile /dev/stdout --no-fork --user $(shell whoami) $(TFTPD_DIR) & \ + sudo atftpd --verbose --bind-address $(TFTP_IPRANGE).100 --daemon --logfile /dev/stdout --no-fork --user $(shell whoami) --group $(shell whoami) $(TFTPD_DIR) & \ elif command -v in.tftpd >/dev/null; then \ echo "Starting in.tftpd"; \ sudo in.tftpd --verbose --listen --address $(TFTP_IPRANGE).100 --user $(shell whoami) -s $(TFTPD_DIR) & \ diff --git a/scripts/build-qemu.sh b/scripts/build-qemu.sh index 93f6294f..0cc12a2e 100755 --- a/scripts/build-qemu.sh +++ b/scripts/build-qemu.sh @@ -118,7 +118,12 @@ if grep -q ETHMAC_BASE $TARGET_BUILD_DIR/software/include/generated/csr.h; then echo "Need to bring up a tun device." IPRANGE=192.168.100 sudo openvpn --mktun --dev tap0 - sudo ifconfig tap0 $IPRANGE.100 up + if command -v ifconfig >/dev/null ; then + sudo ifconfig tap0 $IPRANGE.100 up + else + sudo ip addr add $IPRANGE.100/24 dev tap0 + sudo ip link set dev tap0 up + fi sudo mknod /dev/net/tap0 c 10 200 sudo chown $(whoami) /dev/net/tap0 make tftpd_start From 01b968bdfac74abf87b5e0325f83b799b6b811a2 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Fri, 17 Nov 2017 21:38:15 -0800 Subject: [PATCH 006/219] Allow SoC without cpu_type. --- make.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/make.py b/make.py index d6b781be..9da6b487 100755 --- a/make.py +++ b/make.py @@ -114,11 +114,14 @@ def main(): if not buildargs.get('csr_csv', None): buildargs['csr_csv'] = os.path.join(testdir, "csr.csv") - builder = Builder(soc, **buildargs) - if not args.no_compile_firmware or args.override_firmware: - builder.add_software_package("uip", "{}/firmware/uip".format(os.getcwd())) - builder.add_software_package("firmware", "{}/firmware".format(os.getcwd())) - vns = builder.build(**dict(args.build_option)) + if soc.cpu_type is not None: + builder = Builder(soc, **buildargs) + if not args.no_compile_firmware or args.override_firmware: + builder.add_software_package("uip", "{}/firmware/uip".format(os.getcwd())) + builder.add_software_package("firmware", "{}/firmware".format(os.getcwd())) + vns = builder.build(**dict(args.build_option)) + else: + vns = platform.build(soc) #, **buildargs) if hasattr(soc, 'pcie_phy'): from targets.common import cpu_interface From 0c9ad9f15f03965703393c3238e0da12f095deb1 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Fri, 17 Nov 2017 21:45:44 -0800 Subject: [PATCH 007/219] Check atftpd / in.tftpd using sudo. --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8bcc4167..eef3216e 100644 --- a/Makefile +++ b/Makefile @@ -229,10 +229,10 @@ tftpd_stop: tftpd_start: mkdir -p $(TFTPD_DIR) sudo true - @if command -v atftpd >/dev/null ; then \ + @if command -v sudo atftpd >/dev/null ; then \ echo "Starting aftpd"; \ sudo atftpd --verbose --bind-address $(TFTP_IPRANGE).100 --daemon --logfile /dev/stdout --no-fork --user $(shell whoami) --group $(shell whoami) $(TFTPD_DIR) & \ - elif command -v in.tftpd >/dev/null; then \ + elif command -v sudo in.tftpd >/dev/null; then \ echo "Starting in.tftpd"; \ sudo in.tftpd --verbose --listen --address $(TFTP_IPRANGE).100 --user $(shell whoami) -s $(TFTPD_DIR) & \ else \ From 8ebd52c65e10b8a25f1f9d8342c7c6d82320d44c Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Fri, 17 Nov 2017 22:11:57 -0800 Subject: [PATCH 008/219] Disable leds on arty temporarily. --- targets/arty/base.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/targets/arty/base.py b/targets/arty/base.py index 0e5e40aa..98dc5ae9 100755 --- a/targets/arty/base.py +++ b/targets/arty/base.py @@ -97,8 +97,8 @@ class BaseSoC(SoCSDRAM): "spiflash", "ddrphy", "info", - "leds", - "rgb_leds", +# "leds", +# "rgb_leds", ) csr_map_update(SoCSDRAM.csr_map, csr_peripherals) @@ -120,8 +120,8 @@ def __init__(self, platform, spiflash="spiflash_1x", **kwargs): # Basic peripherals self.submodules.info = info.Info(platform, self.__class__.__name__) - self.submodules.leds = led.ClassicLed(Cat(platform.request("user_led", i) for i in range(4))) - self.submodules.rgb_leds = led.RGBLed(platform.request("rgb_leds")) +# self.submodules.leds = led.ClassicLed(Cat(platform.request("user_led", i) for i in range(4))) +# self.submodules.rgb_leds = led.RGBLed(platform.request("rgb_leds")) # spi flash spiflash_pads = platform.request(spiflash) From a2a3935ad563599b9d6acddf522fe446b5c0984d Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Sat, 18 Nov 2017 17:20:10 +1100 Subject: [PATCH 009/219] Fix platform.build() needs builddir --- make.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make.py b/make.py index 9da6b487..5f3dbd3d 100755 --- a/make.py +++ b/make.py @@ -121,7 +121,7 @@ def main(): builder.add_software_package("firmware", "{}/firmware".format(os.getcwd())) vns = builder.build(**dict(args.build_option)) else: - vns = platform.build(soc) #, **buildargs) + vns = platform.build(soc, build_dir=os.path.join(builddir, "gateware")) if hasattr(soc, 'pcie_phy'): from targets.common import cpu_interface From bbf1dac1ca0c1609b39e87fdd5fb8fc535d77ebe Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Tue, 21 Nov 2017 21:10:48 +1100 Subject: [PATCH 010/219] Use the attribute existence rather than value. --- make.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/make.py b/make.py index 5f3dbd3d..f1bcef93 100755 --- a/make.py +++ b/make.py @@ -111,10 +111,11 @@ def main(): buildargs = builder_argdict(args) if not buildargs.get('output_dir', None): buildargs['output_dir'] = builddir - if not buildargs.get('csr_csv', None): - buildargs['csr_csv'] = os.path.join(testdir, "csr.csv") - if soc.cpu_type is not None: + if hasattr(soc, 'cpu_type'): + if not buildargs.get('csr_csv', None): + buildargs['csr_csv'] = os.path.join(testdir, "csr.csv") + builder = Builder(soc, **buildargs) if not args.no_compile_firmware or args.override_firmware: builder.add_software_package("uip", "{}/firmware/uip".format(os.getcwd())) From 57939fe351792511be31f59fc8f5a10873c3e992 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Wed, 22 Nov 2017 18:08:05 +1100 Subject: [PATCH 011/219] Make -j based on nprocs. --- Makefile | 4 ++++ scripts/build-micropython.sh | 2 +- scripts/build-qemu.sh | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index eef3216e..12f2380a 100644 --- a/Makefile +++ b/Makefile @@ -35,6 +35,9 @@ FIRMWARE ?= firmware CLANG = 0 export CLANG +JOBS ?= $(shell nproc) +JOBS ?= 2 + ifeq ($(PLATFORM_EXPANSION),) FULL_PLATFORM = $(PLATFORM) else @@ -264,6 +267,7 @@ env: @# Hardcoded values @echo "export CLANG=$(CLANG)" @echo "export PYTHONHASHSEED=$(PYTHONHASHSEED)" + @echo "export JOBS=$(JOBS)" @# Files @echo "export IMAGE_FILE='$(IMAGE_FILE)'" @echo "export GATEWARE_FILEBASE='$(GATEWARE_FILEBASE)'" diff --git a/scripts/build-micropython.sh b/scripts/build-micropython.sh index cf5612c8..fad00228 100755 --- a/scripts/build-micropython.sh +++ b/scripts/build-micropython.sh @@ -71,7 +71,7 @@ export BUILDINC_DIRECTORY="$(realpath $TARGET_BUILD_DIR/software/include)" export BUILD="$(realpath $TARGET_MPY_BUILD_DIR)" OLD_DIR=$PWD cd $TARGET_MPY_BUILD_DIR -make V=1 -C $(realpath ../../../../third_party/micropython/litex/) +make V=1 -C $(realpath ../../../../third_party/micropython/litex/) -j$JOBS cd $OLD_DIR # Generate a firmware image suitable for flashing. diff --git a/scripts/build-qemu.sh b/scripts/build-qemu.sh index 0cc12a2e..97b71029 100755 --- a/scripts/build-qemu.sh +++ b/scripts/build-qemu.sh @@ -83,7 +83,7 @@ fi OLD_DIR=$PWD cd $TARGET_QEMU_BUILD_DIR -make -j8 +make -j$JOBS cd $OLD_DIR # Need the .fbi for mkimage below... From 1c839c925e06f9239eddc688ef1e7184435e383f Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Wed, 22 Nov 2017 18:08:28 +1100 Subject: [PATCH 012/219] Rewrite scripts/build-linux.sh to be better. --- scripts/build-linux.sh | 111 ++++++++++++++++++++++++++++++++++------- 1 file changed, 92 insertions(+), 19 deletions(-) diff --git a/scripts/build-linux.sh b/scripts/build-linux.sh index 0497387e..803b0cc6 100755 --- a/scripts/build-linux.sh +++ b/scripts/build-linux.sh @@ -39,14 +39,50 @@ if [ "$CPU" != or1k ]; then exit 1 fi +REMOTE_NAME=h2u-litex-linux + +LITEX_SRC=$TOP_DIR/third_party/litex +LITEX_BRANCH=${LITEX_BRANCH:-or1k-linux} +LITEX_REMOTE="${LITEX_REMOTE:-https://github.com/enjoy-digital/litex.git}" +LITEX_REMOTE_BIT=$(echo $LITEX_REMOTE | sed -e's-^.*://--' -e's/.git$//') ( - cd third_party/litex - if [ "$(git rev-parse --abbrev-ref HEAD)" != "or1k-linux" ]; then - git checkout or1k-linux - cd ../.. - make gateware + # Init the submodule if it doesn't exist + if [ ! -d $LITEX_SRC ]; then + git submodule update --init third_party/litex + fi + + # Change into the dir + cd $LITEX_SRC + + # Add the remote if it doesn't exist + LITEX_REMOTE_NAME="$(git remote -v | grep fetch | grep "$LITEX_REMOTE_BIT" | sed -e's/\t.*$//')" + if [ x"$LITEX_REMOTE_NAME" = x ]; then + git remote add "$REMOTE_NAME" "$LITEX_REMOTE" + LITEX_REMOTE_NAME=$REMOTE_NAME + fi + + # Get any new data + git fetch $LITEX_REMOTE_NAME + + # Checkout or1k-linux branch it not already on it + if [ "$(git rev-parse --abbrev-ref HEAD)" != "$LITEX_BRANCH" ]; then + git checkout $LITEX_BRANCH || \ + git checkout "$LITEX_REMOTE_NAME/$LITEX_BRANCH" -b $LITEX_BRANCH + + # Need to rebuild the gateware + # FIXME: Make this conditional on the gateware /actually/ changing + ( + cd $TOP_DIR + make gateware + ) fi ) +# Unset these values as LITEX and LINUX are very close in name and hence could +# accidentally be used below. +unset LITEX_SRC +unset LITEX_BRANCH +unset LITEX_REMOTE +unset LITEX_REMOTE_BIT # Install a toolchain with the newlib standard library if ! $CPU-elf-newlib-gcc --version > /dev/null 2>&1; then @@ -54,25 +90,62 @@ if ! $CPU-elf-newlib-gcc --version > /dev/null 2>&1; then fi # Get linux-litex is needed -LINUX_SRC_DIR=$TOP_DIR/third_party/linux -if [ ! -d "$LINUX_SRC_DIR" ]; then +LINUX_SRC="$TOP_DIR/third_party/linux" +LINUX_LOCAL="$LINUX_GITLOCAL" # Local place to clone from +LINUX_REMOTE="${LINUX_REMOTE:-https://github.com/mithro/linux-litex.git}" +LINUX_REMOTE_BIT=$(echo $LINUX_REMOTE | sed -e's-^.*://--' -e's/.git$//') +LINUX_CLONE_FROM="${LINUX_LOCAL:-$LINUX_REMOTE}" +LINUX_BRANCH=${LINUX_BRANCH:-litex-minimal} +( + # Download the Linux source for the first time + if [ ! -d "$LINUX_SRC" ]; then ( - cd $(dirname $LINUX_SRC_DIR) - git clone https://github.com/mithro/linux-litex.git -b litex-minimal linux - cd $LINUX_SRC_DIR - wget "https://drive.google.com/a/mithis.com/uc?authuser=0&id=0B5VlNZ_Rvdw6d21LWXdHQlZuOVU&export=download" -O openrisc-rootfs.cpio - gzip openrisc-rootfs.cpio + cd $(dirname $LINUX_SRC) + echo "Downloading Linux source tree." + echo "If you already have a local git checkout you can set 'LINUX_GITLOCAL' to speed up this step." + git clone $LINUX_CLONE_FROM linux ) -fi + fi + + # Change into the dir + cd $LINUX_SRC + + # Add the remote if it doesn't exist + LINUX_REMOTE_NAME=$(git remote -v | grep fetch | grep "$LINUX_REMOTE_BIT" | sed -e's/\t.*$//') + if [ x"$LINUX_REMOTE_NAME" = x ]; then + git remote add $REMOTE_NAME https://github.com/enjoy-digital/litex.git + LINUX_REMOTE_NAME=$REMOTE_NAME + fi + + # Get any new data + git fetch $LINUX_REMOTE_NAME + + # Checkout or1k-linux branch it not already on it + if [ "$(git rev-parse --abbrev-ref HEAD)" != "$LINUX_BRANCH" ]; then + git checkout $LINUX_BRANCH || \ + git checkout "$LINUX_REMOTE_NAME/$LINUX_BRANCH" -b $LINUX_BRANCH + fi +) # Build linux-litex export ARCH=openrisc export CROSS_COMPILE=$CPU-elf-newlib- +TARGET_LINUX_BUILD_DIR=$(dirname $TOP_DIR/$FIRMWARE_FILEBASE) ( - cd $LINUX_SRC_DIR - make litex_defconfig - make -j32 - ls -l arch/openrisc/boot/vmlinux.bin - mkdir -p $(dirname $TOP_DIR/$FIRMWARE_FILEBASE) - cp arch/openrisc/boot/vmlinux.bin $TOP_DIR/$FIRMWARE_FILEBASE.bin + cd $LINUX_SRC + echo "Building Linux in $TARGET_LINUX_BUILD_DIR" + mkdir -p $TARGET_LINUX_BUILD_DIR + ( + cd $TARGET_LINUX_BUILD_DIR + if [ ! -e openrisc-rootfs.cpio ]; then + wget "https://drive.google.com/a/mithis.com/uc?authuser=0&id=0B5VlNZ_Rvdw6d21LWXdHQlZuOVU&export=download" -O openrisc-rootfs.cpio + fi + if [ ! -e openrisc-rootfs.cpio.gz ]; then + gzip openrisc-rootfs.cpio + fi + ) + make O="$TARGET_LINUX_BUILD_DIR" litex_defconfig + make O="$TARGET_LINUX_BUILD_DIR" -j$JOBS + ls -l $TARGET_LINUX_BUILD_DIR/arch/openrisc/boot/vmlinux.bin + ln -s $TARGET_LINUX_BUILD_DIR/arch/openrisc/boot/vmlinux.bin $TOP_DIR/$FIRMWARE_FILEBASE.bin ) From ed7441074cccd36deb4027eb8a317e8c263fe457 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Wed, 22 Nov 2017 18:08:05 +1100 Subject: [PATCH 013/219] Make -j based on nprocs. --- Makefile | 4 ++++ scripts/build-micropython.sh | 2 +- scripts/build-qemu.sh | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8c937e05..c067574c 100644 --- a/Makefile +++ b/Makefile @@ -35,6 +35,9 @@ FIRMWARE ?= firmware CLANG = 0 export CLANG +JOBS ?= $(shell nproc) +JOBS ?= 2 + ifeq ($(PLATFORM_EXPANSION),) FULL_PLATFORM = $(PLATFORM) else @@ -264,6 +267,7 @@ env: @# Hardcoded values @echo "export CLANG=$(CLANG)" @echo "export PYTHONHASHSEED=$(PYTHONHASHSEED)" + @echo "export JOBS=$(JOBS)" @# Files @echo "export IMAGE_FILE='$(IMAGE_FILE)'" @echo "export GATEWARE_FILEBASE='$(GATEWARE_FILEBASE)'" diff --git a/scripts/build-micropython.sh b/scripts/build-micropython.sh index cf5612c8..fad00228 100755 --- a/scripts/build-micropython.sh +++ b/scripts/build-micropython.sh @@ -71,7 +71,7 @@ export BUILDINC_DIRECTORY="$(realpath $TARGET_BUILD_DIR/software/include)" export BUILD="$(realpath $TARGET_MPY_BUILD_DIR)" OLD_DIR=$PWD cd $TARGET_MPY_BUILD_DIR -make V=1 -C $(realpath ../../../../third_party/micropython/litex/) +make V=1 -C $(realpath ../../../../third_party/micropython/litex/) -j$JOBS cd $OLD_DIR # Generate a firmware image suitable for flashing. diff --git a/scripts/build-qemu.sh b/scripts/build-qemu.sh index 93f6294f..f927c103 100755 --- a/scripts/build-qemu.sh +++ b/scripts/build-qemu.sh @@ -83,7 +83,7 @@ fi OLD_DIR=$PWD cd $TARGET_QEMU_BUILD_DIR -make -j8 +make -j$JOBS cd $OLD_DIR # Need the .fbi for mkimage below... From 946d8c2dd4201f0991b205bcefbc65c5c6eac3af Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Tue, 14 Nov 2017 23:28:52 -0800 Subject: [PATCH 014/219] Adding .NOTPARALLEL to Makefile. --- Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Makefile b/Makefile index c067574c..5bcff9ba 100644 --- a/Makefile +++ b/Makefile @@ -124,6 +124,7 @@ image-flash-py: image $(PYTHON) flash.py --mode=image .PHONY: image image-load image-flash image-flash-py image-flash-$(PLATFORM) image-load-$(PLATFORM) +.NOTPARALLEL: image-load image-flash image-flash-py image-flash-$(PLATFORM) image-load-$(PLATFORM) # Gateware - the stuff which configures the FPGA. # -------------------------------------- @@ -163,6 +164,7 @@ gateware-clean: rm -rf $(TARGET_BUILD_DIR)/gateware .PHONY: gateware gateware-load gateware-flash gateware-flash-py gateware-clean gateware-load-$(PLATFORM) gateware-flash-$(PLATFORM) +.NOTPARALLEL: gateware-load gateware-flash gateware-flash-py gateware-flash-$(PLATFORM) gateware-load-$(PLATFORM) # Firmware - the stuff which runs in the soft CPU inside the FPGA. # -------------------------------------- @@ -216,6 +218,7 @@ bios-flash: $(BIOS_FILE) bios-flash-$(PLATFORM) @true .PHONY: $(FIRMWARE_FILE) bios bios-flash bios-flash-$(PLATFORM) +.NOTPARALLEL: bios-flash bios-flash-$(PLATFORM) # TFTP booting stuff @@ -244,6 +247,7 @@ tftpd_start: fi .PHONY: tftp tftpd_stop tftpd_start +.NOTPARALLEL: tftp tftpd_stop tftpd_start # Extra targets # -------------------------------------- @@ -364,6 +368,7 @@ dist-clean: rm -rf build .PHONY: flash help clean dist-clean help-$(PLATFORM) reset reset-$(PLATFORM) +.NOTPARALLEL: flash help help-$(PLATFORM) reset reset-$(PLATFORM) # Tests # -------------------------------------- From 5eb1aaf204a25b0fe0c81e121d503a9d4f505da9 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Thu, 30 Nov 2017 17:19:05 -0800 Subject: [PATCH 015/219] travis: Override JOBS value. --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 00bec819..9663097e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,6 +25,9 @@ env: global: - HDMI2USB_UDEV_IGNORE=1 - CLEAN_CHECK=1 + # Travis reports incorrect the hosts number of processors, override to 2 + # cores. + - JOBS=2 install: - export CPU="$C" From 62169b98cbc7872e8a66c520670c8ef2ff211674 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Thu, 30 Nov 2017 17:27:37 -0800 Subject: [PATCH 016/219] Makefile: Missing .NOTPARALLEL --- Makefile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 5bcff9ba..c787cd03 100644 --- a/Makefile +++ b/Makefile @@ -85,7 +85,6 @@ build/cache.mk: targets/*/*.py scripts/makefile-cache.sh TARGETS=$(TARGETS_$(PLATFORM)) - # Initialize submodules automatically third_party/%/.git: .gitmodules git submodule sync --recursive -- $$(dirname $@) @@ -201,12 +200,13 @@ firmware-connect: firmware-connect-$(PLATFORM) firmware-clear: firmware-clear-$(PLATFORM) @true -.PHONY: firmware-load-$(PLATFORM) firmware-flash-$(PLATFORM) firmware-connect-$(PLATFORM) firmware-clear-$(PLATFORM) - firmware-clean: rm -rf $(TARGET_BUILD_DIR)/software +.PHONY: firmware-load-$(PLATFORM) firmware-flash-$(PLATFORM) firmware-flash-py firmware-connect-$(PLATFORM) firmware-clear-$(PLATFORM) +.NOTPARALLEL: firmware-load-$(PLATFORM) firmware-flash-$(PLATFORM) firmware-flash-py firmware-connect-$(PLATFORM) firmware-clear-$(PLATFORM) .PHONY: firmware-cmd $(FIRMWARE_FILEBASE).bin firmware firmware-load firmware-flash firmware-connect firmware-clean +.NOTPARALLEL: firmware-cmd firmware-load firmware-flash firmware-connect $(BIOS_FILE): firmware-cmd @true @@ -367,8 +367,8 @@ clean: dist-clean: rm -rf build -.PHONY: flash help clean dist-clean help-$(PLATFORM) reset reset-$(PLATFORM) -.NOTPARALLEL: flash help help-$(PLATFORM) reset reset-$(PLATFORM) +.PHONY: flash env info prompt help clean dist-clean help-$(PLATFORM) reset reset-$(PLATFORM) +.NOTPARALLEL: flash env prompt info help help-$(PLATFORM) reset reset-$(PLATFORM) # Tests # -------------------------------------- @@ -383,3 +383,4 @@ test: true .PHONY: test test-edid +.NOTPARALLEL: test test-edid From a39de3e4ade7a936126766ee071dcf15ed654558 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Thu, 30 Nov 2017 17:37:35 -0800 Subject: [PATCH 017/219] Makefile: Set MAKEFLAGS using $JOBS value. --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index c787cd03..ea2ec124 100644 --- a/Makefile +++ b/Makefile @@ -38,6 +38,10 @@ export CLANG JOBS ?= $(shell nproc) JOBS ?= 2 +ifeq ($(shell [ $(JOBS) -gt 1 ] && echo true),true) + export MAKEFLAGS="-j $(JOBS) -l $(JOBS)" +endif + ifeq ($(PLATFORM_EXPANSION),) FULL_PLATFORM = $(PLATFORM) else From 5b8eee3eaf34cd6c842171dd01b7cc977e8840b6 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Sun, 29 Oct 2017 10:40:51 -0700 Subject: [PATCH 018/219] Wrap putchar So that it goes to telnet too. --- firmware/stdio_wrap.c | 14 ++++++++++++++ firmware/stdio_wrap.h | 1 + firmware/version.c | 3 +-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/firmware/stdio_wrap.c b/firmware/stdio_wrap.c index 800e18a9..14348f60 100644 --- a/firmware/stdio_wrap.c +++ b/firmware/stdio_wrap.c @@ -20,6 +20,20 @@ int wputs(const char *s) return 0; } +int wputchar(int c) +{ +#ifdef ETHMAC_BASE + if(telnet_active) { + telnet_putchar(c); + } else { +#endif + putchar(c); +#ifdef ETHMAC_BASE + } +#endif + return 0; +} + int wprintf(const char *fmt, ...) __attribute__((format(printf, 1, 2))); int wprintf(const char *fmt, ...) { diff --git a/firmware/stdio_wrap.h b/firmware/stdio_wrap.h index b83f425c..147c7a57 100644 --- a/firmware/stdio_wrap.h +++ b/firmware/stdio_wrap.h @@ -1,6 +1,7 @@ #include int wputs(const char *s); +int wputchar(int c); int wprintf(const char *fmt, ...) __attribute__((format(printf, 1, 2))); void wputsnonl(const char *s); diff --git a/firmware/version.c b/firmware/version.c index 49a7967b..3a1fca51 100644 --- a/firmware/version.c +++ b/firmware/version.c @@ -23,8 +23,7 @@ static void print_csr_string(unsigned int addr, size_t size) { unsigned char c = MMPTR(ptr+i); if (c == '\0') return; - // FIXME: Wrap putchar - putchar(c); + wputchar(c); } } From e56d634b1463b0ac706fa458d113e98bd4c3b080 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Thu, 3 Aug 2017 20:34:41 -0400 Subject: [PATCH 019/219] Move LF->CR LF translation to stdio_wrap --- firmware/stdio_wrap.c | 40 ++++++++++++++++++++++++++++++++++++---- firmware/stdio_wrap.h | 5 +++++ 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/firmware/stdio_wrap.c b/firmware/stdio_wrap.c index 14348f60..58c3bfa8 100644 --- a/firmware/stdio_wrap.c +++ b/firmware/stdio_wrap.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -9,14 +10,36 @@ #include "stdio_wrap.h" +/* Transform LF -> CRLF in s, putting the result in stdio_write_buffer + */ +char *translate_crlf(const char *s, int trailing_lf) { + assert(tailing_lf == 0 || trailing_lf == 1); + char *out = stdio_write_buffer; + char *end = stdio_write_buffer + STDIO_BUFFER_SIZE - 2 - trailing_lf; + while (*s != '\0') { + if (*s == '\n') { + assert(out < end); + *out++ = '\r'; + } + assert(out < end); + *out++ = *s++; + } + if (trailing_lf) { + *out++ = '\r'; + } + *out++ = '\0'; + return stdio_write_buffer; +} + int wputs(const char *s) { + char *s_crlf = translate_crlf(s, 1); #ifdef ETHMAC_BASE if(telnet_active) - telnet_puts(s); + telnet_puts(s_crlf); else #endif - puts(s); + puts(s_crlf); return 0; } @@ -24,9 +47,15 @@ int wputchar(int c) { #ifdef ETHMAC_BASE if(telnet_active) { + if(c == '\n') { + telnet_putchar('\r'); + } telnet_putchar(c); } else { #endif + if(c == '\n') { + putchar('\r'); + } putchar(c); #ifdef ETHMAC_BASE } @@ -40,12 +69,15 @@ int wprintf(const char *fmt, ...) int len; va_list args; va_start(args, fmt); + + char *fmt_crlf = translate_crlf(fmt, 0); + #ifdef ETHMAC_BASE if(telnet_active) - len = telnet_vprintf(fmt, args); + len = telnet_vprintf(fmt_crlf, args); else #endif - len = vprintf(fmt, args); + len = vprintf(fmt_crlf, args); va_end(args); return len; } diff --git a/firmware/stdio_wrap.h b/firmware/stdio_wrap.h index 147c7a57..5f1d51b4 100644 --- a/firmware/stdio_wrap.h +++ b/firmware/stdio_wrap.h @@ -1,5 +1,10 @@ #include +#define STDIO_BUFFER_SIZE 256 +char stdio_write_buffer[STDIO_BUFFER_SIZE]; + +char *translate_crlf(const char *s, int trailing_lf); + int wputs(const char *s); int wputchar(int c); int wprintf(const char *fmt, ...) __attribute__((format(printf, 1, 2))); From 5298e4640a88269d4762b5284cc78054f2aba656 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Sun, 29 Oct 2017 12:39:36 -0700 Subject: [PATCH 020/219] Don't rely on assert I don't think we ever compile them in --- firmware/stdio_wrap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/stdio_wrap.c b/firmware/stdio_wrap.c index 58c3bfa8..333d8ef6 100644 --- a/firmware/stdio_wrap.c +++ b/firmware/stdio_wrap.c @@ -16,7 +16,7 @@ char *translate_crlf(const char *s, int trailing_lf) { assert(tailing_lf == 0 || trailing_lf == 1); char *out = stdio_write_buffer; char *end = stdio_write_buffer + STDIO_BUFFER_SIZE - 2 - trailing_lf; - while (*s != '\0') { + while (*s != '\0' && out < end) { if (*s == '\n') { assert(out < end); *out++ = '\r'; From b8d8423c660867ce05317f0f0f2f1df763dcbe2a Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Sun, 29 Oct 2017 12:09:44 -0700 Subject: [PATCH 021/219] Remove CRs our wrappers add them stdio_wrap translates LF to CR-LF is printed messages. --- firmware/ci.c | 134 ++++++++++++++++++++-------------------- firmware/encoder.c | 2 +- firmware/fx2.c | 26 ++++---- firmware/hdmi_in0.c | 30 ++++----- firmware/hdmi_out0.c | 18 +++--- firmware/hdmi_out1.c | 18 +++--- firmware/main.c | 2 +- firmware/opsis_eeprom.c | 10 +-- firmware/pll.c | 16 ++--- firmware/processor.c | 2 +- firmware/tofe_eeprom.c | 10 +-- firmware/uptime.c | 2 +- firmware/version.c | 48 +++++++------- 13 files changed, 159 insertions(+), 159 deletions(-) diff --git a/firmware/ci.c b/firmware/ci.c index a8fdddb2..797e8ef8 100644 --- a/firmware/ci.c +++ b/firmware/ci.c @@ -100,13 +100,13 @@ static void help_heartbeat(void) static void heartbeat_enable(void) { hb_status(true); - wprintf("Heartbeat enabled\r\n"); + wprintf("Heartbeat enabled\n"); } static void heartbeat_disable(void) { hb_status(false); - wprintf("Heartbeat disabled\r\n"); + wprintf("Heartbeat disabled\n"); } #ifdef CSR_HDMI_OUT0_BASE @@ -322,25 +322,25 @@ static char *get_token(char **str) static void status_enable(void) { - wprintf("Enabling status\r\n"); + wprintf("Enabling status\n"); status_enabled = 1; } static void status_disable(void) { - wprintf("Disabling status\r\n"); + wprintf("Disabling status\n"); status_enabled = 0; } static void status_short_enable(void) { - wprintf("Enabling short status\r\n"); + wprintf("Enabling short status\n"); status_short_enabled = 1; } static void status_short_disable(void) { - wprintf("Disabling status\r\n"); + wprintf("Disabling status\n"); status_short_enabled = 0; } @@ -411,7 +411,7 @@ static void status_short_print(void) wprintf("off "); #endif - wprintf("\r\nstatus2: "); + wprintf("\nstatus2: "); wprintf("EDID: "); wprintf("%dx%d@" REFRESH_RATE_PRINTF "Hz/", processor_h_active, @@ -444,7 +444,7 @@ static void status_short_print(void) wprintf("ddr: "); debug_ddr(); #endif - wprintf("\r\n"); + wputchar('\n'); } static void status_print(void) @@ -464,7 +464,7 @@ static void status_print(void) wprintf(" (disabled)"); } #endif - wprintf("\r\n"); + wputchar('\n'); #endif #ifdef CSR_HDMI_IN1_BASE @@ -481,7 +481,7 @@ static void status_print(void) } else { wprintf(" (disabled)"); } - wprintf("\r\n"); + wputchar('\n'); #endif #ifdef CSR_HDMI_OUT0_BASE @@ -501,7 +501,7 @@ static void status_print(void) hdmi_out0_core_underflow_enable_write(1); } else wprintf("off"); - wprintf("\r\n"); + wputchar('\n'); #endif #ifdef CSR_HDMI_OUT1_BASE @@ -521,7 +521,7 @@ static void status_print(void) hdmi_out1_core_underflow_enable_write(1); } else wprintf("off"); - wprintf("\r\n"); + wputchar('\n'); #endif wprintf("EDID primary mode: "); @@ -529,7 +529,7 @@ static void status_print(void) processor_h_active, processor_v_active, REFRESH_RATE_PRINTF_ARGS(processor_refresh)); - wprintf("\r\n"); + wputchar('\n'); wprintf("EDID secondary mode: "); if (processor_secondary_mode == EDID_SECONDARY_MODE_OFF) { @@ -540,7 +540,7 @@ static void status_print(void) processor_describe_mode(mode_descriptor, processor_secondary_mode); wprintf("%s", mode_descriptor); } - wprintf("\r\n"); + wputchar('\n'); #ifdef ENCODER_BASE wprintf("encoder: "); @@ -554,12 +554,12 @@ static void status_print(void) encoder_quality); } else wprintf("off"); - wprintf("\r\n"); + wputchar('\n'); #endif #ifdef CSR_SDRAM_CONTROLLER_BANDWIDTH_UPDATE_ADDR wprintf("ddr: "); debug_ddr(); - wprintf("\r\n"); + wputchar('\n'); #endif } @@ -570,7 +570,7 @@ static void status_service(void) if(elapsed(&last_event, SYSTEM_CLOCK_FREQUENCY)) { if(status_enabled) { status_print(); - wprintf("\r\n"); + wputchar('\n'); } if(status_short_enabled) { status_short_print(); @@ -592,30 +592,30 @@ static void status_service(void) static void video_matrix_list(void) { - wprintf("Video sources:\r\n"); + wprintf("Video sources:\n"); #ifdef CSR_HDMI_IN0_BASE - wprintf("input0 (0): %s\r\n", HDMI_IN0_MNEMONIC); + wprintf("input0 (0): %s\n", HDMI_IN0_MNEMONIC); wputs(HDMI_IN0_DESCRIPTION); #endif #ifdef CSR_HDMI_IN1_BASE - wprintf("input1 (1): %s\r\n", HDMI_IN1_MNEMONIC); + wprintf("input1 (1): %s\n", HDMI_IN1_MNEMONIC); wputs(HDMI_IN1_DESCRIPTION); #endif - wprintf("pattern (p):\r\n"); - wprintf(" Video pattern\r\n"); + wprintf("pattern (p):\n"); + wprintf(" Video pattern\n"); wputs(" "); - wprintf("Video sinks:\r\n"); + wprintf("Video sinks:\n"); #ifdef CSR_HDMI_OUT0_BASE - wprintf("output0 (0): %s\r\n", HDMI_OUT0_MNEMONIC); + wprintf("output0 (0): %s\n", HDMI_OUT0_MNEMONIC); wputs(HDMI_OUT0_DESCRIPTION); #endif #ifdef CSR_HDMI_OUT1_BASE - wprintf("output1 (1): %s\r\n", HDMI_OUT1_MNEMONIC); + wprintf("output1 (1): %s\n", HDMI_OUT1_MNEMONIC); wputs(HDMI_OUT1_DESCRIPTION); #endif #ifdef ENCODER_BASE - wprintf("encoder (e):\r\n"); - wprintf(" JPEG encoder (USB output)\r\n"); + wprintf("encoder (e):\n"); + wprintf(" JPEG encoder (USB output)\n"); #endif wputs(" "); } @@ -625,24 +625,24 @@ static void video_matrix_connect(int source, int sink) if(source >= 0 && source <= VIDEO_IN_PATTERN) { if(sink >= 0 && sink <= VIDEO_OUT_HDMI_OUT1) { - wprintf("Connecting %s to output%d\r\n", processor_get_source_name(source), sink); + wprintf("Connecting %s to output%d\n", processor_get_source_name(source), sink); if(sink == VIDEO_OUT_HDMI_OUT0) #ifdef CSR_HDMI_OUT0_BASE processor_set_hdmi_out0_source(source); #else - wprintf("hdmi_out0 is missing.\r\n"); + wprintf("hdmi_out0 is missing.\n"); #endif else if(sink == VIDEO_OUT_HDMI_OUT1) #ifdef CSR_HDMI_OUT1_BASE processor_set_hdmi_out1_source(source); #else - wprintf("hdmi_out1 is missing.\r\n"); + wprintf("hdmi_out1 is missing.\n"); #endif processor_update(); } #ifdef ENCODER_BASE else if(sink == VIDEO_OUT_ENCODER) { - wprintf("Connecting %s to encoder\r\n", processor_get_source_name(source)); + wprintf("Connecting %s to encoder\n", processor_get_source_name(source)); processor_set_encoder_source(source); processor_update(); } @@ -656,10 +656,10 @@ static void video_mode_list(void) int i; processor_list_modes(mode_descriptors); - wprintf("Available video modes:\r\n"); + wprintf("Available video modes:\n"); for(i=0;iflags = modeFlags; processor_set_custom_mode(); - wprintf("Custom video mode set.\r\n"); + wprintf("Custom video mode set.\n"); } static void hdp_toggle(int source) @@ -832,7 +832,7 @@ static void hdp_toggle(int source) #if defined(CSR_HDMI_IN0_BASE) || defined(CSR_HDMI_IN1_BASE) int i; #endif - wprintf("Toggling HDP on output%d\r\n", source); + wprintf("Toggling HDP on output%d\n", source); #ifdef CSR_HDMI_IN0_BASE if(source == VIDEO_IN_HDMI_IN0) { hdmi_in0_edid_hpd_en_write(0); @@ -840,7 +840,7 @@ static void hdp_toggle(int source) hdmi_in0_edid_hpd_en_write(1); } #else - wprintf("hdmi_in0 is missing.\r\n"); + wprintf("hdmi_in0 is missing.\n"); #endif #ifdef CSR_HDMI_IN1_BASE if(source == VIDEO_IN_HDMI_IN1) { @@ -849,20 +849,20 @@ static void hdp_toggle(int source) hdmi_in1_edid_hpd_en_write(1); } #else - wprintf("hdmi_in1 is missing.\r\n"); + wprintf("hdmi_in1 is missing.\n"); #endif } #ifdef CSR_HDMI_IN0_BASE void input0_on(void) { - wprintf("Enabling input0\r\n"); + wprintf("Enabling input0\n"); hdmi_in0_enable(); } void input0_off(void) { - wprintf("Disabling input0\r\n"); + wprintf("Disabling input0\n"); hdmi_in0_disable(); } #endif @@ -870,13 +870,13 @@ void input0_off(void) #ifdef CSR_HDMI_IN1_BASE void input1_on(void) { - wprintf("Enabling input1\r\n"); + wprintf("Enabling input1\n"); hdmi_in1_enable(); } void input1_off(void) { - wprintf("Disabling input1\r\n"); + wprintf("Disabling input1\n"); hdmi_in1_disable(); } #endif @@ -884,13 +884,13 @@ void input1_off(void) #ifdef CSR_HDMI_OUT0_BASE void output0_on(void) { - wprintf("Enabling output0\r\n"); + wprintf("Enabling output0\n"); hdmi_out0_core_initiator_enable_write(1); } void output0_off(void) { - wprintf("Disabling output0\r\n"); + wprintf("Disabling output0\n"); hdmi_out0_core_initiator_enable_write(0); } #endif @@ -898,13 +898,13 @@ void output0_off(void) #ifdef CSR_HDMI_OUT1_BASE void output1_on(void) { - wprintf("Enabling output1\r\n"); + wprintf("Enabling output1\n"); hdmi_out1_core_initiator_enable_write(1); } void output1_off(void) { - wprintf("Disabling output1\r\n"); + wprintf("Disabling output1\n"); hdmi_out1_core_initiator_enable_write(0); } #endif @@ -912,25 +912,25 @@ void output1_off(void) #ifdef ENCODER_BASE void encoder_on(void) { - wprintf("Enabling encoder\r\n"); + wprintf("Enabling encoder\n"); encoder_enable(1); } void encoder_configure_quality(int quality) { - wprintf("Setting encoder quality to %d\r\n", quality); + wprintf("Setting encoder quality to %d\n", quality); encoder_set_quality(quality); } void encoder_configure_fps(int fps) { - wprintf("Setting encoder fps to %d\r\n", fps); + wprintf("Setting encoder fps to %d\n", fps); encoder_set_fps(fps); } void encoder_off(void) { - wprintf("Disabling encoder\r\n"); + wprintf("Disabling encoder\n"); encoder_enable(0); } #endif @@ -965,7 +965,7 @@ static void debug_ddr(void) burstbits = (2*DFII_NPHASES) << DFII_PIX_DATA_SIZE; rdb = (nr*f >> (24 - log2(burstbits)))/1000000ULL; wrb = (nw*f >> (24 - log2(burstbits)))/1000000ULL; - wprintf("read:%5dMbps write:%5dMbps all:%5dMbps\r\n", rdb, wrb, rdb + wrb); + wprintf("read:%5dMbps write:%5dMbps all:%5dMbps\n", rdb, wrb, rdb + wrb); */ } #endif @@ -1051,7 +1051,7 @@ void ci_service(void) source = VIDEO_IN_PATTERN; } else { - wprintf("Unknown video source: '%s'\r\n", token); + wprintf("Unknown video source: '%s'\n", token); } /* get video sink */ @@ -1067,7 +1067,7 @@ void ci_service(void) sink = VIDEO_OUT_ENCODER; } else - wprintf("Unknown video sink: '%s'\r\n", token); + wprintf("Unknown video sink: '%s'\n", token); if (source >= 0 && sink >= 0) video_matrix_connect(source, sink); @@ -1162,7 +1162,7 @@ void ci_service(void) #endif else if((strcmp(token, "p") == 0) || (strcmp(token, "p") == 0)) { pattern_next(); - wprintf("Pattern now %d\r\n", pattern); + wprintf("Pattern now %d\n", pattern); } else if((strcmp(token, "status") == 0) || (strcmp(token, "s") == 0)) { token = get_token(&str); @@ -1198,7 +1198,7 @@ void ci_service(void) hdmi_in0_debug = 1; else hdmi_in0_debug = !hdmi_in0_debug; - wprintf("HDMI Input 0 debug %s\r\n", hdmi_in0_debug ? "on" : "off"); + wprintf("HDMI Input 0 debug %s\n", hdmi_in0_debug ? "on" : "off"); } #endif #ifdef CSR_HDMI_IN1_BASE @@ -1210,13 +1210,13 @@ void ci_service(void) hdmi_in1_debug = 1; else hdmi_in1_debug = !hdmi_in1_debug; - wprintf("HDMI Input 1 debug %s\r\n", hdmi_in1_debug ? "on" : "off"); + wprintf("HDMI Input 1 debug %s\n", hdmi_in1_debug ? "on" : "off"); } #endif #ifdef CSR_SDRAM_CONTROLLER_BANDWIDTH_UPDATE_ADDR else if(strcmp(token, "ddr") == 0) { debug_ddr(); - wprintf("\r\n"); + wputchar('\n'); } #endif #ifdef CSR_INFO_DNA_ID_ADDR @@ -1265,7 +1265,7 @@ void ci_service(void) } #endif if(found == 0) - wprintf("%s port has no EDID capabilities\r\n", token); + wprintf("%s port has no EDID capabilities\n", token); #ifdef CSR_CAS_BASE } else if(strcmp(token, "cas") == 0) { token = get_token(&str); @@ -1278,14 +1278,14 @@ void ci_service(void) #endif #ifdef CSR_CAS_SWITCHES_IN_ADDR else if(strcmp(token, "switches") == 0) { - wprintf("%X\r\n", (int)cas_switches_in_read()); + wprintf("%X\n", (int)cas_switches_in_read()); } #endif #ifdef CSR_CAS_BUTTONS_EV_STATUS_ADDR else if(strcmp(token, "buttons") == 0) { int status = cas_buttons_ev_status_read(); int pending = cas_buttons_ev_pending_read(); - wprintf("%X %X\r\n", status, pending); + wprintf("%X %X\n", status, pending); token = get_token(&str); if(strcmp(token, "clear") == 0) { cas_buttons_ev_pending_write(pending); diff --git a/firmware/encoder.c b/firmware/encoder.c index cd5dc42c..1460f85c 100644 --- a/firmware/encoder.c +++ b/firmware/encoder.c @@ -153,7 +153,7 @@ int encoder_set_quality(int quality) { encoder_quality = quality; break; default: - wprintf("Unsupported encoder quality (50, 75, 85 or 100)\r\n"); + wprintf("Unsupported encoder quality (50, 75, 85 or 100)\n"); return 0; } return 1; diff --git a/firmware/fx2.c b/firmware/fx2.c index 1ffd0410..a57ae222 100644 --- a/firmware/fx2.c +++ b/firmware/fx2.c @@ -35,7 +35,7 @@ static inline uint8_t fx2_fw_get_value(unsigned addr) { #endif } } else { - wprintf("fx2: Read from invalid address %02X (end: %02X)\r\n", addr, end_addr); + wprintf("fx2: Read from invalid address %02X (end: %02X)\n", addr, end_addr); } return r; } @@ -68,7 +68,7 @@ static void fx2_load_init(void) static void fx2_load(void) { fx2_load_init(); - wprintf("fx2: Waiting for FX2 to load firmware.\r\n"); + wprintf("fx2: Waiting for FX2 to load firmware.\n"); uint64_t i = 0; while((i < FX2_WAIT_PERIOD)) { @@ -79,13 +79,13 @@ static void fx2_load(void) break; } } else if ((i % FX2_REPORT_PERIOD) == 0) { - wprintf("fx2: Waiting at %02X (end: %02X)\r\n", next_read_addr, end_addr); + wprintf("fx2: Waiting at %02X (end: %02X)\n", next_read_addr, end_addr); } } if (i > 0) { - wprintf("fx2: Timeout loading!\r\n"); + wprintf("fx2: Timeout loading!\n"); } else { - wprintf("fx2: Booted.\r\n"); + wprintf("fx2: Booted.\n"); } } @@ -94,7 +94,7 @@ bool fx2_service(bool verbose) unsigned char status = opsis_i2c_fx2_hack_status_read(); if(status == FX2_HACK_SHIFT_REG_EMPTY) { // there's been a master READ if (verbose) { - wprintf("fx2: read %02X (end: %02X)\r\n", next_read_addr, end_addr); + wprintf("fx2: read %02X (end: %02X)\n", next_read_addr, end_addr); } if (next_read_addr < end_addr) { // Load next value into the system @@ -102,12 +102,12 @@ bool fx2_service(bool verbose) opsis_i2c_fx2_hack_status_write(FX2_HACK_STATUS_READY); next_read_addr++; } else { - wprintf("fx2: Finished loading firmware.\r\n"); + wprintf("fx2: Finished loading firmware.\n"); fx2_load_init(); } return true; } else if (status != 0) { - wprintf("fx2: Bad status %02X\r\n", status); + wprintf("fx2: Bad status %02X\n", status); } return false; } @@ -117,19 +117,19 @@ void fx2_reboot(enum fx2_fw_version fw) OPSIS_I2C_ACTIVE(OPSIS_I2C_FX2HACK); unsigned int i; fx2_fw_active = fw; - wprintf("fx2: Turning off.\r\n"); + wprintf("fx2: Turning off.\n"); opsis_i2c_fx2_reset_out_write(1); for(i=0;i address_max))) - wprintf("dvisampler0: slot0: stray DMA\r\n"); + wprintf("dvisampler0: slot0: stray DMA\n"); if((hdmi_in0_dma_slot1_status_read() == DVISAMPLER_SLOT_PENDING) && ((hdmi_in0_dma_slot1_address_read() < address_min) || (hdmi_in0_dma_slot1_address_read() > address_max))) - wprintf("dvisampler0: slot1: stray DMA\r\n"); + wprintf("dvisampler0: slot1: stray DMA\n"); #ifdef CLEAN_COMMUTATION if((hdmi_in0_resdetection_hres_read() != hdmi_in0_hres) @@ -75,7 +75,7 @@ void hdmi_in0_isr(void) hdmi_in0_next_fb_index = (hdmi_in0_next_fb_index + 1) & FRAMEBUFFER_MASK; } else { #ifdef DEBUG - wprintf("dvisampler0: slot0: unexpected frame length: %d\r\n", length); + wprintf("dvisampler0: slot0: unexpected frame length: %d\n", length); #endif } hdmi_in0_dma_slot0_address_write(hdmi_in0_framebuffer_base(hdmi_in0_fb_slot_indexes[0])); @@ -89,7 +89,7 @@ void hdmi_in0_isr(void) hdmi_in0_next_fb_index = (hdmi_in0_next_fb_index + 1) & FRAMEBUFFER_MASK; } else { #ifdef DEBUG - wprintf("dvisampler0: slot1: unexpected frame length: %d\r\n", length); + wprintf("dvisampler0: slot1: unexpected frame length: %d\n", length); #endif } hdmi_in0_dma_slot1_address_write(hdmi_in0_framebuffer_base(hdmi_in0_fb_slot_indexes[1])); @@ -180,7 +180,7 @@ void hdmi_in0_print_status(void) hdmi_in0_data0_wer_update_write(1); hdmi_in0_data1_wer_update_write(1); hdmi_in0_data2_wer_update_write(1); - wprintf("dvisampler0: ph:%4d %4d %4d // charsync:%d%d%d [%d %d %d] // WER:%3d %3d %3d // chansync:%d // res:%dx%d\r\n", + wprintf("dvisampler0: ph:%4d %4d %4d // charsync:%d%d%d [%d %d %d] // WER:%3d %3d %3d // chansync:%d // res:%dx%d\n", hdmi_in0_d0, hdmi_in0_d1, hdmi_in0_d2, hdmi_in0_data0_charsync_char_synced_read(), hdmi_in0_data1_charsync_char_synced_read(), @@ -207,7 +207,7 @@ static int wait_idelays(void) || hdmi_in0_data1_cap_dly_busy_read() || hdmi_in0_data2_cap_dly_busy_read()) { if(elapsed(&ev, SYSTEM_CLOCK_FREQUENCY >> 6) == 0) { - wprintf("dvisampler0: IDELAY busy timeout (%hhx %hhx %hhx)\r\n", + wprintf("dvisampler0: IDELAY busy timeout (%hhx %hhx %hhx)\n", hdmi_in0_data0_cap_dly_busy_read(), hdmi_in0_data1_cap_dly_busy_read(), hdmi_in0_data2_cap_dly_busy_read()); @@ -367,16 +367,16 @@ int hdmi_in0_phase_startup(int freq) attempts++; hdmi_in0_calibrate_delays(freq); if(hdmi_in0_debug) - wprintf("dvisampler0: delays calibrated\r\n"); + wprintf("dvisampler0: delays calibrated\n"); ret = hdmi_in0_init_phase(); if(ret) { if(hdmi_in0_debug) - wprintf("dvisampler0: phase init OK\r\n"); + wprintf("dvisampler0: phase init OK\n"); return 1; } else { - wprintf("dvisampler0: phase init failed\r\n"); + wprintf("dvisampler0: phase init failed\n"); if(attempts > 3) { - wprintf("dvisampler0: giving up\r\n"); + wprintf("dvisampler0: giving up\n"); hdmi_in0_calibrate_delays(freq); return 0; } @@ -387,7 +387,7 @@ int hdmi_in0_phase_startup(int freq) static void hdmi_in0_check_overflow(void) { if(hdmi_in0_frame_overflow_read()) { - wprintf("dvisampler0: FIFO overflow\r\n"); + wprintf("dvisampler0: FIFO overflow\n"); hdmi_in0_frame_overflow_write(1); } } @@ -422,7 +422,7 @@ void hdmi_in0_service(int freq) if(hdmi_in0_connected) { if(!hdmi_in0_edid_hpd_notif_read()) { if(hdmi_in0_debug) - wprintf("dvisampler0: disconnected\r\n"); + wprintf("dvisampler0: disconnected\n"); hdmi_in0_connected = 0; hdmi_in0_locked = 0; #ifdef CSR_HDMI_IN0_CLOCKING_PLL_RESET_ADDR @@ -441,14 +441,14 @@ void hdmi_in0_service(int freq) } } else { if(hdmi_in0_debug) - wprintf("dvisampler0: lost PLL lock\r\n"); + wprintf("dvisampler0: lost PLL lock\n"); hdmi_in0_locked = 0; hdmi_in0_clear_framebuffers(); } } else { if(hdmi_in0_clocking_locked_filtered()) { if(hdmi_in0_debug) - wprintf("dvisampler0: PLL locked\r\n"); + wprintf("dvisampler0: PLL locked\n"); hdmi_in0_phase_startup(freq); if(hdmi_in0_debug) hdmi_in0_print_status(); @@ -459,7 +459,7 @@ void hdmi_in0_service(int freq) } else { if(hdmi_in0_edid_hpd_notif_read()) { if(hdmi_in0_debug) - wprintf("dvisampler0: connected\r\n"); + wprintf("dvisampler0: connected\n"); hdmi_in0_connected = 1; #ifdef CSR_HDMI_IN0_CLOCKING_PLL_RESET_ADDR hdmi_in0_clocking_pll_reset_write(0); diff --git a/firmware/hdmi_out0.c b/firmware/hdmi_out0.c index 5bdc1356..2845c3b0 100644 --- a/firmware/hdmi_out0.c +++ b/firmware/hdmi_out0.c @@ -16,7 +16,7 @@ void hdmi_out0_i2c_init(void) { hdmi_out0_i2c.w_write = hdmi_out0_i2c_w_write; hdmi_out0_i2c.r_read = hdmi_out0_i2c_r_read; i2c_init(&hdmi_out0_i2c); - wprintf("finished.\r\n"); + wprintf("finished.\n"); } void hdmi_out0_print_edid(void) { @@ -27,42 +27,42 @@ void hdmi_out0_print_edid(void) { i2c_start_cond(&hdmi_out0_i2c); b = i2c_write(&hdmi_out0_i2c, 0xa0); if (!b && hdmi_out0_debug_enabled) - wprintf("hdmi_out0: NACK while writing slave address!\r\n"); + wprintf("hdmi_out0: NACK while writing slave address!\n"); b = i2c_write(&hdmi_out0_i2c, 0x00); if (!b && hdmi_out0_debug_enabled) - wprintf("hdmi_out0: NACK while writing eeprom address!\r\n"); + wprintf("hdmi_out0: NACK while writing eeprom address!\n"); i2c_start_cond(&hdmi_out0_i2c); b = i2c_write(&hdmi_out0_i2c, 0xa1); if (!b && hdmi_out0_debug_enabled) - wprintf("hdmi_out0: NACK while writing slave address (2)!\r\n"); + wprintf("hdmi_out0: NACK while writing slave address (2)!\n"); for (eeprom_addr = 0 ; eeprom_addr < 128 ; eeprom_addr++) { b = i2c_read(&hdmi_out0_i2c, eeprom_addr == 127 && extension_number == 0 ? 0 : 1); sum +=b; wprintf("%02X ", b); if(!((eeprom_addr+1) % 16)) - wprintf("\r\n"); + wprintf("\n"); if(eeprom_addr == 126) extension_number = b; if(eeprom_addr == 127 && sum != 0) { - wprintf("Checksum ERROR in EDID block 0\r\n"); + wprintf("Checksum ERROR in EDID block 0\n"); i2c_stop_cond(&hdmi_out0_i2c); return; } } for(e = 0; e < extension_number; e++) { - wprintf("\r\n"); + wprintf("\n"); sum = 0; for (eeprom_addr = 0 ; eeprom_addr < 128 ; eeprom_addr++) { b = i2c_read(&hdmi_out0_i2c, eeprom_addr == 127 && e == extension_number - 1 ? 0 : 1); sum += b; wprintf("%02X ", b); if(!((eeprom_addr+1) % 16)) - wprintf("\r\n"); + wprintf("\n"); if(eeprom_addr == 127 && sum != 0) { - wprintf("Checksum ERROR in EDID extension block %d\r\n", e); + wprintf("Checksum ERROR in EDID extension block %d\n", e); i2c_stop_cond(&hdmi_out0_i2c); return; } diff --git a/firmware/hdmi_out1.c b/firmware/hdmi_out1.c index 8fc16531..1733617f 100644 --- a/firmware/hdmi_out1.c +++ b/firmware/hdmi_out1.c @@ -16,7 +16,7 @@ void hdmi_out1_i2c_init(void) { hdmi_out1_i2c.w_write = hdmi_out1_i2c_w_write; hdmi_out1_i2c.r_read = hdmi_out1_i2c_r_read; i2c_init(&hdmi_out1_i2c); - wprintf("finished.\r\n"); + wprintf("finished.\n"); } void hdmi_out1_print_edid(void) { @@ -27,42 +27,42 @@ void hdmi_out1_print_edid(void) { i2c_start_cond(&hdmi_out1_i2c); b = i2c_write(&hdmi_out1_i2c, 0xa0); if (!b && hdmi_out1_debug_enabled) - wprintf("hdmi_out1: NACK while writing slave address!\r\n"); + wprintf("hdmi_out1: NACK while writing slave address!\n"); b = i2c_write(&hdmi_out1_i2c, 0x00); if (!b && hdmi_out1_debug_enabled) - wprintf("hdmi_out1: NACK while writing eeprom address!\r\n"); + wprintf("hdmi_out1: NACK while writing eeprom address!\n"); i2c_start_cond(&hdmi_out1_i2c); b = i2c_write(&hdmi_out1_i2c, 0xa1); if (!b && hdmi_out1_debug_enabled) - wprintf("hdmi_out1: NACK while writing slave address (2)!\r\n"); + wprintf("hdmi_out1: NACK while writing slave address (2)!\n"); for (eeprom_addr = 0 ; eeprom_addr < 128 ; eeprom_addr++) { b = i2c_read(&hdmi_out1_i2c, eeprom_addr == 127 && extension_number == 0 ? 0 : 1); sum +=b; wprintf("%02X ", b); if(!((eeprom_addr+1) % 16)) - wprintf("\r\n"); + wputchar('\n'); if(eeprom_addr == 126) extension_number = b; if(eeprom_addr == 127 && sum != 0) { - wprintf("Checksum ERROR in EDID block 0\r\n"); + wprintf("Checksum ERROR in EDID block 0\n"); i2c_stop_cond(&hdmi_out1_i2c); return; } } for(e = 0; e < extension_number; e++) { - wprintf("\r\n"); + wputchar('\n'); sum = 0; for (eeprom_addr = 0 ; eeprom_addr < 128 ; eeprom_addr++) { b = i2c_read(&hdmi_out1_i2c, eeprom_addr == 127 && e == extension_number - 1 ? 0 : 1); sum += b; wprintf("%02X ", b); if(!((eeprom_addr+1) % 16)) - wprintf("\r\n"); + wputchar('\n'); if(eeprom_addr == 127 && sum != 0) { - wprintf("Checksum ERROR in EDID extension block %d\r\n", e); + wprintf("Checksum ERROR in EDID extension block %d\n", e); i2c_stop_cond(&hdmi_out1_i2c); return; } diff --git a/firmware/main.c b/firmware/main.c index efa18148..6d0dcb62 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -58,7 +58,7 @@ int main(void) irq_setie(1); uart_init(); - wputs("HDMI2USB firmware booting...\r\n"); + wputs("HDMI2USB firmware booting...\n"); #ifdef CSR_OPSIS_I2C_MASTER_W_ADDR opsis_eeprom_i2c_init(); diff --git a/firmware/opsis_eeprom.c b/firmware/opsis_eeprom.c index 1cb10313..b096d381 100644 --- a/firmware/opsis_eeprom.c +++ b/firmware/opsis_eeprom.c @@ -16,7 +16,7 @@ void opsis_eeprom_i2c_init(void) { opsis_eeprom_i2c.r_read = opsis_i2c_master_r_read; OPSIS_I2C_ACTIVE(OPSIS_I2C_GPIO); i2c_init(&opsis_eeprom_i2c); - wprintf("finished.\r\n"); + wprintf("finished.\n"); } static void opsis_eeprom_read(uint8_t addr) { @@ -29,16 +29,16 @@ static void opsis_eeprom_read(uint8_t addr) { i2c_start_cond(&opsis_eeprom_i2c); b = i2c_write(&opsis_eeprom_i2c, OPSIS_EEPROM_SLAVE_ADDRESS | I2C_WRITE); if (!b && opsis_eeprom_debug_enabled) - wprintf("opsis_eeprom: NACK while writing slave address!\r\n"); + wprintf("opsis_eeprom: NACK while writing slave address!\n"); b = i2c_write(&opsis_eeprom_i2c, addr); if (!b && opsis_eeprom_debug_enabled) - wprintf("opsis_eeprom: NACK while writing opsis_eeprom address!\r\n"); + wprintf("opsis_eeprom: NACK while writing opsis_eeprom address!\n"); // Read data from I2C EEPROM i2c_start_cond(&opsis_eeprom_i2c); b = i2c_write(&opsis_eeprom_i2c, OPSIS_EEPROM_SLAVE_ADDRESS | I2C_READ); if (!b && opsis_eeprom_debug_enabled) - wprintf("opsis_eeprom: NACK while writing slave address (2)!\r\n"); + wprintf("opsis_eeprom: NACK while writing slave address (2)!\n"); } void opsis_eeprom_dump(void) { @@ -47,7 +47,7 @@ void opsis_eeprom_dump(void) { unsigned char b = i2c_read(&opsis_eeprom_i2c, 1); wprintf("%02X ", b); if(!((i+1) % 16)) - wprintf("\r\n"); + wputchar('\n'); } i2c_stop_cond(&opsis_eeprom_i2c); } diff --git a/firmware/pll.c b/firmware/pll.c index 077a3b5f..18ebbe82 100644 --- a/firmware/pll.c +++ b/firmware/pll.c @@ -73,13 +73,13 @@ void pll_config_for_clock(int freq) program_data(pll_config_20x); #ifdef XILINX_SPARTAN6_WORKS_AMAZINGLY_WELL if(freq < 2000) - wprintf("Frequency too low for PLLs\r\n"); + wprintf("Frequency too low for PLLs\n"); else if(freq < 4500) program_data(pll_config_20x); else if(freq < 10000) program_data(pll_config_10x); else - wprintf("Frequency too high for PLLs\r\n"); + wprintf("Frequency too high for PLLs\n"); #endif } @@ -89,33 +89,33 @@ void pll_dump(void) int i; #endif #ifdef CSR_HDMI_OUT0_DRIVER_CLOCKING_PLL_RESET_ADDR - wprintf("framebuffer PLL:\r\n"); + wprintf("framebuffer PLL:\n"); for(i=0;i<32;i++) { hdmi_out0_driver_clocking_pll_adr_write(i); hdmi_out0_driver_clocking_pll_read_write(1); while(!hdmi_out0_driver_clocking_pll_drdy_read()); wprintf("%04x ", hdmi_out0_driver_clocking_pll_dat_r_read()); } - wprintf("\r\n"); + wputchar('\n'); #endif #ifdef CSR_HDMI_IN0_CLOCKING_PLL_RESET_ADDR - wprintf("dvisampler0 PLL:\r\n"); + wprintf("dvisampler0 PLL:\n"); for(i=0;i<32;i++) { hdmi_in0_clocking_pll_adr_write(i); hdmi_in0_clocking_pll_read_write(1); while(!hdmi_in0_clocking_pll_drdy_read()); wprintf("%04x ", hdmi_in0_clocking_pll_dat_r_read()); } - wprintf("\r\n"); + wputchar('\n'); #endif #ifdef CSR_HDMI_IN1_CLOCKING_PLL_RESET_ADDR - wprintf("dvisampler1 PLL:\r\n"); + wprintf("dvisampler1 PLL:\n"); for(i=0;i<32;i++) { hdmi_in1_clocking_pll_adr_write(i); hdmi_in1_clocking_pll_read_write(1); while(!hdmi_in1_clocking_pll_drdy_read()); wprintf("%04x ", hdmi_in1_clocking_pll_dat_r_read()); } - wprintf("\r\n"); + wputchar('\n'); #endif } diff --git a/firmware/processor.c b/firmware/processor.c index 43dbab80..48918932 100644 --- a/firmware/processor.c +++ b/firmware/processor.c @@ -491,7 +491,7 @@ static void fb_get_clock_md(unsigned int pixel_clock, unsigned int *best_m, unsi unsigned int md1000 = (bm * 1000) / bd; if (md1000 > hdmi_out0_driver_clocking_clkfx_md_max_1000_read()) { wprintf( - "WARNING: md1000 (%d) > (%d)\r\n", + "WARNING: md1000 (%d) > (%d)\n", md1000, hdmi_out0_driver_clocking_clkfx_md_max_1000_read()); } diff --git a/firmware/tofe_eeprom.c b/firmware/tofe_eeprom.c index 6007f305..27408097 100644 --- a/firmware/tofe_eeprom.c +++ b/firmware/tofe_eeprom.c @@ -13,7 +13,7 @@ void tofe_eeprom_i2c_init(void) { tofe_eeprom_i2c.w_write = tofe_i2c_w_write; tofe_eeprom_i2c.r_read = tofe_i2c_r_read; i2c_init(&tofe_eeprom_i2c); - wprintf("finished.\r\n"); + wprintf("finished.\n"); } void tofe_eeprom_dump(void) { @@ -23,21 +23,21 @@ void tofe_eeprom_dump(void) { i2c_start_cond(&tofe_eeprom_i2c); b = i2c_write(&tofe_eeprom_i2c, 0xa0); if (!b && tofe_eeprom_debug_enabled) - wprintf("tofe_eeprom: NACK while writing slave address!\r\n"); + wprintf("tofe_eeprom: NACK while writing slave address!\n"); b = i2c_write(&tofe_eeprom_i2c, 0x00); if (!b && tofe_eeprom_debug_enabled) - wprintf("tofe_eeprom: NACK while writing tofe_eeprom address!\r\n"); + wprintf("tofe_eeprom: NACK while writing tofe_eeprom address!\n"); i2c_start_cond(&tofe_eeprom_i2c); b = i2c_write(&tofe_eeprom_i2c, 0xa1); if (!b && tofe_eeprom_debug_enabled) - wprintf("tofe_eeprom: NACK while writing slave address (2)!\r\n"); + wprintf("tofe_eeprom: NACK while writing slave address (2)!\n"); for (tofe_eeprom_addr = 0 ; tofe_eeprom_addr < 256 ; tofe_eeprom_addr++) { b = i2c_read(&tofe_eeprom_i2c, 1); wprintf("%02X ", b); if(!((tofe_eeprom_addr+1) % 16)) - wprintf("\r\n"); + wputchar('\n'); } i2c_stop_cond(&tofe_eeprom_i2c); } diff --git a/firmware/uptime.c b/firmware/uptime.c index 4073c31b..e12378d6 100644 --- a/firmware/uptime.c +++ b/firmware/uptime.c @@ -25,7 +25,7 @@ int uptime(void) void uptime_print(void) { - wprintf("uptime: %s\r\n", uptime_str()); + wprintf("uptime: %s\n", uptime_str()); } const char* uptime_str(void) diff --git a/firmware/version.c b/firmware/version.c index 3a1fca51..a568768e 100644 --- a/firmware/version.c +++ b/firmware/version.c @@ -60,44 +60,44 @@ void print_board_mac(void) { } void print_version(void) { - wprintf("\r\n"); - wprintf("hardware version info\r\n"); - wprintf("===============================================\r\n"); + wputchar('\n'); + wprintf("hardware version info\n"); + wprintf("===============================================\n"); wprintf(" DNA: "); print_board_dna(); - wprintf("\r\n"); + wputchar('\n'); wprintf(" MAC: "); print_board_mac(); - wprintf("\r\n"); - wprintf("\r\n"); - wprintf("gateware version info\r\n"); - wprintf("===============================================\r\n"); + wputchar('\n'); + wputchar('\n'); + wprintf("gateware version info\n"); + wprintf("===============================================\n"); #ifdef CSR_INFO_PLATFORM_PLATFORM_ADDR wprintf(" platform: "); print_csr_string(CSR_INFO_PLATFORM_PLATFORM_ADDR, CSR_INFO_PLATFORM_PLATFORM_SIZE); - wprintf("\r\n"); + wputchar('\n'); #endif #ifdef CSR_INFO_PLATFORM_TARGET_ADDR wprintf(" target: "); print_csr_string(CSR_INFO_PLATFORM_TARGET_ADDR, CSR_INFO_PLATFORM_TARGET_SIZE); - wprintf("\r\n"); + wputchar('\n'); #endif #ifdef CSR_INFO_GIT_COMMIT_ADDR wprintf(" revision: "); print_csr_hex(CSR_INFO_GIT_COMMIT_ADDR, CSR_INFO_GIT_COMMIT_SIZE); - wprintf("\r\n"); + wputchar('\n'); #endif -// wprintf("misoc revision: %08x\r\n", identifier_revision_read()); - wprintf("\r\n"); - wprintf("firmware version info\r\n"); - wprintf("===============================================\r\n"); - wprintf(" platform: %s\r\n", board); - wprintf(" target: %s\r\n", target); - wprintf(" git commit: %s\r\n", git_commit); - wprintf(" git branch: %s\r\n", git_branch); - wprintf(" git describe: %s\r\n", git_describe); - wprintf(" git status:\r\n%s\r\n", git_status); - wprintf(" built: "__DATE__" "__TIME__"\r\n"); - wprintf(" uptime: %s\r\n", uptime_str()); - wprintf("-----------------------------------------------\r\n"); +// wprintf("misoc revision: %08x\n", identifier_revision_read()); + wputchar('\n'); + wprintf("firmware version info\n"); + wprintf("===============================================\n"); + wprintf(" platform: %s\n", board); + wprintf(" target: %s\n", target); + wprintf(" git commit: %s\n", git_commit); + wprintf(" git branch: %s\n", git_branch); + wprintf(" git describe: %s\n", git_describe); + wprintf(" git status:\n%s\n", git_status); + wprintf(" built: "__DATE__" "__TIME__"\n"); + wprintf(" uptime: %s\n", uptime_str()); + wprintf("-----------------------------------------------\n"); } From 5cbb21f473bd3488e525977fe18cbcb8a1f68d84 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Sun, 29 Oct 2017 12:10:48 -0700 Subject: [PATCH 022/219] Add missing LF after 'debug dna' --- firmware/ci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/firmware/ci.c b/firmware/ci.c index 797e8ef8..630170ef 100644 --- a/firmware/ci.c +++ b/firmware/ci.c @@ -1220,8 +1220,10 @@ void ci_service(void) } #endif #ifdef CSR_INFO_DNA_ID_ADDR - else if(strcmp(token, "dna") == 0) + else if(strcmp(token, "dna") == 0) { print_board_dna(); + wputchar('\n'); + } #endif #ifdef CSR_OPSIS_I2C_MASTER_W_ADDR else if(strcmp(token, "opsis_eeprom") == 0) { From 5ef7e7e5f45dd5f3fccedeb69052d0b9bf353c88 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Sun, 29 Oct 2017 12:11:07 -0700 Subject: [PATCH 023/219] Use wrapped prints in mmcm --- firmware/mmcm.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/firmware/mmcm.c b/firmware/mmcm.c index 7e73d31b..a83921f0 100644 --- a/firmware/mmcm.c +++ b/firmware/mmcm.c @@ -2,6 +2,7 @@ #include #include "mmcm.h" +#include "stdio_wrap.h" /* * Despite varying pixel clocks, we must keep the PLL VCO operating @@ -68,7 +69,7 @@ void mmcm_config_for_clock(int freq) * FIXME: we also need to configure phase detector */ if(freq < 3000) - printf("Frequency too low for input MMCMs\r\n"); + wprintf("Frequency too low for input MMCMs\n"); else if(freq < 6000) hdmi_in_0_config_30_60mhz(); else if(freq < 12000) @@ -76,7 +77,7 @@ void mmcm_config_for_clock(int freq) else if(freq < 24000) hdmi_in_0_config_120_240mhz(); else - printf("Frequency too high for input MMCMs\r\n"); + wprintf("Frequency too high for input MMCMs\n"); } #endif @@ -84,15 +85,15 @@ void mmcm_dump(void) { int i; #ifdef CSR_HDMI_OUT0_CLOCKING_MMCM_RESET_ADDR - printf("framebuffer MMCM:\r\n"); + wprintf("framebuffer MMCM:\n"); for(i=0;i<128;i++) - printf("%04x ", hdmi_out0_mmcm_read(i)); - printf("\r\n"); + wprintf("%04x ", hdmi_out0_mmcm_read(i)); + wputchar("\n"); #endif #ifdef CSR_HDMI_IN0_CLOCKING_MMCM_RESET_ADDR - printf("dvisampler MMCM:\r\n"); + wprintf("dvisampler MMCM:\n"); for(i=0;i<128;i++) - printf("%04x ", hdmi_in0_clocking_mmcm_read(i)); - printf("\r\n"); + wprintf("%04x ", hdmi_in0_clocking_mmcm_read(i)); + wputchar('\n'); #endif } From 125db02606e587cf3952cb3dba8a332601646fde Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Sun, 29 Oct 2017 12:12:26 -0700 Subject: [PATCH 024/219] Ignore LFs on the serial console They will always be following a CR, that we already consumed. Without this, you can't turn "status on" because it'll see the LF and immediately turn it off, again. --- firmware/ci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/firmware/ci.c b/firmware/ci.c index 630170ef..488107e7 100644 --- a/firmware/ci.c +++ b/firmware/ci.c @@ -272,8 +272,9 @@ static char *readstr(void) break; case 0x07: break; - case '\r': case '\n': + break; + case '\r': s[ptr] = 0x00; wputsnonl("\n"); ptr = 0; From e0f065e38a80afb2f0a69272477594616a22a601 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Sun, 29 Oct 2017 12:36:24 -0700 Subject: [PATCH 025/219] Bump Telnet buffer a bit "help" was causing telnet to disconnect --- firmware/telnet.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/firmware/telnet.h b/firmware/telnet.h index 6aa03229..549bb08d 100644 --- a/firmware/telnet.h +++ b/firmware/telnet.h @@ -18,8 +18,8 @@ #endif #define TELNET_PORT 23 -#define TELNET_BUFFER_SIZE_RX 1512 -#define TELNET_BUFFER_SIZE_TX 1512 +#define TELNET_BUFFER_SIZE_RX 4096 +#define TELNET_BUFFER_SIZE_TX 4096 int telnet_active; From c5438b14811dc67a6260ce49b36a46d4d48a6dce Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Sun, 29 Oct 2017 13:04:07 -0700 Subject: [PATCH 026/219] Use CR-LF on telnet's printfs They go to the serial console only. And don't go through stdio_wrap, which expands LF to CRLF. --- firmware/telnet.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/firmware/telnet.c b/firmware/telnet.c index 278ff456..21db6859 100644 --- a/firmware/telnet.c +++ b/firmware/telnet.c @@ -23,7 +23,7 @@ void telnet_init(void) (tcp_socket_data_callback_t) telnet_data_callback, (tcp_socket_event_callback_t) telnet_event_callback); tcp_socket_listen(&telnet_socket, TELNET_PORT); - printf("Telnet listening on port %d\n", TELNET_PORT); + printf("Telnet listening on port %d\r\n", TELNET_PORT); } int telnet_event_callback(struct tcp_socket *s, void *ptr, tcp_socket_event_t event) @@ -31,13 +31,13 @@ int telnet_event_callback(struct tcp_socket *s, void *ptr, tcp_socket_event_t ev switch(event) { case TCP_SOCKET_CONNECTED: - printf("\nTelnet connected.\n"); + printf("\r\nTelnet connected.\r\n"); telnet_active = 1; break; case TCP_SOCKET_CLOSED: case TCP_SOCKET_TIMEDOUT: case TCP_SOCKET_ABORTED: - printf("\nTelnet disconnected.\n"); + printf("\r\nTelnet disconnected.\r\n"); telnet_active = 0; default: break; From bd5654e4e562f42f2a99212c5c75a0ac72a6846f Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Sun, 26 Nov 2017 15:54:06 +0000 Subject: [PATCH 027/219] Send a CR-LF so that the cursor moves back left, in all serial terminals We noticed that it wasn't happening in tio --- firmware/ci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/ci.c b/firmware/ci.c index 488107e7..6261dae5 100644 --- a/firmware/ci.c +++ b/firmware/ci.c @@ -276,7 +276,7 @@ static char *readstr(void) break; case '\r': s[ptr] = 0x00; - wputsnonl("\n"); + wputs(""); ptr = 0; return s; default: From e050caa950bb1e3d8eef5b6b4236b0b386d517d9 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Sun, 26 Nov 2017 16:51:41 +0000 Subject: [PATCH 028/219] Add a simple test for CR-LFs --- Makefile | 11 ++++++++--- firmware/test.sh | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100755 firmware/test.sh diff --git a/Makefile b/Makefile index 8c937e05..e757e6a3 100644 --- a/Makefile +++ b/Makefile @@ -201,7 +201,10 @@ firmware-clear: firmware-clear-$(PLATFORM) firmware-clean: rm -rf $(TARGET_BUILD_DIR)/software -.PHONY: firmware-cmd $(FIRMWARE_FILEBASE).bin firmware firmware-load firmware-flash firmware-connect firmware-clean +firmware-test: + firmware/test.sh + +.PHONY: firmware-cmd $(FIRMWARE_FILEBASE).bin firmware firmware-load firmware-flash firmware-connect firmware-clean firmware-test $(BIOS_FILE): firmware-cmd @true @@ -333,6 +336,7 @@ help: @echo "" @echo "Firmware make commands avaliable:" @echo " make firmware - Build the firmware" + @echo " make firmware-test - Run firmware tests" @echo " make firmware-load - *Temporarily* load the firmware onto a device" @echo " make firmware-flash - *Permanently* flash the firmware onto a device" @echo " make firmware-connect - *Connect* to the firmware running on a device" @@ -346,6 +350,7 @@ help: @echo "" @echo "Other Make commands avaliable:" @make -s help-$(PLATFORM) + @echo " make test - Run all tests" @echo " make clean - Clean all build artifacts." reset: reset-$(PLATFORM) @@ -370,7 +375,7 @@ test-submodules: $(addsuffix /.git,$(addprefix third_party/,$(TEST_MODULES))) test-edid: test-submodules $(MAKE) -C test/edid check -test: - true +test: firmware-test + @echo "Tests passed" .PHONY: test test-edid diff --git a/firmware/test.sh b/firmware/test.sh new file mode 100755 index 00000000..b1546e4b --- /dev/null +++ b/firmware/test.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +set -euf +cd "$(dirname "$0")" + +find . '(' -name '*.c' -o -name '*.h' ')' \ +| while read fn; do + case $fn in + ./telnet.c) + continue + ;; + esac + if grep -qF '\r\n' $fn; then + echo "$fn" 'contains a \\r\\n.' + echo 'You should just write \\n, stdio_wrap will transform this to a \\r\\n, as appropriate' + exit 1 + fi +done From 951430fba048921a63657cb34db05af047e4cab9 Mon Sep 17 00:00:00 2001 From: Peter Chubb Date: Mon, 18 Dec 2017 14:37:14 +1100 Subject: [PATCH 029/219] Use ip not openvpn to create /dev/tap0. Everyone who has a recent version of the ip tool can use it to create tap0 --- and it's standard on recent Debian, Ubuntu and CentOS. Not everyone has UML-tools (tunctl) or openvpn installed. So use ip instead of openvpn to instantiate the tun devices. --- scripts/build-qemu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build-qemu.sh b/scripts/build-qemu.sh index 97b71029..a8391c57 100755 --- a/scripts/build-qemu.sh +++ b/scripts/build-qemu.sh @@ -117,7 +117,7 @@ if grep -q ETHMAC_BASE $TARGET_BUILD_DIR/software/include/generated/csr.h; then sudo true echo "Need to bring up a tun device." IPRANGE=192.168.100 - sudo openvpn --mktun --dev tap0 + sudo ip tuntap add tap0 mode tap if command -v ifconfig >/dev/null ; then sudo ifconfig tap0 $IPRANGE.100 up else From 000fea21561bc720c1fcb670586abac5fd3234d5 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Wed, 27 Dec 2017 14:19:10 +0100 Subject: [PATCH 030/219] Updating submodules. * litex changed from v0.1-191-gaa6dadf0 to v0.1-211-gb463b216 Full submodule status -- f56f329ed23a25d002352dedba1e8f092a47286f edid-decode (heads/master) 070d8b29acf1445c08ebf3073d04206461819bbe flash_proxies (heads/master) f31f8a03ff6911befa6d07bf347f8478c30448d8 litedram (heads/master) 937c2407276371d9f8c1bb19c4ae8e97e581da83 liteeth (heads/master) c836c467b8d086c7ade23a45557644e4620a4bdc litepcie (heads/master) c3d491552cc77312bbadf6488c08e1e3df9612ef litesata (heads/master) d5887a3eb0de105cfc55e52fbeb9de9da035e7db litescope (heads/master) 7a17876bc7f8943a2a0b500e4c1cb1e454c680b6 liteusb (heads/master) cd44e3f14cd3042a948170d43c21919b00c3c35d litevideo (heads/master) b463b2169b33bd5861bfa94dcb2c8c896dd36cf7 litex (v0.1-211-gb463b216) --- third_party/litex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/litex b/third_party/litex index aa6dadf0..b463b216 160000 --- a/third_party/litex +++ b/third_party/litex @@ -1 +1 @@ -Subproject commit aa6dadf0d843a856ea64288d387869efe0b0c255 +Subproject commit b463b2169b33bd5861bfa94dcb2c8c896dd36cf7 From cb3437d7107d818ecbaf903314c334b7d18bb7ef Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Wed, 27 Dec 2017 15:17:55 +0100 Subject: [PATCH 031/219] Fixing the MMCM defines. --- firmware/mmcm.c | 4 ++-- firmware/mmcm.h | 6 ++++-- firmware/processor.c | 20 +++++++------------- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/firmware/mmcm.c b/firmware/mmcm.c index 7e73d31b..f6f6e905 100644 --- a/firmware/mmcm.c +++ b/firmware/mmcm.c @@ -7,7 +7,7 @@ * Despite varying pixel clocks, we must keep the PLL VCO operating * in the specified range of 600MHz - 1200MHz. */ -#ifdef CSR_HDMI_OUT0_CLOCKING_MMCM_RESET_ADDR +#ifdef CSR_HDMI_OUT0_DRIVER_CLOCKING_MMCM_RESET_ADDR void hdmi_out0_mmcm_write(int adr, int data) { hdmi_out0_driver_clocking_mmcm_adr_write(adr); hdmi_out0_driver_clocking_mmcm_dat_w_write(data); @@ -83,7 +83,7 @@ void mmcm_config_for_clock(int freq) void mmcm_dump(void) { int i; -#ifdef CSR_HDMI_OUT0_CLOCKING_MMCM_RESET_ADDR +#ifdef CSR_HDMI_OUT0_DRIVER_CLOCKING_MMCM_RESET_ADDR printf("framebuffer MMCM:\r\n"); for(i=0;i<128;i++) printf("%04x ", hdmi_out0_mmcm_read(i)); diff --git a/firmware/mmcm.h b/firmware/mmcm.h index 4912b6fc..70172e44 100644 --- a/firmware/mmcm.h +++ b/firmware/mmcm.h @@ -3,10 +3,12 @@ #include -#ifdef CSR_HDMI_IN0_CLOCKING_MMCM_RESET_ADDR - +#ifdef CSR_HDMI_OUT0_DRIVER_CLOCKING_MMCM_RESET_ADDR void hdmi_out0_mmcm_write(int adr, int data); int hdmi_out0_mmcm_read(int adr); +#endif + +#ifdef CSR_HDMI_IN0_CLOCKING_MMCM_RESET_ADDR void hdmi_in0_clocking_mmcm_write(int adr, int data); int hdmi_in0_clocking_mmcm_read(int adr); diff --git a/firmware/processor.c b/firmware/processor.c index 43dbab80..0c0abb3e 100644 --- a/firmware/processor.c +++ b/firmware/processor.c @@ -30,6 +30,7 @@ #include "encoder.h" #include "edid.h" #include "pll.h" +#include "mmcm.h" #include "processor.h" #include "heartbeat.h" @@ -405,14 +406,7 @@ static void fb_clkgen_write(int cmd, int data) hdmi_out0_driver_clocking_send_cmd_data_write(1); while(hdmi_out0_driver_clocking_status_read() & CLKGEN_STATUS_BUSY); } -#elif CSR_HDMI_OUT0_DRIVER_CLOCKING_DRP_DWE_ADDR -static void hdmi_out0_write_mmcm_reg(unsigned int address, unsigned int data) { - hdmi_out0_driver_clocking_drp_addr_write(address); - hdmi_out0_driver_clocking_drp_di_write(data); - hdmi_out0_driver_clocking_drp_dwe_write(1); - hdmi_out0_driver_clocking_drp_den_write(1); -} - +#elif CSR_HDMI_OUT0_DRIVER_CLOCKING_MMCM_RESET_ADDR // Artix-7 MMCM clocking static void fb_clkgen_write(int m, int d) { @@ -462,7 +456,7 @@ static void fb_get_clock_md(unsigned int pixel_clock, unsigned int *best_m, unsi ideal_d = 5000; max_d = 256; max_m = 256; -#elif CSR_HDMI_OUT0_DRIVER_CLOCKING_DRP_DWE_ADDR +#elif CSR_HDMI_OUT0_DRIVER_CLOCKING_MMCM_RESET_ADDR // Artix 7 pixel_clock = pixel_clock * 10; ideal_d = 10000; @@ -510,7 +504,7 @@ static void fb_set_clock(unsigned int pixel_clock) hdmi_out0_driver_clocking_send_go_write(1); while(!(hdmi_out0_driver_clocking_status_read() & CLKGEN_STATUS_PROGDONE)); while(!(hdmi_out0_driver_clocking_status_read() & CLKGEN_STATUS_LOCKED)); -#elif CSR_HDMI_OUT0_CLOCKING_MMCM_RESET_ADDR +#elif CSR_HDMI_OUT0_DRIVER_CLOCKING_MMCM_RESET_ADDR fb_clkgen_write(clock_m, clock_d); #endif } @@ -622,7 +616,7 @@ void processor_start(int mode) #ifdef CSR_HDMI_OUT1_BASE hdmi_out1_core_initiator_enable_write(0); #endif -#ifdef CSR_HDMI_IN0_CLOCKING_MMCM_RESET_ADDR +#ifdef CSR_HDMI_OUT0_DRIVER_CLOCKING_MMCM_RESET_ADDR hdmi_out0_driver_clocking_mmcm_reset_write(1); #endif #ifdef CSR_HDMI_OUT0_DRIVER_CLOCKING_PLL_RESET_ADDR @@ -649,7 +643,7 @@ void processor_start(int mode) #ifdef CSR_HDMI_OUT0_DRIVER_CLOCKING_PLL_RESET_ADDR pll_config_for_clock(m->pixel_clock); -#elif CSR_HDMI_OUT0_DRIVER_CLOCKING_DRP_DWE_ADDR +#elif CSR_HDMI_OUT0_DRIVER_CLOCKING_MMCM_RESET_ADDR mmcm_config_for_clock(m->pixel_clock); #endif @@ -665,7 +659,7 @@ void processor_start(int mode) #ifdef CSR_HDMI_OUT0_DRIVER_CLOCKING_PLL_RESET_ADDR hdmi_out0_driver_clocking_pll_reset_write(0); -#elif CSR_HDMI_OUT0_DRIVER_CLOCKING_DRP_DWE_ADDR +#elif CSR_HDMI_OUT0_DRIVER_CLOCKING_MMCM_RESET_ADDR hdmi_out0_driver_clocking_mmcm_reset_write(0); #endif #ifdef CSR_HDMI_OUT0_BASE From 5347fb8356e86e8ecf6f2b1ef102998f636f004a Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Wed, 27 Dec 2017 15:50:13 +0100 Subject: [PATCH 032/219] Updating submodules. * litex changed from v0.1-189-g56ef2290 to v0.1-213-g9adcc3a8 Full submodule status -- f56f329ed23a25d002352dedba1e8f092a47286f edid-decode (heads/master) 070d8b29acf1445c08ebf3073d04206461819bbe flash_proxies (heads/master) f31f8a03ff6911befa6d07bf347f8478c30448d8 litedram (heads/master) 937c2407276371d9f8c1bb19c4ae8e97e581da83 liteeth (heads/master) c836c467b8d086c7ade23a45557644e4620a4bdc litepcie (heads/master) c3d491552cc77312bbadf6488c08e1e3df9612ef litesata (heads/master) d5887a3eb0de105cfc55e52fbeb9de9da035e7db litescope (heads/master) 7a17876bc7f8943a2a0b500e4c1cb1e454c680b6 liteusb (heads/master) cd44e3f14cd3042a948170d43c21919b00c3c35d litevideo (heads/master) 9adcc3a8b99862cccf6ee6d07190b6a7f3c735de litex (v0.1-213-g9adcc3a8) --- third_party/litex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/litex b/third_party/litex index 56ef2290..9adcc3a8 160000 --- a/third_party/litex +++ b/third_party/litex @@ -1 +1 @@ -Subproject commit 56ef22902926e5edfdb524a064804823fe449502 +Subproject commit 9adcc3a8b99862cccf6ee6d07190b6a7f3c735de From e19fb1fc07d499b25c3945ca5bf39582a469f389 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Wed, 27 Dec 2017 21:13:54 +0100 Subject: [PATCH 033/219] Rework the MMCM code to use a MMCM structure. --- firmware/ci.c | 2 +- firmware/mmcm.c | 86 +++++++++++++++++++++++++++----------------- firmware/mmcm.h | 22 ++++++++---- firmware/processor.c | 22 ++++++------ 4 files changed, 82 insertions(+), 50 deletions(-) diff --git a/firmware/ci.c b/firmware/ci.c index a8fdddb2..5f2b44eb 100644 --- a/firmware/ci.c +++ b/firmware/ci.c @@ -939,7 +939,7 @@ static void debug_clocks(void) { // Only the active clock system will output anything pll_dump(); - mmcm_dump(); + mmcm_dump_all(); } static unsigned int log2(unsigned int v) diff --git a/firmware/mmcm.c b/firmware/mmcm.c index f6f6e905..f4d8019c 100644 --- a/firmware/mmcm.c +++ b/firmware/mmcm.c @@ -8,61 +8,79 @@ * in the specified range of 600MHz - 1200MHz. */ #ifdef CSR_HDMI_OUT0_DRIVER_CLOCKING_MMCM_RESET_ADDR -void hdmi_out0_mmcm_write(int adr, int data) { +void hdmi_out0_driver_clocking_mmcm_write(int adr, int data) +{ hdmi_out0_driver_clocking_mmcm_adr_write(adr); hdmi_out0_driver_clocking_mmcm_dat_w_write(data); hdmi_out0_driver_clocking_mmcm_write_write(1); while(!hdmi_out0_driver_clocking_mmcm_drdy_read()); } -int hdmi_out0_mmcm_read(int adr) { +int hdmi_out0_driver_clocking_mmcm_read(int adr) +{ hdmi_out0_driver_clocking_mmcm_adr_write(adr); hdmi_out0_driver_clocking_mmcm_read_write(1); while(!hdmi_out0_driver_clocking_mmcm_drdy_read()); return hdmi_out0_driver_clocking_mmcm_dat_r_read(); } + +MMCM hdmi_out0_driver_clocking_mmcm = { + .write = &hdmi_out0_driver_clocking_mmcm_write, + .read = &hdmi_out0_driver_clocking_mmcm_read, +}; #endif #ifdef CSR_HDMI_IN0_CLOCKING_MMCM_RESET_ADDR -void hdmi_in0_clocking_mmcm_write(int adr, int data) { +void hdmi_in0_clocking_mmcm_write(int adr, int data) +{ hdmi_in0_clocking_mmcm_adr_write(adr); hdmi_in0_clocking_mmcm_dat_w_write(data); hdmi_in0_clocking_mmcm_write_write(1); while(!hdmi_in0_clocking_mmcm_drdy_read()); } -int hdmi_in0_clocking_mmcm_read(int adr) { +int hdmi_in0_clocking_mmcm_read(int adr) +{ hdmi_in0_clocking_mmcm_adr_write(adr); hdmi_in0_clocking_mmcm_read_write(1); while(!hdmi_in0_clocking_mmcm_drdy_read()); return hdmi_in0_clocking_mmcm_dat_r_read(); } -static void hdmi_in_0_config_30_60mhz(void) { - hdmi_in0_clocking_mmcm_write(0x14, 0x1000 | (10<<6) | 10); /* clkfbout_mult = 20 */ - hdmi_in0_clocking_mmcm_write(0x08, 0x1000 | (10<<6) | 10); /* clkout0_divide = 20 */ - hdmi_in0_clocking_mmcm_write(0x0a, 0x1000 | (8<<6) | 8); /* clkout1_divide = 16 */ - hdmi_in0_clocking_mmcm_write(0x0c, 0x1000 | (2<<6) | 2); /* clkout2_divide = 4 */ - hdmi_in0_clocking_mmcm_write(0x0d, 0); /* clkout2_divide = 4 */ +MMCM hdmi_in0_clocking_mmcm = { + .write = &hdmi_in0_clocking_mmcm_write, + .read = &hdmi_in0_clocking_mmcm_read, +}; +#endif + +static void mmcm_config_30to60mhz(MMCM *mmcm) +{ + mmcm->write(0x14, 0x1000 | (10<<6) | 10); /* clkfbout_mult = 20 */ + mmcm->write(0x08, 0x1000 | (10<<6) | 10); /* clkout0_divide = 20 */ + mmcm->write(0x0a, 0x1000 | (8<<6) | 8); /* clkout1_divide = 16 */ + mmcm->write(0x0c, 0x1000 | (2<<6) | 2); /* clkout2_divide = 4 */ + mmcm->write(0x0d, 0); /* clkout2_divide = 4 */ } -static void hdmi_in_0_config_60_120mhz(void) { - hdmi_in0_clocking_mmcm_write(0x14, 0x1000 | (5<<6) | 5); /* clkfbout_mult = 10 */ - hdmi_in0_clocking_mmcm_write(0x08, 0x1000 | (5<<6) | 5); /* clkout0_divide = 10 */ - hdmi_in0_clocking_mmcm_write(0x0a, 0x1000 | (4<<6) | 4); /* clkout1_divide = 8 */ - hdmi_in0_clocking_mmcm_write(0x0c, 0x1000 | (1<<6) | 1); /* clkout2_divide = 2 */ - hdmi_in0_clocking_mmcm_write(0x0d, 0); /* clkout2_divide = 2 */ +static void mmcm_config_60to120mhz(MMCM *mmcm) +{ + mmcm->write(0x14, 0x1000 | (5<<6) | 5); /* clkfbout_mult = 10 */ + mmcm->write(0x08, 0x1000 | (5<<6) | 5); /* clkout0_divide = 10 */ + mmcm->write(0x0a, 0x1000 | (4<<6) | 4); /* clkout1_divide = 8 */ + mmcm->write(0x0c, 0x1000 | (1<<6) | 1); /* clkout2_divide = 2 */ + mmcm->write(0x0d, 0); /* clkout2_divide = 2 */ } -static void hdmi_in_0_config_120_240mhz(void) { - hdmi_in0_clocking_mmcm_write(0x14, 0x1000 | (2<<6) | 3); /* clkfbout_mult = 5 */ - hdmi_in0_clocking_mmcm_write(0x08, 0x1000 | (2<<6) | 3); /* clkout0_divide = 5 */ - hdmi_in0_clocking_mmcm_write(0x0a, 0x1000 | (2<<6) | 2); /* clkout1_divide = 4 */ - hdmi_in0_clocking_mmcm_write(0x0c, 0x1000 | (0<<6) | 0); /* clkout2_divide = 1 */ - hdmi_in0_clocking_mmcm_write(0x0d, (1<<6)); /* clkout2_divide = 1 */ +static void mmcm_config_120to240mhz(MMCM *mmcm) +{ + mmcm->write(0x14, 0x1000 | (2<<6) | 3); /* clkfbout_mult = 5 */ + mmcm->write(0x08, 0x1000 | (2<<6) | 3); /* clkout0_divide = 5 */ + mmcm->write(0x0a, 0x1000 | (2<<6) | 2); /* clkout1_divide = 4 */ + mmcm->write(0x0c, 0x1000 | (0<<6) | 0); /* clkout2_divide = 1 */ + mmcm->write(0x0d, (1<<6)); /* clkout2_divide = 1 */ } -void mmcm_config_for_clock(int freq) +void mmcm_config_for_clock(MMCM *mmcm, int freq) { /* * FIXME: we also need to configure phase detector @@ -70,29 +88,33 @@ void mmcm_config_for_clock(int freq) if(freq < 3000) printf("Frequency too low for input MMCMs\r\n"); else if(freq < 6000) - hdmi_in_0_config_30_60mhz(); + mmcm_config_30to60mhz(mmcm); else if(freq < 12000) - hdmi_in_0_config_60_120mhz(); + mmcm_config_60to120mhz(mmcm); else if(freq < 24000) - hdmi_in_0_config_120_240mhz(); + mmcm_config_120to240mhz(mmcm); else printf("Frequency too high for input MMCMs\r\n"); } -#endif -void mmcm_dump(void) +void mmcm_dump(MMCM* mmcm) +{ + int i; + for(i=0;i<128;i++) + printf("%04x ", mmcm->read(i)); + +} +void mmcm_dump_all(void) { int i; #ifdef CSR_HDMI_OUT0_DRIVER_CLOCKING_MMCM_RESET_ADDR printf("framebuffer MMCM:\r\n"); - for(i=0;i<128;i++) - printf("%04x ", hdmi_out0_mmcm_read(i)); + mmcm_dump(&hdmi_out0_driver_clocking_mmcm); printf("\r\n"); #endif #ifdef CSR_HDMI_IN0_CLOCKING_MMCM_RESET_ADDR printf("dvisampler MMCM:\r\n"); - for(i=0;i<128;i++) - printf("%04x ", hdmi_in0_clocking_mmcm_read(i)); + mmcm_dump(&hdmi_in0_clocking_mmcm); printf("\r\n"); #endif } diff --git a/firmware/mmcm.h b/firmware/mmcm.h index 70172e44..3dd3b406 100644 --- a/firmware/mmcm.h +++ b/firmware/mmcm.h @@ -3,18 +3,28 @@ #include +typedef void (*mmcm_write_t)(int,int); +typedef int (*mmcm_read_t)(int); + +typedef struct { + mmcm_write_t write; + mmcm_read_t read; +} MMCM; + +void mmcm_config_for_clock(MMCM *mmcm, int freq); +void mmcm_dump(MMCM *mmcm); +void mmcm_dump_all(void); + #ifdef CSR_HDMI_OUT0_DRIVER_CLOCKING_MMCM_RESET_ADDR -void hdmi_out0_mmcm_write(int adr, int data); -int hdmi_out0_mmcm_read(int adr); +void hdmi_out0_driver_clocking_mmcm_write(int adr, int data); +int hdmi_out0_driver_clocking_mmcm_read(int adr); +extern MMCM hdmi_out0_driver_clocking_mmcm; #endif #ifdef CSR_HDMI_IN0_CLOCKING_MMCM_RESET_ADDR void hdmi_in0_clocking_mmcm_write(int adr, int data); int hdmi_in0_clocking_mmcm_read(int adr); - -void mmcm_config_for_clock(int freq); +extern MMCM hdmi_in0_clocking_mmcm; #endif -void mmcm_dump(void); - #endif diff --git a/firmware/processor.c b/firmware/processor.c index 0c0abb3e..7556058f 100644 --- a/firmware/processor.c +++ b/firmware/processor.c @@ -412,20 +412,20 @@ static void fb_clkgen_write(int m, int d) { /* clkfbout_mult = m */ if(m%2) - hdmi_out0_mmcm_write(0x14, 0x1000 | ((m/2)<<6) | (m/2 + 1)); + hdmi_out0_driver_clocking_mmcm_write(0x14, 0x1000 | ((m/2)<<6) | (m/2 + 1)); else - hdmi_out0_mmcm_write(0x14, 0x1000 | ((m/2)<<6) | m/2); + hdmi_out0_driver_clocking_mmcm_write(0x14, 0x1000 | ((m/2)<<6) | m/2); /* divclk_divide = d */ if (d == 1) - hdmi_out0_mmcm_write(0x16, 0x1000); + hdmi_out0_driver_clocking_mmcm_write(0x16, 0x1000); else if(d%2) - hdmi_out0_mmcm_write(0x16, ((d/2)<<6) | (d/2 + 1)); + hdmi_out0_driver_clocking_mmcm_write(0x16, ((d/2)<<6) | (d/2 + 1)); else - hdmi_out0_mmcm_write(0x16, ((d/2)<<6) | d/2); + hdmi_out0_driver_clocking_mmcm_write(0x16, ((d/2)<<6) | d/2); /* clkout0_divide = 10 */ - hdmi_out0_mmcm_write(0x8, 0x1000 | (5<<6) | 5); - /* clkout1_divide = 2 */ - hdmi_out0_mmcm_write(0xa, 0x1000 | (1<<6) | 1); + hdmi_out0_driver_clocking_mmcm_write(0x8, 0x1000 | (5<<6) | 5); + /* clkout1_driver_clocking_divide = 2 */ + hdmi_out0_driver_clocking_mmcm_write(0xa, 0x1000 | (1<<6) | 1); } #else @@ -515,8 +515,6 @@ static void fb_set_mode(const struct video_timing *mode) unsigned int hdmi_out0_enabled; unsigned int hdmi_out1_enabled; - fb_set_clock(mode->pixel_clock); - #ifdef CSR_HDMI_OUT0_BASE if (hdmi_out0_core_initiator_enable_read()) { hdmi_out0_enabled = 1; @@ -554,6 +552,8 @@ static void fb_set_mode(const struct video_timing *mode) hdmi_out1_core_initiator_enable_write(hdmi_out1_enabled); #endif + + fb_set_clock(mode->pixel_clock); } static void edid_set_mode(const struct video_timing *mode, const struct video_timing *sec_mode) @@ -644,7 +644,7 @@ void processor_start(int mode) #ifdef CSR_HDMI_OUT0_DRIVER_CLOCKING_PLL_RESET_ADDR pll_config_for_clock(m->pixel_clock); #elif CSR_HDMI_OUT0_DRIVER_CLOCKING_MMCM_RESET_ADDR - mmcm_config_for_clock(m->pixel_clock); + mmcm_config_for_clock(&hdmi_out0_driver_clocking_mmcm, m->pixel_clock); #endif fb_set_mode(m); From f223ebf451200a0db11a0c929de2fbbf0f388aa1 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Fri, 29 Dec 2017 15:45:13 +0100 Subject: [PATCH 034/219] tests: Fixing the common bits. --- test/common.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/test/common.py b/test/common.py index 810b4c08..11fa49c7 100644 --- a/test/common.py +++ b/test/common.py @@ -8,8 +8,10 @@ from litex.soc.tools.remote import RemoteClient from litex.soc.tools.remote import CommUART -sys.path.append(os.path.join(os.path.dirname(__file__), "..")) -from make import make_args, make_testdir +TOP_DIR=os.path.join(os.path.dirname(__file__), "..") + +sys.path.append(TOP_DIR) +from make import get_args, get_testdir class ServerProxy(threading.Thread): @@ -31,7 +33,7 @@ def run(self): def connect(desc, *args, add_args=None, **kw): parser = argparse.ArgumentParser(description=desc) - make_args(parser, *args, **kw) + get_args(parser, *args, **kw) parser.add_argument("--ipaddress") parser.add_argument("--port") #, desc="Serial port") if add_args is not None: @@ -50,7 +52,8 @@ def connect(desc, *args, add_args=None, **kw): args.ipaddress = "{}.50".format(args.iprange) print("Connecting to {}".format(args.ipaddress)) - wb = RemoteClient(args.ipaddress, 1234, csr_csv="{}/csr.csv".format(make_testdir(args)), csr_data_width=32) + test_dir = os.path.join(TOP_DIR, get_testdir(args)) + wb = RemoteClient(args.ipaddress, 1234, csr_csv="{}/csr.csv".format(test_dir)) wb.open() print() print("Device DNA: {}".format(get_dna(wb))) From 77cadc02c814347d7c33c1b87636248fbbe75c79 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Fri, 29 Dec 2017 23:13:00 +0100 Subject: [PATCH 035/219] scripts: Skip linux --- third_party/merge-upstream.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/merge-upstream.sh b/third_party/merge-upstream.sh index 59573f4a..877a1f7c 100755 --- a/third_party/merge-upstream.sh +++ b/third_party/merge-upstream.sh @@ -2,7 +2,7 @@ set -e -TARGETS=${@-$(find * -maxdepth 0 -type d | grep -v micropython | grep -v qemu | grep -v libuip)} +TARGETS=${@-$(find * -maxdepth 0 -type d | grep -v linux | grep -v micropython | grep -v qemu | grep -v libuip)} COMMIT_MSG=$(tempfile) || exit trap "rm -f -- '$COMMIT_MSG'" EXIT From f660fd945dbdc061f1fabe93dd9cb03494058c5f Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Fri, 29 Dec 2017 23:13:36 +0100 Subject: [PATCH 036/219] Updating submodules. * litedram changed from f31f8a0 to a09b7a0 * liteeth changed from 937c240 to ccdb85b * litepcie changed from c836c46 to 09dbd6d * litesata changed from c3d4915 to a8bf0d4 * litescope changed from d5887a3 to 7757727 * liteusb changed from 7a17876 to 9a78586 * litevideo changed from cd44e3f to c9770cc * litex changed from v0.1-213-g9adcc3a8 to v0.1-217-g0a2d38ec Full submodule status -- f56f329ed23a25d002352dedba1e8f092a47286f edid-decode (heads/master) 070d8b29acf1445c08ebf3073d04206461819bbe flash_proxies (heads/master) a09b7a05b89af317c885b3939e2f13925cb8d95d litedram (remotes/origin/HEAD) ccdb85bcb7c6504d49cf8fabfc6fd5ff179c72c2 liteeth (remotes/origin/HEAD) 09dbd6dd3053cc42baa7090ee042cb314853a7fc litepcie (remotes/origin/HEAD) a8bf0d42b22a5f355a629aad7392c59029164d67 litesata (remotes/origin/HEAD) 7757727f5b9fe4cb4979897fa0aab934b4af6e88 litescope (remotes/origin/HEAD) 9a78586e5e523843834f80826f387ff828012ff7 liteusb (remotes/origin/HEAD) c9770cc2da2df70c941376e9b937a2980822c739 litevideo (remotes/origin/HEAD) 0a2d38ecd2e07fbb7e087631f3db552d178add77 litex (v0.1-217-g0a2d38ec) --- third_party/litedram | 2 +- third_party/liteeth | 2 +- third_party/litepcie | 2 +- third_party/litesata | 2 +- third_party/litescope | 2 +- third_party/liteusb | 2 +- third_party/litevideo | 2 +- third_party/litex | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/third_party/litedram b/third_party/litedram index f31f8a03..a09b7a05 160000 --- a/third_party/litedram +++ b/third_party/litedram @@ -1 +1 @@ -Subproject commit f31f8a03ff6911befa6d07bf347f8478c30448d8 +Subproject commit a09b7a05b89af317c885b3939e2f13925cb8d95d diff --git a/third_party/liteeth b/third_party/liteeth index 937c2407..ccdb85bc 160000 --- a/third_party/liteeth +++ b/third_party/liteeth @@ -1 +1 @@ -Subproject commit 937c2407276371d9f8c1bb19c4ae8e97e581da83 +Subproject commit ccdb85bcb7c6504d49cf8fabfc6fd5ff179c72c2 diff --git a/third_party/litepcie b/third_party/litepcie index c836c467..09dbd6dd 160000 --- a/third_party/litepcie +++ b/third_party/litepcie @@ -1 +1 @@ -Subproject commit c836c467b8d086c7ade23a45557644e4620a4bdc +Subproject commit 09dbd6dd3053cc42baa7090ee042cb314853a7fc diff --git a/third_party/litesata b/third_party/litesata index c3d49155..a8bf0d42 160000 --- a/third_party/litesata +++ b/third_party/litesata @@ -1 +1 @@ -Subproject commit c3d491552cc77312bbadf6488c08e1e3df9612ef +Subproject commit a8bf0d42b22a5f355a629aad7392c59029164d67 diff --git a/third_party/litescope b/third_party/litescope index d5887a3e..7757727f 160000 --- a/third_party/litescope +++ b/third_party/litescope @@ -1 +1 @@ -Subproject commit d5887a3eb0de105cfc55e52fbeb9de9da035e7db +Subproject commit 7757727f5b9fe4cb4979897fa0aab934b4af6e88 diff --git a/third_party/liteusb b/third_party/liteusb index 7a17876b..9a78586e 160000 --- a/third_party/liteusb +++ b/third_party/liteusb @@ -1 +1 @@ -Subproject commit 7a17876bc7f8943a2a0b500e4c1cb1e454c680b6 +Subproject commit 9a78586e5e523843834f80826f387ff828012ff7 diff --git a/third_party/litevideo b/third_party/litevideo index cd44e3f1..c9770cc2 160000 --- a/third_party/litevideo +++ b/third_party/litevideo @@ -1 +1 @@ -Subproject commit cd44e3f14cd3042a948170d43c21919b00c3c35d +Subproject commit c9770cc2da2df70c941376e9b937a2980822c739 diff --git a/third_party/litex b/third_party/litex index 9adcc3a8..0a2d38ec 160000 --- a/third_party/litex +++ b/third_party/litex @@ -1 +1 @@ -Subproject commit 9adcc3a8b99862cccf6ee6d07190b6a7f3c735de +Subproject commit 0a2d38ecd2e07fbb7e087631f3db552d178add77 From 03e92fe9552f77c452268c6cfcde96054a46f211 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Fri, 29 Dec 2017 23:25:16 +0100 Subject: [PATCH 037/219] Update the merge script. --- third_party/merge-upstream.sh | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/third_party/merge-upstream.sh b/third_party/merge-upstream.sh index 877a1f7c..4c284c31 100755 --- a/third_party/merge-upstream.sh +++ b/third_party/merge-upstream.sh @@ -2,23 +2,36 @@ set -e -TARGETS=${@-$(find * -maxdepth 0 -type d | grep -v linux | grep -v micropython | grep -v qemu | grep -v libuip)} +TARGETS=${@-$(find * -maxdepth 0 -type d)} COMMIT_MSG=$(tempfile) || exit trap "rm -f -- '$COMMIT_MSG'" EXIT +MODULES=() for TARGET in $TARGETS; do + if [ ! -e $TARGET/.git ] || ! grep -q "gitdir:" $TARGET/.git 2> /dev/null; then + echo "Skipping $TARGET as not submodule" + continue + else + echo "Submodule $TARGET" + MODULES+=("$TARGET") + fi git submodule sync --recursive -- $TARGET git submodule update --recursive --init $TARGET done +echo +echo "Found submodules:" +declare -p MODULES +echo + cat > $COMMIT_MSG < /dev/null VERSION=$(git describe --always --dirty) echo -n "$TARGET version ($VERSION) " | grep --color -E "dirty|$" @@ -35,7 +48,7 @@ else exit 1 fi -for TARGET in $TARGETS; do +for TARGET in ${MODULES[@]}; do ( case $TARGET in *) From 7d355ec1b14e8a74f6bb9a772b2e25c3aad16d25 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Wed, 27 Dec 2017 20:28:27 +0100 Subject: [PATCH 038/219] Makefile: Working on CPU config support. --- Makefile | 19 +++++++++++++++++-- make.py | 6 +++++- third_party/litex | 2 +- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 12f2380a..b217afeb 100644 --- a/Makefile +++ b/Makefile @@ -23,11 +23,19 @@ endif export TARGET DEFAULT_CPU = lm32 +DEFAULT_CPU_VARIANT = CPU ?= $(DEFAULT_CPU) +CPU_VARIANT ?= $(DEFAULT_CPU_VARIANT) ifeq ($(CPU),) $(error "Internal error: CPU not set.") endif export CPU +ifeq ($(CPU_VARIANT),) +FULL_CPU = $(CPU) +else +FULL_CPU = $(CPU).$(CPU_VARIANT) +LITEX_EXTRA_CMDLINE += -Ot cpu_variant $(CPU_VARIANT) +endif FIRMWARE ?= firmware @@ -44,7 +52,7 @@ else FULL_PLATFORM = $(PLATFORM).$(PLATFORM_EXPANSION) LITEX_EXTRA_CMDLINE += -Ot expansion $(PLATFORM_EXPANSION) endif -TARGET_BUILD_DIR = build/$(FULL_PLATFORM)_$(TARGET)_$(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 @@ -257,6 +265,8 @@ env: @echo "export TARGET='$(TARGET)'" @echo "export DEFAULT_TARGET='$(DEFAULT_TARGET)'" @echo "export CPU='$(CPU)'" + @echo "export CPU_VARIANT='$(CPU_VARIANT)'" + @echo "export FULL_CPU='$(FULL_CPU)'" @echo "export FIRMWARE='$(FIRMWARE)'" @echo "export OVERRIDE_FIRMWARE='$(OVERRIDE_FIRMWARE)'" @echo "export PROG='$(PROG)'" @@ -277,7 +287,7 @@ env: info: @echo " Platform: $(FULL_PLATFORM)" @echo " Target: $(TARGET) (default: $(DEFAULT_TARGET))" - @echo " CPU: $(CPU)" + @echo " CPU: $(FULL_CPU) (default: $(DEFAULT_CPU))" @if [ x"$(FIRMWARE)" != x"firmware" ]; then \ echo " Firmare: $(FIRMWARE) (default: firmware)"; \ fi @@ -286,6 +296,7 @@ prompt: @echo -n "P=$(PLATFORM)" @if [ x"$(TARGET)" != x"$(DEFAULT_TARGET)" ]; then echo -n " T=$(TARGET)"; fi @if [ x"$(CPU)" != x"$(DEFAULT_CPU)" ]; then echo -n " C=$(CPU)"; fi + @if [ x"$(CPU_VARIANT)" != x"$(DEFAULT_CPU_VARIANT)" ]; then echo -n ".$(CPU_VARIANT)"; fi @if [ x"$(FIRMWARE)" != x"firmware" ]; then \ echo -n " F=$(FIRMWARE)"; \ fi @@ -322,6 +333,10 @@ help: @echo " CPU=lm32 OR or1k" @echo " (current: $(CPU), default: $(DEFAULT_CPU))" @echo "" + @echo " CPU_VARIANT describes which soft-CPU variant to use on the FPGA." + @echo " CPU_VARIANT=" + @echo " (current: $(CPU_VARIANT), default: $(DEFAULT_CPU_VARIANT))" + @echo "" @echo " FIRMWARE describes the code running on the soft-CPU inside the FPGA." @echo " FIRMWARE=firmware OR micropython" @echo " (current: $(FIRMWARE))" diff --git a/make.py b/make.py index f1bcef93..d5d27ca7 100755 --- a/make.py +++ b/make.py @@ -14,6 +14,7 @@ def get_args(parser, platform='opsis', target='hdmi2usb'): parser.add_argument("--platform", action="store", default=os.environ.get('PLATFORM', platform)) parser.add_argument("--target", action="store", default=os.environ.get('TARGET', target)) parser.add_argument("--cpu-type", default=os.environ.get('CPU', 'lm32')) + parser.add_argument("--cpu-variant", default=os.environ.get('CPU_VARIANT', '')) parser.add_argument("--iprange", default="192.168.100") @@ -33,7 +34,10 @@ def get_builddir(args): for name, value in args.target_option: if name == 'tofe_board': full_platform = "{}.{}".format(full_platform, value) - return "build/{}_{}_{}/".format(full_platform.lower(), args.target.lower(), args.cpu_type) + full_cpu = args.cpu_type + if args.cpu_variant: + full_cpu = "{}.{}".format(full_cpu, args.cpu_variant) + return "build/{}_{}_{}/".format(full_platform.lower(), args.target.lower(), full_cpu.lower()) def get_testdir(args): diff --git a/third_party/litex b/third_party/litex index b463b216..44650dff 160000 --- a/third_party/litex +++ b/third_party/litex @@ -1 +1 @@ -Subproject commit b463b2169b33bd5861bfa94dcb2c8c896dd36cf7 +Subproject commit 44650dffd8f82018840922ddbbb6570c8c1e6b08 From 6e7d5845484d14b757878cfa16af459614976df5 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Sun, 26 Nov 2017 13:27:16 +0000 Subject: [PATCH 039/219] Move PATTERN_FRAMEBUFFER_BASE down to 0x00000000+x So that we can put inputs above it, simply. --- firmware/pattern.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/pattern.c b/firmware/pattern.c index 7354d13d..9fffd350 100644 --- a/firmware/pattern.c +++ b/firmware/pattern.c @@ -12,7 +12,7 @@ #include "uptime.h" #include "version_data.h" -#define PATTERN_FRAMEBUFFER_BASE 0x02000000 + 0x100000 +#define PATTERN_FRAMEBUFFER_BASE 0x00000000 + 0x100000 unsigned int pattern_framebuffer_base(void) { return PATTERN_FRAMEBUFFER_BASE; From e2e810a970d0f68c8173584da6b2dea71bc30f68 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Sun, 26 Nov 2017 15:01:54 +0000 Subject: [PATCH 040/219] Move the FRAMEBUFFERS_BASE to the header --- firmware/hdmi_in0.c | 2 -- firmware/hdmi_in0.h | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/firmware/hdmi_in0.c b/firmware/hdmi_in0.c index 9e62abc2..96a79d13 100644 --- a/firmware/hdmi_in0.c +++ b/firmware/hdmi_in0.c @@ -19,8 +19,6 @@ int hdmi_in0_debug; int hdmi_in0_fb_index; -#define HDMI_IN0_FRAMEBUFFERS_BASE (0x00000000 + 0x100000) - //#define CLEAN_COMMUTATION //#define DEBUG diff --git a/firmware/hdmi_in0.h b/firmware/hdmi_in0.h index bc618067..196c3c78 100644 --- a/firmware/hdmi_in0.h +++ b/firmware/hdmi_in0.h @@ -4,6 +4,8 @@ #ifndef __HDMI_IN0_H #define __HDMI_IN0_H +#define HDMI_IN0_FRAMEBUFFERS_BASE (0x01000000 + 0x100000) + extern int hdmi_in0_debug; extern int hdmi_in0_fb_index; From 8a30b827498962ecb16dc2a9d999706f20d52947 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Sun, 26 Nov 2017 15:02:40 +0000 Subject: [PATCH 041/219] Calculate a dynamic FRAMEBUFFERS_BASE for each HDMI input --- firmware/hdmi_in.sh | 1 + firmware/hdmi_in0.h | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/firmware/hdmi_in.sh b/firmware/hdmi_in.sh index c7ba3a00..26716547 100755 --- a/firmware/hdmi_in.sh +++ b/firmware/hdmi_in.sh @@ -29,6 +29,7 @@ TMPFILE_H=$(tempfile -s .h | mktemp --suffix=.h) TMPFILE_C=$(tempfile -s .c | mktemp --suffix=.c) cat $FIRMWARE_DIR/hdmi_in0.h | sed \ + -e"s/IN0_INDEX 0/IN${X}_INDEX $X/g" \ -e"s/IN0/IN$X/g" \ -e"s/in0/in$X/g" \ > $TMPFILE_H diff --git a/firmware/hdmi_in0.h b/firmware/hdmi_in0.h index 196c3c78..a37aea82 100644 --- a/firmware/hdmi_in0.h +++ b/firmware/hdmi_in0.h @@ -4,7 +4,8 @@ #ifndef __HDMI_IN0_H #define __HDMI_IN0_H -#define HDMI_IN0_FRAMEBUFFERS_BASE (0x01000000 + 0x100000) +#define HDMI_IN0_INDEX 0 +#define HDMI_IN0_FRAMEBUFFERS_BASE ((HDMI_IN0_INDEX + 1) * 0x01000000 + 0x100000) extern int hdmi_in0_debug; extern int hdmi_in0_fb_index; From 23197e8b4a07ca26bea77f02cceadecd934b68e8 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Sun, 26 Nov 2017 15:03:40 +0000 Subject: [PATCH 042/219] gitignore generated hdmi input source --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 6260aefc..cb814ba6 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ __pycache__ *.pyc *.egg-info *.vcd +firmware/hdmi_in[1-9].[ch] outgoing build *~ From 0d77955f070170c9dbc62470bb65177e073d449b Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sat, 30 Dec 2017 14:58:50 +0100 Subject: [PATCH 043/219] firmware: Refactoring and comments with Stefano. --- firmware/framebuffer.h | 43 +++++++++++++++++++++++++++++++++++++++--- firmware/hdmi_in.sh | 2 +- firmware/hdmi_in0.h | 8 ++++++-- firmware/pattern.c | 12 +++++------- firmware/pattern.h | 12 +++++++----- firmware/processor.c | 2 +- 6 files changed, 60 insertions(+), 19 deletions(-) diff --git a/firmware/framebuffer.h b/firmware/framebuffer.h index e0d7c177..e8623d35 100644 --- a/firmware/framebuffer.h +++ b/firmware/framebuffer.h @@ -17,10 +17,47 @@ #include #include "generated/mem.h" +/** + * Frame buffers must be aligned to XXX boundary. + * + * 0x0100000 - Pattern Buffer - Frame Buffer n + * + * Each input then has 3 frame buffers spaced like this; + * // HDMI Input 0 + * 0x01000000 - HDMI Input 0 - Frame Buffer n + * 0x01000000 - HDMI Input 0 - Frame Buffer n+1 + * 0x01000000 - HDMI Input 0 - Frame Buffer n+2 + * // HDMI Input 1 + * 0x02000000 - HDMI Input 1 - Frame Buffer n + * 0x02000000 - HDMI Input 1 - Frame Buffer n+1 + * 0x02000000 - HDMI Input 1 - Frame Buffer n+2 + * ... + * // HDMI Input x + * 0x0x000000 - HDMI Input x - Frame Buffer n + * 0x0x000000 - HDMI Input x - Frame Buffer n+1 + * 0x0x000000 - HDMI Input x - Frame Buffer n+2 + * + */ +#define FRAMEBUFFER_OFFSET 0x01000000 +#define FRAMEBUFFER_PATTERNS 1 + +#define FRAMEBUFFER_PIXELS_X 1920 // pixels +#define FRAMEBUFFER_PIXELS_Y 1080 // pixels +#define FRAMEBUFFER_PIXELS_BYTES 2 // bytes + +#define FRAMEBUFFER_BASE(x) (x*FRAMEBUFFER_OFFSET) +#define FRAMEBUFFER_BASE_PATTERN FRAMEBUFFER_BASE(0) +#define FRAMEBUFFER_BASE_HDMI_INPUT(x) FRAMEBUFFER_BASE(x+FRAMEBUFFER_PATTERNS) + // Largest frame size at 16bpp (ish) -#define FRAMEBUFFER_SIZE (1920*1080*2) -#define FRAMEBUFFER_COUNT 4 -#define FRAMEBUFFER_MASK (FRAMEBUFFER_COUNT - 1) +#define FRAMEBUFFER_SIZE 0x400000 // bytes +#if (FRAMEBUFFER_PIXELS_X*FRAMEBUFFER_PIXELS_Y*FRAMEBUFFER_PIXELS_BYTES) > FRAMEBUFFER_SIZE +#error "Number of pixels don't fit in frame buffer" +#endif + +#define FRAMEBUFFER_COUNT 4 // Must be a multiple of 2 +#define FRAMEBUFFER_MASK (FRAMEBUFFER_COUNT - 1) + typedef unsigned int fb_ptrdiff_t; // FIXME: typedef uint16_t framebuffer_t[FRAMEBUFFER_SIZE]; diff --git a/firmware/hdmi_in.sh b/firmware/hdmi_in.sh index 26716547..2f32db09 100755 --- a/firmware/hdmi_in.sh +++ b/firmware/hdmi_in.sh @@ -29,7 +29,7 @@ TMPFILE_H=$(tempfile -s .h | mktemp --suffix=.h) TMPFILE_C=$(tempfile -s .c | mktemp --suffix=.c) cat $FIRMWARE_DIR/hdmi_in0.h | sed \ - -e"s/IN0_INDEX 0/IN${X}_INDEX $X/g" \ + -e"s/IN0_INDEX\([^0-9]\+\)0/IN${X}_INDEX\1$X/g" \ -e"s/IN0/IN$X/g" \ -e"s/in0/in$X/g" \ > $TMPFILE_H diff --git a/firmware/hdmi_in0.h b/firmware/hdmi_in0.h index a37aea82..9dbe4848 100644 --- a/firmware/hdmi_in0.h +++ b/firmware/hdmi_in0.h @@ -4,8 +4,12 @@ #ifndef __HDMI_IN0_H #define __HDMI_IN0_H -#define HDMI_IN0_INDEX 0 -#define HDMI_IN0_FRAMEBUFFERS_BASE ((HDMI_IN0_INDEX + 1) * 0x01000000 + 0x100000) +#ifdef HDMI_IN0_INDEX +#error "HDMI_IN0_INDEX already defined!" +#endif + +#define HDMI_IN0_INDEX 0 +#define HDMI_IN0_FRAMEBUFFERS_BASE FRAMEBUFFER_BASE_HDMI_INPUT(HDMI_IN0_INDEX) extern int hdmi_in0_debug; extern int hdmi_in0_fb_index; diff --git a/firmware/pattern.c b/firmware/pattern.c index 9fffd350..828c3f87 100644 --- a/firmware/pattern.c +++ b/firmware/pattern.c @@ -12,10 +12,8 @@ #include "uptime.h" #include "version_data.h" -#define PATTERN_FRAMEBUFFER_BASE 0x00000000 + 0x100000 - unsigned int pattern_framebuffer_base(void) { - return PATTERN_FRAMEBUFFER_BASE; + return FRAMEBUFFER_BASE_PATTERN; } static const unsigned int color_bar[8] = { @@ -136,7 +134,7 @@ static int inc_color(int color) { static void pattern_draw_text_color(int x, int y, char *ptr, long background_color, long text_color) { int i, j, k; int adr; - volatile unsigned int *framebuffer = (unsigned int *)(MAIN_RAM_BASE + PATTERN_FRAMEBUFFER_BASE); + volatile unsigned int *framebuffer = (unsigned int *)(MAIN_RAM_BASE + pattern_framebuffer_base()); for(i=0; ptr[i] != '\0'; i++) { for(j=-1; j<8; j++) { for(k=-1; k<6; k++) { @@ -159,7 +157,7 @@ static void pattern_draw_text(int x, int y, char *ptr) { void pattern_next(void) { pattern++; - pattern = pattern % MAX_PATTERN; + pattern = pattern % PATTERN_MAX; pattern_fill_framebuffer(processor_h_active, processor_v_active); } @@ -170,8 +168,8 @@ void pattern_fill_framebuffer(int h_active, int w_active) int color; flush_l2_cache(); color = -1; - volatile unsigned int *framebuffer = (unsigned int *)(MAIN_RAM_BASE + PATTERN_FRAMEBUFFER_BASE); - if(pattern == COLOR_BAR_PATTERN) { + volatile unsigned int *framebuffer = (unsigned int *)(MAIN_RAM_BASE + pattern_framebuffer_base()); + if(pattern == PATTERN_COLOR_BARS) { /* color bar pattern */ for(i=0; i Date: Sat, 30 Dec 2017 15:09:52 +0100 Subject: [PATCH 044/219] firmware: Fixing the input comments. --- firmware/framebuffer.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/firmware/framebuffer.h b/firmware/framebuffer.h index e8623d35..da4b5701 100644 --- a/firmware/framebuffer.h +++ b/firmware/framebuffer.h @@ -25,17 +25,17 @@ * Each input then has 3 frame buffers spaced like this; * // HDMI Input 0 * 0x01000000 - HDMI Input 0 - Frame Buffer n - * 0x01000000 - HDMI Input 0 - Frame Buffer n+1 - * 0x01000000 - HDMI Input 0 - Frame Buffer n+2 + * 0x01040000 - HDMI Input 0 - Frame Buffer n+1 + * 0x01080000 - HDMI Input 0 - Frame Buffer n+2 * // HDMI Input 1 * 0x02000000 - HDMI Input 1 - Frame Buffer n - * 0x02000000 - HDMI Input 1 - Frame Buffer n+1 - * 0x02000000 - HDMI Input 1 - Frame Buffer n+2 + * 0x02040000 - HDMI Input 1 - Frame Buffer n+1 + * 0x02080000 - HDMI Input 1 - Frame Buffer n+2 * ... * // HDMI Input x * 0x0x000000 - HDMI Input x - Frame Buffer n - * 0x0x000000 - HDMI Input x - Frame Buffer n+1 - * 0x0x000000 - HDMI Input x - Frame Buffer n+2 + * 0x0x040000 - HDMI Input x - Frame Buffer n+1 + * 0x0x080000 - HDMI Input x - Frame Buffer n+2 * */ #define FRAMEBUFFER_OFFSET 0x01000000 From 2d1947034bc0f635602764fc78ca3f503476b674 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sat, 30 Dec 2017 15:24:13 +0100 Subject: [PATCH 045/219] scripts: Move newline check into scripts directory. --- Makefile | 2 +- firmware/test.sh | 18 --------------- scripts/check-firmware-newlines.sh | 37 ++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 19 deletions(-) delete mode 100755 firmware/test.sh create mode 100755 scripts/check-firmware-newlines.sh diff --git a/Makefile b/Makefile index 5475d7ab..f11b6dfb 100644 --- a/Makefile +++ b/Makefile @@ -208,7 +208,7 @@ firmware-clean: rm -rf $(TARGET_BUILD_DIR)/software firmware-test: - firmware/test.sh + scripts/check-firmware-newlines.sh .PHONY: firmware-load-$(PLATFORM) firmware-flash-$(PLATFORM) firmware-flash-py firmware-connect-$(PLATFORM) firmware-clear-$(PLATFORM) .NOTPARALLEL: firmware-load-$(PLATFORM) firmware-flash-$(PLATFORM) firmware-flash-py firmware-connect-$(PLATFORM) firmware-clear-$(PLATFORM) diff --git a/firmware/test.sh b/firmware/test.sh deleted file mode 100755 index b1546e4b..00000000 --- a/firmware/test.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -set -euf -cd "$(dirname "$0")" - -find . '(' -name '*.c' -o -name '*.h' ')' \ -| while read fn; do - case $fn in - ./telnet.c) - continue - ;; - esac - if grep -qF '\r\n' $fn; then - echo "$fn" 'contains a \\r\\n.' - echo 'You should just write \\n, stdio_wrap will transform this to a \\r\\n, as appropriate' - exit 1 - fi -done diff --git a/scripts/check-firmware-newlines.sh b/scripts/check-firmware-newlines.sh new file mode 100755 index 00000000..cebbbe1d --- /dev/null +++ b/scripts/check-firmware-newlines.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +if [ "`whoami`" = "root" ] +then + echo "Running the script as root is not permitted" + exit 1 +fi + +CALLED=$_ +[[ "${BASH_SOURCE[0]}" != "${0}" ]] && SOURCED=1 || SOURCED=0 + +SETUP_SRC="$(realpath ${BASH_SOURCE[0]})" +SETUP_DIR="$(dirname "${SETUP_SRC}")" +TOP_DIR="$(realpath "${SETUP_DIR}/..")" + +if [ $SOURCED = 1 ]; then + echo "You must run this script, rather then try to source it." + echo "$SETUP_SRC" + return +fi + +set -euf +cd $TOP_DIR/firmware + +find . '(' -name '*.c' -o -name '*.h' ')' \ +| while read fn; do + case $fn in + ./telnet.c) + continue + ;; + esac + if grep -qF '\r\n' $fn; then + echo "$fn" 'contains a \\r\\n.' + echo 'You should just write \\n, stdio_wrap will transform this to a \\r\\n, as appropriate' + exit 1 + fi +done From 7ba06a8b5bd5edbc77427242968ad53c6f1fc29f Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Sat, 30 Dec 2017 15:45:15 +0100 Subject: [PATCH 046/219] Only the udev rules are actually a problem The ixo-usb-jtag package in Debian is a firmware-only package, without any udev rules. --- scripts/enter-env.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/enter-env.sh b/scripts/enter-env.sh index bf4ab38c..5a893ce5 100755 --- a/scripts/enter-env.sh +++ b/scripts/enter-env.sh @@ -45,10 +45,10 @@ if echo "${SETUP_DIR}" | grep -q ':'; then exit 1 fi -# Check ixo-usb-jtag *isn't* install -if [ -d /lib/firmware/ixo-usb-jtag/ ]; then - echo "Please uninstall ixo-usb-jtag package, the required firmware is" - echo "included in the HDMI2USB modeswitch tool." +# Check ixo-usb-jtag *isn't* installed +if [ -e /lib/udev/rules.d/85-ixo-usb-jtag.rules ]; then + echo "Please uninstall ixo-usb-jtag package from the timvideos PPA, the" + echo "required firmware is included in the HDMI2USB modeswitch tool." echo echo "On Debian/Ubuntu run:" echo " sudo apt-get remove ixo-usb-jtag" From b6c967d043bd3365a8354f951d7b073a2fa581a4 Mon Sep 17 00:00:00 2001 From: Tim Ansell Date: Sun, 31 Dec 2017 08:48:43 +0100 Subject: [PATCH 047/219] Use $IPRANGE rather than hard coded 192.168.100 --- scripts/build-qemu.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/build-qemu.sh b/scripts/build-qemu.sh index f9634d54..18c5b5b2 100755 --- a/scripts/build-qemu.sh +++ b/scripts/build-qemu.sh @@ -120,13 +120,13 @@ if grep -q ETHMAC_BASE $TARGET_BUILD_DIR/software/include/generated/csr.h; then make tftp # Use the userspace network support. QEMU will pretend to be a - # machine a 192.168.100.100. Any connections to that IP will + # machine a $IPRANGE.100. Any connections to that IP will # automatically be forwarded to the real localhost. # # Connections to real localhost on port 2223, will be - # forwarded to the expected guest ip (192.168.100.50) on port + # forwarded to the expected guest ip ($IPRANGE.50) on port # 23 (telnet). - EXTRA_ARGS+=("-net user,net=192.168.100.0/24,host=192.168.100.100,dhcpstart=192.168.100.50,tftp=$TOP_DIR/build/tftpd,hostfwd=tcp::2223-:23") + EXTRA_ARGS+=("-net user,net=$IPRANGE.0/24,host=$IPRANGE.100,dhcpstart=$IPRANGE.50,tftp=$TOP_DIR/build/tftpd,hostfwd=tcp::2223-:23") # Make debugging the userspace networking easier, dump all # packets to a file. From 13bc0d01d945ae566d7f5edcb307dfd22f70d0f2 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sun, 31 Dec 2017 09:50:51 +0100 Subject: [PATCH 048/219] scripts: Only get some tools on some platforms. --- scripts/download-env.sh | 26 +++++++++++++++----------- scripts/enter-env.sh | 15 +++++++++------ 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/scripts/download-env.sh b/scripts/download-env.sh index 0f79ca44..938d9a43 100755 --- a/scripts/download-env.sh +++ b/scripts/download-env.sh @@ -208,21 +208,25 @@ echo "Installing binaries into environment" echo "---------------------------------" # fxload -echo -echo "Installing fxload (tool for Cypress FX2)" -# conda install fxload -check_exists fxload +if [ "$PLATFORM" == "opsis" -o "$PLATFORM" == "atlys" ]; then + echo + echo "Installing fxload (tool for Cypress FX2)" + # conda install fxload + check_exists fxload +fi # FIXME: Remove this once @jimmo has finished his new firmware # MimasV2Config.py -MIMASV2CONFIG=$BUILD_DIR/conda/bin/MimasV2Config.py -echo -echo "Installing MimasV2Config.py (mimasv2 flashing tool)" -if [ ! -e $MIMASV2CONFIG ]; then - wget https://raw.githubusercontent.com/numato/samplecode/master/FPGA/MimasV2/tools/configuration/python/MimasV2Config.py -O $MIMASV2CONFIG - chmod a+x $MIMASV2CONFIG +if [ "$PLATFORM" == "mimasv2" ]; then + MIMASV2CONFIG=$BUILD_DIR/conda/bin/MimasV2Config.py + echo + echo "Installing MimasV2Config.py (mimasv2 flashing tool)" + if [ ! -e $MIMASV2CONFIG ]; then + wget https://raw.githubusercontent.com/numato/samplecode/master/FPGA/MimasV2/tools/configuration/python/MimasV2Config.py -O $MIMASV2CONFIG + chmod a+x $MIMASV2CONFIG + fi + check_exists MimasV2Config.py fi -check_exists MimasV2Config.py # flterm echo diff --git a/scripts/enter-env.sh b/scripts/enter-env.sh index 5a893ce5..f8f8cc9a 100755 --- a/scripts/enter-env.sh +++ b/scripts/enter-env.sh @@ -180,22 +180,25 @@ echo "Checking binaries in environment" echo "---------------------------------" # fxload +if [ "$PLATFORM" == "opsis" -o "$PLATFORM" == "atlys" ]; then + # check sbin for fxload as well + export PATH=$PATH:/sbin -# check sbin for fxload as well -export PATH=$PATH:/sbin - -check_exists fxload || return 1 + check_exists fxload || return 1 +fi # FIXME: Remove this once @jimmo has finished his new firmware # MimasV2Config.py -MIMASV2CONFIG=$BUILD_DIR/conda/bin/MimasV2Config.py +if [ "$PLATFORM" == "mimasv2" ]; then + MIMASV2CONFIG=$BUILD_DIR/conda/bin/MimasV2Config.py -check_exists MimasV2Config.py || return 1 + check_exists MimasV2Config.py || return 1 +fi # flterm From 64b034b118c5ca580f4f2dd81ee57e466e99795c Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sun, 31 Dec 2017 09:53:22 +0100 Subject: [PATCH 049/219] scripts: Check firmware/cpu_variant for Linux. --- scripts/build-linux.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/build-linux.sh b/scripts/build-linux.sh index 803b0cc6..69131201 100755 --- a/scripts/build-linux.sh +++ b/scripts/build-linux.sh @@ -27,7 +27,6 @@ if [ -z "$HDMI2USB_ENV" ]; then fi # Imports TARGET, PLATFORM, CPU and TARGET_BUILD_DIR from Makefile -export FIRMWARE=linux eval $(make env) make info @@ -38,6 +37,15 @@ if [ "$CPU" != or1k ]; then echo "Linux is only supported on or1k at the moment." exit 1 fi +if [ "$CPU_VARIANT" != "linux" ]; then + echo "Linux needs a CPU_VARIANT set to 'linux' to enable features" + echo "needed by Linux like the MMU." + exit 1 +fi +if [ "$FIRMWARE" != "linux" ]; then + echo "When building Linux you should set FIRMWARE to 'linux'." + exit 1 +fi REMOTE_NAME=h2u-litex-linux From 14bc88eab8585da752a781e90a99422341bae8e6 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sun, 31 Dec 2017 10:24:10 +0100 Subject: [PATCH 050/219] scripts: Use LX in the prompt. --- scripts/enter-env.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/enter-env.sh b/scripts/enter-env.sh index f8f8cc9a..11275a49 100755 --- a/scripts/enter-env.sh +++ b/scripts/enter-env.sh @@ -302,9 +302,9 @@ export HDMI2USB_ENV=1 # Set prompt ORIG_PS1="$PS1" -hdmi2usb_prompt() { +litex_buildenv_prompt() { P="$(cd $TOP_DIR; make prompt)" - PS1="(H2U $P) $ORIG_PS1" + PS1="(LX $P) $ORIG_PS1" case "$TERM" in xterm*|rxvt*) PS1="$PS1\[\033]0;($P) \w\007\]" @@ -313,4 +313,4 @@ hdmi2usb_prompt() { ;; esac } -PROMPT_COMMAND=hdmi2usb_prompt +PROMPT_COMMAND=litex_buildenv_prompt From 49f25bb3a2436773998da96468942c2a2beefece Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sun, 31 Dec 2017 10:24:35 +0100 Subject: [PATCH 051/219] scripts: Fixes to build-linux script. --- scripts/build-linux.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/scripts/build-linux.sh b/scripts/build-linux.sh index 69131201..d3d7199c 100755 --- a/scripts/build-linux.sh +++ b/scripts/build-linux.sh @@ -145,15 +145,16 @@ TARGET_LINUX_BUILD_DIR=$(dirname $TOP_DIR/$FIRMWARE_FILEBASE) mkdir -p $TARGET_LINUX_BUILD_DIR ( cd $TARGET_LINUX_BUILD_DIR - if [ ! -e openrisc-rootfs.cpio ]; then - wget "https://drive.google.com/a/mithis.com/uc?authuser=0&id=0B5VlNZ_Rvdw6d21LWXdHQlZuOVU&export=download" -O openrisc-rootfs.cpio + ROOTFS=openrisc-rootfs.cpio + if [ ! -e $ROOTFS ]; then + wget "https://drive.google.com/a/mithis.com/uc?authuser=0&id=0B5VlNZ_Rvdw6d21LWXdHQlZuOVU&export=download" -O $ROOTFS fi - if [ ! -e openrisc-rootfs.cpio.gz ]; then - gzip openrisc-rootfs.cpio + if [ ! -e $ROOTFS.gz ]; then + gzip -k $ROOTFS fi ) make O="$TARGET_LINUX_BUILD_DIR" litex_defconfig - make O="$TARGET_LINUX_BUILD_DIR" -j$JOBS + time make O="$TARGET_LINUX_BUILD_DIR" -j$JOBS ls -l $TARGET_LINUX_BUILD_DIR/arch/openrisc/boot/vmlinux.bin - ln -s $TARGET_LINUX_BUILD_DIR/arch/openrisc/boot/vmlinux.bin $TOP_DIR/$FIRMWARE_FILEBASE.bin + ln -sf $TARGET_LINUX_BUILD_DIR/arch/openrisc/boot/vmlinux.bin $TOP_DIR/$FIRMWARE_FILEBASE.bin ) From a1514e88a70c45a223ee81272abe4fec0ba93837 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sun, 31 Dec 2017 11:11:42 +0100 Subject: [PATCH 052/219] linux: Don't need a special LiteX any more. --- scripts/build-linux.sh | 45 ------------------------------------------ 1 file changed, 45 deletions(-) diff --git a/scripts/build-linux.sh b/scripts/build-linux.sh index d3d7199c..e1cec824 100755 --- a/scripts/build-linux.sh +++ b/scripts/build-linux.sh @@ -47,51 +47,6 @@ if [ "$FIRMWARE" != "linux" ]; then exit 1 fi -REMOTE_NAME=h2u-litex-linux - -LITEX_SRC=$TOP_DIR/third_party/litex -LITEX_BRANCH=${LITEX_BRANCH:-or1k-linux} -LITEX_REMOTE="${LITEX_REMOTE:-https://github.com/enjoy-digital/litex.git}" -LITEX_REMOTE_BIT=$(echo $LITEX_REMOTE | sed -e's-^.*://--' -e's/.git$//') -( - # Init the submodule if it doesn't exist - if [ ! -d $LITEX_SRC ]; then - git submodule update --init third_party/litex - fi - - # Change into the dir - cd $LITEX_SRC - - # Add the remote if it doesn't exist - LITEX_REMOTE_NAME="$(git remote -v | grep fetch | grep "$LITEX_REMOTE_BIT" | sed -e's/\t.*$//')" - if [ x"$LITEX_REMOTE_NAME" = x ]; then - git remote add "$REMOTE_NAME" "$LITEX_REMOTE" - LITEX_REMOTE_NAME=$REMOTE_NAME - fi - - # Get any new data - git fetch $LITEX_REMOTE_NAME - - # Checkout or1k-linux branch it not already on it - if [ "$(git rev-parse --abbrev-ref HEAD)" != "$LITEX_BRANCH" ]; then - git checkout $LITEX_BRANCH || \ - git checkout "$LITEX_REMOTE_NAME/$LITEX_BRANCH" -b $LITEX_BRANCH - - # Need to rebuild the gateware - # FIXME: Make this conditional on the gateware /actually/ changing - ( - cd $TOP_DIR - make gateware - ) - fi -) -# Unset these values as LITEX and LINUX are very close in name and hence could -# accidentally be used below. -unset LITEX_SRC -unset LITEX_BRANCH -unset LITEX_REMOTE -unset LITEX_REMOTE_BIT - # Install a toolchain with the newlib standard library if ! $CPU-elf-newlib-gcc --version > /dev/null 2>&1; then conda install gcc-$CPU-elf-newlib From 0830848b501ca6bea09ac51348bfa945317eecb6 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sun, 31 Dec 2017 11:13:15 +0100 Subject: [PATCH 053/219] linux: Fixing issues with cloning Linux. --- scripts/build-linux.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/scripts/build-linux.sh b/scripts/build-linux.sh index e1cec824..b7c9edac 100755 --- a/scripts/build-linux.sh +++ b/scripts/build-linux.sh @@ -56,6 +56,7 @@ fi LINUX_SRC="$TOP_DIR/third_party/linux" LINUX_LOCAL="$LINUX_GITLOCAL" # Local place to clone from LINUX_REMOTE="${LINUX_REMOTE:-https://github.com/mithro/linux-litex.git}" +LINUX_REMOTE_NAME=mithro-linux-litex LINUX_REMOTE_BIT=$(echo $LINUX_REMOTE | sed -e's-^.*://--' -e's/.git$//') LINUX_CLONE_FROM="${LINUX_LOCAL:-$LINUX_REMOTE}" LINUX_BRANCH=${LINUX_BRANCH:-litex-minimal} @@ -66,7 +67,7 @@ LINUX_BRANCH=${LINUX_BRANCH:-litex-minimal} cd $(dirname $LINUX_SRC) echo "Downloading Linux source tree." echo "If you already have a local git checkout you can set 'LINUX_GITLOCAL' to speed up this step." - git clone $LINUX_CLONE_FROM linux + git clone $LINUX_CLONE_FROM $LINUX_SRC ) fi @@ -74,19 +75,19 @@ LINUX_BRANCH=${LINUX_BRANCH:-litex-minimal} cd $LINUX_SRC # Add the remote if it doesn't exist - LINUX_REMOTE_NAME=$(git remote -v | grep fetch | grep "$LINUX_REMOTE_BIT" | sed -e's/\t.*$//') - if [ x"$LINUX_REMOTE_NAME" = x ]; then - git remote add $REMOTE_NAME https://github.com/enjoy-digital/litex.git - LINUX_REMOTE_NAME=$REMOTE_NAME + CURRENT_LINUX_REMOTE_NAME=$(git remote -v | grep fetch | grep "$LINUX_REMOTE_BIT" | sed -e's/\t.*$//') + if [ x"$CURRENT_LINUX_REMOTE_NAME" = x ]; then + git remote add $LINUX_REMOTE_NAME $LINUX_REMOTE + CURRENT_LINUX_REMOTE_NAME=$CURRENT_LINUX_REMOTE_NAME fi # Get any new data - git fetch $LINUX_REMOTE_NAME + git fetch $CURRENT_LINUX_REMOTE_NAME # Checkout or1k-linux branch it not already on it if [ "$(git rev-parse --abbrev-ref HEAD)" != "$LINUX_BRANCH" ]; then git checkout $LINUX_BRANCH || \ - git checkout "$LINUX_REMOTE_NAME/$LINUX_BRANCH" -b $LINUX_BRANCH + git checkout "$CURRENT_LINUX_REMOTE_NAME/$LINUX_BRANCH" -b $LINUX_BRANCH fi ) From 480fe788963f49b0811b7aad8e115f8c8ab80be4 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sun, 31 Dec 2017 11:14:03 +0100 Subject: [PATCH 054/219] linux: Get litex-devicetree. --- .gitignore | 1 + scripts/build-linux.sh | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/.gitignore b/.gitignore index d5fb6eac..360dc485 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ build third_party/qemu-litex third_party/micropython third_party/linux +third_party/litex-devicetree diff --git a/scripts/build-linux.sh b/scripts/build-linux.sh index b7c9edac..101ad01e 100755 --- a/scripts/build-linux.sh +++ b/scripts/build-linux.sh @@ -91,6 +91,42 @@ LINUX_BRANCH=${LINUX_BRANCH:-litex-minimal} fi ) +# Get litex-devicetree +LITEX_DT_SRC="$TOP_DIR/third_party/litex-devicetree" +LITEX_DT_REMOTE="${LITEX_DT_REMOTE:-https://github.com/mithro/litex-devicetree.git}" +LITEX_DT_REMOTE_BIT=$(echo $LITEX_DT_REMOTE | sed -e's-^.*://--' -e's/.git$//') +LITEX_DT_REMOTE_NAME=mithro-litex-devicetree +LITEX_DT_BRANCH=master +( + # Download the Linux source for the first time + if [ ! -d "$LITEX_DT_SRC" ]; then + ( + cd $(dirname $LITEX_DT_SRC) + echo "Downloading LiteX devicetree code." + git clone $LITEX_DT_REMOTE $LITEX_DT_SRC + ) + fi + + # Change into the dir + cd $LITEX_DT_SRC + + # Add the remote if it doesn't exist + CURRENT_LITEX_DT_REMOTE_NAME=$(git remote -v | grep fetch | grep "$LITEX_DT_REMOTE_BIT" | sed -e's/\t.*$//') + if [ x"$CURRENT_LITEX_DT_REMOTE_NAME" = x ]; then + git remote add $LITEX_DT_REMOTE_NAME $LITEX_DT_REMOTE + CURRENT_LITEX_DT_REMOTE_NAME=$LITEX_DT_REMOTE_NAME + fi + + # Get any new data + git fetch $CURRENT_LITEX_DT_REMOTE_NAME + + # Checkout or1k-linux branch it not already on it + if [ "$(git rev-parse --abbrev-ref HEAD)" != "$LITEX_DT_BRANCH" ]; then + git checkout $LITEX_DT_BRANCH || \ + git checkout "$CURRENT_LITEX_DT_REMOTE_NAME/$LITEX_DT_BRANCH" -b $LITEX_DT_BRANCH + fi +) + # Build linux-litex export ARCH=openrisc export CROSS_COMPILE=$CPU-elf-newlib- From 50da89c87618077339705a971880a0a4afb2d070 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sun, 31 Dec 2017 11:14:31 +0100 Subject: [PATCH 055/219] Makefile: Allow setting FULL_CPU and FULL_PLATFORM. Needed for Travis. --- Makefile | 87 +++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 71 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 24b071ed..71436b6a 100644 --- a/Makefile +++ b/Makefile @@ -7,25 +7,78 @@ endif PYTHON ?= python export PYTHON -PLATFORM ?= opsis -export PLATFORM -# Default board +# The platform to run on. It is made up of FPGA_MAIN_BOARD.EXPANSION_BOARD +DEFAULT_PLATFORM = opsis +DEFAULT_PLATFORM_EXPANSION = ifeq ($(PLATFORM),) $(error "PLATFORM not set, please set it.") endif -# Include platform specific targets -include targets/$(PLATFORM)/Makefile.mk -TARGET ?= $(DEFAULT_TARGET) -ifeq ($(TARGET),) - $(error "Internal error: TARGET not set.") +ifneq ($(FULL_PLATFORM),) + PLATFORM_PART := $(shell echo $(FULL_PLATFORM) | sed -e's/\..\+$$//') + PLATFORM_EXPANSION_PART := $(shell echo $(FULL_PLATFORM) | sed -e's/^[^.]\+\.//') + + # Check PLATFORM value matches FULL_PLATFORM bits + ifneq ($(PLATFORM),) + ifneq ($(PLATFORM),$(PLATFORM_PART)) + $(error "FULL_PLATFORM was set to '$(FULL_PLATFORM)' ($(PLATFORM_PART)), but PLATFORM was set to '$(PLATFORM)'.") + endif + else + PLATFORM="$(PLATFORM_PART)" + endif + + # Check PLATFORM_EXPANSION value matches FULL_PLATFORM bits + ifneq ($(PLATFORM_EXPANSION),) + ifneq ($(PLATFORM_EXPANSION),$(PLATFORM_EXPANSION_PART)) + $(error "FULL_PLATFORM was set to '$(FULL_PLATFORM)', but PLATFORM_EXPANSION was set to '$(PLATFORM_EXPANSION)'.") + endif + else + PLATFORM_EXPANSION="$(PLATFORM_EXPANSION_PART)" + endif +endif +PLATFORM ?= $(DEFAULT_PLATFORM) +PLATFORM_EXPANSION ?= $(DEFAULT_PLATFORM_EXPANSION) + +ifeq ($(PLATFORM),) + $(error "Internal error: PLATFORM not set.") +endif +export PLATFORM +ifeq ($(PLATFORM_EXPANSION),) +FULL_PLATFORM = $(PLATFORM) +else +FULL_PLATFORM = $(PLATFORM).$(PLATFORM_EXPANSION) +LITEX_EXTRA_CMDLINE += -Ot expansion $(PLATFORM_EXPANSION) endif -export TARGET +# The soft CPU core to use inside the FPGA it is made up of CPU.VARIANT. DEFAULT_CPU = lm32 DEFAULT_CPU_VARIANT = +ifneq ($(FULL_CPU),) + CPU_PART := $(shell echo $(FULL_CPU) | sed -e's/\..\+$$//') + CPU_VARIANT_PART := $(shell echo $(FULL_CPU) | sed -e's/^[^.]\+\.//') + + # Check CPU value matches FULL_CPU bits + ifneq ($(CPU),) + ifneq ($(CPU),$(CPU_PART)) + $(error "FULL_CPU was set to '$(FULL_CPU)' ($(CPU_PART)), but CPU was set to '$(CPU)'.") + endif + else + CPU="$(CPU_PART)" + endif + + # Check CPU_VARIANT value matches FULL_CPU bits + ifneq ($(CPU_VARIANT),) + ifneq ($(CPU_VARIANT),$(CPU_VARIANT_PART)) + $(error "FULL_CPU was set to '$(FULL_CPU)', but CPU_VARIANT was set to '$(CPU_VARIANT)'.") + endif + else + CPU_VARIANT="$(CPU_VARIANT_PART)" + endif +endif + CPU ?= $(DEFAULT_CPU) CPU_VARIANT ?= $(DEFAULT_CPU_VARIANT) + ifeq ($(CPU),) $(error "Internal error: CPU not set.") endif @@ -37,6 +90,14 @@ FULL_CPU = $(CPU).$(CPU_VARIANT) LITEX_EXTRA_CMDLINE += -Ot cpu_variant $(CPU_VARIANT) endif +# Include platform specific targets +include targets/$(PLATFORM)/Makefile.mk +TARGET ?= $(DEFAULT_TARGET) +ifeq ($(TARGET),) + $(error "Internal error: TARGET not set.") +endif +export TARGET + FIRMWARE ?= firmware # We don't use CLANG @@ -50,12 +111,6 @@ ifeq ($(shell [ $(JOBS) -gt 1 ] && echo true),true) export MAKEFLAGS="-j $(JOBS) -l $(JOBS)" endif -ifeq ($(PLATFORM_EXPANSION),) -FULL_PLATFORM = $(PLATFORM) -else -FULL_PLATFORM = $(PLATFORM).$(PLATFORM_EXPANSION) -LITEX_EXTRA_CMDLINE += -Ot expansion $(PLATFORM_EXPANSION) -endif TARGET_BUILD_DIR = build/$(FULL_PLATFORM)_$(TARGET)_$(FULL_CPU)/ GATEWARE_FILEBASE = $(TARGET_BUILD_DIR)/gateware/top @@ -304,7 +359,7 @@ info: fi prompt: - @echo -n "P=$(PLATFORM)" + @echo -n "P=$(FULL_PLATFORM)" @if [ x"$(TARGET)" != x"$(DEFAULT_TARGET)" ]; then echo -n " T=$(TARGET)"; fi @if [ x"$(CPU)" != x"$(DEFAULT_CPU)" ]; then echo -n " C=$(CPU)"; fi @if [ x"$(CPU_VARIANT)" != x"$(DEFAULT_CPU_VARIANT)" ]; then echo -n ".$(CPU_VARIANT)"; fi From 2bcf0d66fe268ed25147d07be11aaecc13896c76 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sun, 31 Dec 2017 11:23:34 +0100 Subject: [PATCH 056/219] travis: Major refactor to enable building Linux. --- .travis.yml | 13 +- .travis/build.sh | 338 +++++++++++------------------------ .travis/download-prebuilt.sh | 65 +++++++ .travis/push-prebuilt.sh | 67 +++++++ .travis/run.inc.sh | 58 ++++++ .travis/setup.sh | 100 ++++++++--- Makefile | 27 +-- scripts/download-env.sh | 24 ++- scripts/enter-env.sh | 8 + scripts/settings.sh | 4 - 10 files changed, 424 insertions(+), 280 deletions(-) create mode 100755 .travis/download-prebuilt.sh create mode 100755 .travis/push-prebuilt.sh create mode 100644 .travis/run.inc.sh diff --git a/.travis.yml b/.travis.yml index 9663097e..a0bde5a1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,14 +25,16 @@ env: global: - HDMI2USB_UDEV_IGNORE=1 - CLEAN_CHECK=1 + - PREBUILT_DIR="/tmp/HDMI2USB-firmware-prebuilt" # Travis reports incorrect the hosts number of processors, override to 2 # cores. - JOBS=2 install: - - export CPU="$C" - - export PLATFORMS="$P" - - export TARGETS="$T" + - export CPUS="$C" && echo "CPUS='$CPUS'" + - export PLATFORMS="$P" && echo "PLATFORMS='$PLATFORMS'" + - export TARGETS="$T" && echo "TARGETS='$TARGETS'" + - export FIRMWARE="$F" && echo "FIRMWARE='$FIRMWARE'" - $PWD/.travis/setup.sh script: @@ -97,6 +99,11 @@ jobs: - stage: Targets - Base env: C=or1k P=pipistrello T="base" + # Linux Targets + #-------------------------------------------- + - stage: Targets - Base + env: C=or1k.linux F=linux P=arty T="net" + #-------------------------------------------- # Video Targets #-------------------------------------------- diff --git a/.travis/build.sh b/.travis/build.sh index 74e072e8..6c9f4839 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -1,19 +1,5 @@ #!/bin/bash -if [ -z "$PLATFORMS" ]; then - if [ -z "$SKIP_PLATFORMS" ]; then - SKIP_PLATFORMS="sim" - fi - if [ -z "$PLATFORM" ]; then - PLATFORMS=$(ls targets/ | grep -v ".py" | grep -v "common" | grep -v "$SKIP_PLATFORMS" | sed -e"s+targets/++") - else - PLATFORMS="$PLATFORM" - fi -fi -echo "Running with PLATFORMS='$PLATFORMS'" - -source scripts/enter-env.sh || exit 1 - # How long to wait for "make gateware" to finish. # Normal LiteX targets should take no longer than 20ish minutes on a modern # machine. We round up to 40mins. @@ -25,31 +11,67 @@ elif [ -x /usr/bin/timelimit ]; then export GATEWARE_TIMEOUT_CMD="/usr/bin/timelimit -T $GATEWARE_KILLOUT -t $GATEWARE_TIMEOUT" fi -ls -l $XILINX_DIR/opt/Xilinx/14.7/ISE_DS/ISE/bin/lin64/xreport -if [ -f $XILINX_DIR/opt/Xilinx/14.7/ISE_DS/ISE/bin/lin64/xreport ]; then - HAVE_XILINX_ISE=1 +# Check for the Xilinx toolchain being downloaded +XILINX_DOWNLOAD_DIR=build/Xilinx/opt/Xilinx +ls -l . +ls -l $XILINX_DOWNLOAD_DIR +if [ -d $XILINX_DOWNLOAD_DIR ]; then + export HAVE_XILINX_TOOLCHAIN=1 else - HAVE_XILINX_ISE=0 + export HAVE_XILINX_TOOLCHAIN=0 fi +GIT_REVISION=$TRAVIS_BRANCH/$(git describe) +ORIG_COMMITTER_NAME=$(git log -1 --pretty=%an) +ORIG_COMMITTER_EMAIL=$(git log -1 --pretty=%ae) + set +x set -e +FILELIST='find | sort | grep -v "__pycache__" | grep -v "conda"' + function build() { - export PLATFORM=$1 + export FULL_PLATFORM=$1 export TARGET=$2 - export CPU=$3 + export FULL_CPU=$3 + + if [ x"$4" != x"" ]; then + FIRMWARE=$4 + else + unset $FIRMWARE + fi + export FIRMWARE - if [ -z "$PLATFORM" -o -z "$TARGET" -o -z "$CPU" ]; then - echo "usage: build PLATFORM TARGET CPU" - echo " got: build '$PLATFORM' '$TARGET' '$CPU'" + if [ -z "$FULL_PLATFORM" -o -z "$TARGET" -o -z "$FULL_CPU" ]; then + echo "usage: build FULL_PLATFORM TARGET FULL_CPU FIRMWARE" + echo " got: build '$FULL_PLATFORM' '$TARGET' '$FULL_CPU' '$FIRMWARE'" return 1 fi + ( + # Imports TARGET, PLATFORM, CPU and TARGET_BUILD_DIR from Makefile + source scripts/enter-env.sh || exit 1 + echo "" + echo "" + echo "" + echo "- make info" + echo "---------------------------------------------" + make info + echo "=============================================" + + echo "" + echo "" + echo "" + echo "- make clean" + echo "---------------------------------------------" + make clean + echo "=============================================" + # Create "clean" file list before build - find | sort | grep -v "__pycache__" > /tmp/filelist.before + $FILELIST > /tmp/filelist.before + + TITLE="$FULL_PLATFORM $TARGET $FULL_CPU $FIRMWARE" - export TARGET_BUILD_DIR=$PWD/build/${PLATFORM}_${TARGET}_${CPU} export LOGFILE=$TARGET_BUILD_DIR/output.$(date +%Y%m%d-%H%M%S).log echo "Using logfile $LOGFILE" echo "" @@ -64,11 +86,11 @@ function build() { echo "" echo "" echo "=============================================" - echo "- $PLATFORM $TARGET $CPU" + echo "- $TITLE" echo "=============================================" # Output the commands available to make it easier to debug. echo "" - echo "- make help ($PLATFORM $TARGET $CPU)" + echo "- make help ($TITLE)" echo "---------------------------------------------" make help echo "=============================================" @@ -76,9 +98,9 @@ function build() { echo "" echo "" echo "" - echo "- make test ($PLATFORM $TARGET $CPU)" + echo "- make test ($TITLE)" echo "---------------------------------------------" - make test || return 1 + make test || exit 1 echo "=============================================" # We build the firmware first as it is very quick to build and @@ -87,9 +109,9 @@ function build() { echo "" echo "" echo "" - echo "- make firmware ($PLATFORM $TARGET $CPU) (prerun)" + echo "- make firmware check ($TITLE)" echo "---------------------------------------------" - make -j4 firmware || return 1 + make FIRMWARE=firmware firmware || exit 1 echo "- Firmware version data" echo "---------------------------------------------" VERSION_DATA="$(find $TARGET_BUILD_DIR -name version_data.c)" @@ -100,12 +122,12 @@ function build() { if grep -q -- "??" $VERSION_DATA; then echo "Repository had unknown files, failing to build!" -# return 1 + exit 1 fi if grep -q -- "-dirty" $VERSION_DATA; then echo "Repository was dirty, failing to build!" -# return 1 + exit 1 fi fi echo "=============================================" @@ -117,7 +139,7 @@ function build() { echo "" echo "" echo "" - echo "- make firmware-clean ($PLATFORM $TARGET $CPU) (prerun)" + echo "- make firmware-clean ($TITLE) (prerun)" echo "---------------------------------------------" make firmware-clean echo "=============================================" @@ -125,9 +147,9 @@ function build() { echo "" echo "" echo "" - echo "- make gateware ($PLATFORM $TARGET $CPU)" + echo "- make gateware ($TITLE)" echo "---------------------------------------------" - if [ $HAVE_XILINX_ISE -eq 0 ]; then + if [ $HAVE_XILINX_TOOLCHAIN -eq 0 ]; then echo "Skipping gateware" make gateware-fake else @@ -136,24 +158,46 @@ function build() { # FIXME: Should this be in the Makefile instead? echo "Using $GATEWARE_TIMEOUT timeout (with '$GATEWARE_TIMEOUT_CMD')." export FILTER=$PWD/.travis/run-make-gateware-filter.py - $GATEWARE_TIMEOUT_CMD time --verbose make gateware || return 1 + $GATEWARE_TIMEOUT_CMD time --verbose make gateware || exit 1 fi echo "=============================================" - echo "" - echo "" - echo "" - echo "- make firmware ($PLATFORM $TARGET $CPU)" - echo "---------------------------------------------" - make -j4 firmware || return 1 - echo "=============================================" + case "$FIRMWARE" in + linux) + echo "" + echo "" + echo "" + echo "- make firmware ($TITLE - $FIRMWARE)" + echo "---------------------------------------------" + ./scripts/build-linux.sh || exit 1 + echo "=============================================" + ;; + micropython) + echo "" + echo "" + echo "" + echo "- make firmware ($TITLE - $FIRMWARE)" + echo "---------------------------------------------" + ./scripts/build-micropython.sh || exit 1 + echo "=============================================" + ;; + *) + echo "" + echo "" + echo "" + echo "- make firmware ($TITLE - $FIRMWARE)" + echo "---------------------------------------------" + make firmware || exit 1 + echo "=============================================" + ;; + esac echo "" echo "" echo "" - echo "- make image ($PLATFORM $TARGET $CPU)" + echo "- make image ($TITLE)" echo "---------------------------------------------" - make image || true + make image echo "=============================================" if [ ! -z "$PROGS" ]; then @@ -161,7 +205,7 @@ function build() { echo "" echo "" echo "" - echo "- make load ($PROG $PLATFORM $TARGET $CPU)" + echo "- make load ($PROG $TITLE)" echo "---------------------------------------------" # Allow the programming to fail. PROG=$PROG make load || true @@ -170,17 +214,16 @@ function build() { # Save the resulting binaries into the prebuilt repo. The gateware # should always exist, but others might not. - if [ ! -z "$PREBUILT_DIR" ]; then - COPY_DEST="$PREBUILT_DIR/archive/$GIT_REVISION/$PLATFORM/$TARGET/$CPU/" + if [ -d "$PREBUILT_DIR" ]; then + COPY_DEST="$PREBUILT_DIR/archive/$GIT_REVISION/$FULL_PLATFORM/$TARGET/$FULL_CPU/" + + mkdir -p $COPY_DEST echo "" echo "" echo "" - echo "- Adding built files to github.com/$PREBUILT_REPO_OWNER/$PREBUILT_REPO" + echo "- Adding built files to $(cd $COPY_DEST; git remote get-url origin)" echo "---------------------------------------------" - mkdir -p $COPY_DEST - - declare -a SAVE declare -a SAVE SAVE+="image*.bin" # Combined binary include gateware+bios+firmware # Gateware output for using @@ -226,10 +269,12 @@ function build() { export GIT_COMMITTER_NAME="TimVideos Robot" echo "" ( - cd $PREBUILT_DIR + cd $COPY_DEST + echo $PWD + ls -l -a . git add -A . git commit -a \ - -m "Travis build #$TRAVIS_BUILD_NUMBER of $GIT_REVISION for PLATFORM=$PLATFORM TARGET=$TARGET CPU=$CPU" \ + -m "Travis build #$TRAVIS_BUILD_NUMBER of $GIT_REVISION for PLATFORM=$FULL_PLATFORM TARGET=$TARGET CPU=$FULL_CPU FIRMWARE=$FIRMWARE" \ -m "" \ -m "From https://github.com/$TRAVIS_REPO_SLUG/tree/$TRAVIS_COMMIT" \ -m "$TRAVIS_COMIT_MESSAGE" @@ -253,13 +298,13 @@ function build() { echo "" echo "" echo "" - echo "- make clean ($PLATFORM $TARGET)" + echo "- make clean ($FULL_PLATFORM $TARGET)" echo "---------------------------------------------" - make clean || return 1 + make clean || exit 1 echo "=============================================" # Check that make clean didn't leave anything behind - find | sort | grep -v "__pycache__" > /tmp/filelist.after + $FILELIST > /tmp/filelist.after echo "" echo "" echo "" @@ -271,183 +316,14 @@ function build() { echo "=============================================" cat /tmp/filelist.diff echo "=============================================" - return 1 + exit 1 fi fi - return 0 + ); return $? } -declare -a SUCCESSES -declare -a FAILURES - - -# Clone prebuilt repo to copy results into -if [ ! -z "$TRAVIS_PULL_REQUEST" -a "$TRAVIS_PULL_REQUEST" != "false" ]; then - # Don't do prebuilt for a pull request. - echo "" - echo "" - echo "" - echo "- Pull request, so no prebuilt pushing." -elif [ -z "$GH_TOKEN" ]; then - # Only if run by travis display error - if [ ! -z $TRAVIS_BUILD_NUMBER ]; then - echo "" - echo "" - echo "" - echo "- No Github token so unable to copy built files" - fi -elif [ -z "$TRAVIS_BRANCH" ]; then - echo "" - echo "" - echo "" - echo "- No branch name, unable to copy built files" -else - # Look at repo we are running in to determine where to try pushing to if in a fork - PREBUILT_REPO=HDMI2USB-firmware-prebuilt - PREBUILT_REPO_OWNER=$(echo $TRAVIS_REPO_SLUG|awk -F'/' '{print $1}') - GIT_REVISION=$TRAVIS_BRANCH/$(git describe) - ORIG_COMMITTER_NAME=$(git log -1 --pretty=%an) - ORIG_COMMITTER_EMAIL=$(git log -1 --pretty=%ae) - echo "" - echo "" - echo "" - echo "- Uploading built files to github.com/$PREBUILT_REPO_OWNER/$PREBUILT_REPO" - echo "---------------------------------------------" - export PREBUILT_DIR="/tmp/HDMI2USB-firmware-prebuilt" - ( - # Do a sparse, shallow checkout to keep disk space usage down. - mkdir -p $PREBUILT_DIR - cd $PREBUILT_DIR - git init > /dev/null - git config core.sparseCheckout true - git remote add origin https://$GH_TOKEN@github.com/$PREBUILT_REPO_OWNER/${PREBUILT_REPO}.git - cat > .git/info/sparse-checkout < /dev/null 2>&1 ; then - echo "Push success!" - else - echo "Push failed :-(" - fi - done - echo - echo "Push finished!" - ) -fi +export FUNC=build +. .travis/run.inc.sh echo "" echo "" diff --git a/.travis/download-prebuilt.sh b/.travis/download-prebuilt.sh new file mode 100755 index 00000000..41d4131a --- /dev/null +++ b/.travis/download-prebuilt.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +# Clone prebuilt repo to copy results into +if [ ! -z "$TRAVIS_PULL_REQUEST" -a "$TRAVIS_PULL_REQUEST" != "false" ]; then + # Don't do prebuilt for a pull request. + echo "" + echo "" + echo "" + echo "- Pull request, so no prebuilt pushing." +elif [ -z "$GH_TOKEN" ]; then + # Only if run by travis display error + if [ ! -z $TRAVIS_BUILD_NUMBER ]; then + echo "" + echo "" + echo "" + echo "- No Github token so unable to copy built files" + fi +elif [ -z "$TRAVIS_BRANCH" ]; then + echo "" + echo "" + echo "" + echo "- No branch name, unable to copy built files" +elif [ ! -z "$PREBUILT_DIR" ]; then + # Look at repo we are running in to determine where to try pushing to if in a fork + PREBUILT_REPO=HDMI2USB-firmware-prebuilt + PREBUILT_REPO_OWNER=$(echo $TRAVIS_REPO_SLUG|awk -F'/' '{print $1}') + echo "" + echo "" + echo "" + echo "- Download built files from github.com/$PREBUILT_REPO_OWNER/$PREBUILT_REPO (to upload results)" + echo "---------------------------------------------" + ( + # Do a sparse, shallow checkout to keep disk space usage down. + mkdir -p $PREBUILT_DIR + cd $PREBUILT_DIR + git init > /dev/null + git config core.sparseCheckout true + ( + git remote add origin https://$GH_TOKEN@github.com/$PREBUILT_REPO_OWNER/${PREBUILT_REPO}.git + ) > /dev/null + cat > .git/info/sparse-checkout < /dev/null 2>&1 ; then + echo "Push success!" + else + echo "Push failed :-(" + fi + done + echo + echo "Push finished!" + ) +fi diff --git a/.travis/run.inc.sh b/.travis/run.inc.sh new file mode 100644 index 00000000..588b517e --- /dev/null +++ b/.travis/run.inc.sh @@ -0,0 +1,58 @@ +if [ -z "$PLATFORMS" ]; then + if [ -z "$SKIP_PLATFORMS" ]; then + SKIP_PLATFORMS="sim" + fi + if [ -z "$PLATFORM" ]; then + PLATFORMS=$(ls targets/ | grep -v ".py" | grep -v "common" | grep -v "$SKIP_PLATFORMS" | sed -e"s+targets/++") + else + PLATFORMS="$PLATFORM" + fi +fi +echo "Running with PLATFORMS='$PLATFORMS'" + +if [ -z "$CPUS" ]; then + if [ -z "$CPU" ]; then + #CPUS="lm32 or1k riscv32" + CPUS="lm32 or1k" + else + CPUS="$CPU" + unset CPU + fi +fi + +declare -a SUCCESSES +declare -a FAILURES + +START_TARGET="$TARGET" +START_TARGETS="$TARGETS" +for FULL_PLATFORM in $PLATFORMS; do + if [ -z "$START_TARGETS" ]; then + if [ -z "$SKIP_TARGETS" ]; then + SKIP_TARGETS="__" + fi + if [ ! -z "$START_TARGETS" ]; then + TARGETS="$START_TARGETS" + elif [ ! -z "$START_TARGET" ]; then + TARGETS="$START_TARGET" + else + TARGETS=$(ls targets/${FULL_PLATFORM}/*.py | grep -v "__" | grep -v "$SKIP_TARGETS" | sed -e"s+targets/${FULL_PLATFORM}/++" -e"s/.py//") + fi + fi + + echo "" + echo "" + echo "" + echo "Running with TARGETS='$TARGETS'" + for TARGET in $TARGETS; do + echo "Running with CPUS='$CPUS'" + for FULL_CPU in $CPUS; do + $FUNC $FULL_PLATFORM $TARGET $FULL_CPU $FIRMWARE && : + RETURN=$? + if [ "$RETURN" -eq 0 ]; then + SUCCESSES+=("$FULL_PLATFORM+$TARGET+$FULL_CPU+$FIRMWARE") + else + FAILURES+=("$FULL_PLATFORM+$TARGET+$FULL_CPU+$FIRMWARE") + fi + done + done +done diff --git a/.travis/setup.sh b/.travis/setup.sh index 4b3dff5b..c7c2be2a 100755 --- a/.travis/setup.sh +++ b/.travis/setup.sh @@ -110,38 +110,94 @@ DF_AFTER_GIT="$(($(stat -f --format="%a*%S" .)))" awk "BEGIN {printf \"Git is using %.2f megabytes\n\",($DF_LAST-$DF_AFTER_GIT)/1024/1024}" DF_LAST="$DF_AFTER_GIT" +function setup() { + export FULL_PLATFORM=$1 + export TARGET=$2 + export FULL_CPU=$3 + + if [ x$4 != x ]; then + FIRMWARE=$4 + else + unset $FIRMWARE + fi + + if [ -z "$FULL_PLATFORM" -o -z "$TARGET" -o -z "$FULL_CPU" ]; then + echo "usage: setup FULL_PLATFORM TARGET FULL_CPU FIRMWARE" + echo " got: setup '$FULL_PLATFORM' '$TARGET' '$FULL_CPU' '$FIRMWARE'" + return 1 + fi + + DF_BEFORE_DOWNLOAD="$(($(stat -f --format="%a*%S" .)))" + ( + echo "" + echo "=============================================" + echo "" + echo "" + # Run the script once to check it works + time scripts/download-env.sh || exit 1 + echo "" + echo "" + echo "=============================================" + echo "" + echo "" + # Run the script again to check it doesn't break things + time scripts/download-env.sh || exit 1 + echo "" + echo "" + echo "=============================================" + + echo "" + echo "" + echo "" + echo "- Disk space free (after downloading environment)" + echo "---------------------------------------------" + df -h + echo "" + DF_AFTER_DOWNLOAD="$(($(stat -f --format="%a*%S" .)))" + awk "BEGIN {printf \"Environment is using %.2f megabytes\n\",($DF_BEFORE_DOWNLOAD-$DF_AFTER_DOWNLOAD)/1024/1024}" + + echo "=============================================" + echo "=============================================" + echo "" + echo "" + set +x + set +e + source scripts/enter-env.sh || exit 1 + ); return $? +} + +export FUNC=setup +source .travis/run.inc.sh + echo "" -echo "=============================================" -echo "" -echo "" -# Run the script once to check it works -time scripts/download-env.sh echo "" echo "" +echo "The following setups succeeded" echo "=============================================" + +for S in ${SUCCESSES[@]}; do + echo $S | sed -e's/+/ /g' +done echo "" echo "" -# Run the script again to check it doesn't break things -time scripts/download-env.sh -echo "" echo "" +echo "The following setups failed!" echo "=============================================" +for F in ${FAILURES[@]}; do + echo $F | sed -e's/+/ /g' +done + echo "" echo "" echo "" -echo "- Disk space free (after downloading environment)" -echo "---------------------------------------------" -df -h -echo "" -DF_AFTER_DOWNLOAD="$(($(stat -f --format="%a*%S" .)))" -awk "BEGIN {printf \"Environment is using %.2f megabytes\n\",($DF_LAST-$DF_AFTER_DOWNLOAD)/1024/1024}" -DF_LAST="$DF_AFTER_DOWNLOAD" - -echo "=============================================" echo "=============================================" -echo "" -echo "" -set +x -set +e -source scripts/enter-env.sh + +if [ ${#FAILURES[@]} -ne 0 ]; then + echo "One or more setups failed :(" + exit 1 +else + echo "All setups succeeded! \\o/" +fi + +./.travis/download-prebuilt.sh diff --git a/Makefile b/Makefile index 71436b6a..8090f720 100644 --- a/Makefile +++ b/Makefile @@ -7,16 +7,15 @@ endif PYTHON ?= python export PYTHON +SPLIT_REGEX := ^\([^.]*\)\.\?\(.*\)$$ + # The platform to run on. It is made up of FPGA_MAIN_BOARD.EXPANSION_BOARD DEFAULT_PLATFORM = opsis DEFAULT_PLATFORM_EXPANSION = -ifeq ($(PLATFORM),) - $(error "PLATFORM not set, please set it.") -endif ifneq ($(FULL_PLATFORM),) - PLATFORM_PART := $(shell echo $(FULL_PLATFORM) | sed -e's/\..\+$$//') - PLATFORM_EXPANSION_PART := $(shell echo $(FULL_PLATFORM) | sed -e's/^[^.]\+\.//') + PLATFORM_PART := $(shell echo $(FULL_PLATFORM) | sed -e's/$(SPLIT_REGEX)/\1/') + PLATFORM_EXPANSION_PART := $(shell echo $(FULL_PLATFORM) | sed -e's/$(SPLIT_REGEX)/\2/') # Check PLATFORM value matches FULL_PLATFORM bits ifneq ($(PLATFORM),) @@ -24,7 +23,7 @@ ifneq ($(FULL_PLATFORM),) $(error "FULL_PLATFORM was set to '$(FULL_PLATFORM)' ($(PLATFORM_PART)), but PLATFORM was set to '$(PLATFORM)'.") endif else - PLATFORM="$(PLATFORM_PART)" + PLATFORM=$(PLATFORM_PART) endif # Check PLATFORM_EXPANSION value matches FULL_PLATFORM bits @@ -33,7 +32,7 @@ ifneq ($(FULL_PLATFORM),) $(error "FULL_PLATFORM was set to '$(FULL_PLATFORM)', but PLATFORM_EXPANSION was set to '$(PLATFORM_EXPANSION)'.") endif else - PLATFORM_EXPANSION="$(PLATFORM_EXPANSION_PART)" + PLATFORM_EXPANSION=$(PLATFORM_EXPANSION_PART) endif endif PLATFORM ?= $(DEFAULT_PLATFORM) @@ -54,8 +53,8 @@ endif DEFAULT_CPU = lm32 DEFAULT_CPU_VARIANT = ifneq ($(FULL_CPU),) - CPU_PART := $(shell echo $(FULL_CPU) | sed -e's/\..\+$$//') - CPU_VARIANT_PART := $(shell echo $(FULL_CPU) | sed -e's/^[^.]\+\.//') + CPU_PART := $(shell echo $(FULL_CPU) | sed -e's/$(SPLIT_REGEX)/\1/') + CPU_VARIANT_PART := $(shell echo $(FULL_CPU) | sed -e's/$(SPLIT_REGEX)/\2/') # Check CPU value matches FULL_CPU bits ifneq ($(CPU),) @@ -63,7 +62,7 @@ ifneq ($(FULL_CPU),) $(error "FULL_CPU was set to '$(FULL_CPU)' ($(CPU_PART)), but CPU was set to '$(CPU)'.") endif else - CPU="$(CPU_PART)" + CPU=$(CPU_PART) endif # Check CPU_VARIANT value matches FULL_CPU bits @@ -72,7 +71,7 @@ ifneq ($(FULL_CPU),) $(error "FULL_CPU was set to '$(FULL_CPU)', but CPU_VARIANT was set to '$(CPU_VARIANT)'.") endif else - CPU_VARIANT="$(CPU_VARIANT_PART)" + CPU_VARIANT=$(CPU_VARIANT_PART) endif endif @@ -99,6 +98,10 @@ endif export TARGET FIRMWARE ?= firmware +ifeq ($(FIRMWARE),) + FIRMWARE = firmware +endif +export FIRMWARE # We don't use CLANG CLANG = 0 @@ -439,7 +442,7 @@ reset: reset-$(PLATFORM) @true clean: - rm build/cache.mk + rm -f build/cache.mk rm -rf $(TARGET_BUILD_DIR) py3clean . || rm -rf $$(find -name __pycache__) diff --git a/scripts/download-env.sh b/scripts/download-env.sh index 938d9a43..141ceeef 100755 --- a/scripts/download-env.sh +++ b/scripts/download-env.sh @@ -196,10 +196,18 @@ export PATH=$CONDA_DIR/bin:$PATH:/sbin conda config --add channels timvideos ) +eval $(cd $TOP_DIR; export HDMI2USB_ENV=1; make env || return 1) || exit 1 +( + cd $TOP_DIR + export HDMI2USB_ENV=1 + make info || return 1 + echo +) || exit 1 + # Check the Python version echo echo "Installing python3.5" -conda install python=3.5 +conda install -y $CONDA_FLAGS python=3.5 check_version python 3.5 echo "python ==3.5.4" > $CONDA_DIR/conda-meta/pinned # Make sure it stays at version 3.5 @@ -231,31 +239,31 @@ fi # flterm echo echo "Installing flterm (serial terminal tool)" -conda install flterm +conda install -y $CONDA_FLAGS flterm check_exists flterm # binutils for the target echo echo "Installing binutils for ${CPU} (assembler, linker, and other tools)" -conda install binutils-${CPU}-elf=$BINUTILS_VERSION +conda install -y $CONDA_FLAGS binutils-${CPU}-elf=$BINUTILS_VERSION check_version ${CPU}-elf-ld $BINUTILS_VERSION # gcc for the target echo echo "Installing gcc for ${CPU} ('bare metal' C cross compiler)" -conda install gcc-${CPU}-elf-nostdc=$GCC_VERSION +conda install -y $CONDA_FLAGS gcc-${CPU}-elf-nostdc=$GCC_VERSION check_version ${CPU}-elf-gcc $GCC_VERSION # gdb for the target #echo #echo "Installing gdb for ${CPU} (debugger)" -#conda install gdb-${CPU}-elf=$GDB_VERSION +#conda install -y $CONDA_FLAGS gdb-${CPU}-elf=$GDB_VERSION #check_version ${CPU}-elf-gdb $GDB_VERSION # openocd for programming via Cypress FX2 echo echo "Installing openocd (jtag tool for programming and debug)" -conda install openocd=$OPENOCD_VERSION +conda install -y $CONDA_FLAGS openocd=$OPENOCD_VERSION check_version openocd $OPENOCD_VERSION echo "" @@ -264,13 +272,13 @@ echo "---------------------------------------" # pyserial for communicating via uarts echo echo "Installing pyserial (python module)" -conda install pyserial +conda install -y $CONDA_FLAGS pyserial check_import serial # ipython for interactive debugging echo echo "Installing ipython (python module)" -conda install ipython +conda install -y $CONDA_FLAGS ipython check_import IPython # progressbar2 for progress bars diff --git a/scripts/enter-env.sh b/scripts/enter-env.sh index 11275a49..ea93a893 100755 --- a/scripts/enter-env.sh +++ b/scripts/enter-env.sh @@ -169,6 +169,14 @@ echo "---------------------------------" # Install and setup conda for downloading packages export PATH=$CONDA_DIR/bin:$PATH +eval $(cd $TOP_DIR; export HDMI2USB_ENV=1; make env || return 1) || return 1 +( + cd $TOP_DIR + export HDMI2USB_ENV=1 + make info || return 1 + echo +) || return 1 + # Check the Python version diff --git a/scripts/settings.sh b/scripts/settings.sh index 5eba63e0..54e91497 100644 --- a/scripts/settings.sh +++ b/scripts/settings.sh @@ -1,10 +1,6 @@ #!/bin/bash # Settings for the download-env.sh and setup-env.sh scripts - -export PLATFORM=${PLATFORM:-opsis} -export CPU=${CPU:-lm32} - BUILD_DIR=$TOP_DIR/build THIRD_DIR=$TOP_DIR/third_party CONDA_DIR=$BUILD_DIR/conda From 14b0ffea6fab2683877b3f86914466696f1fe798 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Wed, 3 Jan 2018 13:55:25 +0000 Subject: [PATCH 057/219] travis: Adding back prebuilt pushing. --- .travis/build.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis/build.sh b/.travis/build.sh index 6c9f4839..8f98281e 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -359,6 +359,8 @@ for F in ${FAILURES[@]}; do echo $F | sed -e's/+/ /g' done +. ./.travis/push-prebuilt.sh + echo "" echo "" echo "" From e17337c9c050d462796bd395cde2fe7523671570 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Wed, 3 Jan 2018 14:42:42 +0000 Subject: [PATCH 058/219] travis: Fixing findlist for clean check. --- .travis/build.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.travis/build.sh b/.travis/build.sh index 8f98281e..a22dfb45 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -28,7 +28,9 @@ ORIG_COMMITTER_EMAIL=$(git log -1 --pretty=%ae) set +x set -e -FILELIST='find | sort | grep -v "__pycache__" | grep -v "conda"' +function filelist() { + find | sort | grep -v "__pycache__" | grep -v "conda" +} function build() { export FULL_PLATFORM=$1 @@ -68,7 +70,7 @@ function build() { echo "=============================================" # Create "clean" file list before build - $FILELIST > /tmp/filelist.before + filelist > /tmp/filelist.before TITLE="$FULL_PLATFORM $TARGET $FULL_CPU $FIRMWARE" @@ -304,7 +306,7 @@ function build() { echo "=============================================" # Check that make clean didn't leave anything behind - $FILELIST > /tmp/filelist.after + filelist > /tmp/filelist.after echo "" echo "" echo "" From fe23e8562e3306ce5be2d1a32424cc3575456f31 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Wed, 3 Jan 2018 16:03:31 +0000 Subject: [PATCH 059/219] travis: Ignore third_party in file listing. --- .travis/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis/build.sh b/.travis/build.sh index a22dfb45..55a6f866 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -29,7 +29,7 @@ set +x set -e function filelist() { - find | sort | grep -v "__pycache__" | grep -v "conda" + find | sort | grep -v "__pycache__" | grep -v "conda" | grep -v third_party } function build() { From b0d0b408b992fbc0f2fb82aca3f64c696f4f9e1a Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Wed, 3 Jan 2018 22:59:37 +0000 Subject: [PATCH 060/219] Makefile: Use which to find aftpd or in.tftpd --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 8090f720..efe4aa3b 100644 --- a/Makefile +++ b/Makefile @@ -308,10 +308,10 @@ tftpd_stop: tftpd_start: mkdir -p $(TFTPD_DIR) sudo true - @if command -v sudo atftpd >/dev/null ; then \ + @if sudo which atftpd >/dev/null ; then \ echo "Starting aftpd"; \ - sudo atftpd --verbose --bind-address $(TFTP_IPRANGE).100 --daemon --logfile /dev/stdout --no-fork --user $(shell whoami) --group $(shell whoami) $(TFTPD_DIR) & \ - elif command -v sudo in.tftpd >/dev/null; then \ + sudo atftpd --verbose --bind-address $(TFTP_IPRANGE).100 --daemon --logfile /dev/stdout --no-fork --user $(shell whoami) $(TFTPD_DIR) & \ + elif sudo which in.tftpd >/dev/null; then \ echo "Starting in.tftpd"; \ sudo in.tftpd --verbose --listen --address $(TFTP_IPRANGE).100 --user $(shell whoami) -s $(TFTPD_DIR) & \ else \ From d5cee1b7961bf7c796c103bfbe9d4b1e8d162dd1 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Thu, 4 Jan 2018 00:29:57 +0000 Subject: [PATCH 061/219] scripts: Export TFTP_IPRANGE value and allow multiple qemu modes. * export QEMU_NETWORK=tap - Use tun/tap interface (requires root). * export QEMU_NETWORK=user - Use QEMU user networking (runs as a user). --- Makefile | 3 +++ scripts/build-qemu.sh | 59 +++++++++++++++++++++++++++++++------------ 2 files changed, 46 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index efe4aa3b..6cd2bcaf 100644 --- a/Makefile +++ b/Makefile @@ -352,6 +352,9 @@ env: @echo "export GATEWARE_FILEBASE='$(GATEWARE_FILEBASE)'" @echo "export FIRMWARE_FILEBASE='$(FIRMWARE_FILEBASE)'" @echo "export BIOS_FILE='$(BIOS_FILE)'" + @# Network settings + @echo "export TFTP_IPRANGE='$(TFTP_IPRANGE)'" + @echo "export TFTPD_DIR='$(TFTPD_DIR)'" info: @echo " Platform: $(FULL_PLATFORM)" diff --git a/scripts/build-qemu.sh b/scripts/build-qemu.sh index 4da31bb6..6daa67b1 100755 --- a/scripts/build-qemu.sh +++ b/scripts/build-qemu.sh @@ -113,25 +113,52 @@ fi # Ethernet if grep -q ETHMAC_BASE $TARGET_BUILD_DIR/software/include/generated/csr.h; then - # Make qemu emulate a network device - EXTRA_ARGS+=("-net nic") + QEMU_NETWORK=${QEMU_NETWORK:-tap} + case $QEMU_NETWORK in + tap) + if [ ! -e /dev/net/tap0 ]; then + echo "Need to create and bring up a tun device, needing sudo..." + sudo true + sudo mknod /dev/net/tap0 c 10 200 + if sudo which openvpn > /dev/null; then + sudo openvpn --mktun --dev tap0 + elif sudo which tunctl > /dev/null; then + sudo tunctl -t tap0 -u $(whoami) + else + echo "Unable to find tool to create tap0 device!" + exit 1 + fi + sudo chown $(whoami) /dev/net/tap0 + sudo ifconfig tap0 $TFTP_IPRANGE.100 up + make tftpd_start + fi + EXTRA_ARGS+=("-net nic -net tap,ifname=tap0,script=no,downscript=no") + ;; + + user) + # Make qemu emulate a network device + EXTRA_ARGS+=("-net nic") + # Use the userspace network support. QEMU will pretend to be a + # machine a $TFTP_IPRANGE.100. Any connections to that IP will + # automatically be forwarded to the real localhost. + # + # Connections to real localhost on port 2223, will be + # forwarded to the expected guest ip ($TFTP_IPRANGE.50) on port + # 23 (telnet). + EXTRA_ARGS+=("-net user,net=$TFTP_IPRANGE.0/24,host=$TFTP_IPRANGE.100,dhcpstart=$TFTP_IPRANGE.50,tftp=$TFTPD_DIR,hostfwd=tcp::2223-:23") + + # Make debugging the userspace networking easier, dump all + # packets to a file. + # FIXME: Make this optional. + EXTRA_ARGS+=("-net dump,file=/tmp/data.pcap") + ;; + *) + echo "Unknown QEMU_NETWORK mode '$QEMU_NETWORK'" + ;; + esac # Build/copy the image into the TFTP directory. make tftp - - # Use the userspace network support. QEMU will pretend to be a - # machine a $IPRANGE.100. Any connections to that IP will - # automatically be forwarded to the real localhost. - # - # Connections to real localhost on port 2223, will be - # forwarded to the expected guest ip ($IPRANGE.50) on port - # 23 (telnet). - EXTRA_ARGS+=("-net user,net=$IPRANGE.0/24,host=$IPRANGE.100,dhcpstart=$IPRANGE.50,tftp=$TOP_DIR/build/tftpd,hostfwd=tcp::2223-:23") - - # Make debugging the userspace networking easier, dump all - # packets to a file. - # FIXME: Make this optional. - EXTRA_ARGS+=("-net dump,file=/tmp/data.pcap") fi # Allow gdb connections From 7481b009d2754ad2c816f0289d4dd2f95fee5503 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Thu, 4 Jan 2018 01:11:45 +0000 Subject: [PATCH 062/219] Makefile: Split Makefile added extra from user provided. --- Makefile | 8 +++++--- scripts/build-micropython.sh | 5 +++-- scripts/build-qemu.sh | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 6cd2bcaf..33e00659 100644 --- a/Makefile +++ b/Makefile @@ -46,7 +46,7 @@ ifeq ($(PLATFORM_EXPANSION),) FULL_PLATFORM = $(PLATFORM) else FULL_PLATFORM = $(PLATFORM).$(PLATFORM_EXPANSION) -LITEX_EXTRA_CMDLINE += -Ot expansion $(PLATFORM_EXPANSION) +MAKE_LITEX_EXTRA_CMDLINE += -Ot expansion $(PLATFORM_EXPANSION) endif # The soft CPU core to use inside the FPGA it is made up of CPU.VARIANT. @@ -86,7 +86,7 @@ ifeq ($(CPU_VARIANT),) FULL_CPU = $(CPU) else FULL_CPU = $(CPU).$(CPU_VARIANT) -LITEX_EXTRA_CMDLINE += -Ot cpu_variant $(CPU_VARIANT) +MAKE_LITEX_EXTRA_CMDLINE += -Ot cpu_variant $(CPU_VARIANT) endif # Include platform specific targets @@ -140,6 +140,7 @@ MAKE_CMD=\ --iprange=$(TFTP_IPRANGE) \ $(MISOC_EXTRA_CMDLINE) \ $(LITEX_EXTRA_CMDLINE) \ + $(MAKE_LITEX_EXTRA_CMDLINE) \ # We use the special PIPESTATUS which is bash only below. SHELL := /bin/bash @@ -171,7 +172,7 @@ endif $(IMAGE_FILE): $(GATEWARE_FILEBASE).bin $(BIOS_FILE) $(FIRMWARE_FILEBASE).fbi $(PYTHON) mkimage.py \ - $(MISOC_EXTRA_CMDLINE) $(LITEX_EXTRA_CMDLINE) \ + $(MISOC_EXTRA_CMDLINE) $(LITEX_EXTRA_CMDLINE) $(MAKE_LITEX_EXTRA_CMDLINE) \ --override-gateware=$(GATEWARE_FILEBASE).bin \ --override-bios=$(BIOS_FILE) \ $(OVERRIDE_FIRMWARE) \ @@ -343,6 +344,7 @@ env: @echo "export TFTP_DIR='$(TFTPD_DIR)'" @echo "export MISOC_EXTRA_CMDLINE='$(MISOC_EXTRA_CMDLINE)'" @echo "export LITEX_EXTRA_CMDLINE='$(LITEX_EXTRA_CMDLINE)'" + @echo "export MAKE_LITEX_EXTRA_CMDLINE='$(MAKE_LITEX_EXTRA_CMDLINE)'" @# Hardcoded values @echo "export CLANG=$(CLANG)" @echo "export PYTHONHASHSEED=$(PYTHONHASHSEED)" diff --git a/scripts/build-micropython.sh b/scripts/build-micropython.sh index fad00228..cea8c2dc 100755 --- a/scripts/build-micropython.sh +++ b/scripts/build-micropython.sh @@ -75,5 +75,6 @@ make V=1 -C $(realpath ../../../../third_party/micropython/litex/) -j$JOBS cd $OLD_DIR # Generate a firmware image suitable for flashing. -python -m litex.soc.tools.mkmscimg -f $TARGET_MPY_BUILD_DIR/firmware.bin -o $TARGET_MPY_BUILD_DIR/firmware.fbi -/usr/bin/env python mkimage.py $MISOC_EXTRA_CMDLINE $LITEX_EXTRA_CMDLINE --output-file=$TARGET_BUILD_DIR/micropython.bin --override-firmware=$TARGET_MPY_BUILD_DIR/firmware.fbi +#python -m litex.soc.tools.mkmscimg -f $TARGET_MPY_BUILD_DIR/firmware.bin -o $TARGET_MPY_BUILD_DIR/firmware.fbi +#/usr/bin/env python mkimage.py $MISOC_EXTRA_CMDLINE $LITEX_EXTRA_CMDLINE --output-file=$TARGET_BUILD_DIR/micropython.bin --override-firmware=$TARGET_MPY_BUILD_DIR/firmware.fbi +make image diff --git a/scripts/build-qemu.sh b/scripts/build-qemu.sh index 6daa67b1..94f2f680 100755 --- a/scripts/build-qemu.sh +++ b/scripts/build-qemu.sh @@ -92,7 +92,7 @@ if [ ! -d $FIRMWARE_FILEBASE.fbi ]; then fi QEMU_IMAGE_FILE=$IMAGE_FILE.4qemu -/usr/bin/env python mkimage.py $MISOC_EXTRA_CMDLINE $LITEX_EXTRA_CMDLINE --output-file=$QEMU_IMAGE_FILE --override-gateware=none --force-image-size=true $OVERRIDE_FIRMWARE +/usr/bin/env python mkimage.py $MISOC_EXTRA_CMDLINE $LITEX_EXTRA_CMDLINE $MAKE_LITEX_EXTRA_CMDLINE --output-file=$QEMU_IMAGE_FILE --override-gateware=none --force-image-size=true $OVERRIDE_FIRMWARE $TARGET_QEMU_BUILD_DIR/qemu-img convert -f raw $QEMU_IMAGE_FILE -O qcow2 -S 16M $TARGET_BUILD_DIR/qemu.qcow2 # BIOS From 3b7f834f6197eb65dc2c223cb36a769d3bf50aa9 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Thu, 4 Jan 2018 01:12:12 +0000 Subject: [PATCH 063/219] Makefile: Don't export the FULL_XXX values. --- Makefile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Makefile b/Makefile index 33e00659..f6b7bd9f 100644 --- a/Makefile +++ b/Makefile @@ -331,12 +331,10 @@ flash: image-flash env: @echo "export PLATFORM='$(PLATFORM)'" @echo "export PLATFORM_EXPANSION='$(PLATFORM_EXPANSION)'" - @echo "export FULL_PLATFORM='$(FULL_PLATFORM)'" @echo "export TARGET='$(TARGET)'" @echo "export DEFAULT_TARGET='$(DEFAULT_TARGET)'" @echo "export CPU='$(CPU)'" @echo "export CPU_VARIANT='$(CPU_VARIANT)'" - @echo "export FULL_CPU='$(FULL_CPU)'" @echo "export FIRMWARE='$(FIRMWARE)'" @echo "export OVERRIDE_FIRMWARE='$(OVERRIDE_FIRMWARE)'" @echo "export PROG='$(PROG)'" From d6d8af6ab49f9c3f49530d7de40add71f9c8f727 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Thu, 4 Jan 2018 01:12:38 +0000 Subject: [PATCH 064/219] liteeth: Roll back to version before changes. --- third_party/liteeth | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/liteeth b/third_party/liteeth index ccdb85bc..937c2407 160000 --- a/third_party/liteeth +++ b/third_party/liteeth @@ -1 +1 @@ -Subproject commit ccdb85bcb7c6504d49cf8fabfc6fd5ff179c72c2 +Subproject commit 937c2407276371d9f8c1bb19c4ae8e97e581da83 From 65a68f603d6949eab33a9c512b33d84535d4af49 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Thu, 4 Jan 2018 01:32:26 +0000 Subject: [PATCH 065/219] firmware: Put pattern framebuffer at FRAMEBUFFER_OFFSET and everything below that. --- firmware/framebuffer.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/firmware/framebuffer.h b/firmware/framebuffer.h index da4b5701..adbfd595 100644 --- a/firmware/framebuffer.h +++ b/firmware/framebuffer.h @@ -20,22 +20,22 @@ /** * Frame buffers must be aligned to XXX boundary. * - * 0x0100000 - Pattern Buffer - Frame Buffer n + * 0x01000000 - Pattern Buffer - Frame Buffer n * * Each input then has 3 frame buffers spaced like this; * // HDMI Input 0 - * 0x01000000 - HDMI Input 0 - Frame Buffer n - * 0x01040000 - HDMI Input 0 - Frame Buffer n+1 - * 0x01080000 - HDMI Input 0 - Frame Buffer n+2 + * 0x02000000 - HDMI Input 0 - Frame Buffer n + * 0x02040000 - HDMI Input 0 - Frame Buffer n+1 + * 0x02080000 - HDMI Input 0 - Frame Buffer n+2 * // HDMI Input 1 - * 0x02000000 - HDMI Input 1 - Frame Buffer n - * 0x02040000 - HDMI Input 1 - Frame Buffer n+1 - * 0x02080000 - HDMI Input 1 - Frame Buffer n+2 + * 0x03000000 - HDMI Input 1 - Frame Buffer n + * 0x03040000 - HDMI Input 1 - Frame Buffer n+1 + * 0x03080000 - HDMI Input 1 - Frame Buffer n+2 * ... * // HDMI Input x - * 0x0x000000 - HDMI Input x - Frame Buffer n - * 0x0x040000 - HDMI Input x - Frame Buffer n+1 - * 0x0x080000 - HDMI Input x - Frame Buffer n+2 + * 0x0.000000 - HDMI Input x - Frame Buffer n + * 0x0.040000 - HDMI Input x - Frame Buffer n+1 + * 0x0.080000 - HDMI Input x - Frame Buffer n+2 * */ #define FRAMEBUFFER_OFFSET 0x01000000 @@ -45,7 +45,7 @@ #define FRAMEBUFFER_PIXELS_Y 1080 // pixels #define FRAMEBUFFER_PIXELS_BYTES 2 // bytes -#define FRAMEBUFFER_BASE(x) (x*FRAMEBUFFER_OFFSET) +#define FRAMEBUFFER_BASE(x) ((x+1)*FRAMEBUFFER_OFFSET) #define FRAMEBUFFER_BASE_PATTERN FRAMEBUFFER_BASE(0) #define FRAMEBUFFER_BASE_HDMI_INPUT(x) FRAMEBUFFER_BASE(x+FRAMEBUFFER_PATTERNS) From 8c0abd06b5ba0602ca1de37cb9c3cff83410c54d Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Thu, 4 Jan 2018 01:33:09 +0000 Subject: [PATCH 066/219] scripts: Put QEMU monitor on a telnet port. --- scripts/build-qemu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build-qemu.sh b/scripts/build-qemu.sh index 94f2f680..60f58773 100755 --- a/scripts/build-qemu.sh +++ b/scripts/build-qemu.sh @@ -170,6 +170,6 @@ echo $SPIFLASH_MODEL $TARGET_QEMU_BUILD_DIR/$QEMU_ARCH/qemu-system-$QEMU_CPU \ -M litex \ -nographic -nodefaults \ - -monitor pty \ + -monitor telnet::10000,server,nowait \ -serial stdio \ ${EXTRA_ARGS[@]} From 004835d58343ee68f4b6d56829837a4a3b0fbb4b Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Thu, 4 Jan 2018 01:32:26 +0000 Subject: [PATCH 067/219] firmware: Put pattern framebuffer at FRAMEBUFFER_OFFSET and everything below that. --- firmware/framebuffer.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/firmware/framebuffer.h b/firmware/framebuffer.h index da4b5701..adbfd595 100644 --- a/firmware/framebuffer.h +++ b/firmware/framebuffer.h @@ -20,22 +20,22 @@ /** * Frame buffers must be aligned to XXX boundary. * - * 0x0100000 - Pattern Buffer - Frame Buffer n + * 0x01000000 - Pattern Buffer - Frame Buffer n * * Each input then has 3 frame buffers spaced like this; * // HDMI Input 0 - * 0x01000000 - HDMI Input 0 - Frame Buffer n - * 0x01040000 - HDMI Input 0 - Frame Buffer n+1 - * 0x01080000 - HDMI Input 0 - Frame Buffer n+2 + * 0x02000000 - HDMI Input 0 - Frame Buffer n + * 0x02040000 - HDMI Input 0 - Frame Buffer n+1 + * 0x02080000 - HDMI Input 0 - Frame Buffer n+2 * // HDMI Input 1 - * 0x02000000 - HDMI Input 1 - Frame Buffer n - * 0x02040000 - HDMI Input 1 - Frame Buffer n+1 - * 0x02080000 - HDMI Input 1 - Frame Buffer n+2 + * 0x03000000 - HDMI Input 1 - Frame Buffer n + * 0x03040000 - HDMI Input 1 - Frame Buffer n+1 + * 0x03080000 - HDMI Input 1 - Frame Buffer n+2 * ... * // HDMI Input x - * 0x0x000000 - HDMI Input x - Frame Buffer n - * 0x0x040000 - HDMI Input x - Frame Buffer n+1 - * 0x0x080000 - HDMI Input x - Frame Buffer n+2 + * 0x0.000000 - HDMI Input x - Frame Buffer n + * 0x0.040000 - HDMI Input x - Frame Buffer n+1 + * 0x0.080000 - HDMI Input x - Frame Buffer n+2 * */ #define FRAMEBUFFER_OFFSET 0x01000000 @@ -45,7 +45,7 @@ #define FRAMEBUFFER_PIXELS_Y 1080 // pixels #define FRAMEBUFFER_PIXELS_BYTES 2 // bytes -#define FRAMEBUFFER_BASE(x) (x*FRAMEBUFFER_OFFSET) +#define FRAMEBUFFER_BASE(x) ((x+1)*FRAMEBUFFER_OFFSET) #define FRAMEBUFFER_BASE_PATTERN FRAMEBUFFER_BASE(0) #define FRAMEBUFFER_BASE_HDMI_INPUT(x) FRAMEBUFFER_BASE(x+FRAMEBUFFER_PATTERNS) From 9d35f558679e7f07b0cdb67998e5e814115f6cc2 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Wed, 10 Jan 2018 13:51:52 +1100 Subject: [PATCH 068/219] travis: Allow unshallow to fail. --- .travis/setup.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis/setup.sh b/.travis/setup.sh index c7c2be2a..738832b6 100755 --- a/.travis/setup.sh +++ b/.travis/setup.sh @@ -17,7 +17,8 @@ echo "" echo "" echo "- Fetching non shallow to get git version" echo "---------------------------------------------" -git fetch origin --unshallow && git fetch origin --tags +git fetch origin --unshallow || true +git fetch origin --tags if [ z"$TRAVIS_PULL_REQUEST_SLUG" != z ]; then echo "" From f85ab1e37c1e3daa2ab3e532c24801db6cdfd6b7 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Thu, 11 Jan 2018 17:54:00 +1100 Subject: [PATCH 069/219] scripts: Allow download-env to be run inside the env. --- scripts/download-env.sh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/scripts/download-env.sh b/scripts/download-env.sh index 141ceeef..984d0779 100755 --- a/scripts/download-env.sh +++ b/scripts/download-env.sh @@ -19,12 +19,6 @@ if [ $SOURCED = 1 ]; then return fi -if [ ! -z "$HDMI2USB_ENV" ]; then - echo "You appear to have sourced the HDMI2USB settings, these are incompatible with setting up." - echo "Please exit this terminal and run again from a clean shell." - exit 1 -fi - if [ ! -z "$SETTINGS_FILE" -o ! -z "$XILINX" ]; then echo "You appear to have sourced the Xilinx ISE settings, these are incompatible with setting up." echo "Please exit this terminal and run again from a clean shell." From c6a9a995628353fcafbcce40f9356473373b3ae7 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Thu, 11 Jan 2018 19:18:51 +1100 Subject: [PATCH 070/219] travis: Understand the git pull request failure problem now. See the following page - https://discourse.drone.io/t/github-claims-that-merge-refs-are-undocumented-feature/1100 > There appears to be a bug in Github where upon pull request creation, > or pushing to an existing pull request, the PR webhook is fired before > the merge ref is created. > > This results in dangerous bugs in CI systems where the code being > tested in a CI job is not the code that the PR author thinks is being > tested. > > Specifically when this happens, one of two things happens: > > 1) The CI job fails because the merge ref cannot be found (if this is > right when the PR is opened) > > 2) The CI job runs but uses the wrong commit (if this is a subsequent > push to an existing PR) - This is because the FETCH_HEAD is > pointing to an older commit. --- .travis/fixup-git.sh | 118 +++++++++++++++++++++++++++++++++++++++++++ .travis/setup.sh | 109 +-------------------------------------- 2 files changed, 119 insertions(+), 108 deletions(-) create mode 100755 .travis/fixup-git.sh diff --git a/.travis/fixup-git.sh b/.travis/fixup-git.sh new file mode 100755 index 00000000..463b41d3 --- /dev/null +++ b/.travis/fixup-git.sh @@ -0,0 +1,118 @@ +#!/bin/bash + +set -e + +echo "" +echo "" +echo "" +echo "- Fetching non shallow to get git version" +echo "---------------------------------------------" +git fetch origin --unshallow || true +git fetch origin --tags + +if [ z"$TRAVIS_PULL_REQUEST_SLUG" != z ]; then + echo "" + echo "" + echo "" + echo "- Fetching from pull request source" + echo "---------------------------------------------" + git remote add source https://github.com/$TRAVIS_PULL_REQUEST_SLUG.git + git fetch source && git fetch --tags + + echo "" + echo "" + echo "" + echo "- Fetching the actual pull request" + echo "---------------------------------------------" + git fetch origin pull/$TRAVIS_PULL_REQUEST/head:pull-$TRAVIS_PULL_REQUEST-head + git fetch origin pull/$TRAVIS_PULL_REQUEST/merge:pull-$TRAVIS_PULL_REQUEST-merge + echo "---------------------------------------------" + git log -n 5 --graph pull-$TRAVIS_PULL_REQUEST-head + echo "---------------------------------------------" + git log -n 5 --graph pull-$TRAVIS_PULL_REQUEST-merge + echo "---------------------------------------------" + + GITHUB_CURRENT_MERGE_SHA1="$(git log --pretty=format:'%H' -n 1 pull-$TRAVIS_PULL_REQUEST-merge)" + if [ "$GITHUB_CURRENT_MERGE_SHA1" != "$TRAVIS_COMMIT" ]; then + echo "" + echo "" + echo "" + echo "- Pull request triggered for $TRAVIS_COMMIT but now at $GITHUB_CURRENT_MERGE_SHA1" + echo "" + echo " SKIPPING!" + echo "" + exit 1 + fi + + echo "" + echo "" + echo "" + echo "- Using pull request version of submodules (if they exist)" + echo "---------------------------------------------" + git submodule status | while read SHA1 MODULE_PATH + do + "$PWD/.travis/add-local-submodule.sh" "$TRAVIS_PULL_REQUEST_SLUG" "$MODULE_PATH" + done + echo "---------------------------------------------" + git submodule foreach --recursive 'git remote -v; echo' + echo "---------------------------------------------" +fi + +if [ z"$TRAVIS_REPO_SLUG" != z ]; then + echo "" + echo "" + echo "" + echo "- Using local version of submodules (if they exist)" + echo "---------------------------------------------" + git submodule status | while read SHA1 MODULE_PATH DESC + do + "$PWD/.travis/add-local-submodule.sh" "$TRAVIS_REPO_SLUG" "$MODULE_PATH" + done + echo "---------------------------------------------" + git submodule foreach --recursive 'git remote -v; echo' + echo "---------------------------------------------" +fi + +echo "---------------------------------------------" +git show-ref +echo "---------------------------------------------" + +if [ z"$TRAVIS_BRANCH" != z ]; then + TRAVIS_COMMIT_ACTUAL=$(git log --pretty=format:'%H' -n 1) + echo "" + echo "" + echo "" + echo "Fixing detached head (current $TRAVIS_COMMIT_ACTUAL -> $TRAVIS_COMMIT)" + echo "---------------------------------------------" + git log -n 5 --graph + echo "---------------------------------------------" + git fetch origin $TRAVIS_COMMIT + git branch -v + echo "---------------------------------------------" + git log -n 5 --graph + echo "---------------------------------------------" + git branch -D $TRAVIS_BRANCH || true + git checkout $TRAVIS_COMMIT -b $TRAVIS_BRANCH + git branch -v +fi +echo "" +echo "" +echo "" +echo "Git Revision" +echo "---------------------------------------------" +git status +echo "---------------------------------------------" +git describe +echo "=============================================" +GIT_REVISION=$(git describe) + +echo "" +echo "" +echo "" +echo "- Disk space free (after fixing git)" +echo "---------------------------------------------" +df -h +echo "" +DF_AFTER_GIT="$(($(stat -f --format="%a*%S" .)))" +awk "BEGIN {printf \"Git is using %.2f megabytes\n\",($DF_LAST-$DF_AFTER_GIT)/1024/1024}" +DF_LAST="$DF_AFTER_GIT" diff --git a/.travis/setup.sh b/.travis/setup.sh index 738832b6..e8810670 100755 --- a/.travis/setup.sh +++ b/.travis/setup.sh @@ -2,114 +2,7 @@ set -e -echo "" -echo "" -echo "" -echo "- Disk space free (initial)" -echo "---------------------------------------------" -df -h -echo "" -DF_INITIAL="$(($(stat -f --format="%a*%S" .)))" -DF_LAST=$DF_INITIAL - -echo "" -echo "" -echo "" -echo "- Fetching non shallow to get git version" -echo "---------------------------------------------" -git fetch origin --unshallow || true -git fetch origin --tags - -if [ z"$TRAVIS_PULL_REQUEST_SLUG" != z ]; then - echo "" - echo "" - echo "" - echo "- Fetching from pull request source" - echo "---------------------------------------------" - git remote add source https://github.com/$TRAVIS_PULL_REQUEST_SLUG.git - git fetch source && git fetch --tags - - echo "" - echo "" - echo "" - echo "- Fetching the actual pull request" - echo "---------------------------------------------" - git fetch origin pull/$TRAVIS_PULL_REQUEST/head:pull-$TRAVIS_PULL_REQUEST-head - git fetch origin pull/$TRAVIS_PULL_REQUEST/merge:pull-$TRAVIS_PULL_REQUEST-merge - echo "---------------------------------------------" - git log -n 5 --graph pull-$TRAVIS_PULL_REQUEST-head - echo "---------------------------------------------" - git log -n 5 --graph pull-$TRAVIS_PULL_REQUEST-merge - echo "---------------------------------------------" - - echo "" - echo "" - echo "" - echo "- Using pull request version of submodules (if they exist)" - echo "---------------------------------------------" - git submodule status | while read SHA1 MODULE_PATH - do - "$PWD/.travis/add-local-submodule.sh" "$TRAVIS_PULL_REQUEST_SLUG" "$MODULE_PATH" - done - echo "---------------------------------------------" - git submodule foreach --recursive 'git remote -v; echo' - echo "---------------------------------------------" -fi - -if [ z"$TRAVIS_REPO_SLUG" != z ]; then - echo "" - echo "" - echo "" - echo "- Using local version of submodules (if they exist)" - echo "---------------------------------------------" - git submodule status | while read SHA1 MODULE_PATH DESC - do - "$PWD/.travis/add-local-submodule.sh" "$TRAVIS_REPO_SLUG" "$MODULE_PATH" - done - echo "---------------------------------------------" - git submodule foreach --recursive 'git remote -v; echo' - echo "---------------------------------------------" -fi - -if [ z"$TRAVIS_BRANCH" != z ]; then - TRAVIS_COMMIT_ACTUAL=$(git log --pretty=format:'%H' -n 1) - echo "" - echo "" - echo "" - echo "Fixing detached head (current $TRAVIS_COMMIT_ACTUAL -> $TRAVIS_COMMIT)" - echo "---------------------------------------------" - git log -n 5 --graph - echo "---------------------------------------------" - git fetch origin $TRAVIS_COMMIT - git branch -v - echo "---------------------------------------------" - git log -n 5 --graph - echo "---------------------------------------------" - git branch -D $TRAVIS_BRANCH || true - git checkout $TRAVIS_COMMIT -b $TRAVIS_BRANCH - git branch -v -fi -echo "" -echo "" -echo "" -echo "Git Revision" -echo "---------------------------------------------" -git status -echo "---------------------------------------------" -git describe -echo "=============================================" -GIT_REVISION=$(git describe) - -echo "" -echo "" -echo "" -echo "- Disk space free (after fixing git)" -echo "---------------------------------------------" -df -h -echo "" -DF_AFTER_GIT="$(($(stat -f --format="%a*%S" .)))" -awk "BEGIN {printf \"Git is using %.2f megabytes\n\",($DF_LAST-$DF_AFTER_GIT)/1024/1024}" -DF_LAST="$DF_AFTER_GIT" +./.travis/fixup-git.sh function setup() { export FULL_PLATFORM=$1 From 86ce6c43e82a3bf1b9d4071a7f01945e6f91d4a7 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sat, 13 Jan 2018 17:58:31 +1100 Subject: [PATCH 071/219] scripts: Change conda config rather then ~/.condarc --- scripts/download-env.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/download-env.sh b/scripts/download-env.sh index 984d0779..c3936ef1 100755 --- a/scripts/download-env.sh +++ b/scripts/download-env.sh @@ -184,10 +184,10 @@ export PATH=$CONDA_DIR/bin:$PATH:/sbin # -b to enable batch mode (no prompts) # -f to not return an error if the location specified by -p already exists ./Miniconda3-latest-Linux-x86_64.sh -p $CONDA_DIR -b -f - conda config --set always_yes yes --set changeps1 no + conda config --system --set always_yes yes --set changeps1 no conda update -q conda fi - conda config --add channels timvideos + conda config --system --add channels timvideos ) eval $(cd $TOP_DIR; export HDMI2USB_ENV=1; make env || return 1) || exit 1 From 688bae1207ac9ceadaf0a4dfa21f3bd09090c80d Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sat, 13 Jan 2018 17:59:40 +1100 Subject: [PATCH 072/219] travis: Make sure conda isn't writing to ~/.conda --- .travis/prevent-condarc.sh | 4 ++++ .travis/setup.sh | 2 ++ 2 files changed, 6 insertions(+) create mode 100755 .travis/prevent-condarc.sh diff --git a/.travis/prevent-condarc.sh b/.travis/prevent-condarc.sh new file mode 100755 index 00000000..9ad7b862 --- /dev/null +++ b/.travis/prevent-condarc.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +mkdir -p ~/.conda +chmod 0000 ~/.conda diff --git a/.travis/setup.sh b/.travis/setup.sh index e8810670..9913f56f 100755 --- a/.travis/setup.sh +++ b/.travis/setup.sh @@ -2,6 +2,8 @@ set -e +./.travis/prevent-condarc.sh + ./.travis/fixup-git.sh function setup() { From 625991a4e065de174e26f2828421be1bf9120017 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sat, 13 Jan 2018 18:34:21 +1100 Subject: [PATCH 073/219] scripts: More settings to make conda stop using ~/.conda --- scripts/download-env.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/download-env.sh b/scripts/download-env.sh index c3936ef1..c5522a3a 100755 --- a/scripts/download-env.sh +++ b/scripts/download-env.sh @@ -184,7 +184,10 @@ export PATH=$CONDA_DIR/bin:$PATH:/sbin # -b to enable batch mode (no prompts) # -f to not return an error if the location specified by -p already exists ./Miniconda3-latest-Linux-x86_64.sh -p $CONDA_DIR -b -f - conda config --system --set always_yes yes --set changeps1 no + conda config --system --set always_yes yes + conda config --system --set changeps1 no + conda config --system --add envs_dirs $CONDA_DIR/envs + conda config --system --add pkgs_dirs $CONDA_DIR/pkgs conda update -q conda fi conda config --system --add channels timvideos From 752fc0493dec17ce09783ab114289b1fa2551627 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sat, 13 Jan 2018 19:55:00 +1100 Subject: [PATCH 074/219] scripts: Force conda to not use ~/.conda/environments.txt OMG this is horrible, am I really doing this!? --- scripts/download-env.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/scripts/download-env.sh b/scripts/download-env.sh index c5522a3a..2396f76f 100755 --- a/scripts/download-env.sh +++ b/scripts/download-env.sh @@ -167,6 +167,17 @@ function check_import_version { fi } +function fix_conda { + for py in $(find $CONDA_DIR -name envs_manager.py); do + START_SUM=$(sha256sum $py | sed -e's/ .*//') + sed -i -e"s^expand(join('~', '.conda', 'environments.txt'))^join('$CONDA_DIR', 'environments.txt')^" $py + END_SUM=$(sha256sum $py | sed -e's/ .*//') + if [ $START_SUM != $END_SUM ]; then + sed -i -e"s/$START_SUM/$END_SUM/" $(find $CONDA_DIR -name paths.json) + fi + done +} + echo "" echo "Initializing environment" echo "---------------------------------" @@ -184,13 +195,16 @@ export PATH=$CONDA_DIR/bin:$PATH:/sbin # -b to enable batch mode (no prompts) # -f to not return an error if the location specified by -p already exists ./Miniconda3-latest-Linux-x86_64.sh -p $CONDA_DIR -b -f + fix_conda conda config --system --set always_yes yes conda config --system --set changeps1 no conda config --system --add envs_dirs $CONDA_DIR/envs conda config --system --add pkgs_dirs $CONDA_DIR/pkgs conda update -q conda fi + fix_conda conda config --system --add channels timvideos + conda info ) eval $(cd $TOP_DIR; export HDMI2USB_ENV=1; make env || return 1) || exit 1 @@ -205,6 +219,7 @@ eval $(cd $TOP_DIR; export HDMI2USB_ENV=1; make env || return 1) || exit 1 echo echo "Installing python3.5" conda install -y $CONDA_FLAGS python=3.5 +fix_conda check_version python 3.5 echo "python ==3.5.4" > $CONDA_DIR/conda-meta/pinned # Make sure it stays at version 3.5 From 3b5311a807b9a69860554bb0e79e473053eb5ec4 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sat, 13 Jan 2018 19:03:50 +1100 Subject: [PATCH 075/219] firmware: Only define the values if they don't exist. --- firmware/ci.c | 44 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/firmware/ci.c b/firmware/ci.c index d40c02e5..fa6277c2 100644 --- a/firmware/ci.c +++ b/firmware/ci.c @@ -579,17 +579,49 @@ static void status_service(void) } } -// FIXME +#ifdef CSR_HDMI_IN0_BASE +#ifndef HDMI_IN0_MNEMONIC +#warning "Missing HDMI IN0 mnemonic!" #define HDMI_IN0_MNEMONIC "" -#define HDMI_IN1_MNEMONIC "" -#define HDMI_OUT0_MNEMONIC "" -#define HDMI_OUT1_MNEMONIC "" - +#endif +#ifndef HDMI_IN0_DESCRIPTION +#warning "Missing HDMI IN0 description!" #define HDMI_IN0_DESCRIPTION "" +#endif +#endif + +#ifdef CSR_HDMI_IN1_BASE +#ifndef HDMI_IN1_MNEMONIC +#warning "Missing HDMI IN1 mnemonic!" +#define HDMI_IN1_MNEMONIC "" +#endif +#ifndef HDMI_IN1_DESCRIPTION +#warning "Missing HDMI IN1 description!" #define HDMI_IN1_DESCRIPTION "" +#endif +#endif + +#ifdef CSR_HDMI_OUT0_BASE +#ifndef HDMI_OUT0_MNEMONIC +#warning "Missing HDMI OUT0 mnemonic!" +#define HDMI_OUT0_MNEMONIC "" +#endif +#ifndef HDMI_OUT0_DESCRIPTION +#warning "Missing HDMI OUT0 description!" #define HDMI_OUT0_DESCRIPTION "" +#endif +#endif + +#ifdef CSR_HDMI_OUT1_BASE +#ifndef HDMI_OUT1_MNEMONIC +#warning "Missing HDMI OUT1 mnemonic!" +#define HDMI_OUT1_MNEMONIC "" +#endif +#ifndef HDMI_OUT1_DESCRIPTION +#warning "Missing HDMI OUT1 description!" #define HDMI_OUT1_DESCRIPTION "" -// FIXME +#endif +#endif static void video_matrix_list(void) { From 115ffbaf145cd3147c7ef8da3d9fb4020e99cb56 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sat, 13 Jan 2018 19:04:19 +1100 Subject: [PATCH 076/219] opsis: Export HDMI infos as constants. --- targets/opsis/video.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/targets/opsis/video.py b/targets/opsis/video.py index a7ec6b94..4fb104ce 100644 --- a/targets/opsis/video.py +++ b/targets/opsis/video.py @@ -122,5 +122,8 @@ def __init__(self, platform, *args, **kwargs): self.hdmi_out0.driver.clocking.cd_pix.clk, self.hdmi_out1.driver.clocking.cd_pix.clk) + for name, value in sorted(self.platform.hdmi_infos.items()): + self.add_constant(name, value) + SoC = VideoSoC From 947bf353376e6f4f4e0c4af58097893a22404e93 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sat, 13 Jan 2018 19:13:19 +1100 Subject: [PATCH 077/219] Updating submodules. * litex changed from v0.1-220-g44650dff to v0.1-244-gab1146e1 Full submodule status -- f56f329ed23a25d002352dedba1e8f092a47286f edid-decode (heads/master) 070d8b29acf1445c08ebf3073d04206461819bbe flash_proxies (heads/master) a09b7a05b89af317c885b3939e2f13925cb8d95d litedram (remotes/origin/HEAD) 937c2407276371d9f8c1bb19c4ae8e97e581da83 liteeth (heads/before-changes) 09dbd6dd3053cc42baa7090ee042cb314853a7fc litepcie (heads/master-1-g09dbd6d) a8bf0d42b22a5f355a629aad7392c59029164d67 litesata (remotes/origin/HEAD) 7757727f5b9fe4cb4979897fa0aab934b4af6e88 litescope (remotes/origin/HEAD) 9a78586e5e523843834f80826f387ff828012ff7 liteusb (remotes/origin/HEAD) c9770cc2da2df70c941376e9b937a2980822c739 litevideo (heads/master-4-gc9770cc) ab1146e1b01132b07aceaff65f96a3e6956dd86d litex (v0.1-244-gab1146e1) --- third_party/litex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/litex b/third_party/litex index 44650dff..ab1146e1 160000 --- a/third_party/litex +++ b/third_party/litex @@ -1 +1 @@ -Subproject commit 44650dffd8f82018840922ddbbb6570c8c1e6b08 +Subproject commit ab1146e1b01132b07aceaff65f96a3e6956dd86d From 5231bb32ea2df5af2c4cea45041f986007cfe2b4 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sat, 13 Jan 2018 20:00:14 +1100 Subject: [PATCH 078/219] atlys/video: Also define the HDMI infos. --- targets/atlys/video.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/targets/atlys/video.py b/targets/atlys/video.py index e2ee4674..11d8477b 100644 --- a/targets/atlys/video.py +++ b/targets/atlys/video.py @@ -71,5 +71,8 @@ def __init__(self, platform, *args, **kwargs): self.hdmi_out0.driver.clocking.cd_pix.clk, self.hdmi_out1.driver.clocking.cd_pix.clk) + for name, value in sorted(self.platform.hdmi_infos.items()): + self.add_constant(name, value) + SoC = VideoSoC From f65ddb00f90d5f0a0251ee5e75d022d5be53b081 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sat, 13 Jan 2018 20:40:29 +1100 Subject: [PATCH 079/219] netv2+nexys_video: Adding temporary HDMI infos. Someone should figure them out. --- platforms/netv2.py | 12 ++++++++++++ platforms/nexys_video.py | 13 +++++++++++++ targets/netv2/video.py | 3 +++ targets/nexys_video/video.py | 3 +++ 4 files changed, 31 insertions(+) diff --git a/platforms/netv2.py b/platforms/netv2.py index 5e88c8f0..309a1a24 100644 --- a/platforms/netv2.py +++ b/platforms/netv2.py @@ -83,11 +83,23 @@ ] +_hdmi_infos = { + "HDMI_OUT0_MNEMONIC": "TX1", + "HDMI_OUT0_DESCRIPTION" : ( + " FIXME in platforms/netv2.py\\r\\n" + ), + + "HDMI_IN0_MNEMONIC": "RX1", + "HDMI_IN0_DESCRIPTION" : ( + " FIXME in platforms/netv2.py\\r\\n" + ), +} class Platform(XilinxPlatform): name = "netv2" default_clk_name = "clk50" default_clk_period = 20.0 + hdmi_infos = _hdmi_infos # From https://www.xilinx.com/support/documentation/user_guides/ug470_7Series_Config.pdf # 17536096 bits == 2192012 == 0x21728c -- Therefore 0x220000 diff --git a/platforms/nexys_video.py b/platforms/nexys_video.py index 28e3c9b7..2a6cf00c 100644 --- a/platforms/nexys_video.py +++ b/platforms/nexys_video.py @@ -228,10 +228,23 @@ ) ] +_hdmi_infos = { + "HDMI_OUT0_MNEMONIC": "TX1", + "HDMI_OUT0_DESCRIPTION" : ( + " FIXME in platforms/nexys_video.py\\r\\n" + ), + + "HDMI_IN0_MNEMONIC": "RX1", + "HDMI_IN0_DESCRIPTION" : ( + " FIXME in platforms/nexys_video.py\\r\\n" + ), +} + class Platform(XilinxPlatform): name = "nexys_video" default_clk_name = "clk100" default_clk_period = 10.0 + hdmi_infos = _hdmi_infos # From https://www.xilinx.com/support/documentation/user_guides/ug470_7Series_Config.pdf # 77,845,216 bits == 9730652 == 0x947a5c -- Therefore 0x1000000 diff --git a/targets/netv2/video.py b/targets/netv2/video.py index b88c30eb..2be9baec 100644 --- a/targets/netv2/video.py +++ b/targets/netv2/video.py @@ -37,5 +37,8 @@ def __init__(self, platform, *args, **kwargs): self.crg.cd_sys.clk, self.hdmi_out0.driver.clocking.cd_pix.clk) + for name, value in sorted(self.platform.hdmi_infos.items()): + self.add_constant(name, value) + SoC = VideoOutSoC diff --git a/targets/nexys_video/video.py b/targets/nexys_video/video.py index e499de6e..c99e2971 100755 --- a/targets/nexys_video/video.py +++ b/targets/nexys_video/video.py @@ -89,6 +89,9 @@ def __init__(self, platform, *args, **kwargs): self.hdmi_out0.driver.clocking.cd_pix.clk, self.hdmi_out0.driver.clocking.cd_pix5x.clk) + for name, value in sorted(self.platform.hdmi_infos.items()): + self.add_constant(name, value) + class VideoSoCDebug(VideoSoC): csr_peripherals = ( From b50d5e02f017c3a6f2eeccfb8b5b96faa3bab757 Mon Sep 17 00:00:00 2001 From: Oleg Malashenko Date: Sat, 13 Jan 2018 21:23:15 +1000 Subject: [PATCH 080/219] firmware: fix typo in version_data.sh --- firmware/version_data.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/firmware/version_data.sh b/firmware/version_data.sh index da8af13e..0b2c5fdf 100755 --- a/firmware/version_data.sh +++ b/firmware/version_data.sh @@ -7,8 +7,8 @@ COMMIT="$(git log --format="%H" -n 1)" BRANCH="$(git symbolic-ref --short HEAD)" DESCRIBE="$(git describe --dirty)" -TMPFILE_H=$(tempfile -s .h | mktemp --suffix=.h) -TMPFILE_C=$(tempfile -s .c | mktemp --suffix=.c) +TMPFILE_H=$(tempfile -s .h || mktemp --suffix=.h) +TMPFILE_C=$(tempfile -s .c || mktemp --suffix=.c) UPLATFORM="$(echo $PLATFORM | tr '[:lower:]' '[:upper:]')" UTARGET="$(echo $TARGET | tr '[:lower:]' '[:upper:]')" From c443e9b27d8d325cde07630150d0190d217b0c84 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sun, 14 Jan 2018 20:14:13 +1100 Subject: [PATCH 081/219] settings: HDMI2USB mode switch version bump. --- scripts/settings.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/settings.sh b/scripts/settings.sh index 54e91497..3ba920e6 100644 --- a/scripts/settings.sh +++ b/scripts/settings.sh @@ -6,7 +6,7 @@ THIRD_DIR=$TOP_DIR/third_party CONDA_DIR=$BUILD_DIR/conda # Python module versions -HDMI2USB_MODESWITCH_VERSION=0.0.0 +HDMI2USB_MODESWITCH_VERSION=0.0.1 HEXFILE_VERSION=0.1 # Conda package versions From d70462d9a4de02035223aa0a89683a7503647af0 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Sun, 14 Jan 2018 23:40:24 +1100 Subject: [PATCH 082/219] Don't do mdio_dump in mdio_status We have a separate command for that. --- firmware/mdio.c | 1 - 1 file changed, 1 deletion(-) diff --git a/firmware/mdio.c b/firmware/mdio.c index 2344bab6..f417fc8a 100644 --- a/firmware/mdio.c +++ b/firmware/mdio.c @@ -93,7 +93,6 @@ void mdio_dump(void) { int mdio_status(void) { int status; - mdio_dump(); status = mdio_read(0, 17); From d10a8f1f222ef4354e63dec633a7334005828fd6 Mon Sep 17 00:00:00 2001 From: Rohit Kumar Singh Date: Sun, 14 Jan 2018 18:11:24 +0530 Subject: [PATCH 083/219] arty/base: Fix ddr3 parameters for upstream changes --- targets/arty/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/targets/arty/base.py b/targets/arty/base.py index 98dc5ae9..230f84c6 100755 --- a/targets/arty/base.py +++ b/targets/arty/base.py @@ -148,8 +148,8 @@ def __init__(self, platform, spiflash="spiflash_1x", **kwargs): sdram_module = MT41K128M16(self.clk_freq, "1:4") self.submodules.ddrphy = a7ddrphy.A7DDRPHY( platform.request("ddram")) - self.add_constant("A7DDRPHY_BITSLIP", 2) - self.add_constant("A7DDRPHY_DELAY", 6) + self.add_constant("READ_LEVELING_BITSLIP", 3) + self.add_constant("READ_LEVELING_DELAY", 14) controller_settings = ControllerSettings( with_bandwidth=True, cmd_buffer_depth=8, From 58dd95053999cfe88b43c565d544e4011ed42fbf Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Mon, 15 Jan 2018 11:05:28 +1100 Subject: [PATCH 084/219] scripts: Fix ISE complaints about wbtc on Travis. --- scripts/download-env.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/download-env.sh b/scripts/download-env.sh index 2396f76f..35783890 100755 --- a/scripts/download-env.sh +++ b/scripts/download-env.sh @@ -87,6 +87,10 @@ if [ ! -z "$XILINX_PASSPHRASE" ]; then mkdir -p $XILINX_DIR/opt/Xilinx/Vivado/2017.3/scripts/rt/data/svlog/sdbs mkdir -p $XILINX_DIR/opt/Xilinx/Vivado/2017.3/tps/lnx64/jre + # Make ISE stop complaining about missing wbtc binary + mkdir -p $XILINX_DIR/opt/Xilinx/14.7/ISE_DS/ISE/bin/lin64 + ln -s /bin/true $XILINX_DIR/opt/Xilinx/14.7/ISE_DS/ISE/bin/lin64/wbtc + # Relocate ISE from /opt to $XILINX_DIR for i in $(grep -l -Rsn "/opt/Xilinx" $XILINX_DIR/opt) do From a5bcfb2a2d3dbf143091423254e265e49ba80baf Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Mon, 15 Jan 2018 16:40:36 +1100 Subject: [PATCH 085/219] arty/base: Fix reset polarity. --- targets/arty/base.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/targets/arty/base.py b/targets/arty/base.py index 230f84c6..ab438ff9 100755 --- a/targets/arty/base.py +++ b/targets/arty/base.py @@ -26,7 +26,7 @@ def __init__(self, platform): self.clock_domains.cd_clk50 = ClockDomain() clk100 = platform.request("clk100") - rst = platform.request("cpu_reset") + rst = ~platform.request("cpu_reset") pll_locked = Signal() pll_fb = Signal() @@ -69,9 +69,9 @@ def __init__(self, platform): Instance("BUFG", i_I=pll_sys4x_dqs, o_O=self.cd_sys4x_dqs.clk), Instance("BUFG", i_I=pll_clk200, o_O=self.cd_clk200.clk), Instance("BUFG", i_I=pll_clk50, o_O=self.cd_clk50.clk), - AsyncResetSynchronizer(self.cd_sys, ~pll_locked | ~rst), + AsyncResetSynchronizer(self.cd_sys, ~pll_locked | rst), AsyncResetSynchronizer(self.cd_clk200, ~pll_locked | rst), - AsyncResetSynchronizer(self.cd_clk50, ~pll_locked | ~rst), + AsyncResetSynchronizer(self.cd_clk50, ~pll_locked | rst), ] reset_counter = Signal(4, reset=15) @@ -159,4 +159,5 @@ def __init__(self, platform, spiflash="spiflash_1x", **kwargs): sdram_module.timing_settings, controller_settings=controller_settings) + SoC = BaseSoC From a1ee3d52f4f1836ca2690af088738a228e9077e2 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Mon, 15 Jan 2018 16:43:19 +1100 Subject: [PATCH 086/219] nexys_video/base: Also fix nexys_video. --- targets/nexys_video/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/targets/nexys_video/base.py b/targets/nexys_video/base.py index 00513258..364160b1 100755 --- a/targets/nexys_video/base.py +++ b/targets/nexys_video/base.py @@ -127,8 +127,8 @@ def __init__(self, platform, spiflash="spiflash_1x", **kwargs): # sdram self.submodules.ddrphy = a7ddrphy.A7DDRPHY(platform.request("ddram")) - self.add_constant("A7DDRPHY_BITSLIP", 3) - self.add_constant("A7DDRPHY_DELAY", 14) + self.add_constant("READ_LEVELING_BITSLIP", 3) + self.add_constant("READ_LEVELING_DELAY", 14) sdram_module = MT41K256M16(self.clk_freq, "1:4") self.register_sdram(self.ddrphy, sdram_module.geom_settings, From 1be967a19145ea7f0816f4c236b5651ff68ed6c4 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Mon, 15 Jan 2018 09:32:11 +0100 Subject: [PATCH 087/219] targets: update artix 7 ddr phy parameters --- targets/arty/base.py | 4 ++-- targets/netv2/base.py | 4 ++-- targets/netv2/bridge_uart.py | 4 ++-- targets/nexys_video/base.py | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/targets/arty/base.py b/targets/arty/base.py index 98dc5ae9..78115561 100755 --- a/targets/arty/base.py +++ b/targets/arty/base.py @@ -148,8 +148,8 @@ def __init__(self, platform, spiflash="spiflash_1x", **kwargs): sdram_module = MT41K128M16(self.clk_freq, "1:4") self.submodules.ddrphy = a7ddrphy.A7DDRPHY( platform.request("ddram")) - self.add_constant("A7DDRPHY_BITSLIP", 2) - self.add_constant("A7DDRPHY_DELAY", 6) + self.add_constant("READ_LEVELING_BITSLIP", 2) + self.add_constant("READ_LEVELING_DELAY", 6) controller_settings = ControllerSettings( with_bandwidth=True, cmd_buffer_depth=8, diff --git a/targets/netv2/base.py b/targets/netv2/base.py index 68c0e6af..db33c575 100755 --- a/targets/netv2/base.py +++ b/targets/netv2/base.py @@ -108,8 +108,8 @@ def __init__(self, platform, **kwargs): sdram_module = MT41J128M16(self.clk_freq, "1:4") self.submodules.ddrphy = a7ddrphy.A7DDRPHY( platform.request("ddram")) - self.add_constant("A7DDRPHY_BITSLIP", 2) - self.add_constant("A7DDRPHY_DELAY", 8) + self.add_constant("READ_LEVELING_BITSLIP", 2) + self.add_constant("READ_LEVELING_DELAY", 8) controller_settings = ControllerSettings( with_bandwidth=True, cmd_buffer_depth=8, diff --git a/targets/netv2/bridge_uart.py b/targets/netv2/bridge_uart.py index 97611664..cad73fd6 100644 --- a/targets/netv2/bridge_uart.py +++ b/targets/netv2/bridge_uart.py @@ -126,8 +126,8 @@ def __init__(self, platform, **kwargs): # sdram self.submodules.ddrphy = a7ddrphy.A7DDRPHY(platform.request("ddram")) - self.add_constant("A7DDRPHY_BITSLIP", 2) - self.add_constant("A7DDRPHY_DELAY", 8) + self.add_constant("READ_LEVELING_BITSLIP", 2) + self.add_constant("READ_LEVELING_DELAY", 8) sdram_module = MT41J128M16(self.clk_freq, "1:4") self.register_sdram(self.ddrphy, sdram_module.geom_settings, diff --git a/targets/nexys_video/base.py b/targets/nexys_video/base.py index 00513258..364160b1 100755 --- a/targets/nexys_video/base.py +++ b/targets/nexys_video/base.py @@ -127,8 +127,8 @@ def __init__(self, platform, spiflash="spiflash_1x", **kwargs): # sdram self.submodules.ddrphy = a7ddrphy.A7DDRPHY(platform.request("ddram")) - self.add_constant("A7DDRPHY_BITSLIP", 3) - self.add_constant("A7DDRPHY_DELAY", 14) + self.add_constant("READ_LEVELING_BITSLIP", 3) + self.add_constant("READ_LEVELING_DELAY", 14) sdram_module = MT41K256M16(self.clk_freq, "1:4") self.register_sdram(self.ddrphy, sdram_module.geom_settings, From 1987531c9dda7068f2f1640da2555733e8357544 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Mon, 30 Oct 2017 21:34:47 -0700 Subject: [PATCH 088/219] probot: Adding autolabeler config. --- .github/autolabeler.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/autolabeler.yml diff --git a/.github/autolabeler.yml b/.github/autolabeler.yml new file mode 100644 index 00000000..2c6ab692 --- /dev/null +++ b/.github/autolabeler.yml @@ -0,0 +1,20 @@ +board-arty: ["targets/arty", "platforms/arty.py"] +board-atlys: ["targets/atlys", "platforms/atlys.py"] +board-mimasv2: ["targets/mimasv2", "platforms/mimasv2.py"] +board-minispartan6: ["targets/minispartan6", "platforms/minispartan6.py"] +board-netv2: ["targets/netv2", "platforms/netv2.py"] +board-nexys-video: ["targets/nexys-video", "platforms/nexys-video.py"] +board-opsis: ["targets/opsis", "platforms/opsis.py", "platforms/tofe_*.py"] +board-pipstrello: ["targets/pipstrello", "platforms/pipstrello.py"] +boards-all: ["targets/common/"] +boards-artix7: ["targets/arty", "platforms/arty.py", "targets/netv2", "platforms/netv2.py", "targets/nexys-video", "platforms/nexys-video.py"] +boards-spartan6: ["targets/atlys", "platforms/atlys.py", "targets/mimasv2", "platforms/mimasv2.py", "targets/minispartan6", "platforms/minispartan6.py", "targets/opsis", "platforms/opsis.py", "targets/pipstrello", "platforms/pipstrello.py"] +firmware-fpga: ["gateware/"] +firmware-softcpu: ["firmware/"] +hdmi2ethernet: ["targets/*/net.py", "targets/*/hdmi2eth.py", "firmware/uip/", "third_party/libuip/"] +hdmi2usb: ["targets/*/hdmi2usb.py", "gateware/encoder/"] +hdmi2***: ["targets/*/base.py"] +level-docs: ["docs/", "README.md", "*.md"] +level-firmware: ["gateware/", "firmware/"] +level-infrastructure: [".travis.yml", ".travis/", "scripts/", ".github/"] +level-software: ["software/"] From b514587c692e21a3123f7cc68af06c199cc182e2 Mon Sep 17 00:00:00 2001 From: Ewen McNeill Date: Wed, 17 Jan 2018 16:34:24 +1100 Subject: [PATCH 089/219] build-micropython.sh: new URL, build micropython.bin Updated git repo URL for micropython.git; re-enabled building of combined micropython.bin as it is useful on Nuamto Mimas v2. Tested with lm32 soft CPU; appears not to work with or1k soft CPU at this time ("system.h not found") --- scripts/build-micropython.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/build-micropython.sh b/scripts/build-micropython.sh index cea8c2dc..8135a22a 100755 --- a/scripts/build-micropython.sh +++ b/scripts/build-micropython.sh @@ -43,7 +43,7 @@ MPY_SRC_DIR=$TOP_DIR/third_party/micropython if [ ! -d "$MPY_SRC_DIR" ]; then ( cd $(dirname $MPY_SRC_DIR) - git clone https://github.com/upy-fpga/micropython.git + git clone https://github.com/fupy/micropython.git cd $MPY_SRC_DIR git submodule update --init ) @@ -75,6 +75,7 @@ make V=1 -C $(realpath ../../../../third_party/micropython/litex/) -j$JOBS cd $OLD_DIR # Generate a firmware image suitable for flashing. -#python -m litex.soc.tools.mkmscimg -f $TARGET_MPY_BUILD_DIR/firmware.bin -o $TARGET_MPY_BUILD_DIR/firmware.fbi -#/usr/bin/env python mkimage.py $MISOC_EXTRA_CMDLINE $LITEX_EXTRA_CMDLINE --output-file=$TARGET_BUILD_DIR/micropython.bin --override-firmware=$TARGET_MPY_BUILD_DIR/firmware.fbi make image +# +python -m litex.soc.tools.mkmscimg -f $TARGET_MPY_BUILD_DIR/firmware.bin -o $TARGET_MPY_BUILD_DIR/firmware.fbi +/usr/bin/env python mkimage.py $MISOC_EXTRA_CMDLINE $LITEX_EXTRA_CMDLINE --output-file=$TARGET_BUILD_DIR/micropython.bin --override-firmware=$TARGET_MPY_BUILD_DIR/firmware.fbi From 054d35ee004230169b60fe13513642baef83fa6b Mon Sep 17 00:00:00 2001 From: Joel Stanley Date: Wed, 17 Jan 2018 00:33:11 -0600 Subject: [PATCH 090/219] build-linux: Update buildroot rootfs location This contains fixes to uclibc that allow userspace applications to work correctly. It is a build of Buildroot master, 2018.02-git-00441-g5b85c6a038cc with this config: http://ozlabs.org/~joel/litex_or1k_defconfig To reproduce: git clone git://git.buildroot.net/buildroot && cd buildroot wget http://ozlabs.org/~joel/litex_or1k_defconfig -O configs/litex_or1k_defconfig make litex_or1k_defconfig make Signed-off-by: Joel Stanley --- scripts/build-linux.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/build-linux.sh b/scripts/build-linux.sh index 101ad01e..342710d6 100755 --- a/scripts/build-linux.sh +++ b/scripts/build-linux.sh @@ -137,9 +137,10 @@ TARGET_LINUX_BUILD_DIR=$(dirname $TOP_DIR/$FIRMWARE_FILEBASE) mkdir -p $TARGET_LINUX_BUILD_DIR ( cd $TARGET_LINUX_BUILD_DIR - ROOTFS=openrisc-rootfs.cpio + # To rebuild, use https://ozlabs.org/~joel/litex_or1k_defconfig + ROOTFS=openrisc-rootfs.cpio.gz if [ ! -e $ROOTFS ]; then - wget "https://drive.google.com/a/mithis.com/uc?authuser=0&id=0B5VlNZ_Rvdw6d21LWXdHQlZuOVU&export=download" -O $ROOTFS + wget "https://ozlabs.org/~joel/openrisc-rootfs.cpio.gz" -O $ROOTFS fi if [ ! -e $ROOTFS.gz ]; then gzip -k $ROOTFS From 6465bc834d4f145071988964228e2d86e7f1d4d5 Mon Sep 17 00:00:00 2001 From: Joel Stanley Date: Wed, 17 Jan 2018 00:36:50 -0600 Subject: [PATCH 091/219] liteeth: bump to latest upstream version This contains a new CSR register required by the Linux kernel driver. Other register changes due to a sync with upstream mean that the BIOS and firmware will need a recompile in order to work with this gateware. Signed-off-by: Joel Stanley --- third_party/liteeth | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/liteeth b/third_party/liteeth index 937c2407..8fc71610 160000 --- a/third_party/liteeth +++ b/third_party/liteeth @@ -1 +1 @@ -Subproject commit 937c2407276371d9f8c1bb19c4ae8e97e581da83 +Subproject commit 8fc716103670e703c7fe98c9bdf653b9b53ca12a From 1ed9ef3c630001f446a1cc529111beafd087c50c Mon Sep 17 00:00:00 2001 From: Ewen McNeill Date: Wed, 17 Jan 2018 19:34:05 +1100 Subject: [PATCH 092/219] build-micropython.sh: insist FIRMWARE=micropython Insist that FIRMWARE=micropython, so that "make image" automatically produces a iamge-gatware+bios+micropython.bin file, and manual steps to build micropython.bin are not required; remove manual steps that were building micropython.bin. --- scripts/build-micropython.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/build-micropython.sh b/scripts/build-micropython.sh index 8135a22a..5147defc 100755 --- a/scripts/build-micropython.sh +++ b/scripts/build-micropython.sh @@ -33,6 +33,11 @@ make info set -x set -e +if [ "$FIRMWARE" != "micropython" ]; then + echo "When building MicroPython you should set FIRMWARE to 'micropython'." + exit 1 +fi + # Install a toolchain with the newlib standard library if ! $CPU-elf-newlib-gcc --version > /dev/null 2>&1; then conda install gcc-$CPU-elf-newlib @@ -76,6 +81,3 @@ cd $OLD_DIR # Generate a firmware image suitable for flashing. make image -# -python -m litex.soc.tools.mkmscimg -f $TARGET_MPY_BUILD_DIR/firmware.bin -o $TARGET_MPY_BUILD_DIR/firmware.fbi -/usr/bin/env python mkimage.py $MISOC_EXTRA_CMDLINE $LITEX_EXTRA_CMDLINE --output-file=$TARGET_BUILD_DIR/micropython.bin --override-firmware=$TARGET_MPY_BUILD_DIR/firmware.fbi From cc79d867453e11914aa070d321e4febf9cffca6e Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Wed, 17 Jan 2018 21:39:46 +1100 Subject: [PATCH 093/219] Make qemu script work on Arch --- Makefile | 2 +- scripts/build-qemu.sh | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index f6b7bd9f..067491f0 100644 --- a/Makefile +++ b/Makefile @@ -311,7 +311,7 @@ tftpd_start: sudo true @if sudo which atftpd >/dev/null ; then \ echo "Starting aftpd"; \ - sudo atftpd --verbose --bind-address $(TFTP_IPRANGE).100 --daemon --logfile /dev/stdout --no-fork --user $(shell whoami) $(TFTPD_DIR) & \ + sudo atftpd --verbose --bind-address $(TFTP_IPRANGE).100 --daemon --logfile /dev/stdout --no-fork --user $(shell whoami) --group $(shell whoami) $(TFTPD_DIR) & \ elif sudo which in.tftpd >/dev/null; then \ echo "Starting in.tftpd"; \ sudo in.tftpd --verbose --listen --address $(TFTP_IPRANGE).100 --user $(shell whoami) -s $(TFTPD_DIR) & \ diff --git a/scripts/build-qemu.sh b/scripts/build-qemu.sh index 60f58773..2e498f55 100755 --- a/scripts/build-qemu.sh +++ b/scripts/build-qemu.sh @@ -129,7 +129,15 @@ if grep -q ETHMAC_BASE $TARGET_BUILD_DIR/software/include/generated/csr.h; then exit 1 fi sudo chown $(whoami) /dev/net/tap0 - sudo ifconfig tap0 $TFTP_IPRANGE.100 up + if sudo which ifconifg > /dev/null; then + sudo ifconfig tap0 $TFTP_IPRANGE.100 up + elif sudo which ip > /dev/null; then + sudo ip addr add $TFTP_IPRANGE.100/24 dev tap0 + sudo ip link set dev tap0 up + else + echo "Unable to find tool to configure tap0 address" + exit 1 + fi make tftpd_start fi EXTRA_ARGS+=("-net nic -net tap,ifname=tap0,script=no,downscript=no") From e1860b53febace37006440a4f47fc86c542d7b81 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Wed, 17 Jan 2018 14:59:54 +1100 Subject: [PATCH 094/219] travis: Using subversion for prebuilt stuff. --- .travis/build.sh | 26 +++++++++----- .travis/download-prebuilt.sh | 53 ++++++++++++++-------------- .travis/push-prebuilt.sh | 67 +++++++++++++++++++----------------- 3 files changed, 78 insertions(+), 68 deletions(-) diff --git a/.travis/build.sh b/.travis/build.sh index 55a6f866..2c18c6e5 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -219,7 +219,7 @@ function build() { if [ -d "$PREBUILT_DIR" ]; then COPY_DEST="$PREBUILT_DIR/archive/$GIT_REVISION/$FULL_PLATFORM/$TARGET/$FULL_CPU/" - mkdir -p $COPY_DEST + svn mkdir --parents $COPY_DEST echo "" echo "" echo "" @@ -274,13 +274,23 @@ function build() { cd $COPY_DEST echo $PWD ls -l -a . - git add -A . - git commit -a \ - -m "Travis build #$TRAVIS_BUILD_NUMBER of $GIT_REVISION for PLATFORM=$FULL_PLATFORM TARGET=$TARGET CPU=$FULL_CPU FIRMWARE=$FIRMWARE" \ - -m "" \ - -m "From https://github.com/$TRAVIS_REPO_SLUG/tree/$TRAVIS_COMMIT" \ - -m "$TRAVIS_COMIT_MESSAGE" - git diff HEAD~1 --stat=1000,1000 + svn add --parents * + ) + ( + cd $PREBUILT_DIR + echo $PWD + COMMIT_MSG=$(tempfile -s .msg) + cat > $COMMIT_MSG < /dev/null - git config core.sparseCheckout true - ( - git remote add origin https://$GH_TOKEN@github.com/$PREBUILT_REPO_OWNER/${PREBUILT_REPO}.git - ) > /dev/null - cat > .git/info/sparse-checkout < /dev/null 2>&1 ; then echo "Push success!" else From f95eaf40fd9e7b91488bbadf8061636916b8e4db Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Thu, 18 Jan 2018 12:12:30 +1100 Subject: [PATCH 095/219] travis: Fix the git disk usage output. --- .travis/fixup-git.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis/fixup-git.sh b/.travis/fixup-git.sh index 463b41d3..f03fbdfe 100755 --- a/.travis/fixup-git.sh +++ b/.travis/fixup-git.sh @@ -2,6 +2,8 @@ set -e +DF_BEFORE_GIT="$(($(stat -f --format="%a*%S" .)))" + echo "" echo "" echo "" @@ -114,5 +116,4 @@ echo "---------------------------------------------" df -h echo "" DF_AFTER_GIT="$(($(stat -f --format="%a*%S" .)))" -awk "BEGIN {printf \"Git is using %.2f megabytes\n\",($DF_LAST-$DF_AFTER_GIT)/1024/1024}" -DF_LAST="$DF_AFTER_GIT" +awk "BEGIN {printf \"Git is using %.2f megabytes\n\",($DF_BEFORE_GIT-$DF_AFTER_GIT)/1024/1024}" From 2a9ff93fb3eb04c1b1d1077112de1840f0c883d4 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Thu, 18 Jan 2018 13:35:16 +1100 Subject: [PATCH 096/219] travis: Small cleanup of new subversion support. --- .travis/build.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.travis/build.sh b/.travis/build.sh index 2c18c6e5..4e29842a 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -217,15 +217,16 @@ function build() { # Save the resulting binaries into the prebuilt repo. The gateware # should always exist, but others might not. if [ -d "$PREBUILT_DIR" ]; then - COPY_DEST="$PREBUILT_DIR/archive/$GIT_REVISION/$FULL_PLATFORM/$TARGET/$FULL_CPU/" - - svn mkdir --parents $COPY_DEST echo "" echo "" echo "" - echo "- Adding built files to $(cd $COPY_DEST; git remote get-url origin)" + echo "- Adding built files to $(cd $COPY_DEST; svn info | grep "Repository Root:")" echo "---------------------------------------------" + COPY_DEST="$PREBUILT_DIR/archive/$GIT_REVISION/$FULL_PLATFORM/$TARGET/$FULL_CPU/" + + svn mkdir --parents $COPY_DEST + declare -a SAVE SAVE+="image*.bin" # Combined binary include gateware+bios+firmware # Gateware output for using @@ -260,6 +261,8 @@ function build() { cp $TARGET_BUILD_DIR/software/firmware/version_data.c $COPY_DEST/logs/version_data.c cp $TARGET_BUILD_DIR/output.*.log $COPY_DEST/logs/ + find $COPY_DEST -empty -delete + ( cd $COPY_DEST sha256sum $(find -type f) > sha256sum.txt From 26eeeefcc6879002c124d02d531996ade9290ce3 Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Thu, 18 Jan 2018 13:37:18 +1100 Subject: [PATCH 097/219] Use default group instead --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 067491f0..cc96897f 100644 --- a/Makefile +++ b/Makefile @@ -311,7 +311,7 @@ tftpd_start: sudo true @if sudo which atftpd >/dev/null ; then \ echo "Starting aftpd"; \ - sudo atftpd --verbose --bind-address $(TFTP_IPRANGE).100 --daemon --logfile /dev/stdout --no-fork --user $(shell whoami) --group $(shell whoami) $(TFTPD_DIR) & \ + sudo atftpd --verbose --bind-address $(TFTP_IPRANGE).100 --daemon --logfile /dev/stdout --no-fork --user $(shell whoami) --group $(shell id -gn) $(TFTPD_DIR) & \ elif sudo which in.tftpd >/dev/null; then \ echo "Starting in.tftpd"; \ sudo in.tftpd --verbose --listen --address $(TFTP_IPRANGE).100 --user $(shell whoami) -s $(TFTPD_DIR) & \ From e9f875223f2c7a5354050763ec2f2bd98b68dce6 Mon Sep 17 00:00:00 2001 From: Ewen McNeill Date: Thu, 18 Jan 2018 14:46:34 +1100 Subject: [PATCH 098/219] TFTP: Support alternate TFTP Server Port If TFTP_SERVER_PORT is set in the environment, TFTP server will be started on that port; if not, it is started on UDP/69 (well known TFTP service port) as before. If TFTP_SERVER_PORT is set in environment during build of litex BIOS, then TFTP client will try to reach TFTP server on that port first before falling back to UDP/69. If TFTP_SERVER_PORT >= 1024 then TFTP server is started as user without using sudo (otherwise sudo is used as before). Tested with atftpd; in.tftpd equivalent added but not tested. --- Makefile | 24 +++++++++++++++++++++--- third_party/litex | 2 +- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index cc96897f..abd8f089 100644 --- a/Makefile +++ b/Makefile @@ -125,6 +125,9 @@ TFTP_IPRANGE ?= 192.168.100 export TFTP_IPRANGE TFTPD_DIR ?= build/tftpd/ +# Default TFTP Server Port to IANA well known UDP/69 +TFTP_SERVER_PORT ?= 69 + # Couple of Python settings. # --------------------------------- # Turn off Python's hash randomization @@ -298,6 +301,10 @@ bios-flash: $(BIOS_FILE) bios-flash-$(PLATFORM) # TFTP booting stuff # -------------------------------------- # TFTP server for minisoc to load firmware from +# +# We can run the TFTP server as the user if port >= 1024 +# otherwise we need to run as root using sudo + tftp: $(FIRMWARE_FILEBASE).bin mkdir -p $(TFTPD_DIR) cp $(FIRMWARE_FILEBASE).bin $(TFTPD_DIR)/boot.bin @@ -308,13 +315,24 @@ tftpd_stop: tftpd_start: mkdir -p $(TFTPD_DIR) - sudo true + @if [ $(TFTP_SERVER_PORT) -lt 1024 ]; then \ + echo "Root required to run TFTP Server, will use sudo"; \ + sudo true; \ + fi @if sudo which atftpd >/dev/null ; then \ echo "Starting aftpd"; \ - sudo atftpd --verbose --bind-address $(TFTP_IPRANGE).100 --daemon --logfile /dev/stdout --no-fork --user $(shell whoami) --group $(shell id -gn) $(TFTPD_DIR) & \ + if [ $(TFTP_SERVER_PORT) -lt 1024 ]; then \ + sudo atftpd --verbose --bind-address $(TFTP_IPRANGE).100 --port $(TFTP_SERVER_PORT) --daemon --logfile /dev/stdout --no-fork --user $(shell whoami) --group $(shell id -gn) $(TFTPD_DIR) & \ + else \ + atftpd --verbose --bind-address $(TFTP_IPRANGE).100 --port $(TFTP_SERVER_PORT) --daemon --logfile /dev/stdout --no-fork --user $(shell whoami) --group $(shell id -gn) $(TFTPD_DIR) & \ + fi \ elif sudo which in.tftpd >/dev/null; then \ echo "Starting in.tftpd"; \ - sudo in.tftpd --verbose --listen --address $(TFTP_IPRANGE).100 --user $(shell whoami) -s $(TFTPD_DIR) & \ + if [ $(TFTP_SERVER_PORT) -lt 1024 ]; then \ + sudo in.tftpd --verbose --listen --address $(TFTP_IPRANGE).100 --port-range $(TFTP_SERVER_PORT):$(TFTP_SERVER_PORT) --user $(shell whoami) -s $(TFTPD_DIR) & \ + else \ + in.tftpd --verbose --listen --address $(TFTP_IPRANGE).100 --port-range $(TFTP_SERVER_PORT):$(TFTP_SERVER_PORT) --user $(shell whoami) -s $(TFTPD_DIR) & \ + fi \ else \ echo "Cannot find an appropriate tftpd binary to launch the server."; \ false; \ diff --git a/third_party/litex b/third_party/litex index ab1146e1..fcc22350 160000 --- a/third_party/litex +++ b/third_party/litex @@ -1 +1 @@ -Subproject commit ab1146e1b01132b07aceaff65f96a3e6956dd86d +Subproject commit fcc22350fb6f9fa38ee07bb77ae0a3dca90a9e04 From 41af38f9feb4c803b690b48f9d535ea4a76199c2 Mon Sep 17 00:00:00 2001 From: Tim Ansell Date: Thu, 18 Jan 2018 15:10:01 +1100 Subject: [PATCH 099/219] Use non-privileged port by default Less root is good... --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index abd8f089..c84f00b6 100644 --- a/Makefile +++ b/Makefile @@ -126,7 +126,7 @@ export TFTP_IPRANGE TFTPD_DIR ?= build/tftpd/ # Default TFTP Server Port to IANA well known UDP/69 -TFTP_SERVER_PORT ?= 69 +TFTP_SERVER_PORT ?= 6069 # Couple of Python settings. # --------------------------------- From 920d5122ed10111df16a3af70c913bc2b5729280 Mon Sep 17 00:00:00 2001 From: Ewen McNeill Date: Thu, 18 Jan 2018 16:13:21 +1100 Subject: [PATCH 100/219] TFTP: Run TFTP server without sudo by default This also removes the "sudo which atftpd" command to avoid running sudo just to find out where TFTP server is; instead we try "which atftpd" (as user, not root), and then fall back to /usr/sbin/atftpd --- Makefile | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index c84f00b6..003a1292 100644 --- a/Makefile +++ b/Makefile @@ -125,8 +125,12 @@ TFTP_IPRANGE ?= 192.168.100 export TFTP_IPRANGE TFTPD_DIR ?= build/tftpd/ -# Default TFTP Server Port to IANA well known UDP/69 +# Well known TFTP Server Port is UDP/69 +# Default to high numbered port so we can run TFTP server as non-root +# (export into shell environment to use during building firmware BIOS) +# TFTP_SERVER_PORT ?= 6069 +export TFTP_SERVER_PORT # Couple of Python settings. # --------------------------------- @@ -305,6 +309,12 @@ bios-flash: $(BIOS_FILE) bios-flash-$(PLATFORM) # We can run the TFTP server as the user if port >= 1024 # otherwise we need to run as root using sudo +ATFTPD=$(shell which atftpd) +ATFTPD?=/usr/sbin/atftpd + +IN_TFTPD=$(shell which in.tfptd) +IN_TFTPD=?=/usr/sbin/in.tftpd + tftp: $(FIRMWARE_FILEBASE).bin mkdir -p $(TFTPD_DIR) cp $(FIRMWARE_FILEBASE).bin $(TFTPD_DIR)/boot.bin @@ -319,19 +329,19 @@ tftpd_start: echo "Root required to run TFTP Server, will use sudo"; \ sudo true; \ fi - @if sudo which atftpd >/dev/null ; then \ + @if [ -x "$(ATFTPD)" ]; then \ echo "Starting aftpd"; \ if [ $(TFTP_SERVER_PORT) -lt 1024 ]; then \ - sudo atftpd --verbose --bind-address $(TFTP_IPRANGE).100 --port $(TFTP_SERVER_PORT) --daemon --logfile /dev/stdout --no-fork --user $(shell whoami) --group $(shell id -gn) $(TFTPD_DIR) & \ + sudo "$(ATFTPD)" --verbose --bind-address $(TFTP_IPRANGE).100 --port $(TFTP_SERVER_PORT) --daemon --logfile /dev/stdout --no-fork --user $(shell whoami) --group $(shell id -gn) $(TFTPD_DIR) & \ else \ - atftpd --verbose --bind-address $(TFTP_IPRANGE).100 --port $(TFTP_SERVER_PORT) --daemon --logfile /dev/stdout --no-fork --user $(shell whoami) --group $(shell id -gn) $(TFTPD_DIR) & \ + "$(ATFTPD)" --verbose --bind-address $(TFTP_IPRANGE).100 --port $(TFTP_SERVER_PORT) --daemon --logfile /dev/stdout --no-fork --user $(shell whoami) --group $(shell id -gn) $(TFTPD_DIR) & \ fi \ - elif sudo which in.tftpd >/dev/null; then \ + elif [ -x "$(IN_TFTPD)" ]; then \ echo "Starting in.tftpd"; \ if [ $(TFTP_SERVER_PORT) -lt 1024 ]; then \ - sudo in.tftpd --verbose --listen --address $(TFTP_IPRANGE).100 --port-range $(TFTP_SERVER_PORT):$(TFTP_SERVER_PORT) --user $(shell whoami) -s $(TFTPD_DIR) & \ + sudo "$(IN_TFTPD)" --verbose --listen --address $(TFTP_IPRANGE).100 --port-range $(TFTP_SERVER_PORT):$(TFTP_SERVER_PORT) --user $(shell whoami) -s $(TFTPD_DIR) & \ else \ - in.tftpd --verbose --listen --address $(TFTP_IPRANGE).100 --port-range $(TFTP_SERVER_PORT):$(TFTP_SERVER_PORT) --user $(shell whoami) -s $(TFTPD_DIR) & \ + "$(IN_TFTPD)" --verbose --listen --address $(TFTP_IPRANGE).100 --port-range $(TFTP_SERVER_PORT):$(TFTP_SERVER_PORT) --user $(shell whoami) -s $(TFTPD_DIR) & \ fi \ else \ echo "Cannot find an appropriate tftpd binary to launch the server."; \ @@ -372,6 +382,7 @@ env: @echo "export BIOS_FILE='$(BIOS_FILE)'" @# Network settings @echo "export TFTP_IPRANGE='$(TFTP_IPRANGE)'" + @echo "export TFTP_SERVER_PORT='$(TFTP_SERVER_PORT)'" @echo "export TFTPD_DIR='$(TFTPD_DIR)'" info: From ba0f8ea0f76b645f4577caeabda69dee0b41b32c Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Thu, 18 Jan 2018 14:44:54 +1100 Subject: [PATCH 101/219] Makefile: Colors work now! --- Makefile | 5 +++++ third_party/litex | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 003a1292..fd3d6073 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,11 @@ ifneq ($(OS),Windows_NT) ifeq ($(HDMI2USB_ENV),) $(error "Please enter environment. 'source scripts/enter-env.sh'") endif + +# Force colors despite running through tee. +COLORAMA=force +export COLORAMA + endif PYTHON ?= python diff --git a/third_party/litex b/third_party/litex index fcc22350..ead88ed6 160000 --- a/third_party/litex +++ b/third_party/litex @@ -1 +1 @@ -Subproject commit fcc22350fb6f9fa38ee07bb77ae0a3dca90a9e04 +Subproject commit ead88ed66d15cbf92c165092dff86fbef071ff9b From 057034c59f68ab4cbc706734a718a04f5c387346 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Wed, 10 Jan 2018 13:54:26 +1100 Subject: [PATCH 102/219] scripts: Move to Python 3.6 --- scripts/download-env.sh | 9 +++++---- scripts/enter-env.sh | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/download-env.sh b/scripts/download-env.sh index 35783890..fe9e512f 100755 --- a/scripts/download-env.sh +++ b/scripts/download-env.sh @@ -219,13 +219,14 @@ eval $(cd $TOP_DIR; export HDMI2USB_ENV=1; make env || return 1) || exit 1 echo ) || exit 1 +echo "python ==3.6" > $CONDA_DIR/conda-meta/pinned # Make sure it stays at version 3.6 + # Check the Python version echo -echo "Installing python3.5" -conda install -y $CONDA_FLAGS python=3.5 +echo "Installing python3.6" +conda install -y $CONDA_FLAGS python=3.6 fix_conda -check_version python 3.5 -echo "python ==3.5.4" > $CONDA_DIR/conda-meta/pinned # Make sure it stays at version 3.5 +check_version python 3.6 echo "" echo "Installing binaries into environment" diff --git a/scripts/enter-env.sh b/scripts/enter-env.sh index ea93a893..c90d1601 100755 --- a/scripts/enter-env.sh +++ b/scripts/enter-env.sh @@ -181,7 +181,8 @@ eval $(cd $TOP_DIR; export HDMI2USB_ENV=1; make env || return 1) || return 1 -check_version python 3.5 || return 1 + +check_version python 3.6 || return 1 echo "" echo "Checking binaries in environment" From ddd71f41b1e4942610de5e3f6cac667a6d2dd53b Mon Sep 17 00:00:00 2001 From: Ewen McNeill Date: Fri, 19 Jan 2018 14:16:51 +1100 Subject: [PATCH 103/219] arty: Support "make firmware-load" for F=micropython --- targets/arty/Makefile.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/targets/arty/Makefile.mk b/targets/arty/Makefile.mk index d2af89c4..51f04b77 100644 --- a/targets/arty/Makefile.mk +++ b/targets/arty/Makefile.mk @@ -25,7 +25,8 @@ gateware-flash-$(PLATFORM): gateware-flash-py # Firmware firmware-load-$(PLATFORM): - flterm --port=$(COMM_PORT) --kernel=$(TARGET_BUILD_DIR)/software/firmware/firmware.bin --speed=$(BAUD) + flterm --port=$(COMM_PORT) --kernel=$(FIRMWARE_FILEBASE).bin --speed=$(BAUD) + firmware-flash-$(PLATFORM): firmwage-flash-py @true From f6e36d5671627320533df4e18badffd55274caf8 Mon Sep 17 00:00:00 2001 From: Ryan Verner Date: Fri, 19 Jan 2018 15:20:27 +1100 Subject: [PATCH 104/219] Fixes dvisampler1 displaying as dvisampler0 --- firmware/hdmi_in.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/firmware/hdmi_in.sh b/firmware/hdmi_in.sh index 2f32db09..fd32c629 100755 --- a/firmware/hdmi_in.sh +++ b/firmware/hdmi_in.sh @@ -32,11 +32,13 @@ cat $FIRMWARE_DIR/hdmi_in0.h | sed \ -e"s/IN0_INDEX\([^0-9]\+\)0/IN${X}_INDEX\1$X/g" \ -e"s/IN0/IN$X/g" \ -e"s/in0/in$X/g" \ + -e"s/dvisampler0/dvisampler$X/g" \ > $TMPFILE_H cat $FIRMWARE_DIR/hdmi_in0.c | sed \ -e"s/IN0/IN$X/g" \ -e"s/in0/in$X/g" \ + -e"s/dvisampler0/dvisampler$X/g" \ > $TMPFILE_C if ! cmp -s $TMPFILE_H hdmi_in$X.h; then From a8fb41447751fd0b911174fd89db1722d0c5fe42 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Fri, 19 Jan 2018 18:51:54 +1100 Subject: [PATCH 105/219] make: Always pass an ident value. --- make.py | 2 +- targets/netv2/base.py | 1 - targets/netv2/bridge_pcie.py | 1 - targets/netv2/bridge_uart.py | 1 - 4 files changed, 1 insertion(+), 4 deletions(-) diff --git a/make.py b/make.py index d5d27ca7..488fb70c 100755 --- a/make.py +++ b/make.py @@ -105,7 +105,7 @@ def main(): platform = get_platform(args) exec("from targets.{}.{} import SoC".format(args.platform, args.target.lower(), args.target), globals()) - soc = SoC(platform, **soc_sdram_argdict(args), **dict(args.target_option)) + soc = SoC(platform, ident=SoC.__class__.__name__, **soc_sdram_argdict(args), **dict(args.target_option)) if hasattr(soc, 'configure_iprange'): soc.configure_iprange(args.iprange) diff --git a/targets/netv2/base.py b/targets/netv2/base.py index db33c575..15a54a86 100755 --- a/targets/netv2/base.py +++ b/targets/netv2/base.py @@ -94,7 +94,6 @@ def __init__(self, platform, **kwargs): SoCSDRAM.__init__(self, platform, clk_freq, integrated_rom_size=0x8000, integrated_sram_size=0x8000, - ident="NeTV2 LiteX Base SoC", **kwargs) self.submodules.crg = _CRG(platform) diff --git a/targets/netv2/bridge_pcie.py b/targets/netv2/bridge_pcie.py index 656d6224..3965d06a 100644 --- a/targets/netv2/bridge_pcie.py +++ b/targets/netv2/bridge_pcie.py @@ -64,7 +64,6 @@ def __init__(self, platform, with_uart_bridge=True, **kwargs): shadow_base=0x00000000, csr_data_width=32, with_uart=False, - ident="NeTV2 LiteX PCIe SoC", with_timer=False, **kwargs) self.submodules.crg = _CRG(platform) diff --git a/targets/netv2/bridge_uart.py b/targets/netv2/bridge_uart.py index cad73fd6..d1eaf3bd 100644 --- a/targets/netv2/bridge_uart.py +++ b/targets/netv2/bridge_uart.py @@ -113,7 +113,6 @@ def __init__(self, platform, **kwargs): SoCSDRAM.__init__(self, platform, clk_freq, integrated_rom_size=0x8000, integrated_sram_size=0x8000, - ident="NeTV2 LiteX Base SoC", with_uart=False, **kwargs) From a28dcbf833fa5acea630cad29b43cd321d2c9ede Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Sat, 20 Jan 2018 00:08:41 +1100 Subject: [PATCH 106/219] make: fix ident string --- make.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make.py b/make.py index 488fb70c..d5e5d009 100755 --- a/make.py +++ b/make.py @@ -105,7 +105,7 @@ def main(): platform = get_platform(args) exec("from targets.{}.{} import SoC".format(args.platform, args.target.lower(), args.target), globals()) - soc = SoC(platform, ident=SoC.__class__.__name__, **soc_sdram_argdict(args), **dict(args.target_option)) + soc = SoC(platform, ident=SoC.__name__, **soc_sdram_argdict(args), **dict(args.target_option)) if hasattr(soc, 'configure_iprange'): soc.configure_iprange(args.iprange) From 9eaa6220b885e502446591247b39f184ecd4802e Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sat, 20 Jan 2018 20:35:55 +1100 Subject: [PATCH 107/219] scripts: Remove unneeded gzip. The cpio.gz is now already compressed. --- scripts/build-linux.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/build-linux.sh b/scripts/build-linux.sh index 342710d6..02bdcc5f 100755 --- a/scripts/build-linux.sh +++ b/scripts/build-linux.sh @@ -142,9 +142,6 @@ TARGET_LINUX_BUILD_DIR=$(dirname $TOP_DIR/$FIRMWARE_FILEBASE) if [ ! -e $ROOTFS ]; then wget "https://ozlabs.org/~joel/openrisc-rootfs.cpio.gz" -O $ROOTFS fi - if [ ! -e $ROOTFS.gz ]; then - gzip -k $ROOTFS - fi ) make O="$TARGET_LINUX_BUILD_DIR" litex_defconfig time make O="$TARGET_LINUX_BUILD_DIR" -j$JOBS From 2f85afe1da58be9a2b911ff14d17640a40a51c3a Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sat, 20 Jan 2018 20:37:30 +1100 Subject: [PATCH 108/219] Makefile: Don't use sudo for stop atftp if running on low port. --- Makefile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index fd3d6073..4bbe9133 100644 --- a/Makefile +++ b/Makefile @@ -325,8 +325,13 @@ tftp: $(FIRMWARE_FILEBASE).bin cp $(FIRMWARE_FILEBASE).bin $(TFTPD_DIR)/boot.bin tftpd_stop: - sudo true - sudo killall atftpd || sudo killall in.tftpd || true # FIXME: This is dangerous... + # FIXME: This is dangerous... + @if [ $(TFTP_SERVER_PORT) -lt 1024 ]; then \ + sudo true; \ + sudo killall atftpd || sudo killall in.tftpd || true; \ + else \ + killall atftpd || killall in.tftpd || true; \ + fi tftpd_start: mkdir -p $(TFTPD_DIR) From 6e1dc17dbeca1a4c9c486825789aaf7a2bf377c4 Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Sat, 20 Jan 2018 20:40:55 +1100 Subject: [PATCH 109/219] Makefile: Update the submodules when building gateware and firmware. --- Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 4bbe9133..2722dc1b 100644 --- a/Makefile +++ b/Makefile @@ -208,13 +208,13 @@ image-flash-py: image .PHONY: image image-load image-flash image-flash-py image-flash-$(PLATFORM) image-load-$(PLATFORM) .NOTPARALLEL: image-load image-flash image-flash-py image-flash-$(PLATFORM) image-load-$(PLATFORM) -# Gateware - the stuff which configures the FPGA. -# -------------------------------------- -GATEWARE_MODULES=litex litedram liteeth litepcie litesata litescope liteusb litevideo litex -gateware-submodules: $(addsuffix /.git,$(addprefix third_party/,$(GATEWARE_MODULES))) +LITEX_SUBMODULES=litex litedram liteeth litepcie litesata litescope liteusb litevideo +litex-submodules: $(addsuffix /.git,$(addprefix third_party/,$(LITEX_SUBMODULES))) @true -gateware: gateware-submodules +# Gateware - the stuff which configures the FPGA. +# -------------------------------------- +gateware: litex-submodules mkdir -p $(TARGET_BUILD_DIR) ifneq ($(OS),Windows_NT) $(MAKE_CMD) \ @@ -250,7 +250,7 @@ gateware-clean: # Firmware - the stuff which runs in the soft CPU inside the FPGA. # -------------------------------------- -firmware-cmd: +firmware-cmd: litex-submodules mkdir -p $(TARGET_BUILD_DIR) ifneq ($(OS),Windows_NT) $(MAKE_CMD) --no-compile-gateware \ From 2ed881484747b9de83f88f77e370e09fab91dbf8 Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Sat, 20 Jan 2018 20:44:01 +1100 Subject: [PATCH 110/219] Makefile: Make pyclean quiet. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2722dc1b..13bdc06c 100644 --- a/Makefile +++ b/Makefile @@ -486,7 +486,7 @@ reset: reset-$(PLATFORM) clean: rm -f build/cache.mk rm -rf $(TARGET_BUILD_DIR) - py3clean . || rm -rf $$(find -name __pycache__) + py3clean . 2>/dev/null || rm -rf $$(find -name __pycache__) dist-clean: rm -rf build From 41abcb39414daf3d7ab5cb1e58ef296e0b9b7796 Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Sat, 20 Jan 2018 20:51:34 +1100 Subject: [PATCH 111/219] firmware/*.sh: Not finding tempfile should be quiet. --- firmware/hdmi_in.sh | 4 ++-- firmware/version_data.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/firmware/hdmi_in.sh b/firmware/hdmi_in.sh index fd32c629..c334a5c9 100755 --- a/firmware/hdmi_in.sh +++ b/firmware/hdmi_in.sh @@ -25,8 +25,8 @@ X=$1 set -e # These must be outside the heredoc below otherwise the script won't error. -TMPFILE_H=$(tempfile -s .h | mktemp --suffix=.h) -TMPFILE_C=$(tempfile -s .c | mktemp --suffix=.c) +TMPFILE_H=$(tempfile -s .h 2>/dev/null || mktemp --suffix=.h) +TMPFILE_C=$(tempfile -s .c 2>/dev/null || mktemp --suffix=.c) cat $FIRMWARE_DIR/hdmi_in0.h | sed \ -e"s/IN0_INDEX\([^0-9]\+\)0/IN${X}_INDEX\1$X/g" \ diff --git a/firmware/version_data.sh b/firmware/version_data.sh index 0b2c5fdf..17e06f26 100755 --- a/firmware/version_data.sh +++ b/firmware/version_data.sh @@ -7,8 +7,8 @@ COMMIT="$(git log --format="%H" -n 1)" BRANCH="$(git symbolic-ref --short HEAD)" DESCRIBE="$(git describe --dirty)" -TMPFILE_H=$(tempfile -s .h || mktemp --suffix=.h) -TMPFILE_C=$(tempfile -s .c || mktemp --suffix=.c) +TMPFILE_H=$(tempfile -s .h 2>/dev/null || mktemp --suffix=.h) +TMPFILE_C=$(tempfile -s .c 2>/dev/null || mktemp --suffix=.c) UPLATFORM="$(echo $PLATFORM | tr '[:lower:]' '[:upper:]')" UTARGET="$(echo $TARGET | tr '[:lower:]' '[:upper:]')" From 09c0364c2c11be4c3198e4a7c042c5eff0900f39 Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Sat, 20 Jan 2018 23:12:12 +1100 Subject: [PATCH 112/219] scripts: Fix broken GIT_LOCAL usage. --- scripts/build-linux.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build-linux.sh b/scripts/build-linux.sh index 02bdcc5f..e6477cbd 100755 --- a/scripts/build-linux.sh +++ b/scripts/build-linux.sh @@ -78,7 +78,7 @@ LINUX_BRANCH=${LINUX_BRANCH:-litex-minimal} CURRENT_LINUX_REMOTE_NAME=$(git remote -v | grep fetch | grep "$LINUX_REMOTE_BIT" | sed -e's/\t.*$//') if [ x"$CURRENT_LINUX_REMOTE_NAME" = x ]; then git remote add $LINUX_REMOTE_NAME $LINUX_REMOTE - CURRENT_LINUX_REMOTE_NAME=$CURRENT_LINUX_REMOTE_NAME + CURRENT_LINUX_REMOTE_NAME=$LINUX_REMOTE_NAME fi # Get any new data From 26a2c2c6583a2e6588a1e4e5405f8203ce86749b Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sat, 20 Jan 2018 23:08:51 +1100 Subject: [PATCH 113/219] scripts: Fetch qemu in build-qemu in the same way we do Linux. --- scripts/build-qemu.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/scripts/build-qemu.sh b/scripts/build-qemu.sh index 2e498f55..9edf80d4 100755 --- a/scripts/build-qemu.sh +++ b/scripts/build-qemu.sh @@ -33,6 +33,10 @@ make info set -x set -e +QEMU_REMOTE="${QEMU_REMOTE:-https://github.com/timvideos/qemu-litex.git}" +QEMU_REMOTE_NAME=timvideos-qemu-litex +QEMU_REMOTE_BIT=$(echo $QEMU_REMOTE | sed -e's-^.*://--' -e's/.git$//') +QEMU_BRANCH=${QEMU_BRANCH:-master} QEMU_SRC_DIR=$TOP_DIR/third_party/qemu-litex if [ ! -d "$QEMU_SRC_DIR" ]; then ( @@ -41,6 +45,26 @@ if [ ! -d "$QEMU_SRC_DIR" ]; then cd $QEMU_SRC_DIR git submodule update --init dtc ) +else + ( + cd $QEMU_SRC_DIR + + # Add the remote if it doesn't exist + CURRENT_QEMU_REMOTE_NAME=$(git remote -v | grep fetch | grep "$QEMU_REMOTE_BIT" | sed -e's/\t.*$//') + if [ x"$CURRENT_QEMU_REMOTE_NAME" = x ]; then + git remote add $QEMU_REMOTE_NAME $QEMU_REMOTE + CURRENT_QEMU_REMOTE_NAME=$QEMU_REMOTE_NAME + fi + + # Get any new data + git fetch $CURRENT_QEMU_REMOTE_NAME + + # Checkout or1k-linux branch it not already on it + if [ "$(git rev-parse --abbrev-ref HEAD)" != "$QEMU_BRANCH" ]; then + git checkout $QEMU_BRANCH || \ + git checkout "$CURRENT_QEMU_REMOTE_NAME/$QEMU_BRANCH" -b $QEMU_BRANCH + fi + ) fi TARGET_QEMU_BUILD_DIR=$TARGET_BUILD_DIR/qemu From 63076749cf49ec83af4661918824bd98f63eb222 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sun, 21 Jan 2018 00:35:51 +1100 Subject: [PATCH 114/219] scripts: Make the network setup in build-qemu more robust. --- scripts/build-qemu.sh | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/scripts/build-qemu.sh b/scripts/build-qemu.sh index 9edf80d4..78b82903 100755 --- a/scripts/build-qemu.sh +++ b/scripts/build-qemu.sh @@ -140,30 +140,48 @@ if grep -q ETHMAC_BASE $TARGET_BUILD_DIR/software/include/generated/csr.h; then QEMU_NETWORK=${QEMU_NETWORK:-tap} case $QEMU_NETWORK in tap) + echo "Using tun device for QEmu networking, (may need sudo)..." + # Make the tap0 dev node exists if [ ! -e /dev/net/tap0 ]; then - echo "Need to create and bring up a tun device, needing sudo..." sudo true sudo mknod /dev/net/tap0 c 10 200 + sudo chown $(whoami) /dev/net/tap0 + fi + + # Check that the tap0 network interface exists + if [ ! -e /sys/class/net/tap0 ]; then + sudo true if sudo which openvpn > /dev/null; then - sudo openvpn --mktun --dev tap0 + sudo openvpn --mktun --dev tap0 --user $(whoami) elif sudo which tunctl > /dev/null; then sudo tunctl -t tap0 -u $(whoami) else echo "Unable to find tool to create tap0 device!" exit 1 fi - sudo chown $(whoami) /dev/net/tap0 - if sudo which ifconifg > /dev/null; then - sudo ifconfig tap0 $TFTP_IPRANGE.100 up - elif sudo which ip > /dev/null; then + fi + + # Check the tap0 device if configure and up + if sudo which ifconfig > /dev/null; then + if ! ifconfig tap0 | grep -q "UP" || ! ifconfig tap0 | grep -q "$TFTP_IPRANGE.100"; then + sudo true + sudo ifconfig tap0 $TFTP_IPRANGE.100 netmask 255.255.255.0 up + fi + elif sudo which ip > /dev/null; then + if ! ip addr show tap0 | grep -q "UP" || ! ip addr show tap0 | grep -q "$TFTP_IPRANGE.100"; then + sudo true sudo ip addr add $TFTP_IPRANGE.100/24 dev tap0 sudo ip link set dev tap0 up - else - echo "Unable to find tool to configure tap0 address" - exit 1 fi - make tftpd_start + else + echo "Unable to find tool to configure tap0 address" + exit 1 fi + + # Restart tftpd + make tftpd_stop + make tftpd_start + EXTRA_ARGS+=("-net nic -net tap,ifname=tap0,script=no,downscript=no") ;; From 918860ac4ab59e489b538c13817efe2bb0257913 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sun, 21 Jan 2018 00:46:44 +1100 Subject: [PATCH 115/219] scripts: Add mode for no-qemu networking. --- scripts/build-qemu.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/build-qemu.sh b/scripts/build-qemu.sh index 78b82903..db719c86 100755 --- a/scripts/build-qemu.sh +++ b/scripts/build-qemu.sh @@ -202,6 +202,9 @@ if grep -q ETHMAC_BASE $TARGET_BUILD_DIR/software/include/generated/csr.h; then # FIXME: Make this optional. EXTRA_ARGS+=("-net dump,file=/tmp/data.pcap") ;; + none) + echo "QEmu networking disabled..." + ;; *) echo "Unknown QEMU_NETWORK mode '$QEMU_NETWORK'" ;; From d2f7eeb85085b05eecaaaa9306e5f1c7e303ac09 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sun, 21 Jan 2018 12:21:04 +1100 Subject: [PATCH 116/219] scripts: Fix comment in build-qemu. --- scripts/build-qemu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build-qemu.sh b/scripts/build-qemu.sh index db719c86..e4308bfc 100755 --- a/scripts/build-qemu.sh +++ b/scripts/build-qemu.sh @@ -59,7 +59,7 @@ else # Get any new data git fetch $CURRENT_QEMU_REMOTE_NAME - # Checkout or1k-linux branch it not already on it + # Checkout master branch it not already on it if [ "$(git rev-parse --abbrev-ref HEAD)" != "$QEMU_BRANCH" ]; then git checkout $QEMU_BRANCH || \ git checkout "$CURRENT_QEMU_REMOTE_NAME/$QEMU_BRANCH" -b $QEMU_BRANCH From aa201c61f917313f8a6609c6d7dc414014788037 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Sun, 21 Jan 2018 14:54:20 +0100 Subject: [PATCH 117/219] atlys: request 128 bits dram port for encoder (should fix issue) --- gateware/encoder/core.py | 2 +- targets/atlys/hdmi2usb.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gateware/encoder/core.py b/gateware/encoder/core.py index 31eb0e2e..0b6f7daa 100644 --- a/gateware/encoder/core.py +++ b/gateware/encoder/core.py @@ -29,7 +29,7 @@ def __init__(self, dram_port): burst_pixels = dram_port.dw//pixel_bits alignment_bits = bits_for(dram_port.dw//8) - 1 - self.comb += dma.source.connect(source) # XXX add Converter + self.comb += dma.source.connect(source) base = Signal(32) h_width = self.h_width.storage diff --git a/targets/atlys/hdmi2usb.py b/targets/atlys/hdmi2usb.py index f9a0ea0b..5eba3cbd 100644 --- a/targets/atlys/hdmi2usb.py +++ b/targets/atlys/hdmi2usb.py @@ -23,7 +23,7 @@ class HDMI2USBSoC(BaseSoC): def __init__(self, platform, *args, **kwargs): BaseSoC.__init__(self, platform, *args, **kwargs) - encoder_port = self.sdram.crossbar.get_port() + encoder_port = self.sdram.crossbar.get_port(mode="read", dw=128) self.submodules.encoder_reader = EncoderDMAReader(encoder_port) encoder_cdc = stream.AsyncFIFO([("data", 128)], 4) encoder_cdc = ClockDomainsRenamer({"write": "sys", From b4aa7b523d03edee7ac2da5620a9dacbfe44c3af Mon Sep 17 00:00:00 2001 From: Ewen McNeill Date: Mon, 22 Jan 2018 19:51:58 +1100 Subject: [PATCH 118/219] Makefile: tftpd: fix detection logic Rework tftpd detection logic to use immediate Makefile assignment, and "check for empty" instead of "check for not assigned". Thanks to @stffrdhrn for pointing this out: https://github.com/timvideos/litex-buildenv/pull/16/files#r162814028 --- Makefile | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 13bdc06c..225b9a66 100644 --- a/Makefile +++ b/Makefile @@ -314,11 +314,15 @@ bios-flash: $(BIOS_FILE) bios-flash-$(PLATFORM) # We can run the TFTP server as the user if port >= 1024 # otherwise we need to run as root using sudo -ATFTPD=$(shell which atftpd) -ATFTPD?=/usr/sbin/atftpd +ATFTPD:=$(shell which atftpd) +ifeq ($(ATFTPD),) +ATFTPD:=/usr/sbin/atftpd +endif -IN_TFTPD=$(shell which in.tfptd) -IN_TFTPD=?=/usr/sbin/in.tftpd +IN_TFTPD:=$(shell which in.tfptd) +ifeq ($(IN_TFTPD),) +IN_TFTPD:=/usr/sbin/in.tftpd +endif tftp: $(FIRMWARE_FILEBASE).bin mkdir -p $(TFTPD_DIR) @@ -340,7 +344,7 @@ tftpd_start: sudo true; \ fi @if [ -x "$(ATFTPD)" ]; then \ - echo "Starting aftpd"; \ + echo "Starting atftpd"; \ if [ $(TFTP_SERVER_PORT) -lt 1024 ]; then \ sudo "$(ATFTPD)" --verbose --bind-address $(TFTP_IPRANGE).100 --port $(TFTP_SERVER_PORT) --daemon --logfile /dev/stdout --no-fork --user $(shell whoami) --group $(shell id -gn) $(TFTPD_DIR) & \ else \ From 7e8f01bcfce7821940911e094b1528c73f292212 Mon Sep 17 00:00:00 2001 From: Ewen McNeill Date: Mon, 22 Jan 2018 20:35:56 +1100 Subject: [PATCH 119/219] Makefile: check if submodules are current, warn if not Make litex-submodules also check if submodules are "current" (ie, match the sha1 indicated in the parent repository -- timvideos/litex-buildenv) and if not, emit a warning that they are out of date. NOTE: we do _not_ force update in the Makefile, as this would make it difficult to test changes inside submodules by building at top level (eg, building new litex firmware, gateware, etc). Possible future enhancements: 1. Bail out of makefile (eg, "exit 1") if a variable indicating "development" is not set; 2. Forcibly run "git submodule update --init --recursive" if found to be out of date, unless a variable indicating "development" is set --- Makefile | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 13bdc06c..6df3c1b2 100644 --- a/Makefile +++ b/Makefile @@ -208,9 +208,32 @@ image-flash-py: image .PHONY: image image-load image-flash image-flash-py image-flash-$(PLATFORM) image-load-$(PLATFORM) .NOTPARALLEL: image-load image-flash image-flash-py image-flash-$(PLATFORM) image-load-$(PLATFORM) +# Submodule checks +# +# Generate third_party/*/.git dependencies to force checkouts of submodules +# +# Also check for non-matching submodules, and warn that update might be +# needed (but do not force to match, as that makes development difficult) +# This is indicated by a "git submodule status" that does not start with +# a space (" "). +# LITEX_SUBMODULES=litex litedram liteeth litepcie litesata litescope liteusb litevideo litex-submodules: $(addsuffix /.git,$(addprefix third_party/,$(LITEX_SUBMODULES))) - @true + @if git submodule status --recursive | grep "^[^ ]" >/dev/null; then \ + echo ""; \ + echo "***************************************************************************"; \ + echo "WARNING: the following submodules do not match expected commit:"; \ + echo ""; \ + git submodule status --recursive | grep "^[^ ]"; \ + echo ""; \ + echo "If you are not developing in submodules you may need to run:"; \ + echo ""; \ + echo "git submodule update --init --recursive"; \ + echo ""; \ + echo "manually to bring everything back in sync with upstream"; \ + echo "***************************************************************************"; \ + echo ""; \ + fi # Gateware - the stuff which configures the FPGA. # -------------------------------------- From 22758cb01ca08094cfa620159d1cbc4edb184343 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Thu, 25 Jan 2018 06:29:44 +0100 Subject: [PATCH 120/219] atlys/hdmi2usb: reverse words order on encoder port --- targets/atlys/hdmi2usb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/targets/atlys/hdmi2usb.py b/targets/atlys/hdmi2usb.py index 5eba3cbd..82a8f8da 100644 --- a/targets/atlys/hdmi2usb.py +++ b/targets/atlys/hdmi2usb.py @@ -23,7 +23,7 @@ class HDMI2USBSoC(BaseSoC): def __init__(self, platform, *args, **kwargs): BaseSoC.__init__(self, platform, *args, **kwargs) - encoder_port = self.sdram.crossbar.get_port(mode="read", dw=128) + encoder_port = self.sdram.crossbar.get_port(mode="read", dw=128, reverse=True) self.submodules.encoder_reader = EncoderDMAReader(encoder_port) encoder_cdc = stream.AsyncFIFO([("data", 128)], 4) encoder_cdc = ClockDomainsRenamer({"write": "sys", From bc7feb50d7d564043bb8f24174a446d56a2ac610 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Fri, 26 Jan 2018 00:37:50 +0100 Subject: [PATCH 121/219] target/atlys: build without ethernet for now to speed up p&r and tests --- targets/atlys/video.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/targets/atlys/video.py b/targets/atlys/video.py index 11d8477b..e65c13ac 100644 --- a/targets/atlys/video.py +++ b/targets/atlys/video.py @@ -2,7 +2,7 @@ from litevideo.output import VideoOut from targets.utils import csr_map_update -from targets.atlys.net import NetSoC as BaseSoC +from targets.atlys.base import BaseSoC class VideoSoC(BaseSoC): From 2d6bf8eece1dc19c00d23defdf652e29f335f5af Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Fri, 26 Jan 2018 11:10:40 +1100 Subject: [PATCH 122/219] merge-upstream: Update submodules after checkout. --- third_party/merge-upstream.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/third_party/merge-upstream.sh b/third_party/merge-upstream.sh index 4c284c31..396fb34b 100755 --- a/third_party/merge-upstream.sh +++ b/third_party/merge-upstream.sh @@ -41,7 +41,7 @@ for TARGET in ${MODULES[@]}; do popd > /dev/null done -if [ $DIRTY -eq 0 ]; then +if [ $DIRTY = 0 ]; then echo "All targets clean, good to update." else echo "Some target are dirty, can't update." @@ -62,6 +62,7 @@ for TARGET in ${MODULES[@]}; do BEFORE_VER=$(git describe --always --dirty) git fetch origin | sed -e's/^/ /' git checkout origin/$BRANCH | sed -e's/^/ /' + git submodule update --recursive --init AFTER_VER=$(git describe --always --dirty) if [ x"$BEFORE_VER" = x"$AFTER_VER" ]; then echo "$TARGET is unchanged" From c2f5d3711b37c8e0d51289474a722a65d9068150 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Fri, 26 Jan 2018 11:15:21 +1100 Subject: [PATCH 123/219] merge-upstream: Fail if update makes things dirty. --- third_party/merge-upstream.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/third_party/merge-upstream.sh b/third_party/merge-upstream.sh index 396fb34b..8ebbc417 100755 --- a/third_party/merge-upstream.sh +++ b/third_party/merge-upstream.sh @@ -64,6 +64,10 @@ for TARGET in ${MODULES[@]}; do git checkout origin/$BRANCH | sed -e's/^/ /' git submodule update --recursive --init AFTER_VER=$(git describe --always --dirty) + if echo $AFTER_VER | grep -q "dirty"; then + echo "Updated version is dirty!?" + exit 1 + fi if [ x"$BEFORE_VER" = x"$AFTER_VER" ]; then echo "$TARGET is unchanged" else From a8da8918f082ad8060f0556d1acbde5b92e82e47 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Fri, 26 Jan 2018 11:15:35 +1100 Subject: [PATCH 124/219] merge-upstream: Also include log message. --- third_party/merge-upstream.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/third_party/merge-upstream.sh b/third_party/merge-upstream.sh index 8ebbc417..61305cf8 100755 --- a/third_party/merge-upstream.sh +++ b/third_party/merge-upstream.sh @@ -74,6 +74,8 @@ for TARGET in ${MODULES[@]}; do echo "Move $TARGET from $BEFORE_VER to $AFTER_VER" cat >> $COMMIT_MSG <' --no-color --abbrev-commit $BEFORE_VER..$AFTER_VER | sed -e's/^/ /') + EOF fi echo From 314f9e6591aec4606da11751910208591e1e4505 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Fri, 26 Jan 2018 11:38:15 +1100 Subject: [PATCH 125/219] Updating submodules. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * flash_proxies changed from 070d8b2 to c506426 * c506426 - Merge pull request #3 from cr1901/master * bf63a40 - Add Spartan 7 (xc7s50) bitstream, plus corresponding logic to regenerate. * litedram changed from a09b7a0 to 13d41f6 * 13d41f6 - Merge pull request #9 from felixheld/indentation-fixes * 72b1b10 - Fix all remaining indentation issues in python code * litepcie changed from 09dbd6d to 945963d * 945963d - phy/s7pciephy: set sys_rst_n to 1 if no rst_n pad * 5590f11 - Merge pull request #7 from felixheld/indentation-fixes |\ | * d602010 - Fix all remaining indentation issues in python code * 9469929 - Merge pull request #6 from felixheld/indentation-fixes * 5376257 - fix code indentation * litesata changed from a8bf0d4 to af00fa6 * af00fa6 - Merge pull request #13 from felixheld/indentation-fixes * 220b601 - Fix all indentation issues in python code * litescope changed from 7757727 to aa44da3 * aa44da3 - example_designs/make.py: fix typos * 72e71e7 - core: simplify * 7803591 - Merge pull request #9 from felixheld/indentation-fixes * febb358 - Fix all remaining indentation issues in python code * liteusb changed from 9a78586 to 0b05b6c * 0b05b6c - +x on scripts * litevideo changed from c9770cc to 8d940dc * 8d940dc - output: add raw support (10 bits tmds in dram), untested * 5c168aa - input: add capability to get raw 10 bits data when not using dram port * dcd9624 - input/edid: simplify scl inversion * 3b04d1b - Merge pull request #14 from bunnie/scl-merge |\ | * 7845c85 - add inverted attribute to SCL |/ * a7fd5f6 - Merge pull request #13 from felixheld/indentation-fixes |\ | * 34b1a0f - Fix all remaining indentation issues in python code |/ * 4d6bc46 - input/datacapture: simplify inverted data in S7DataCapture * af096a5 - input/clocking/s7: use bufr and fix input connection to mmcm * 9ebdd1b - output: use new inverted property of pads to invert polarity * 218b708 - output: add assertion if inverted property is used (since not yet implemented) * 113bdb7 - input: use new inverted property of pads to invert polarity * 091c9ec - litevideo: add __init__.py, fix install * 9aae319 - input: add clk_polarity parameter, rename data_polarities to datas_polarity * litex changed from v0.1-251-gead88ed6 to v0.1-270-g4f272580 * 4f272580 - software/common: revert PYTHON to python3 (since breaking things) * 4e168221 - bios: fix riscv processor print * d4488748 - sim: rename top module to dut and use --top-module parameter (needed for picorv32 simulation) * a3851437 - Merge pull request #59 from q3k/for-upstream/multiple-synthesis-directives |\ | * 21bd26dc - Allow for multiple synthesis directives in specials. |/ * 67f8718b - minor cleanup * d07ddd11 - Merge pull request #58 from q3k/for-upstream/picorv32-support |\ | * 6daf3eab - Implement IRQ software support for RISC-V. | * 2108c97b - Import PicoRV32-specific instruction macros. | * cf74c781 - Write init files that respect CPU's endianness. | * 71764922 - Set the MABI and MArch of the riscv target. | * 7ea5a267 - Enable hardware multiplier and divider in PicoRV32 | * 75e230aa - Replace __riscv__ macros with __riscv. | * 20ed2344 - Export trap signal from PicoRV32. | * b0be5630 - Bump PicoRV32 version. |/ * 3a5f93db - software/bios: add litex logo * d6877300 - Merge pull request #56 from cr1901/mimasv2 |\ | * c553fe2b - Add mimasv2 platform (pulled from litex-buildenv). |/ * d6f2f637 - Merge pull request #53 from mithro/allow-forcing-colorama Full submodule status -- f56f329ed23a25d002352dedba1e8f092a47286f edid-decode (heads/master) c5064269868396b2c7a78bff28f8e3cf421d1f6e flash_proxies (remotes/origin/HEAD) 13d41f67ab3070f6af955aa8752c616d034f82f6 litedram (remotes/origin/HEAD) 8fc716103670e703c7fe98c9bdf653b9b53ca12a liteeth (remotes/origin/HEAD) 945963d186b3c0287426ef6655e00ad4e250d279 litepcie (remotes/origin/HEAD) af00fa613f1b6921e14788dd0ebf301e51009e74 litesata (remotes/origin/HEAD) aa44da35c6a232a9e39c43987a3afc9b025ab614 litescope (remotes/origin/HEAD) 0b05b6c8f9279bb7e476b2c8ae4f39ea88534f08 liteusb (remotes/origin/HEAD) 8d940dcaf21cffb18cd157e079ec94946878a5d7 litevideo (remotes/origin/HEAD) 4f2725809e0b9b6cee94cb569c1878f48ab52a15 litex (v0.1-270-g4f272580) --- third_party/flash_proxies | 2 +- third_party/litedram | 2 +- third_party/litepcie | 2 +- third_party/litesata | 2 +- third_party/litescope | 2 +- third_party/liteusb | 2 +- third_party/litevideo | 2 +- third_party/litex | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/third_party/flash_proxies b/third_party/flash_proxies index 070d8b29..c5064269 160000 --- a/third_party/flash_proxies +++ b/third_party/flash_proxies @@ -1 +1 @@ -Subproject commit 070d8b29acf1445c08ebf3073d04206461819bbe +Subproject commit c5064269868396b2c7a78bff28f8e3cf421d1f6e diff --git a/third_party/litedram b/third_party/litedram index a09b7a05..13d41f67 160000 --- a/third_party/litedram +++ b/third_party/litedram @@ -1 +1 @@ -Subproject commit a09b7a05b89af317c885b3939e2f13925cb8d95d +Subproject commit 13d41f67ab3070f6af955aa8752c616d034f82f6 diff --git a/third_party/litepcie b/third_party/litepcie index 09dbd6dd..945963d1 160000 --- a/third_party/litepcie +++ b/third_party/litepcie @@ -1 +1 @@ -Subproject commit 09dbd6dd3053cc42baa7090ee042cb314853a7fc +Subproject commit 945963d186b3c0287426ef6655e00ad4e250d279 diff --git a/third_party/litesata b/third_party/litesata index a8bf0d42..af00fa61 160000 --- a/third_party/litesata +++ b/third_party/litesata @@ -1 +1 @@ -Subproject commit a8bf0d42b22a5f355a629aad7392c59029164d67 +Subproject commit af00fa613f1b6921e14788dd0ebf301e51009e74 diff --git a/third_party/litescope b/third_party/litescope index 7757727f..aa44da35 160000 --- a/third_party/litescope +++ b/third_party/litescope @@ -1 +1 @@ -Subproject commit 7757727f5b9fe4cb4979897fa0aab934b4af6e88 +Subproject commit aa44da35c6a232a9e39c43987a3afc9b025ab614 diff --git a/third_party/liteusb b/third_party/liteusb index 9a78586e..0b05b6c8 160000 --- a/third_party/liteusb +++ b/third_party/liteusb @@ -1 +1 @@ -Subproject commit 9a78586e5e523843834f80826f387ff828012ff7 +Subproject commit 0b05b6c8f9279bb7e476b2c8ae4f39ea88534f08 diff --git a/third_party/litevideo b/third_party/litevideo index c9770cc2..8d940dca 160000 --- a/third_party/litevideo +++ b/third_party/litevideo @@ -1 +1 @@ -Subproject commit c9770cc2da2df70c941376e9b937a2980822c739 +Subproject commit 8d940dcaf21cffb18cd157e079ec94946878a5d7 diff --git a/third_party/litex b/third_party/litex index ead88ed6..4f272580 160000 --- a/third_party/litex +++ b/third_party/litex @@ -1 +1 @@ -Subproject commit ead88ed66d15cbf92c165092dff86fbef071ff9b +Subproject commit 4f2725809e0b9b6cee94cb569c1878f48ab52a15 From 155c7db27d8966b1d7d3589843bb5a76f0d1ce9e Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Sat, 3 Feb 2018 11:04:30 +0100 Subject: [PATCH 126/219] targets/arty/base: add clk100 --- targets/arty/base.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/targets/arty/base.py b/targets/arty/base.py index ab438ff9..7d8a92b6 100755 --- a/targets/arty/base.py +++ b/targets/arty/base.py @@ -23,6 +23,7 @@ def __init__(self, platform): self.clock_domains.cd_sys4x = ClockDomain(reset_less=True) self.clock_domains.cd_sys4x_dqs = ClockDomain(reset_less=True) self.clock_domains.cd_clk200 = ClockDomain() + self.clock_domains.cd_clk100 = ClockDomain() self.clock_domains.cd_clk50 = ClockDomain() clk100 = platform.request("clk100") @@ -34,6 +35,7 @@ def __init__(self, platform): pll_sys4x = Signal() pll_sys4x_dqs = Signal() pll_clk200 = Signal() + pll_clk100 = Signal() pll_clk50 = Signal() self.specials += [ Instance("PLLE2_BASE", @@ -62,15 +64,21 @@ def __init__(self, platform): # 50MHz p_CLKOUT4_DIVIDE=32, p_CLKOUT4_PHASE=0.0, - o_CLKOUT4=pll_clk50 + o_CLKOUT4=pll_clk50, + + # 100MHz + p_CLKOUT5_DIVIDE=32, p_CLKOUT5_PHASE=0.0, + o_CLKOUT5=pll_clk100 ), Instance("BUFG", i_I=self.pll_sys, o_O=self.cd_sys.clk), Instance("BUFG", i_I=pll_sys4x, o_O=self.cd_sys4x.clk), Instance("BUFG", i_I=pll_sys4x_dqs, o_O=self.cd_sys4x_dqs.clk), Instance("BUFG", i_I=pll_clk200, o_O=self.cd_clk200.clk), + Instance("BUFG", i_I=pll_clk100, o_O=self.cd_clk100.clk), Instance("BUFG", i_I=pll_clk50, o_O=self.cd_clk50.clk), AsyncResetSynchronizer(self.cd_sys, ~pll_locked | rst), AsyncResetSynchronizer(self.cd_clk200, ~pll_locked | rst), + AsyncResetSynchronizer(self.cd_clk100, ~pll_locked | rst), AsyncResetSynchronizer(self.cd_clk50, ~pll_locked | rst), ] From 380496f1523f7ac1842acaed6c7107f26d126159 Mon Sep 17 00:00:00 2001 From: Hasjim Williams Date: Sun, 4 Feb 2018 18:10:27 +1000 Subject: [PATCH 127/219] Fix PLL for clk100 on arty --- targets/arty/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/targets/arty/base.py b/targets/arty/base.py index 7d8a92b6..390385e0 100755 --- a/targets/arty/base.py +++ b/targets/arty/base.py @@ -67,7 +67,7 @@ def __init__(self, platform): o_CLKOUT4=pll_clk50, # 100MHz - p_CLKOUT5_DIVIDE=32, p_CLKOUT5_PHASE=0.0, + p_CLKOUT5_DIVIDE=16, p_CLKOUT5_PHASE=0.0, o_CLKOUT5=pll_clk100 ), Instance("BUFG", i_I=self.pll_sys, o_O=self.cd_sys.clk), From bb9c4d9239002672ce54c696626bb320364c4992 Mon Sep 17 00:00:00 2001 From: Ewen McNeill Date: Wed, 7 Feb 2018 11:43:32 +1300 Subject: [PATCH 128/219] tftpd: Fix in.tftp alternate port syntax --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 23954572..e3b446d0 100644 --- a/Makefile +++ b/Makefile @@ -342,6 +342,7 @@ ifeq ($(ATFTPD),) ATFTPD:=/usr/sbin/atftpd endif +# Requires HPA in.tftpd not traditional BSD in.tftpd IN_TFTPD:=$(shell which in.tfptd) ifeq ($(IN_TFTPD),) IN_TFTPD:=/usr/sbin/in.tftpd @@ -376,9 +377,9 @@ tftpd_start: elif [ -x "$(IN_TFTPD)" ]; then \ echo "Starting in.tftpd"; \ if [ $(TFTP_SERVER_PORT) -lt 1024 ]; then \ - sudo "$(IN_TFTPD)" --verbose --listen --address $(TFTP_IPRANGE).100 --port-range $(TFTP_SERVER_PORT):$(TFTP_SERVER_PORT) --user $(shell whoami) -s $(TFTPD_DIR) & \ + sudo "$(IN_TFTPD)" --verbose --listen --address $(TFTP_IPRANGE).100:$(TFTP_SERVER_PORT) --user $(shell whoami) -s $(TFTPD_DIR) & \ else \ - "$(IN_TFTPD)" --verbose --listen --address $(TFTP_IPRANGE).100 --port-range $(TFTP_SERVER_PORT):$(TFTP_SERVER_PORT) --user $(shell whoami) -s $(TFTPD_DIR) & \ + "$(IN_TFTPD)" --verbose --listen --address $(TFTP_IPRANGE).100:$(TFTP_SERVER_PORT) --user $(shell whoami) -s $(TFTPD_DIR) & \ fi \ else \ echo "Cannot find an appropriate tftpd binary to launch the server."; \ From 3f438c129242420e2a84ea6a958f73c5571ad8c0 Mon Sep 17 00:00:00 2001 From: Ewen McNeill Date: Wed, 7 Feb 2018 19:22:05 +1300 Subject: [PATCH 129/219] tftpd: in.tftpd always needs to run with sudo --- Makefile | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index e3b446d0..885ffba5 100644 --- a/Makefile +++ b/Makefile @@ -343,6 +343,10 @@ ATFTPD:=/usr/sbin/atftpd endif # Requires HPA in.tftpd not traditional BSD in.tftpd +# Unfortunately in.tftpd seems to require root always +# even if run as current user, otherwise it reports +# "cannot set groups for user $USER" +# IN_TFTPD:=$(shell which in.tfptd) ifeq ($(IN_TFTPD),) IN_TFTPD:=/usr/sbin/in.tftpd @@ -358,7 +362,11 @@ tftpd_stop: sudo true; \ sudo killall atftpd || sudo killall in.tftpd || true; \ else \ - killall atftpd || killall in.tftpd || true; \ + killall atftpd || \ + if ps axuwww | grep -v grep | \ + grep "[i]n.tftpd" >/dev/null 2>&1; then \ + sudo killall in.tftpd; \ + fi || true; \ fi tftpd_start: @@ -379,7 +387,9 @@ tftpd_start: if [ $(TFTP_SERVER_PORT) -lt 1024 ]; then \ sudo "$(IN_TFTPD)" --verbose --listen --address $(TFTP_IPRANGE).100:$(TFTP_SERVER_PORT) --user $(shell whoami) -s $(TFTPD_DIR) & \ else \ - "$(IN_TFTPD)" --verbose --listen --address $(TFTP_IPRANGE).100:$(TFTP_SERVER_PORT) --user $(shell whoami) -s $(TFTPD_DIR) & \ + echo "Root required to run in.tftpd, will use sudo"; \ + sudo true; \ + sudo "$(IN_TFTPD)" --verbose --listen --address $(TFTP_IPRANGE).100:$(TFTP_SERVER_PORT) --user $(shell whoami) -s $(TFTPD_DIR) & \ fi \ else \ echo "Cannot find an appropriate tftpd binary to launch the server."; \ From abc1cde07998493ca905bbfe893852846cb63eb0 Mon Sep 17 00:00:00 2001 From: Ewen McNeill Date: Thu, 8 Feb 2018 09:43:43 +1300 Subject: [PATCH 130/219] tftpd: s/in.tfptd/in.tftpd/ Fixed typo in in.tftpd name (thanks to @stffrdhrn and @mithro for spotting the typo) --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 885ffba5..795915ce 100644 --- a/Makefile +++ b/Makefile @@ -347,7 +347,7 @@ endif # even if run as current user, otherwise it reports # "cannot set groups for user $USER" # -IN_TFTPD:=$(shell which in.tfptd) +IN_TFTPD:=$(shell which in.tftpd) ifeq ($(IN_TFTPD),) IN_TFTPD:=/usr/sbin/in.tftpd endif From efd401a18a9e2ebe7c42e6b53bf75e0971e7ea7a Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Thu, 8 Feb 2018 10:39:31 -0800 Subject: [PATCH 131/219] travis: Don't source push-build. push-build was disabled with a "exit 0" and thus all builds were succeeding despite them failing :-( --- .travis/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis/build.sh b/.travis/build.sh index 4e29842a..c4938343 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -374,7 +374,7 @@ for F in ${FAILURES[@]}; do echo $F | sed -e's/+/ /g' done -. ./.travis/push-prebuilt.sh +bash ./.travis/push-prebuilt.sh echo "" echo "" From a0361a8e05c6556459c8dd4f701a2a7c68a070a4 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Thu, 8 Feb 2018 14:35:26 -0800 Subject: [PATCH 132/219] travis: Adding new script to update prebuilt lists. --- .travis.yml | 3 + .travis/build.sh | 2 - .travis/generate-prebuilt-list.py | 231 ++++++++++++++++++++++++++++++ .travis/push-prebuilt.sh | 70 --------- .travis/update-prebuilt-list.sh | 38 +++++ 5 files changed, 272 insertions(+), 72 deletions(-) create mode 100755 .travis/generate-prebuilt-list.py delete mode 100755 .travis/push-prebuilt.sh create mode 100755 .travis/update-prebuilt-list.sh diff --git a/.travis.yml b/.travis.yml index a0bde5a1..a90222e4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,6 +40,9 @@ install: script: - $PWD/.travis/build.sh +after_success: + - $PWD/.travis/update-prebuilt-list.sh + notifications: email: - hdmi2usb-spam@googlegroups.com diff --git a/.travis/build.sh b/.travis/build.sh index c4938343..3ffe7aab 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -374,8 +374,6 @@ for F in ${FAILURES[@]}; do echo $F | sed -e's/+/ /g' done -bash ./.travis/push-prebuilt.sh - echo "" echo "" echo "" diff --git a/.travis/generate-prebuilt-list.py b/.travis/generate-prebuilt-list.py new file mode 100755 index 00000000..2ba818c9 --- /dev/null +++ b/.travis/generate-prebuilt-list.py @@ -0,0 +1,231 @@ +#!/usr/bin/env python3 + +import argparse +import csv +import os +import pprint +import sys +import tempfile +import urllib.request + +import subprocess + +slug = os.getenv("TRAVIS_REPO_SLUG", None) +prebuilt_repo_name = 'HDMI2USB-firmware-prebuilt' +if slug: + prebuilt_repo_owner = slug.split('/',1)[0] +else: + prebuilt_repo_owner = None + +parser = argparse.ArgumentParser( + description="""\ +Update the index files in the prebuilt repo.""") +parser.add_argument( + '--repo', default=prebuilt_repo_name) +parser.add_argument( + '--owner', default=prebuilt_repo_owner) +parser.add_argument( + '--branch', default=os.getenv('TRAVIS_BRANCH', None)) +parser.add_argument( + '--full-platform', default=os.getenv('FULL_PLATFORM', None)) +parser.add_argument( + '--target', default=os.getenv('TARGET', None)) +parser.add_argument( + '--full-cpu', default=os.getenv('FULL_CPU', None)) +parser.add_argument( + '--firmware', default=os.getenv('FIRMWARE', None)) +parser.add_argument( + '--gh-user', default=os.getenv('GH_USER', None)) +parser.add_argument( + '--gh-token', default=os.getenv('GH_TOKEN', None)) +args = parser.parse_args() + +assert args.repo +assert args.owner +assert args.branch == "master" + +assert args.gh_user +assert args.gh_token + +assert args.full_platform +assert args.target +assert args.full_cpu + +svn_base_url = "https://github.com/{}/{}/trunk/archive/{}".format( + args.owner, args.repo, args.branch) +pre_base_url = "https://github.com/{}/{}/branches/gh-pages".format( + args.owner, args.repo, args.branch) + +git_dir_url = "https://github.com/{}/{}/blob/master/archive/{}".format( + args.owner, args.repo, args.branch) +git_file_url = "https://github.com/{}/{}/blob/master/archive/{}".format( + args.owner, args.repo, args.branch) + +svn_args = '--non-interactive --username {} --password {}'.format( + args.gh_user, args.gh_token) + +revs_data = subprocess.check_output( + "svn list {} {}".format(svn_args, svn_base_url).split()).decode('utf-8') + +revs = [v[:-1] for v in revs_data.splitlines()] +def parse_version(v): + if "-" not in v: + return v,0,'' + a,b,c = v.split('-') + return a,int(b),c +revs.sort(key=parse_version) + +def get_channel_spreadsheet(): + data = urllib.request.urlopen( + "https://docs.google.com/spreadsheets/d/e/2PACX-1vTmqEM-XXPW4oHrJMD7QrCeKOiq1CPng9skQravspmEmaCt04Kz4lTlQLFTyQyJhcjqzCc--eO2f11x/pub?output=csv" + ).read().decode('utf-8') + + rev_names = {} + for i in csv.reader(data.splitlines(), dialect='excel'): + if not i: + continue + if i[0] != "GitHub": + continue + if len(i) != 6: + print("Skipping row %s" % i) + continue + + _, _, rev, name, conf, _ = i + if not name: + continue + assert name not in rev_names, "{} is listed multiple times!".format( + name) + rev_names[name] = rev + + return rev_names + +_get_sha256sum_cache = {} +def get_sha256sum(rev, full_platform, target, full_cpu, svn_args=svn_args, svn_base_url=svn_base_url): + global _get_sha256sum_cache + full_path = "{rev}/{full_platform}/{target}/{full_cpu}/".format( + rev=rev, + full_platform=full_platform, + target=target, + full_cpu=full_cpu, + ) + try: + return _get_sha256sum_cache[full_path] + except KeyError: + try: + data = subprocess.check_output( + "svn cat {svn_args} {svn_base_url}/{full_path}/sha256sum.txt".format( + svn_args=svn_args, + svn_base_url=svn_base_url, + full_path=full_path, + ).split() + ).decode('utf-8') + data = data.replace("./", "{}/{}".format(git_file_url, full_path)) + except subprocess.CalledProcessError: + data = None + _get_sha256sum_cache[full_path] = data + return data + +# Get the stable/testing revisions +channels = get_channel_spreadsheet() + +# Find the unstable revision +urevs = list(revs) +while True: + rev = urevs.pop(-1) + if not get_sha256sum(rev, args.full_platform, args.target, args.full_cpu): + continue + channels['unstable'] = rev + break + +print() +print("Looking at target '{}' for platform '{}' from '{}/{}'".format( + args.target, args.full_platform, args.owner, args.repo)) +print() +print("Found {} revisions, 10 latest:\n * ".format(len(revs)), end="") +print("\n * ".join(reversed(revs[-10:]))) +print() +for channel, rev in sorted(channels.items()): + print("Channel {:10s} is at rev {}".format(channel, rev)) +print() + +output = {} +for channel, rev in sorted(channels.items()): + output[channel] = get_sha256sum( + rev, args.full_platform, args.target, args.full_cpu) + +# Download the gh-pages branch of the HDMI2USB-firmware-prebuilt repo +tmpdir = tempfile.mkdtemp() +print("Using {}".format(tmpdir)) +print() + +os.chdir(tmpdir) +print("Download github pages repo...") +subprocess.check_call( + "svn checkout {}".format(pre_base_url).split()) +os.chdir("gh-pages") +print("") + +with open("revs.txt", "w") as f: + for rev in revs: + f.write("{}\n".format(rev)) + +out_dir = os.path.join(args.full_platform, args.target, args.full_cpu) +os.makedirs(out_dir, exist_ok=True) + +with open(os.path.join(out_dir, "channels.txt"), "w") as f: + for channel, rev in sorted(channels.items()): + gh_url = "{git_base_url}/{rev}/{full_platform}/{target}/{full_cpu}/".format( + git_base_url=git_dir_url, + rev=rev, + full_platform=args.full_platform, + target=args.target, + full_cpu=args.full_cpu) + f.write("{} {} {}\n".format(channel, rev, gh_url)) + +for channel, lines in sorted(output.items()): + with open(os.path.join(out_dir, "{}.sha256sum".format(channel)), "w") as f: + f.write("".join(lines)) + +all_files = [] +for root, dirs, files in os.walk('.'): + skip_dirs = [] + for d in dirs: + if d.startswith('.'): + skip_dirs.append(d) + for d in skip_dirs: + dirs.remove(d) + for f in files: + if f == 'index.txt': + continue + all_files.append(os.path.join(root, f)) + +all_files.sort() + +with open('index.txt', 'w') as f: + subprocess.check_call(["sha256sum"]+all_files, stdout=f) + +print("Adding files...") +subprocess.check_call(["svn", "add", "--parents", "--force"]+all_files) +subprocess.check_call(["svn", "add", "--parents", "--force", "index.txt"]) +print() + +print("Current status...") +changes = subprocess.check_output("svn status -u --depth infinity".split(), stderr=subprocess.STDOUT).decode('utf-8') +print(changes) +subprocess.check_call("svn diff .".split(), stderr=subprocess.STDOUT) + +if len(changes.splitlines()) == 1: + print("Committing changes...") + print() + sys.exit(0) + +print() +print("Committing changes...") + +with tempfile.NamedTemporaryFile() as f: + f.write("Updating channels (in Travis build {})\n".format(os.getenv("TRAVIS_BUILD_NUMBER", "None")).encode('utf-8')) + f.flush() + + subprocess.check_call("svn commit {} --file {}".format(svn_args, f.name).split()) + +print() diff --git a/.travis/push-prebuilt.sh b/.travis/push-prebuilt.sh deleted file mode 100755 index 21613249..00000000 --- a/.travis/push-prebuilt.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash -exit 0 -if [ -d "$PREBUILT_DIR" ]; then - echo "" - echo "" - echo "" - echo "Pushing prebuilt binaries" - echo "=============================================" - ( - cd $PREBUILT_DIR - for i in 1 2 3 4 5 6 7 8 9 10; do # Try 10 times. - if [ "$TRAVIS_BRANCH" = "master" ]; then - echo "Pushing with PLATFORMS='$PLATFORMS'" - echo - #for FULL_PLATFORM in $PLATFORMS; do - # ( - # if [ ! -d "$FULL_PLATFORM/$FIRMWARE" ]; then - # echo "No $FIRMWARE directory for $FULL_PLATFORM, skipping." - # continue - # fi - # echo - # echo "Updating unstable link (Try $i)" - # echo "---------------------------------------------" - # cd $FULL_PLATFORM/firmware - # LATEST="$(ls ../../archive/master/ | sort -V | tail -n 1)" - # echo "Latest firmware is $LATEST (current is $(readlink unstable))" - # HDMI2USB_FIRMWARE="../../archive/master/$LATEST/$FULL_PLATFORM/hdmi2usb/lm32" - # echo "Checking for '$HDMI2USB_FIRMWARE'" - # if [ -d "$HDMI2USB_FIRMWARE" -a "$(readlink unstable)" != "$HDMI2USB_FIRMWARE" ]; then - # echo "Changing $FULL_PLATFORM from '$(readlink unstable)' to '$HDMI2USB_FIRMWARE'" - # ln -sfT "$HDMI2USB_FIRMWARE" unstable - # git add unstable - # git commit -a \ - # -m "Updating unstable link (Travis build #$TRAVIS_BUILD_NUMBER of $GIT_REVISION for PLATFORM=$FULL_PLATFORM TARGET=$TARGET CPU=$FULL_CPU FIRMWARE=$FIRMWARE)" \ - # -m "" \ - # -m "From https://github.com/$TRAVIS_REPO_SLUG/tree/$TRAVIS_COMMIT" \ - # -m "$TRAVIS_COMMIT_MESSAGE" - # else - # echo "Not updating $FULL_PLATFORM" - # fi - # ) - #done - else - echo "Not updating link as on branch '$TRAVIS_BRANCH'" - fi - echo - echo "Merging (Try $i)" - echo "---------------------------------------------" - svn update - echo - echo "Changes to be pushed (Try $i)" - echo "---------------------------------------------" - svn status - if [ $(svn status | wc -l) -eq 0 ]; then - break - fi - echo - echo "Pushing (Try $i)" - echo "---------------------------------------------" - svn commit - if git push --quiet origin master > /dev/null 2>&1 ; then - echo "Push success!" - else - echo "Push failed :-(" - fi - done - echo - echo "Push finished!" - ) -fi diff --git a/.travis/update-prebuilt-list.sh b/.travis/update-prebuilt-list.sh new file mode 100755 index 00000000..5fad27f7 --- /dev/null +++ b/.travis/update-prebuilt-list.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +function prebuilt() { + export FULL_PLATFORM=$1 + export TARGET=$2 + export FULL_CPU=$3 + + if [ x"$4" != x"" ]; then + FIRMWARE=$4 + else + unset $FIRMWARE + fi + export FIRMWARE + .travis/generate-prebuilt-list.py +} + +if [ x"$TRAVIS_BRANCH" = x"master" ]; then + echo "" + echo "" + echo "" + echo "Updating prebuilt binaries" + echo "=============================================" + for i in 1 2 3 4 5 6 7 8 9 10; do # Try 10 times. + export FUNC=prebuilt + + . .travis/run.inc.sh && : + FAILED=$? + + if [ $FAILED -eq 0 ]; then + echo "Update succeed!" + break + else + echo "Update failed!" + fi + done + echo + echo "Push finished!" +fi From 5b5d790c1df534e416c2a4dae21281a2bd3b2a70 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Thu, 8 Feb 2018 22:51:03 -0800 Subject: [PATCH 133/219] travis: Some small printing fixes to prebuilt list generator. --- .travis/generate-prebuilt-list.py | 48 +++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/.travis/generate-prebuilt-list.py b/.travis/generate-prebuilt-list.py index 2ba818c9..44c914ef 100755 --- a/.travis/generate-prebuilt-list.py +++ b/.travis/generate-prebuilt-list.py @@ -117,18 +117,31 @@ def get_sha256sum(rev, full_platform, target, full_cpu, svn_args=svn_args, svn_b svn_args=svn_args, svn_base_url=svn_base_url, full_path=full_path, - ).split() + ).split(), + stderr=subprocess.STDOUT, ).decode('utf-8') data = data.replace("./", "{}/{}".format(git_file_url, full_path)) except subprocess.CalledProcessError: + print(" - Did not find {full_platform}/{target}/{full_cpu} at {rev}".format( + rev=rev, + full_platform=full_platform, + target=target, + full_cpu=full_cpu, + )) data = None _get_sha256sum_cache[full_path] = data return data -# Get the stable/testing revisions -channels = get_channel_spreadsheet() +print() +print("Looking at cpu '{}' in target '{}' for platform '{}' from '{}/{}'".format( + args.full_cpu, args.target, args.full_platform, args.owner, args.repo)) +print() + +channels = {} # Find the unstable revision +print("Found {} revisions, 10 latest:\n * ".format(len(revs)), end="") +print("\n * ".join(reversed(revs[-10:]))) urevs = list(revs) while True: rev = urevs.pop(-1) @@ -136,22 +149,24 @@ def get_sha256sum(rev, full_platform, target, full_cpu, svn_args=svn_args, svn_b continue channels['unstable'] = rev break - -print() -print("Looking at target '{}' for platform '{}' from '{}/{}'".format( - args.target, args.full_platform, args.owner, args.repo)) -print() -print("Found {} revisions, 10 latest:\n * ".format(len(revs)), end="") -print("\n * ".join(reversed(revs[-10:]))) -print() -for channel, rev in sorted(channels.items()): - print("Channel {:10s} is at rev {}".format(channel, rev)) print() +# Get the stable/testing revisions +print("Getting other channels..") +channels.update(get_channel_spreadsheet()) + +# Get the sha254 files for each channel output = {} for channel, rev in sorted(channels.items()): output[channel] = get_sha256sum( rev, args.full_platform, args.target, args.full_cpu) +print() + +for channel, rev in sorted(channels.items()): + if not output[channel]: + rev = "unknown" + print("Channel {:10s} is at rev {}".format(channel, rev)) +print() # Download the gh-pages branch of the HDMI2USB-firmware-prebuilt repo tmpdir = tempfile.mkdtemp() @@ -161,9 +176,10 @@ def get_sha256sum(rev, full_platform, target, full_cpu, svn_args=svn_args, svn_b os.chdir(tmpdir) print("Download github pages repo...") subprocess.check_call( - "svn checkout {}".format(pre_base_url).split()) -os.chdir("gh-pages") + "svn checkout {} -q {}".format(svn_args, pre_base_url).split()) +print("Done.") print("") +os.chdir("gh-pages") with open("revs.txt", "w") as f: for rev in revs: @@ -183,6 +199,8 @@ def get_sha256sum(rev, full_platform, target, full_cpu, svn_args=svn_args, svn_b f.write("{} {} {}\n".format(channel, rev, gh_url)) for channel, lines in sorted(output.items()): + if not lines: + continue with open(os.path.join(out_dir, "{}.sha256sum".format(channel)), "w") as f: f.write("".join(lines)) From 8528a1926987459a72e2770389652493f612e8b5 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Thu, 8 Feb 2018 23:06:04 -0800 Subject: [PATCH 134/219] Updating submodules. * litevideo changed from 8d940dc to 9907975 * 9907975 - fix variable name * 416ec42 - output/vga: shift datas when pads don't have 8 bits dynamic * 1ff01f2 - output: fix vga * a385c73 - output: add vga phy * c058946 - output/hdmi/s6: fix phy * ad882a7 - output/hdmi/s6: fix missing mode to phy_layout * c868806 - input/clocking: remove check on clock_polarity (obsolete) Full submodule status -- f56f329ed23a25d002352dedba1e8f092a47286f edid-decode (heads/master) c5064269868396b2c7a78bff28f8e3cf421d1f6e flash_proxies (remotes/origin/HEAD) 13d41f67ab3070f6af955aa8752c616d034f82f6 litedram (heads/master-7-g13d41f6) 8fc716103670e703c7fe98c9bdf653b9b53ca12a liteeth (remotes/origin/HEAD) 945963d186b3c0287426ef6655e00ad4e250d279 litepcie (heads/master-9-g945963d) af00fa613f1b6921e14788dd0ebf301e51009e74 litesata (remotes/origin/HEAD) aa44da35c6a232a9e39c43987a3afc9b025ab614 litescope (remotes/origin/HEAD) 0b05b6c8f9279bb7e476b2c8ae4f39ea88534f08 liteusb (remotes/origin/HEAD) 9907975f8b5842800089f52a9122156c73eb22fd litevideo (remotes/origin/HEAD) 4f2725809e0b9b6cee94cb569c1878f48ab52a15 litex (v0.1-270-g4f272580) --- third_party/litevideo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/litevideo b/third_party/litevideo index 8d940dca..9907975f 160000 --- a/third_party/litevideo +++ b/third_party/litevideo @@ -1 +1 @@ -Subproject commit 8d940dcaf21cffb18cd157e079ec94946878a5d7 +Subproject commit 9907975f8b5842800089f52a9122156c73eb22fd From 31d5c60caed1d95abb38eadfd52cb26d812b794f Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Fri, 9 Feb 2018 14:32:24 -0800 Subject: [PATCH 135/219] travis: Add return codes to prebuilt list function request. --- .travis/update-prebuilt-list.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis/update-prebuilt-list.sh b/.travis/update-prebuilt-list.sh index 5fad27f7..3fa491ab 100755 --- a/.travis/update-prebuilt-list.sh +++ b/.travis/update-prebuilt-list.sh @@ -11,7 +11,8 @@ function prebuilt() { unset $FIRMWARE fi export FIRMWARE - .travis/generate-prebuilt-list.py + .travis/generate-prebuilt-list.py || return 1 + return 0 } if [ x"$TRAVIS_BRANCH" = x"master" ]; then From d11f5b85e7a962b3b3e55aaee70a693159f59957 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Fri, 9 Feb 2018 15:11:16 -0800 Subject: [PATCH 136/219] travis: Small output fixes to prebuilt list script. --- .travis/generate-prebuilt-list.py | 47 ++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/.travis/generate-prebuilt-list.py b/.travis/generate-prebuilt-list.py index 44c914ef..e86e224b 100755 --- a/.travis/generate-prebuilt-list.py +++ b/.travis/generate-prebuilt-list.py @@ -38,6 +38,8 @@ '--gh-user', default=os.getenv('GH_USER', None)) parser.add_argument( '--gh-token', default=os.getenv('GH_TOKEN', None)) +parser.add_argument( + '--outdir', default=os.getenv('OUTDIR', None)) args = parser.parse_args() assert args.repo @@ -64,6 +66,13 @@ svn_args = '--non-interactive --username {} --password {}'.format( args.gh_user, args.gh_token) +print() +print("Looking at cpu '{}' in target '{}' for platform '{}' from '{}/{}'".format( + args.full_cpu, args.target, args.full_platform, args.owner, args.repo)) +print() +print("-"*75) +print() + revs_data = subprocess.check_output( "svn list {} {}".format(svn_args, svn_base_url).split()).decode('utf-8') @@ -132,11 +141,6 @@ def get_sha256sum(rev, full_platform, target, full_cpu, svn_args=svn_args, svn_b _get_sha256sum_cache[full_path] = data return data -print() -print("Looking at cpu '{}' in target '{}' for platform '{}' from '{}/{}'".format( - args.full_cpu, args.target, args.full_platform, args.owner, args.repo)) -print() - channels = {} # Find the unstable revision @@ -169,14 +173,20 @@ def get_sha256sum(rev, full_platform, target, full_cpu, svn_args=svn_args, svn_b print() # Download the gh-pages branch of the HDMI2USB-firmware-prebuilt repo -tmpdir = tempfile.mkdtemp() +if args.outdir is None: + tmpdir = tempfile.mkdtemp() +else: + tmpdir = args.outdir + +os.makedirs(tmpdir, exist_ok=True) print("Using {}".format(tmpdir)) print() os.chdir(tmpdir) print("Download github pages repo...") -subprocess.check_call( - "svn checkout {} -q {}".format(svn_args, pre_base_url).split()) +if not os.path.exists("gh-pages"): + subprocess.check_call( + "svn checkout {} -q {}".format(svn_args, pre_base_url).split()) print("Done.") print("") os.chdir("gh-pages") @@ -231,19 +241,22 @@ def get_sha256sum(rev, full_platform, target, full_cpu, svn_args=svn_args, svn_b changes = subprocess.check_output("svn status -u --depth infinity".split(), stderr=subprocess.STDOUT).decode('utf-8') print(changes) subprocess.check_call("svn diff .".split(), stderr=subprocess.STDOUT) +print() if len(changes.splitlines()) == 1: - print("Committing changes...") + print("No changes to commit...") print() - sys.exit(0) - -print() -print("Committing changes...") +else: + print() + print("Committing changes...") -with tempfile.NamedTemporaryFile() as f: - f.write("Updating channels (in Travis build {})\n".format(os.getenv("TRAVIS_BUILD_NUMBER", "None")).encode('utf-8')) - f.flush() + with tempfile.NamedTemporaryFile() as f: + f.write("Updating channels (in Travis build {})\n".format(os.getenv("TRAVIS_BUILD_NUMBER", "None")).encode('utf-8')) + f.flush() - subprocess.check_call("svn commit {} --file {}".format(svn_args, f.name).split()) + subprocess.check_call("svn commit {} --file {}".format(svn_args, f.name).split()) print() +print("-"*75) +print("Done..") +print() From a8b3fa1b10c8e4e89378f005e1e395b911f40099 Mon Sep 17 00:00:00 2001 From: Ewen McNeill Date: Sat, 10 Feb 2018 18:31:28 +1300 Subject: [PATCH 137/219] Makefile: omit FIRMWARE.fbi dep if FIRMWARE=none --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 795915ce..9fdbb8b1 100644 --- a/Makefile +++ b/Makefile @@ -178,11 +178,13 @@ third_party/%/.git: .gitmodules # -------------------------------------- ifeq ($(FIRMWARE),none) OVERRIDE_FIRMWARE=--override-firmware=none +FIRMWARE_FBI= else OVERRIDE_FIRMWARE=--override-firmware=$(FIRMWARE_FILEBASE).fbi +FIRMWARE_FBI=$(FIRMWARE_FILEBASE).fbi endif -$(IMAGE_FILE): $(GATEWARE_FILEBASE).bin $(BIOS_FILE) $(FIRMWARE_FILEBASE).fbi +$(IMAGE_FILE): $(GATEWARE_FILEBASE).bin $(BIOS_FILE) $(FIRMWARE_FBI) $(PYTHON) mkimage.py \ $(MISOC_EXTRA_CMDLINE) $(LITEX_EXTRA_CMDLINE) $(MAKE_LITEX_EXTRA_CMDLINE) \ --override-gateware=$(GATEWARE_FILEBASE).bin \ From ca1b76d946fa314660b5b991708272bbaa518e22 Mon Sep 17 00:00:00 2001 From: Ewen McNeill Date: Sat, 10 Feb 2018 19:24:30 +1300 Subject: [PATCH 138/219] Mimas v2: make gateware-flash include BIOS On the Mimas v2 the Gateware and the BIOS need to be stored in the same flash on the Mimas v2 board, updated via the same method (MimasV2Config.py). As a result it is not very usfeul to *just* install the Gateware, with no BIOS image, as the only way to get a BIOS image onto the board would be to use "make image-flash" with no application, which would also load the Gateware again. Redirect the "make gateware-flash" on the Mimas v2 to load an image that contains the Gateware + BIOS, but no application. The result is: make gateware-flash - flashes Gateware+BIOS, make firmware-load works make image-flash - flashes Gateware+BIOS+Firmware, use firmware-connect --- targets/mimasv2/Makefile.mk | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/targets/mimasv2/Makefile.mk b/targets/mimasv2/Makefile.mk index c56f5cdf..902f1a76 100644 --- a/targets/mimasv2/Makefile.mk +++ b/targets/mimasv2/Makefile.mk @@ -30,8 +30,26 @@ gateware-load-$(PLATFORM): @echo "make gateware-flash" @false -gateware-flash-$(PLATFORM): - $(PYTHON) $$(which MimasV2Config.py) $(PROG_PORT) $(GATEWARE_FILEBASE).bin +# On Mimas v2 both the gateware and the BIOS need to be in the same flash, +# which means that they can only really usefully be updated together. As +# a result we should flash "Gateware + BIOS + no application" if the user +# asks us to flash the gatware. This mirrors the behaviour of embedding +# the BIOS in the Gateware loaded via gateware-load, on other platforms, +# eg, on the Arty. +# +GATEWARE_BIOS_FILE = $(TARGET_BUILD_DIR)/image-gateware+bios+none.bin + +gateware-flash-$(PLATFORM): $(GATEWARE_BIOS_FILE) + $(PYTHON) $$(which MimasV2Config.py) $(PROG_PORT) $(GATEWARE_BIOS_FILE) + +# To avoid duplicating the mkimage.py call here, if the user has not +# already built a image-gateware+bios+none.bin, we call make recursively +# to build one here, with the FIRMWARE=none override. +# +ifneq ($(GATEWARE_BIOS_FILE),$(IMAGE_FILE)) +$(GATEWARE_BIOS_FILE): $(GATEWARE_FILEBASE).bin $(BIOS_FILE) mkimage.py + FIRMWARE=none make image +endif # Firmware firmware-load-$(PLATFORM): From 27451214304a89d10d2fe3139d54b3dbcfddb417 Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Sat, 10 Feb 2018 17:13:40 +0100 Subject: [PATCH 139/219] gateware opsis: declare debug_io0/1 which are actually present on the pcb as .1" header --- platforms/opsis.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/platforms/opsis.py b/platforms/opsis.py index f190813b..7b97cc28 100644 --- a/platforms/opsis.py +++ b/platforms/opsis.py @@ -240,8 +240,9 @@ def tofe_pin(tofe_netname): Subsignal("hpd_en", Pins("V19"), IOStandard("LVCMOS33")) ), - # Debug header? - #("debug", 0, Pins("AA2"), IOStandard("LVCMOS15")), # (/FPGA_Bank_0_3/DEBUG_IO0) + # Debug header + ("debug_io0", 0, Pins("AA2"), IOStandard("LVCMOS15")), # (/FPGA_Bank_0_3/DEBUG_IO0) + ("debug_io1", 0, Pins("AA1"), IOStandard("LVCMOS15")), # (/FPGA_Bank_0_3/DEBUG_IO1) ## onboard HDMI OUT1 ## HDMI - connector J3 - Direction TX From 4bae74681d8ab8a0650600adf015bf66fee47a51 Mon Sep 17 00:00:00 2001 From: andrewreds Date: Mon, 12 Feb 2018 00:05:55 +1100 Subject: [PATCH 140/219] Correct getting-started.md 's make commands --- getting-started.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/getting-started.md b/getting-started.md index b19f42b2..a7a943ee 100644 --- a/getting-started.md +++ b/getting-started.md @@ -240,7 +240,7 @@ this step. Load the gateware and firmware - see [1] if using a VM: ``` -make load-gateware +make gateware-load ``` On the Opsis, while loading the Blue LED (D1 / Done) and Green LED (D2) will @@ -319,7 +319,7 @@ hdmi2usb-mode-switch --mode=jtag Connect to lm32 softcore to send direct commands to the HDMI2USB such as changing resolution: ``` -make connect-lm32 +make firmware-connect ``` Set a mode/capture - type 'help' and read instructions. From c32bcefe9331e90e8f6bf9cb5f7c863d8539e467 Mon Sep 17 00:00:00 2001 From: gsmalik Date: Wed, 14 Feb 2018 20:36:27 -0500 Subject: [PATCH 141/219] #405 Python script of version_data --- firmware/version_data.py | 117 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 firmware/version_data.py diff --git a/firmware/version_data.py b/firmware/version_data.py new file mode 100644 index 00000000..35855d0d --- /dev/null +++ b/firmware/version_data.py @@ -0,0 +1,117 @@ +import subprocess +import os +import tempfile +import filecmp +import shutil + +commit = subprocess.Popen(['git', 'log', '--format="%H"', '-n''1'], stdout=subprocess.PIPE) +commit,gar = commit.communicate() +print "Showing commit variable" +print commit[1:-2] + +branch = subprocess.Popen(['git', 'symbolic-ref', '--short', 'HEAD'], stdout=subprocess.PIPE) +branch,gar = branch.communicate() +print "Showing branch variable" +print branch[:-1] + +describe = subprocess.Popen(['git', 'describe', '--dirty'], stdout=subprocess.PIPE) +describe,gar = describe.communicate(); +print "Showing describe variable" +print describe[:-1] + +status = subprocess.Popen(['git', 'status', '--short'], stdout=subprocess.PIPE) +status,gar = status.communicate(); + +platform = os.environ['PLATFORM'] +print "Showing uplatform" +print platform.upper() + +target = os.environ['TARGET'] +print "Showing utarget" +print target.upper() + +temp_h = tempfile.NamedTemporaryFile( suffix='.h',delete='true') +print "Showing temp file .h" +print temp_h.name +temp_h.write ('#ifndef __VERSION_DATA_H\n' ) +temp_h.write ('#define __VERSION_DATA_H\n' ) +temp_h.write ('\n' ) +temp_h.write ('extern const char* board;\n' ) +temp_h.write ('extern const char* target;\n' ) +temp_h.write ('\n' ) +temp_h.write ('extern const char* git_commit;\n' ) +temp_h.write ('extern const char* git_branch;\n' ) +temp_h.write ('extern const char* git_describe;\n' ) +temp_h.write ('extern const char* git_status;\n' ) +temp_h.write ('\n' ) +temp_h.write ('#endif // __VERSION_DATA_H\n' ) +temp_h.seek(0) + +temp_c = tempfile.NamedTemporaryFile( suffix='.c',delete='true') +print "Showing temp file .c" +print temp_c.name +temp_c.write ('#ifndef PLATFORM_' ) +temp_c.write (platform ) +temp_c.write ('\n' ) +temp_c.write ('#error "Version mismatch - PLATFORM_' ) +temp_c.write (platform ) +temp_c.write (' not defined!"' ) +temp_c.write ('\n' ) +temp_c.write ('#endif' ) +temp_c.write ('\n' ) +temp_c.write ('\n' ) +temp_c.write ('const char* board = "' ) +temp_c.write (platform ) +temp_c.write ('";' ) +temp_c.write ('\n' ) + +temp_c.write ('#ifndef TARGET_' ) +temp_c.write (target ) +temp_c.write ('\n' ) +temp_c.write ('#error "Version mismatch - TARGET_' ) +temp_c.write (target ) +temp_c.write (' not defined!"' ) +temp_c.write ('\n' ) +temp_c.write ('#endif' ) +temp_c.write ('\n' ) +temp_c.write ('\n' ) +temp_c.write ('const char* target = "' ) +temp_c.write (target ) +temp_c.write ('";' ) +temp_c.write ('\n' ) + +temp_c.write ('const char* git_commit = "' ) +temp_c.write (commit[1:-2] ) +temp_c.write ('";' ) +temp_c.write ('\n' ) +temp_c.write ('const char* git_branch = "' ) +temp_c.write (branch[:-1] ) +temp_c.write ('";' ) +temp_c.write ('\n' ) +temp_c.write ('const char* git_describe = "' ) +temp_c.write (describe[:-1] ) +temp_c.write ('";' ) +temp_c.write ('\n' ) + +temp_c.write ('const char* git_status =\n' ) +temp_c.write (' " --\\r\\n"\n') + +for x in range ( 0, len(status.split('\n'))-1 ): + temp = status.splitlines()[x] + temp = ' " ' + temp + '\\r\\n"' + temp_c.write (temp) + temp_c.write ('\n') +temp_c.write (' " --\\r\\n";') +temp_c.seek(0) + +if not ( filecmp.cmp(temp_h.name,'version_data.h') ): + print "Updating version_data.h" + os.remove ('version_data.h') + shutil.copyfile (temp_h.name,'version_data.h') + +if not ( filecmp.cmp(temp_c.name,'version_data.c') ): + print "Updating version_data.c" + os.remove ('version_data.c') + shutil.copyfile (temp_c.name,'version_data.c') +temp_c.close() +temp_h.close() From b952701983a7eae0dda516b1ddcd30af3c42005b Mon Sep 17 00:00:00 2001 From: gsmalik Date: Thu, 15 Feb 2018 01:34:43 -0500 Subject: [PATCH 142/219] Incorporated the proposed changes --- firmware/version_data.py | 142 +++++++++++++++++---------------------- 1 file changed, 61 insertions(+), 81 deletions(-) diff --git a/firmware/version_data.py b/firmware/version_data.py index 35855d0d..53d7a973 100644 --- a/firmware/version_data.py +++ b/firmware/version_data.py @@ -1,100 +1,79 @@ +#!/usr/bin/env python + import subprocess import os import tempfile import filecmp import shutil -commit = subprocess.Popen(['git', 'log', '--format="%H"', '-n''1'], stdout=subprocess.PIPE) -commit,gar = commit.communicate() -print "Showing commit variable" -print commit[1:-2] +commit = subprocess.check_output(['git', 'log', '--format="%H"', '-n', '1']) +print "Showing commit variable" +print commit[1:-2] -branch = subprocess.Popen(['git', 'symbolic-ref', '--short', 'HEAD'], stdout=subprocess.PIPE) -branch,gar = branch.communicate() -print "Showing branch variable" -print branch[:-1] +branch = subprocess.check_output(['git', 'symbolic-ref', '--short', 'HEAD']) +print "Showing branch variable" +print branch[:-1] -describe = subprocess.Popen(['git', 'describe', '--dirty'], stdout=subprocess.PIPE) -describe,gar = describe.communicate(); +describe = subprocess.check_output(['git', 'describe', '--dirty']) print "Showing describe variable" print describe[:-1] -status = subprocess.Popen(['git', 'status', '--short'], stdout=subprocess.PIPE) -status,gar = status.communicate(); - -platform = os.environ['PLATFORM'] -print "Showing uplatform" -print platform.upper() - -target = os.environ['TARGET'] -print "Showing utarget" -print target.upper() - -temp_h = tempfile.NamedTemporaryFile( suffix='.h',delete='true') -print "Showing temp file .h" -print temp_h.name -temp_h.write ('#ifndef __VERSION_DATA_H\n' ) -temp_h.write ('#define __VERSION_DATA_H\n' ) -temp_h.write ('\n' ) -temp_h.write ('extern const char* board;\n' ) -temp_h.write ('extern const char* target;\n' ) -temp_h.write ('\n' ) -temp_h.write ('extern const char* git_commit;\n' ) -temp_h.write ('extern const char* git_branch;\n' ) -temp_h.write ('extern const char* git_describe;\n' ) -temp_h.write ('extern const char* git_status;\n' ) -temp_h.write ('\n' ) -temp_h.write ('#endif // __VERSION_DATA_H\n' ) +status = subprocess.check_output(['git', 'status', '--short']) + +print "Showing uplatform" +if "PLATFORM" in os.environ: + platform = os.environ['PLATFORM'] + print platform.upper() +else: + platform = "" + +print "Showing utarget" +if "TARGET" in os.environ: + target = os.environ['TARGET'] + print target.upper() +else: + target = "" + +temp_h = tempfile.NamedTemporaryFile( suffix='.h',delete='true') +print "Showing temp file .h" +print temp_h.name +temp_h.write ("""\ +#ifndef __VERSION_DATA_H +#define __VERSION_DATA_H + +extern const char* board; +extern const char* target; + +extern const char* git_commit; +extern const char* git_branch; +extern const char* git_describe; +extern const char* git_status; + +#endif // __VERSION_DATA_H""") temp_h.seek(0) temp_c = tempfile.NamedTemporaryFile( suffix='.c',delete='true') print "Showing temp file .c" print temp_c.name -temp_c.write ('#ifndef PLATFORM_' ) -temp_c.write (platform ) -temp_c.write ('\n' ) -temp_c.write ('#error "Version mismatch - PLATFORM_' ) -temp_c.write (platform ) -temp_c.write (' not defined!"' ) -temp_c.write ('\n' ) -temp_c.write ('#endif' ) -temp_c.write ('\n' ) -temp_c.write ('\n' ) -temp_c.write ('const char* board = "' ) -temp_c.write (platform ) -temp_c.write ('";' ) -temp_c.write ('\n' ) - -temp_c.write ('#ifndef TARGET_' ) -temp_c.write (target ) -temp_c.write ('\n' ) -temp_c.write ('#error "Version mismatch - TARGET_' ) -temp_c.write (target ) -temp_c.write (' not defined!"' ) -temp_c.write ('\n' ) -temp_c.write ('#endif' ) -temp_c.write ('\n' ) -temp_c.write ('\n' ) -temp_c.write ('const char* target = "' ) -temp_c.write (target ) -temp_c.write ('";' ) -temp_c.write ('\n' ) - -temp_c.write ('const char* git_commit = "' ) -temp_c.write (commit[1:-2] ) -temp_c.write ('";' ) -temp_c.write ('\n' ) -temp_c.write ('const char* git_branch = "' ) -temp_c.write (branch[:-1] ) -temp_c.write ('";' ) -temp_c.write ('\n' ) -temp_c.write ('const char* git_describe = "' ) -temp_c.write (describe[:-1] ) -temp_c.write ('";' ) -temp_c.write ('\n' ) - -temp_c.write ('const char* git_status =\n' ) -temp_c.write (' " --\\r\\n"\n') + +temp_c.write ("""\ + +#ifndef PLATFORM_%s +#error \"Version mismatch - PLATFORM_%s not defined!\" +#endif +const char* board = \"%s\"; + +#ifndef TARGET_%s +#error \"Version mismatch - TARGET_%s not defined!\" +#endif +const char* target = \"%s\"; + +const char* git_commit = \"%s\"; +const char* git_branch = \"%s\"; +const char* git_describe = \"%s\"; +const char* git_status = + \" --\\r\\n\" +""" % (platform.upper(),platform.upper(),platform,target.upper(),target.upper(),target,commit[1:-2],branch[:-1],describe[:-1])) for x in range ( 0, len(status.split('\n'))-1 ): temp = status.splitlines()[x] @@ -104,6 +83,7 @@ temp_c.write (' " --\\r\\n";') temp_c.seek(0) + if not ( filecmp.cmp(temp_h.name,'version_data.h') ): print "Updating version_data.h" os.remove ('version_data.h') From 48a3b77f560f985379179c83cbc799558411db5b Mon Sep 17 00:00:00 2001 From: gsmalik Date: Thu, 15 Feb 2018 22:15:38 -0500 Subject: [PATCH 143/219] Moving to python3 --- firmware/version_data.py | 60 ++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/firmware/version_data.py b/firmware/version_data.py index 53d7a973..a84a4ca2 100644 --- a/firmware/version_data.py +++ b/firmware/version_data.py @@ -7,56 +7,56 @@ import shutil commit = subprocess.check_output(['git', 'log', '--format="%H"', '-n', '1']) -print "Showing commit variable" -print commit[1:-2] +print ("Showing commit variable") +print (commit[1:-2]) branch = subprocess.check_output(['git', 'symbolic-ref', '--short', 'HEAD']) -print "Showing branch variable" -print branch[:-1] +print ("Showing branch variable") +print (branch[:-1]) describe = subprocess.check_output(['git', 'describe', '--dirty']) -print "Showing describe variable" -print describe[:-1] +print ("Showing describe variable") +print (describe[:-1]) status = subprocess.check_output(['git', 'status', '--short']) +print (status) -print "Showing uplatform" +print ("Showing uplatform") if "PLATFORM" in os.environ: platform = os.environ['PLATFORM'] - print platform.upper() + print (platform.upper()) else: platform = "" -print "Showing utarget" +print ("Showing utarget") if "TARGET" in os.environ: target = os.environ['TARGET'] - print target.upper() + print (target.upper()) else: target = "" temp_h = tempfile.NamedTemporaryFile( suffix='.h',delete='true') -print "Showing temp file .h" -print temp_h.name -temp_h.write ("""\ +print ("Showing temp file .h") +print (temp_h.name) +temp_h.write (b"""\ #ifndef __VERSION_DATA_H #define __VERSION_DATA_H - extern const char* board; extern const char* target; - extern const char* git_commit; extern const char* git_branch; extern const char* git_describe; extern const char* git_status; - -#endif // __VERSION_DATA_H""") +#endif // __VERSION_DATA_H""" ) temp_h.seek(0) +length = status.count(b'\n') + temp_c = tempfile.NamedTemporaryFile( suffix='.c',delete='true') -print "Showing temp file .c" -print temp_c.name +print ("Showing temp file .c") +print (temp_c.name) -temp_c.write ("""\ +temp_c.write (b"""\ #ifndef PLATFORM_%s #error \"Version mismatch - PLATFORM_%s not defined!\" @@ -73,25 +73,25 @@ const char* git_describe = \"%s\"; const char* git_status = \" --\\r\\n\" -""" % (platform.upper(),platform.upper(),platform,target.upper(),target.upper(),target,commit[1:-2],branch[:-1],describe[:-1])) +""" % (platform.upper().encode(),platform.upper().encode(),platform.encode(),target.upper().encode(),target.upper().encode(),target.encode(),commit[1:-2],branch[:-1],describe[:-1])) -for x in range ( 0, len(status.split('\n'))-1 ): +for x in range ( 0, length): temp = status.splitlines()[x] - temp = ' " ' + temp + '\\r\\n"' - temp_c.write (temp) - temp_c.write ('\n') -temp_c.write (' " --\\r\\n";') + temp = ' " ' + temp.decode() + '\\r\\n"' + temp_c.write (temp.encode()) + temp_c.write (b'\n') +temp_c.write (b' " --\\r\\n";') temp_c.seek(0) if not ( filecmp.cmp(temp_h.name,'version_data.h') ): - print "Updating version_data.h" - os.remove ('version_data.h') + print ( "Updating version_data.h") + os.remove ('version_data.h') shutil.copyfile (temp_h.name,'version_data.h') if not ( filecmp.cmp(temp_c.name,'version_data.c') ): - print "Updating version_data.c" - os.remove ('version_data.c') + print ( "Updating version_data.c") + os.remove ('version_data.c') shutil.copyfile (temp_c.name,'version_data.c') temp_c.close() temp_h.close() From cee2138629e22f98b74d1318faaa8f0292ecbb5d Mon Sep 17 00:00:00 2001 From: gsmalik Date: Thu, 15 Feb 2018 22:54:38 -0500 Subject: [PATCH 144/219] Made pep8 compatible. Neat pycodestyle tool! --- firmware/version_data.py | 56 +++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/firmware/version_data.py b/firmware/version_data.py index a84a4ca2..f1177fc3 100644 --- a/firmware/version_data.py +++ b/firmware/version_data.py @@ -1,10 +1,10 @@ #!/usr/bin/env python -import subprocess -import os -import tempfile -import filecmp -import shutil +import subprocess +import os +import tempfile +import filecmp +import shutil commit = subprocess.check_output(['git', 'log', '--format="%H"', '-n', '1']) print ("Showing commit variable") @@ -19,6 +19,7 @@ print (describe[:-1]) status = subprocess.check_output(['git', 'status', '--short']) +length = status.count(b'\n') print (status) print ("Showing uplatform") @@ -35,10 +36,10 @@ else: target = "" -temp_h = tempfile.NamedTemporaryFile( suffix='.h',delete='true') +temp_h = tempfile.NamedTemporaryFile(suffix='.h', delete='true') print ("Showing temp file .h") print (temp_h.name) -temp_h.write (b"""\ +temp_h.write(b"""\ #ifndef __VERSION_DATA_H #define __VERSION_DATA_H extern const char* board; @@ -47,16 +48,15 @@ extern const char* git_branch; extern const char* git_describe; extern const char* git_status; -#endif // __VERSION_DATA_H""" ) +#endif // __VERSION_DATA_H""") temp_h.seek(0) -length = status.count(b'\n') -temp_c = tempfile.NamedTemporaryFile( suffix='.c',delete='true') +temp_c = tempfile.NamedTemporaryFile(suffix='.c', delete='true') print ("Showing temp file .c") print (temp_c.name) -temp_c.write (b"""\ +temp_c.write(b"""\ #ifndef PLATFORM_%s #error \"Version mismatch - PLATFORM_%s not defined!\" @@ -73,25 +73,27 @@ const char* git_describe = \"%s\"; const char* git_status = \" --\\r\\n\" -""" % (platform.upper().encode(),platform.upper().encode(),platform.encode(),target.upper().encode(),target.upper().encode(),target.encode(),commit[1:-2],branch[:-1],describe[:-1])) - -for x in range ( 0, length): - temp = status.splitlines()[x] - temp = ' " ' + temp.decode() + '\\r\\n"' - temp_c.write (temp.encode()) - temp_c.write (b'\n') -temp_c.write (b' " --\\r\\n";') +""" % (platform.upper().encode(), platform.upper().encode(), platform.encode(), + target.upper().encode(), target.upper().encode(), target.encode(), + commit[1:-2], branch[:-1], describe[:-1])) + +for x in range(0, length): + temp = status.splitlines()[x] + temp = ' " ' + temp.decode() + '\\r\\n"' + temp_c.write(temp.encode()) + temp_c.write(b'\n') +temp_c.write(b' " --\\r\\n";') temp_c.seek(0) -if not ( filecmp.cmp(temp_h.name,'version_data.h') ): - print ( "Updating version_data.h") - os.remove ('version_data.h') - shutil.copyfile (temp_h.name,'version_data.h') +if not (filecmp.cmp(temp_h.name, 'version_data.h')): + print ("Updating version_data.h") + os.remove('version_data.h') + shutil.copyfile(temp_h.name, 'version_data.h') -if not ( filecmp.cmp(temp_c.name,'version_data.c') ): - print ( "Updating version_data.c") - os.remove ('version_data.c') - shutil.copyfile (temp_c.name,'version_data.c') +if not (filecmp.cmp(temp_c.name, 'version_data.c')): + print ("Updating version_data.c") + os.remove('version_data.c') + shutil.copyfile(temp_c.name, 'version_data.c') temp_c.close() temp_h.close() From 42f5db00ef30b5a76a013701cf6395d39be5d08c Mon Sep 17 00:00:00 2001 From: gsmalik Date: Fri, 16 Feb 2018 00:10:15 -0500 Subject: [PATCH 145/219] pycodestyle in the build env O_O --- firmware/version_data.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/firmware/version_data.py b/firmware/version_data.py index f1177fc3..0bb17b1c 100644 --- a/firmware/version_data.py +++ b/firmware/version_data.py @@ -7,38 +7,38 @@ import shutil commit = subprocess.check_output(['git', 'log', '--format="%H"', '-n', '1']) -print ("Showing commit variable") -print (commit[1:-2]) +print("Showing commit variable") +print(commit[1:-2]) branch = subprocess.check_output(['git', 'symbolic-ref', '--short', 'HEAD']) -print ("Showing branch variable") -print (branch[:-1]) +print("Showing branch variable") +print(branch[:-1]) describe = subprocess.check_output(['git', 'describe', '--dirty']) -print ("Showing describe variable") -print (describe[:-1]) +print("Showing describe variable") +print(describe[:-1]) status = subprocess.check_output(['git', 'status', '--short']) length = status.count(b'\n') -print (status) +print(status) -print ("Showing uplatform") +print("Showing uplatform") if "PLATFORM" in os.environ: platform = os.environ['PLATFORM'] - print (platform.upper()) + print(platform.upper()) else: platform = "" -print ("Showing utarget") +print("Showing utarget") if "TARGET" in os.environ: target = os.environ['TARGET'] - print (target.upper()) + print(target.upper()) else: target = "" temp_h = tempfile.NamedTemporaryFile(suffix='.h', delete='true') -print ("Showing temp file .h") -print (temp_h.name) +print("Showing temp file .h") +print(temp_h.name) temp_h.write(b"""\ #ifndef __VERSION_DATA_H #define __VERSION_DATA_H @@ -53,8 +53,8 @@ temp_c = tempfile.NamedTemporaryFile(suffix='.c', delete='true') -print ("Showing temp file .c") -print (temp_c.name) +print("Showing temp file .c") +print(temp_c.name) temp_c.write(b"""\ @@ -87,12 +87,12 @@ if not (filecmp.cmp(temp_h.name, 'version_data.h')): - print ("Updating version_data.h") + print("Updating version_data.h") os.remove('version_data.h') shutil.copyfile(temp_h.name, 'version_data.h') if not (filecmp.cmp(temp_c.name, 'version_data.c')): - print ("Updating version_data.c") + print("Updating version_data.c") os.remove('version_data.c') shutil.copyfile(temp_c.name, 'version_data.c') temp_c.close() From f79c68cd5cbb4f128ea2258c9b1fb5932efa4bc7 Mon Sep 17 00:00:00 2001 From: gsmalik Date: Sat, 17 Feb 2018 02:47:45 -0500 Subject: [PATCH 146/219] 1. Added Docstring.2. Changed to string format.3. Removed unnecessary prints.4. Better decoing to UTF-8 --- firmware/version_data.py | 88 ++++++++++++++++++++-------------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/firmware/version_data.py b/firmware/version_data.py index 0bb17b1c..0a350509 100644 --- a/firmware/version_data.py +++ b/firmware/version_data.py @@ -1,4 +1,8 @@ #!/usr/bin/env python +""" +This file embeds in the firmware information like the git commit +number,git branch information and git status of the build tree. +""" import subprocess import os @@ -6,83 +10,79 @@ import filecmp import shutil -commit = subprocess.check_output(['git', 'log', '--format="%H"', '-n', '1']) -print("Showing commit variable") -print(commit[1:-2]) +commit = subprocess.check_output(['git', 'log', '--format="%H"', '-n', '1'])\ + .decode('utf-8') +branch = subprocess.check_output(['git', 'symbolic-ref', '--short', 'HEAD'])\ + .decode('utf-8') +describe = subprocess.check_output(['git', 'describe', '--dirty'])\ + .decode('utf-8') +status = subprocess.check_output(['git', 'status', '--short']).decode('utf-8') +length = status.count('\n') -branch = subprocess.check_output(['git', 'symbolic-ref', '--short', 'HEAD']) -print("Showing branch variable") -print(branch[:-1]) - -describe = subprocess.check_output(['git', 'describe', '--dirty']) -print("Showing describe variable") -print(describe[:-1]) - -status = subprocess.check_output(['git', 'status', '--short']) -length = status.count(b'\n') -print(status) - -print("Showing uplatform") if "PLATFORM" in os.environ: platform = os.environ['PLATFORM'] - print(platform.upper()) else: platform = "" + print("PLATFORM NOT SET") -print("Showing utarget") if "TARGET" in os.environ: target = os.environ['TARGET'] - print(target.upper()) else: target = "" + print("TARGET NOT SET") -temp_h = tempfile.NamedTemporaryFile(suffix='.h', delete='true') +temp_h = tempfile.NamedTemporaryFile(suffix='.h', delete=True, mode='w+t') print("Showing temp file .h") print(temp_h.name) -temp_h.write(b"""\ +string = ("""\ #ifndef __VERSION_DATA_H #define __VERSION_DATA_H + extern const char* board; extern const char* target; + extern const char* git_commit; extern const char* git_branch; extern const char* git_describe; extern const char* git_status; + #endif // __VERSION_DATA_H""") +temp_h.write(string) temp_h.seek(0) - -temp_c = tempfile.NamedTemporaryFile(suffix='.c', delete='true') +temp_c = tempfile.NamedTemporaryFile(suffix='.c', delete=True, mode='w+t') print("Showing temp file .c") print(temp_c.name) -temp_c.write(b"""\ +string = ("""\ -#ifndef PLATFORM_%s -#error \"Version mismatch - PLATFORM_%s not defined!\" +#ifndef PLATFORM_{} +#error "Version mismatch - PLATFORM_{} not defined!" #endif -const char* board = \"%s\"; +const char* board = "{}"; -#ifndef TARGET_%s -#error \"Version mismatch - TARGET_%s not defined!\" +#ifndef TARGET_{} +#error "Version mismatch - TARGET_{} not defined!" #endif -const char* target = \"%s\"; +const char* target = "{}"; -const char* git_commit = \"%s\"; -const char* git_branch = \"%s\"; -const char* git_describe = \"%s\"; +const char* git_commit = "{}"; +const char* git_branch = "{}"; +const char* git_describe = "{}"; const char* git_status = - \" --\\r\\n\" -""" % (platform.upper().encode(), platform.upper().encode(), platform.encode(), - target.upper().encode(), target.upper().encode(), target.encode(), - commit[1:-2], branch[:-1], describe[:-1])) - -for x in range(0, length): - temp = status.splitlines()[x] - temp = ' " ' + temp.decode() + '\\r\\n"' - temp_c.write(temp.encode()) - temp_c.write(b'\n') -temp_c.write(b' " --\\r\\n";') + " --\\r\\n" +""") + +temp_c.write(string.format(platform.upper(), platform.upper(), platform, + target.upper(), target.upper(), target, commit[1:-2], + branch[:-1], describe[:-1])) + +for line in range(0, length): + temp = status.splitlines()[line] + temp = ' " ' + temp + '\\r\\n"' + temp_c.write(temp) + temp_c.write('\n') +temp_c.write(' " --\\r\\n";') temp_c.seek(0) From 71382ef9ae5b4e125e001cdd203f90d31ea6f46e Mon Sep 17 00:00:00 2001 From: Greg Darke Date: Sun, 18 Feb 2018 13:10:10 -0800 Subject: [PATCH 147/219] Reduce error output from prompt_command. If 'atftpd' or 'in.tftpd' are not installed then which will output an error whenever the Makefile is evaluated. This happens everytime the bash prompt is evaluated. Specifically because $PROMPT_COMMAND is overwritten by 'scripts/enter-env.sh'. --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 9fdbb8b1..9ac314bb 100644 --- a/Makefile +++ b/Makefile @@ -339,7 +339,7 @@ bios-flash: $(BIOS_FILE) bios-flash-$(PLATFORM) # We can run the TFTP server as the user if port >= 1024 # otherwise we need to run as root using sudo -ATFTPD:=$(shell which atftpd) +ATFTPD:=$(shell which atftpd 2>/dev/null) ifeq ($(ATFTPD),) ATFTPD:=/usr/sbin/atftpd endif @@ -349,7 +349,7 @@ endif # even if run as current user, otherwise it reports # "cannot set groups for user $USER" # -IN_TFTPD:=$(shell which in.tftpd) +IN_TFTPD:=$(shell which in.tftpd 2>/dev/null) ifeq ($(IN_TFTPD),) IN_TFTPD:=/usr/sbin/in.tftpd endif From 896a32ab825536525f464b8ac403b1f9e5bab53e Mon Sep 17 00:00:00 2001 From: Greg Darke Date: Sun, 18 Feb 2018 16:38:46 -0800 Subject: [PATCH 148/219] Stop enter-env.sh from clobbering PROMPT_COMMAND. Previously `scripts/enter-env.sh` would unconditionally set PROMPT_COMMAND to run the litex_buildenv_prompt function, overwriting any value set by the user. --- scripts/enter-env.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/enter-env.sh b/scripts/enter-env.sh index c90d1601..b2d74023 100755 --- a/scripts/enter-env.sh +++ b/scripts/enter-env.sh @@ -322,4 +322,4 @@ litex_buildenv_prompt() { ;; esac } -PROMPT_COMMAND=litex_buildenv_prompt +PROMPT_COMMAND="litex_buildenv_prompt; ${PROMPT_COMMAND}" From 3c9045eaf37dd7158352b5e18f3c8a484213c961 Mon Sep 17 00:00:00 2001 From: gsmalik Date: Mon, 19 Feb 2018 04:43:09 -0500 Subject: [PATCH 149/219] Adding the minute nits. --- firmware/version_data.py | 112 +++++++++++++++++++++++---------------- 1 file changed, 65 insertions(+), 47 deletions(-) diff --git a/firmware/version_data.py b/firmware/version_data.py index 0a350509..7f5825f5 100644 --- a/firmware/version_data.py +++ b/firmware/version_data.py @@ -6,35 +6,44 @@ import subprocess import os -import tempfile -import filecmp -import shutil - -commit = subprocess.check_output(['git', 'log', '--format="%H"', '-n', '1'])\ - .decode('utf-8') -branch = subprocess.check_output(['git', 'symbolic-ref', '--short', 'HEAD'])\ - .decode('utf-8') -describe = subprocess.check_output(['git', 'describe', '--dirty'])\ - .decode('utf-8') +import sys +import io + +commit = subprocess.check_output( + ['git', 'log', '--format="%H"', '-n', '1']).decode('utf-8') +branch = subprocess.check_output( + ['git', 'symbolic-ref', '--short', 'HEAD']).decode('utf-8') +describe = subprocess.check_output( + ['git', 'describe', '--dirty']).decode('utf-8') status = subprocess.check_output(['git', 'status', '--short']).decode('utf-8') length = status.count('\n') if "PLATFORM" in os.environ: platform = os.environ['PLATFORM'] else: - platform = "" - print("PLATFORM NOT SET") + sys.stderr.write("""\ + PLATFORM environment variable is not set. + + This script should only be run as part of LiteX Build Environment. + + Try 'source ./scripts/enter-env.sh' +""") + sys.exit(1) if "TARGET" in os.environ: target = os.environ['TARGET'] else: - target = "" - print("TARGET NOT SET") + sys.stderr.write("""\ + TARGET environment variable is not set. + + This script should only be run as part of LiteX Build Environment -temp_h = tempfile.NamedTemporaryFile(suffix='.h', delete=True, mode='w+t') -print("Showing temp file .h") -print(temp_h.name) -string = ("""\ + Try 'source ./scripts/enter-env.sh' +""") + sys.exit(1) + +temp_h = io.StringIO() +temp_h.write("""\ #ifndef __VERSION_DATA_H #define __VERSION_DATA_H @@ -47,35 +56,28 @@ extern const char* git_status; #endif // __VERSION_DATA_H""") -temp_h.write(string) temp_h.seek(0) -temp_c = tempfile.NamedTemporaryFile(suffix='.c', delete=True, mode='w+t') -print("Showing temp file .c") -print(temp_c.name) - -string = ("""\ - -#ifndef PLATFORM_{} -#error "Version mismatch - PLATFORM_{} not defined!" +temp_c = io.StringIO() +temp_c.write("""\ +#ifndef PLATFORM_{UPLATFORM} +#error "Version mismatch - PLATFORM_{UPLATFORM} not defined!" #endif -const char* board = "{}"; +const char* board = "{PLATFORM}"; -#ifndef TARGET_{} -#error "Version mismatch - TARGET_{} not defined!" +#ifndef TARGET_{UTARGET} +#error "Version mismatch - TARGET_{UTARGET} not defined!" #endif -const char* target = "{}"; +const char* target = "{TARGET}"; -const char* git_commit = "{}"; -const char* git_branch = "{}"; -const char* git_describe = "{}"; +const char* git_commit = "{COMMIT}"; +const char* git_branch = "{BRANCH}"; +const char* git_describe = "{DESCRIBE}"; const char* git_status = " --\\r\\n" -""") - -temp_c.write(string.format(platform.upper(), platform.upper(), platform, - target.upper(), target.upper(), target, commit[1:-2], - branch[:-1], describe[:-1])) +""".format(UPLATFORM=platform.upper(), PLATFORM=platform, + UTARGET=target.upper(), TARGET=target, + COMMIT=commit[1:-2], BRANCH=branch[:-1], DESCRIBE=describe[:-1])) for line in range(0, length): temp = status.splitlines()[line] @@ -85,15 +87,31 @@ temp_c.write(' " --\\r\\n";') temp_c.seek(0) - -if not (filecmp.cmp(temp_h.name, 'version_data.h')): +try: + myfile = open("version_data.c", "r+") +except IOError: + myfile = open("version_data.c", "w+") +data = myfile.read() +data_c = temp_c.getvalue() +if not (dat a == data_c): + print("Updating version_data.c") + myfile.seek(0) + myfile.truncate(0) + myfile.write(data_c) +myfile.close() + +try: + myfile = open("version_data.h", "r+") +except IOError: + myfile = open("version_data.h", "w+") +data = myfile.read() +data_h = temp_h.getvalue() +if not (data == data_h): print("Updating version_data.h") - os.remove('version_data.h') - shutil.copyfile(temp_h.name, 'version_data.h') + myfile.seek(0) + myfile.truncate(0) + myfile.write(data_h) +myfile.close() -if not (filecmp.cmp(temp_c.name, 'version_data.c')): - print("Updating version_data.c") - os.remove('version_data.c') - shutil.copyfile(temp_c.name, 'version_data.c') temp_c.close() temp_h.close() From ad1bc266ce74d7b930e844d0ddfe3c96d04dabc7 Mon Sep 17 00:00:00 2001 From: gsmalik Date: Tue, 20 Feb 2018 01:34:46 -0500 Subject: [PATCH 150/219] Adding space between number git --- firmware/version_data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/version_data.py b/firmware/version_data.py index 7f5825f5..bc67853c 100644 --- a/firmware/version_data.py +++ b/firmware/version_data.py @@ -1,7 +1,7 @@ #!/usr/bin/env python """ This file embeds in the firmware information like the git commit -number,git branch information and git status of the build tree. +number, git branch information and git status of the build tree. """ import subprocess From 15a01e41ce8b352e841efeceb9117a8d7f7bb69d Mon Sep 17 00:00:00 2001 From: "William D. Jones" Date: Wed, 28 Feb 2018 16:06:03 -0500 Subject: [PATCH 151/219] Update litex submodules; imports changed, does not compile. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * flash_proxies changed from c506426 to a628956 * a628956 - Merge pull request #4 from cr1901/more-series7 * 8be7e2d - Add new bitstream proxies for devices available as of Vivado 2017.4.1. * 29d9124 - Add new packages for missing Series 7 family members. * c1d8007 - Add missing Series 7 family members. * litedram changed from 13d41f6 to 48bc3cb * 48bc3cb - README: add migen dependency * 697f46a - replace litex.gen imports with migen imports * bd43fd6 - bump to 0.2.dev * 45a948d - uniformize litex cores * 5838953 - modules: add MT47H64M16 * 57c63c1 - phy/a7ddrphy: make reset_n optional * ec9ad2f - frontend/dma: add description of fifo_buffered parameter * liteeth changed from 8fc7161 to 33afda7 * 33afda7 - README: add migen dependency * 79a6ba7 - replace litex.gen imports with migen imports * c15f089 - bump to 0.2.dev * c42aa09 - uniformize litex cores * 4e08d6e - Merge pull request #13 from felixheld/crc_pythonize * 9dcc7bc - mac/crc.py: make crc calculation more pythonic * 2ceaa74 - clarify the comments in mac/crc.py code * litepcie changed from 945963d to 6b147e1 * 6b147e1 - frontend/dma: add 16 bits control field to descriptors * 08a4501 - README: add migen dependency * 6afbd1c - frontend/dma/LitePCIeDMAWriter: switch to next decriptor when sink.last is asserted * ed0b8a4 - phy/xilinx/7-series: integrate v3.3 files (working for x2) * d9b8b2a - core/tlp/packetizer: add 128 bits support * 686da6b - core/tlp/depacketizer: add 128 bits support * 0724533 - replace litex.gen imports with migen imports * 3e38b54 - bump to 0.2.dev * 96cdfe6 - revert phy to 3.0 and tlp packetizer/depacketizer to fixed 64 bit version (until we investigate the regression) * d7d9e5f - uniformize litex cores * 058c493 - phy/xilinx/7-series: update to 3.3 * 98a2c77 - core/tlp/packetizer: typo * d8bc19c - phy/s7pciephy: add x4 support (untested) * 4609a88 - test/model/phy: fix typo * a058223 - test/test_dma: remove converter parameter * 525b843 - core/tlp/depacketizer: add 128 bits support (untested) * 6210998 - core/tlp/packetizer: add 128 bits support (untested) * 45227fe - example_designs/targets: fix dma target * 7b5b806 - core/tlp/depacketizer: simplify using NextValue * litesata changed from af00fa6 to a559afb * a559afb - README: add migen dependency * c1e1341 - replace litex.gen imports with migen imports * eafaf16 - bump to 0.2.dev * a6c08ce - uniformize litex cores * litescope changed from aa44da3 to 9d5e605 * 9d5e605 - replace litex.gen imports with migen imports * 302a484 - bump to 0.2.dev * 62c4bdd - uniformize litex cores * 985585f - __init__: add LiteScopeIODriver and LiteScopeAnalyzerDriver imports * liteusb changed from 0b05b6c to 23d6a68 * 23d6a68 - README: add migen dependency * 102a751 - replace litex.gen imports with migen imports * 3faa9ae - bump to 0.2.dev * d52cf32 - uniformize litex cores * litevideo changed from 9907975 to 18b88df * 18b88df - input/edid: fix scl polarity * a3c1984 - README: add migen dependency * 152b6d7 - replace litex.gen imports with migen imports * c96ef9c - bump to 0.2.dev * 2274b01 - uniformize litex cores * 50e8ac9 - output/VGAPHY: add missing self.sink.ready.eq(1) * a7e289a - make split-clocking optional, also make output stage PLLE2 + BUFG * 78274ed - input/clocking: fix pix_o issue with spartan6 (will need cleaner fix) * 61fa158 - Merge pull request #16 from MaZderMind/fix_hdmi_phy_cls_variable_name * 96fdbec - Merge pull request #15 from bunnie/try_florent_720p * a44b5d7 - tweak clocking parameters -- maybe marginally better? * 2d81c5b - fix phase relationship between master/slave MMCM * 9d99716 - these mods add a second MMCM, to fix the BUFG/BUFIO issue * litex changed from 4f272580 to 3e7cc255 * 3e7cc255 - Merge pull request #69 from mithro/conda-support |\ | * 3bf50479 - travis: Adding some color. | * 083c2613 - travis: Move the conda install into script so it can be folded. | * da3189c8 - travis: Making the output more readable. | * 12bb3ebf - travis: Build all the SoCs (without gateware). | * e65c121a - Adding a travis config which tests the conda environment still works. | * 795e8285 - Adding conda environment example. |/ * ab2a3277 - Merge pull request #67 from cr1901/vivado-paths |\ | * 2b00b7eb - xilinx/vivado: Provide a fallback mechanism for using the same root for Vivado and ISE toolchains. * | db20df49 - Merge pull request #65 from cr1901/tinyfpga-serial |\ \ | * | e71593d6 - platforms/tinyfpga_b: Move serial peripheral out of default I/O, make it optional via `add_extension`. * | | fa6b2561 - build/xilinx/platform: fix merge * | | 87d4af0b - Merge pull request #66 from cr1901/arty_s7 |\ \ \ | * | | d40c5773 - boards/arty_s7: Fix IOStandard on System Clock. |/ / / * | | 7bd718eb - README: add migen installation to quick start guide | |/ |/| * | 0332f73a - build/xilinx/vivado: revert toolchain_path * | 2ff50a88 - build: fix merge * | 64e4e1ce - build: merge with migen.build 27beffe7 * | 0edfd9b9 - boards/kcu105: regroup sfp tx and rx |/ * c5be6e26 - README: add section for newcomers * f372e8c8 - README: cleanup * fb088b79 - README: update, migen is no longer forked * 1925ba17 - replace litex.gen imports with migen imports * 43164b9a - remove migen fork from litex * 212e1a70 - bump to 0.2.dev * 64aa4ae4 - uniformize with litex cores and make things more clear about what LiteX vs Migen/MiSoC * aaf09705 - Merge pull request #64 from q3k/q3k/axi4lite |\ | * 688f26cc - Change AXI interface and tidy code | * 512ed2b3 - Preliminary AXI4Lite CSR bridge support |/ * 55fc9d2d - Merge pull request #60 from q3k/for-upstream/top-level-module-selection |\ | * ef511e7e - Specify top-level module in Lattice Diemond build script. | * ef6c517d - Build top module as 'dut' in Verilator and set it as top-level. * 7b5bd404 - Merge pull request #57 from rohitk-singh/master |\ | * 75e7f950 - BIOS: Flashboot without main ram * c1450280 - board/targets/nexys4ddr: use MT47H64M16 * 95ebba42 - boards/platforms/nexys4ddr: add user_sw, user_btn, fix ddr3 * ee4fa597 - boards: add nexys4ddr * 2ecd1b06 - Merge pull request #61 from PaulSchulz/master |\ | * 0ac35300 - Merge branch 'master' of https://github.com/enjoy-digital/litex into upstream | * 3ac28ed6 - platform/arty.py: Move Pmod definitions to 'connectors' section. * c83ae98b - Merge pull request #63 from cr1901/arty_s7 * 4607e532 - boards/platforms: Add Arty S7 Board. Full submodule status -- f56f329ed23a25d002352dedba1e8f092a47286f edid-decode (heads/master) a628956da7dc794e6e3c95b31ff9ce3af58bc763 flash_proxies (remotes/origin/HEAD) 48bc3cb15d17202a19e621acd83d2733190285b2 litedram (remotes/origin/HEAD) 33afda74f77f7bafa3e4e19641b9043320c47e4e liteeth (remotes/origin/HEAD) 6b147e1d120a3a062cf2c85e950d358b39edb8eb litepcie (remotes/origin/HEAD) a559afb2c53932f29ecc4cec8aa394d1004377c1 litesata (remotes/origin/HEAD) 9d5e605df3e5f1d54609acc5a2f10764045127e9 litescope (remotes/origin/HEAD) 23d6a6840d4276f8d1a7f31bafb8d0aaaecff6d1 liteusb (remotes/origin/HEAD) 18b88dfee6bf6f4ab55d196747ca00c6c84c2ef2 litevideo (remotes/origin/HEAD) 3e7cc2554b7dcc578ca86fd881d3523625b888f8 litex (remotes/origin/HEAD) --- third_party/flash_proxies | 2 +- third_party/litedram | 2 +- third_party/liteeth | 2 +- third_party/litepcie | 2 +- third_party/litesata | 2 +- third_party/litescope | 2 +- third_party/liteusb | 2 +- third_party/litevideo | 2 +- third_party/litex | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/third_party/flash_proxies b/third_party/flash_proxies index c5064269..a628956d 160000 --- a/third_party/flash_proxies +++ b/third_party/flash_proxies @@ -1 +1 @@ -Subproject commit c5064269868396b2c7a78bff28f8e3cf421d1f6e +Subproject commit a628956da7dc794e6e3c95b31ff9ce3af58bc763 diff --git a/third_party/litedram b/third_party/litedram index 13d41f67..48bc3cb1 160000 --- a/third_party/litedram +++ b/third_party/litedram @@ -1 +1 @@ -Subproject commit 13d41f67ab3070f6af955aa8752c616d034f82f6 +Subproject commit 48bc3cb15d17202a19e621acd83d2733190285b2 diff --git a/third_party/liteeth b/third_party/liteeth index 8fc71610..33afda74 160000 --- a/third_party/liteeth +++ b/third_party/liteeth @@ -1 +1 @@ -Subproject commit 8fc716103670e703c7fe98c9bdf653b9b53ca12a +Subproject commit 33afda74f77f7bafa3e4e19641b9043320c47e4e diff --git a/third_party/litepcie b/third_party/litepcie index 945963d1..6b147e1d 160000 --- a/third_party/litepcie +++ b/third_party/litepcie @@ -1 +1 @@ -Subproject commit 945963d186b3c0287426ef6655e00ad4e250d279 +Subproject commit 6b147e1d120a3a062cf2c85e950d358b39edb8eb diff --git a/third_party/litesata b/third_party/litesata index af00fa61..a559afb2 160000 --- a/third_party/litesata +++ b/third_party/litesata @@ -1 +1 @@ -Subproject commit af00fa613f1b6921e14788dd0ebf301e51009e74 +Subproject commit a559afb2c53932f29ecc4cec8aa394d1004377c1 diff --git a/third_party/litescope b/third_party/litescope index aa44da35..9d5e605d 160000 --- a/third_party/litescope +++ b/third_party/litescope @@ -1 +1 @@ -Subproject commit aa44da35c6a232a9e39c43987a3afc9b025ab614 +Subproject commit 9d5e605df3e5f1d54609acc5a2f10764045127e9 diff --git a/third_party/liteusb b/third_party/liteusb index 0b05b6c8..23d6a684 160000 --- a/third_party/liteusb +++ b/third_party/liteusb @@ -1 +1 @@ -Subproject commit 0b05b6c8f9279bb7e476b2c8ae4f39ea88534f08 +Subproject commit 23d6a6840d4276f8d1a7f31bafb8d0aaaecff6d1 diff --git a/third_party/litevideo b/third_party/litevideo index 9907975f..18b88dfe 160000 --- a/third_party/litevideo +++ b/third_party/litevideo @@ -1 +1 @@ -Subproject commit 9907975f8b5842800089f52a9122156c73eb22fd +Subproject commit 18b88dfee6bf6f4ab55d196747ca00c6c84c2ef2 diff --git a/third_party/litex b/third_party/litex index 4f272580..3e7cc255 160000 --- a/third_party/litex +++ b/third_party/litex @@ -1 +1 @@ -Subproject commit 4f2725809e0b9b6cee94cb569c1878f48ab52a15 +Subproject commit 3e7cc2554b7dcc578ca86fd881d3523625b888f8 From f3d64cc48e5cc6cb164c7350d42646b152c49143 Mon Sep 17 00:00:00 2001 From: "William D. Jones" Date: Wed, 28 Feb 2018 16:29:10 -0500 Subject: [PATCH 152/219] Replace litex.gen with migen imports in main tree. --- gateware/cas.py | 2 +- gateware/encoder/core.py | 6 +++--- gateware/firmware.py | 2 +- gateware/freq_measurement.py | 6 +++--- gateware/i2c.py | 6 +++--- gateware/info/__init__.py | 2 +- gateware/info/dna.py | 2 +- gateware/info/git.py | 2 +- gateware/info/platform.py | 2 +- gateware/info/xadc.py | 2 +- gateware/led.py | 2 +- gateware/memtest.py | 2 +- gateware/oled.py | 4 ++-- gateware/opsis_i2c.py | 12 ++++++------ gateware/pwm.py | 2 +- gateware/s6rgmii.py | 8 ++++---- gateware/shared_uart.py | 2 +- gateware/spi_flash.py | 4 ++-- gateware/streamer/core.py | 4 ++-- gateware/tofe.py | 2 +- targets/arty/base.py | 4 ++-- targets/arty/ddr3.py | 4 ++-- targets/atlys/base.py | 6 +++--- targets/atlys/hdmi2usb.py | 2 +- targets/common/cpu_interface.py | 2 +- targets/mimasv2/base.py | 4 ++-- targets/minispartan6/base.py | 6 +++--- targets/netv2/base.py | 4 ++-- targets/netv2/bridge_pcie.py | 8 ++++---- targets/netv2/bridge_uart.py | 6 +++--- targets/netv2/pcie.py | 2 +- targets/nexys_video/base.py | 4 ++-- targets/nexys_video/bridge_net.py | 2 +- targets/nexys_video/ddr3.py | 4 ++-- targets/opsis/axiom.py | 2 +- targets/opsis/base.py | 6 +++--- targets/opsis/encoder.py | 2 +- targets/opsis/hdmi2usb.py | 2 +- targets/pipistrello/base.py | 4 ++-- targets/sim/base.py | 4 ++-- targets/sim/video.py | 2 +- 41 files changed, 77 insertions(+), 77 deletions(-) diff --git a/gateware/cas.py b/gateware/cas.py index 677d1725..70603b65 100644 --- a/gateware/cas.py +++ b/gateware/cas.py @@ -7,7 +7,7 @@ from litex.soc.interconnect.csr import AutoCSR from litex.soc.interconnect.csr_eventmanager import * -from litex.gen.genlib.misc import WaitTimer +from migen.genlib.misc import WaitTimer from litex.soc.cores.gpio import GPIOIn, GPIOOut diff --git a/gateware/encoder/core.py b/gateware/encoder/core.py index 0b6f7daa..bfff2a36 100644 --- a/gateware/encoder/core.py +++ b/gateware/encoder/core.py @@ -1,8 +1,8 @@ import os -from litex.gen import * -from litex.gen.genlib.cdc import MultiReg -from litex.gen.genlib.misc import chooser +from migen import * +from migen.genlib.cdc import MultiReg +from migen.genlib.misc import chooser from litex.soc.interconnect import wishbone from litex.soc.interconnect import stream diff --git a/gateware/firmware.py b/gateware/firmware.py index f2a7b11c..7c50a3d4 100644 --- a/gateware/firmware.py +++ b/gateware/firmware.py @@ -1,7 +1,7 @@ import os import struct -from litex.gen import * +from migen import * from litex.soc.interconnect import wishbone diff --git a/gateware/freq_measurement.py b/gateware/freq_measurement.py index 4545b8de..c421cd18 100644 --- a/gateware/freq_measurement.py +++ b/gateware/freq_measurement.py @@ -1,6 +1,6 @@ -from litex.gen import * -from litex.gen.genlib.cdc import MultiReg, GrayCounter -from litex.gen.genlib.cdc import GrayDecoder +from migen import * +from migen.genlib.cdc import MultiReg, GrayCounter +from migen.genlib.cdc import GrayDecoder from litex.soc.interconnect.csr import * diff --git a/gateware/i2c.py b/gateware/i2c.py index 409da42a..24114271 100644 --- a/gateware/i2c.py +++ b/gateware/i2c.py @@ -1,6 +1,6 @@ -from litex.gen import * -from litex.gen.fhdl import * -from litex.gen.fhdl.specials import TSTriple +from migen import * +from migen.fhdl import * +from migen.fhdl.specials import TSTriple from litex.soc.interconnect.csr import * diff --git a/gateware/info/__init__.py b/gateware/info/__init__.py index bb4c92f5..2cc96869 100644 --- a/gateware/info/__init__.py +++ b/gateware/info/__init__.py @@ -3,7 +3,7 @@ """ from litex.build.generic_platform import ConstraintError -from litex.gen import * +from migen import * from litex.soc.interconnect.csr import * from gateware.info import git diff --git a/gateware/info/dna.py b/gateware/info/dna.py index 324659d7..879f938e 100644 --- a/gateware/info/dna.py +++ b/gateware/info/dna.py @@ -1,6 +1,6 @@ # Copyright 2014-2015 Robert Jordens -from litex.gen import * +from migen import * from litex.soc.interconnect.csr import * diff --git a/gateware/info/git.py b/gateware/info/git.py index fd4c750a..f7104c32 100644 --- a/gateware/info/git.py +++ b/gateware/info/git.py @@ -3,7 +3,7 @@ import subprocess import sys -from litex.gen.fhdl import * +from migen.fhdl import * from litex.soc.interconnect.csr import * def git_root(): diff --git a/gateware/info/platform.py b/gateware/info/platform.py index 8e42a56d..a15c2e89 100644 --- a/gateware/info/platform.py +++ b/gateware/info/platform.py @@ -1,4 +1,4 @@ -from litex.gen.fhdl import * +from migen.fhdl import * from litex.soc.interconnect.csr import * diff --git a/gateware/info/xadc.py b/gateware/info/xadc.py index b4c2896d..1aae84bd 100644 --- a/gateware/info/xadc.py +++ b/gateware/info/xadc.py @@ -1,4 +1,4 @@ -from litex.gen import * +from migen import * from litex.soc.interconnect.csr import * diff --git a/gateware/led.py b/gateware/led.py index cf9e1960..a245f9e1 100644 --- a/gateware/led.py +++ b/gateware/led.py @@ -1,4 +1,4 @@ -from litex.gen import * +from migen import * from litex.soc.interconnect.csr import * from litex.soc.cores import gpio diff --git a/gateware/memtest.py b/gateware/memtest.py index 8cc9331f..329c0ed1 100644 --- a/gateware/memtest.py +++ b/gateware/memtest.py @@ -1,6 +1,6 @@ """Built In Self Test (BIST) modules for testing liteDRAM functionality.""" -from litex.gen import * +from migen import * class LiteDRAMBISTCheckerScope(Module): diff --git a/gateware/oled.py b/gateware/oled.py index 97ed8c9c..0170f5cb 100644 --- a/gateware/oled.py +++ b/gateware/oled.py @@ -1,8 +1,8 @@ -from litex.gen import * +from migen import * from litex.soc.interconnect.csr import * from litex.soc.cores.gpio import GPIOOut -from litex.gen import * +from migen import * from litex.soc.interconnect.csr import * diff --git a/gateware/opsis_i2c.py b/gateware/opsis_i2c.py index 8136ec8a..6376c73b 100644 --- a/gateware/opsis_i2c.py +++ b/gateware/opsis_i2c.py @@ -3,13 +3,13 @@ FIXME: Refactor this properly... """ -from litex.gen.fhdl import * -from litex.gen.fhdl.specials import TSTriple +from migen.fhdl import * +from migen.fhdl.specials import TSTriple -from litex.gen.genlib.cdc import MultiReg -from litex.gen.genlib.fsm import FSM, NextState -from litex.gen.genlib.misc import chooser -from litex.gen.genlib.misc import split, displacer, chooser +from migen.genlib.cdc import MultiReg +from migen.genlib.fsm import FSM, NextState +from migen.genlib.misc import chooser +from migen.genlib.misc import split, displacer, chooser from litex.soc.cores.gpio import GPIOIn, GPIOOut from litex.soc.interconnect.csr import * diff --git a/gateware/pwm.py b/gateware/pwm.py index 31d8cbe9..3725346f 100644 --- a/gateware/pwm.py +++ b/gateware/pwm.py @@ -1,4 +1,4 @@ -from litex.gen import * +from migen import * from litex.soc.interconnect.csr import * diff --git a/gateware/s6rgmii.py b/gateware/s6rgmii.py index ac8a6ffb..0a1d96f7 100644 --- a/gateware/s6rgmii.py +++ b/gateware/s6rgmii.py @@ -1,11 +1,11 @@ # RGMII PHY for Spartan-6 from liteeth.common import * -from litex.gen.genlib.io import DDROutput -from litex.gen.genlib.misc import WaitTimer -from litex.gen.genlib.fsm import FSM, NextState +from migen.genlib.io import DDROutput +from migen.genlib.misc import WaitTimer +from migen.genlib.fsm import FSM, NextState -from litex.gen.genlib.resetsync import AsyncResetSynchronizer +from migen.genlib.resetsync import AsyncResetSynchronizer from liteeth.phy.common import * diff --git a/gateware/shared_uart.py b/gateware/shared_uart.py index fe2ab237..130188f1 100644 --- a/gateware/shared_uart.py +++ b/gateware/shared_uart.py @@ -5,7 +5,7 @@ import operator -from litex.gen import * +from migen import * from litex.soc.cores import uart diff --git a/gateware/spi_flash.py b/gateware/spi_flash.py index 02f3dcfb..b5e860aa 100644 --- a/gateware/spi_flash.py +++ b/gateware/spi_flash.py @@ -1,5 +1,5 @@ -from litex.gen import * -from litex.gen.genlib.misc import timeline +from migen import * +from migen.genlib.misc import timeline from litex.soc.interconnect import wishbone from litex.soc.interconnect.csr import AutoCSR, CSRStorage, CSRStatus diff --git a/gateware/streamer/core.py b/gateware/streamer/core.py index d61a1477..914f404c 100644 --- a/gateware/streamer/core.py +++ b/gateware/streamer/core.py @@ -1,7 +1,7 @@ import os -from litex.gen import * -from litex.gen.genlib.resetsync import AsyncResetSynchronizer +from migen import * +from migen.genlib.resetsync import AsyncResetSynchronizer from litex.soc.interconnect import stream class USBStreamer(Module): diff --git a/gateware/tofe.py b/gateware/tofe.py index 476b53d1..aef02a03 100644 --- a/gateware/tofe.py +++ b/gateware/tofe.py @@ -1,6 +1,6 @@ """Module for talking to TOFE boards.""" -from litex.gen.fhdl import * +from migen.fhdl import * from litex.soc.cores.gpio import GPIOIn, GPIOOut from litex.soc.interconnect.csr import * diff --git a/targets/arty/base.py b/targets/arty/base.py index 390385e0..f0346352 100755 --- a/targets/arty/base.py +++ b/targets/arty/base.py @@ -1,6 +1,6 @@ # Support for the Digilent Arty Board -from litex.gen import * -from litex.gen.genlib.resetsync import AsyncResetSynchronizer +from migen import * +from migen.genlib.resetsync import AsyncResetSynchronizer from litex.soc.integration.soc_core import mem_decoder from litex.soc.integration.soc_sdram import * diff --git a/targets/arty/ddr3.py b/targets/arty/ddr3.py index 83411197..9b63dc0a 100755 --- a/targets/arty/ddr3.py +++ b/targets/arty/ddr3.py @@ -1,5 +1,5 @@ -from litex.gen import * -from litex.gen.genlib.resetsync import AsyncResetSynchronizer +from migen import * +from migen.genlib.resetsync import AsyncResetSynchronizer from litex.soc.integration.soc_core import mem_decoder from litex.soc.integration.soc_sdram import * diff --git a/targets/atlys/base.py b/targets/atlys/base.py index 3c09475a..9dca3784 100644 --- a/targets/atlys/base.py +++ b/targets/atlys/base.py @@ -1,9 +1,9 @@ # Support for the Digilent Atlys board - digilentinc.com/atlys/ from fractions import Fraction -from litex.gen import * -from litex.gen.genlib.resetsync import AsyncResetSynchronizer -from litex.gen.genlib.misc import WaitTimer +from migen import * +from migen.genlib.resetsync import AsyncResetSynchronizer +from migen.genlib.misc import WaitTimer from litex.soc.integration.soc_sdram import * from litex.soc.integration.builder import * diff --git a/targets/atlys/hdmi2usb.py b/targets/atlys/hdmi2usb.py index 82a8f8da..b8db83b6 100644 --- a/targets/atlys/hdmi2usb.py +++ b/targets/atlys/hdmi2usb.py @@ -1,4 +1,4 @@ -from litex.gen.fhdl.decorators import ClockDomainsRenamer +from migen.fhdl.decorators import ClockDomainsRenamer from litex.soc.integration.soc_core import mem_decoder from litex.soc.interconnect import stream diff --git a/targets/common/cpu_interface.py b/targets/common/cpu_interface.py index 2a18b291..d013567b 100644 --- a/targets/common/cpu_interface.py +++ b/targets/common/cpu_interface.py @@ -1,4 +1,4 @@ -from litex.gen import * +from migen import * from litex.soc.interconnect.csr import CSRStatus diff --git a/targets/mimasv2/base.py b/targets/mimasv2/base.py index 18dcc454..9cafccb5 100644 --- a/targets/mimasv2/base.py +++ b/targets/mimasv2/base.py @@ -4,8 +4,8 @@ from fractions import Fraction -from litex.gen import * -from litex.gen.genlib.resetsync import AsyncResetSynchronizer +from migen import * +from migen.genlib.resetsync import AsyncResetSynchronizer from litex.soc.integration.soc_sdram import * from litex.soc.integration.builder import * diff --git a/targets/minispartan6/base.py b/targets/minispartan6/base.py index 3137d485..60b6b43a 100755 --- a/targets/minispartan6/base.py +++ b/targets/minispartan6/base.py @@ -1,9 +1,9 @@ # Support for the MiniSpartan6+ - https://www.scarabhardware.com/minispartan6/ from fractions import Fraction -from litex.gen import * -from litex.gen.genlib.io import CRG -from litex.gen.genlib.resetsync import AsyncResetSynchronizer +from migen import * +from migen.genlib.io import CRG +from migen.genlib.resetsync import AsyncResetSynchronizer from litex.soc.integration.soc_sdram import * from litex.soc.integration.builder import * diff --git a/targets/netv2/base.py b/targets/netv2/base.py index 15a54a86..417671dc 100755 --- a/targets/netv2/base.py +++ b/targets/netv2/base.py @@ -1,6 +1,6 @@ # Support for netv2 -from litex.gen import * -from litex.gen.genlib.resetsync import AsyncResetSynchronizer +from migen import * +from migen.genlib.resetsync import AsyncResetSynchronizer from litex.soc.integration.soc_core import mem_decoder from litex.soc.integration.soc_sdram import * diff --git a/targets/netv2/bridge_pcie.py b/targets/netv2/bridge_pcie.py index 3965d06a..50a8220e 100644 --- a/targets/netv2/bridge_pcie.py +++ b/targets/netv2/bridge_pcie.py @@ -1,7 +1,7 @@ -from litex.gen import * -from litex.gen.genlib.io import CRG -from litex.gen.genlib.resetsync import AsyncResetSynchronizer -from litex.gen.genlib.misc import timeline +from migen import * +from migen.genlib.io import CRG +from migen.genlib.resetsync import AsyncResetSynchronizer +from migen.genlib.misc import timeline from litex.soc.interconnect.csr import * from litex.soc.interconnect import wishbone diff --git a/targets/netv2/bridge_uart.py b/targets/netv2/bridge_uart.py index d1eaf3bd..43895822 100644 --- a/targets/netv2/bridge_uart.py +++ b/targets/netv2/bridge_uart.py @@ -1,6 +1,6 @@ -from litex.gen import * -from litex.gen.genlib.resetsync import AsyncResetSynchronizer -from litex.gen.fhdl.specials import Keep +from migen import * +from migen.genlib.resetsync import AsyncResetSynchronizer +from migen.fhdl.specials import Keep from litex.soc.integration.soc_core import mem_decoder from litex.soc.integration.soc_sdram import * diff --git a/targets/netv2/pcie.py b/targets/netv2/pcie.py index 7469c29c..fac7416e 100644 --- a/targets/netv2/pcie.py +++ b/targets/netv2/pcie.py @@ -1,4 +1,4 @@ -from litex.gen import * +from migen import * from litepcie.phy.s7pciephy import S7PCIEPHY from litepcie.core import LitePCIeEndpoint, LitePCIeMSI diff --git a/targets/nexys_video/base.py b/targets/nexys_video/base.py index 364160b1..f17e4dde 100755 --- a/targets/nexys_video/base.py +++ b/targets/nexys_video/base.py @@ -1,6 +1,6 @@ # Support for Digilent Nexys Video board -from litex.gen import * -from litex.gen.genlib.resetsync import AsyncResetSynchronizer +from migen import * +from migen.genlib.resetsync import AsyncResetSynchronizer from litex.soc.integration.soc_core import mem_decoder from litex.soc.integration.soc_sdram import * diff --git a/targets/nexys_video/bridge_net.py b/targets/nexys_video/bridge_net.py index 5c8855fd..a54032c1 100755 --- a/targets/nexys_video/bridge_net.py +++ b/targets/nexys_video/bridge_net.py @@ -3,7 +3,7 @@ from liteeth.core import LiteEthUDPIPCore from liteeth.frontend.etherbone import LiteEthEtherbone -from litex.gen.fhdl.specials import Keep +from migen.fhdl.specials import Keep from targets.nexys_video.base import BaseSoC diff --git a/targets/nexys_video/ddr3.py b/targets/nexys_video/ddr3.py index fd884bac..915846e1 100755 --- a/targets/nexys_video/ddr3.py +++ b/targets/nexys_video/ddr3.py @@ -1,5 +1,5 @@ -from litex.gen import * -from litex.gen.genlib.resetsync import AsyncResetSynchronizer +from migen import * +from migen.genlib.resetsync import AsyncResetSynchronizer from litex.soc.integration.soc_core import mem_decoder from litex.soc.integration.soc_sdram import * diff --git a/targets/opsis/axiom.py b/targets/opsis/axiom.py index 4794511a..db3ab512 100644 --- a/targets/opsis/axiom.py +++ b/targets/opsis/axiom.py @@ -1,4 +1,4 @@ -from litex.gen import * +from migen import * from litex.soc.cores.gpio import GPIOIn, GPIOOut from targets.utils import csr_map_update diff --git a/targets/opsis/base.py b/targets/opsis/base.py index bdece491..1ddf6913 100644 --- a/targets/opsis/base.py +++ b/targets/opsis/base.py @@ -1,9 +1,9 @@ # Support for Numato Opsis - https://opsis.hdmi2usb.tv from fractions import Fraction -from litex.gen import * -from litex.gen.genlib.resetsync import AsyncResetSynchronizer -from litex.gen.genlib.misc import WaitTimer +from migen import * +from migen.genlib.resetsync import AsyncResetSynchronizer +from migen.genlib.misc import WaitTimer from litex.soc.integration.soc_sdram import * from litex.soc.integration.builder import * diff --git a/targets/opsis/encoder.py b/targets/opsis/encoder.py index f86bd0eb..9ad69c9b 100644 --- a/targets/opsis/encoder.py +++ b/targets/opsis/encoder.py @@ -1,4 +1,4 @@ -from litex.gen.fhdl.decorators import ClockDomainsRenamer +from migen.fhdl.decorators import ClockDomainsRenamer from litex.soc.integration.soc_core import mem_decoder from litex.soc.interconnect import stream diff --git a/targets/opsis/hdmi2usb.py b/targets/opsis/hdmi2usb.py index 427666c9..00f94f2d 100644 --- a/targets/opsis/hdmi2usb.py +++ b/targets/opsis/hdmi2usb.py @@ -1,4 +1,4 @@ -from litex.gen.fhdl.decorators import ClockDomainsRenamer +from migen.fhdl.decorators import ClockDomainsRenamer from litex.soc.integration.soc_core import mem_decoder from litex.soc.interconnect import stream diff --git a/targets/pipistrello/base.py b/targets/pipistrello/base.py index dc005726..146100c7 100644 --- a/targets/pipistrello/base.py +++ b/targets/pipistrello/base.py @@ -1,8 +1,8 @@ # Support for the Pipistrello - http://pipistrello.saanlima.com/ from fractions import Fraction -from litex.gen import * -from litex.gen.genlib.resetsync import AsyncResetSynchronizer +from migen import * +from migen.genlib.resetsync import AsyncResetSynchronizer from litex.soc.integration.soc_sdram import * from litex.soc.integration.builder import * diff --git a/targets/sim/base.py b/targets/sim/base.py index 2ba1b742..1ee20703 100644 --- a/targets/sim/base.py +++ b/targets/sim/base.py @@ -1,6 +1,6 @@ # Support for simulation via verilator -from litex.gen import * -from litex.gen.genlib.io import CRG +from migen import * +from migen.genlib.io import CRG from litex.soc.integration.soc_sdram import * from litex.soc.integration.builder import * diff --git a/targets/sim/video.py b/targets/sim/video.py index f2e06d2f..fa92849f 100644 --- a/targets/sim/video.py +++ b/targets/sim/video.py @@ -1,4 +1,4 @@ -from litex.gen import * +from migen import * from litevideo.output.common import * from litevideo.output.core import VideoOutCore From 66c61d9bf6ded17256754c705edb496f2981684f Mon Sep 17 00:00:00 2001 From: "William D. Jones" Date: Wed, 28 Feb 2018 16:42:14 -0500 Subject: [PATCH 153/219] Add migen submodule and corresponding script support. * Migen needs to be installed first- litescope installation fails otherwise. --- .gitmodules | 3 +++ Makefile | 2 +- scripts/settings.sh | 1 + third_party/migen | 1 + 4 files changed, 6 insertions(+), 1 deletion(-) create mode 160000 third_party/migen diff --git a/.gitmodules b/.gitmodules index f2a04704..c124265d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -28,3 +28,6 @@ [submodule "third_party/flash_proxies"] path = third_party/flash_proxies url = https://github.com/jordens/bscan_spi_bitstreams +[submodule "third_party/migen"] + path = third_party/migen + url = https://github.com/m-labs/migen.git diff --git a/Makefile b/Makefile index 9ac314bb..26145226 100644 --- a/Makefile +++ b/Makefile @@ -219,7 +219,7 @@ image-flash-py: image # This is indicated by a "git submodule status" that does not start with # a space (" "). # -LITEX_SUBMODULES=litex litedram liteeth litepcie litesata litescope liteusb litevideo +LITEX_SUBMODULES=migen litex litedram liteeth litepcie litesata litescope liteusb litevideo litex-submodules: $(addsuffix /.git,$(addprefix third_party/,$(LITEX_SUBMODULES))) @if git submodule status --recursive | grep "^[^ ]" >/dev/null; then \ echo ""; \ diff --git a/scripts/settings.sh b/scripts/settings.sh index 3ba920e6..29f51761 100644 --- a/scripts/settings.sh +++ b/scripts/settings.sh @@ -17,6 +17,7 @@ OPENOCD_VERSION=0.10.0 # lite modules LITE_REPOS=" + migen litex litedram liteeth diff --git a/third_party/migen b/third_party/migen new file mode 160000 index 00000000..27beffe7 --- /dev/null +++ b/third_party/migen @@ -0,0 +1 @@ +Subproject commit 27beffe7aa2ae21faad9ad06db5983e87b1e8f37 From 53d484fd83c8c786fbdbfe69c111c3dbb33aad6e Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sun, 11 Mar 2018 11:01:07 -0700 Subject: [PATCH 154/219] Updating submodules. * litevideo changed from 18b88df to 7b755d5 * 7b755d5 - clocking: Fixing clocking arguments for S6Clocking. Full submodule status -- f56f329ed23a25d002352dedba1e8f092a47286f edid-decode (heads/master) a628956da7dc794e6e3c95b31ff9ce3af58bc763 flash_proxies (remotes/origin/HEAD) 48bc3cb15d17202a19e621acd83d2733190285b2 litedram (heads/master-4-g48bc3cb) 33afda74f77f7bafa3e4e19641b9043320c47e4e liteeth (remotes/origin/HEAD) 6b147e1d120a3a062cf2c85e950d358b39edb8eb litepcie (heads/master-10-g6b147e1) a559afb2c53932f29ecc4cec8aa394d1004377c1 litesata (remotes/origin/HEAD) 9d5e605df3e5f1d54609acc5a2f10764045127e9 litescope (remotes/origin/HEAD) 23d6a6840d4276f8d1a7f31bafb8d0aaaecff6d1 liteusb (remotes/origin/HEAD) 7b755d596315e359793ccfc7be802a7f0286d96b litevideo (heads/master) 3e7cc2554b7dcc578ca86fd881d3523625b888f8 litex (heads/master-26-g3e7cc255) 27beffe7aa2ae21faad9ad06db5983e87b1e8f37 migen (0.6.dev-91-g27beffe) --- third_party/litevideo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/litevideo b/third_party/litevideo index 18b88dfe..7b755d59 160000 --- a/third_party/litevideo +++ b/third_party/litevideo @@ -1 +1 @@ -Subproject commit 18b88dfee6bf6f4ab55d196747ca00c6c84c2ef2 +Subproject commit 7b755d596315e359793ccfc7be802a7f0286d96b From e34d1f082ea869e43939d3593addb742c8899b23 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Mon, 12 Mar 2018 10:45:08 -0700 Subject: [PATCH 155/219] Updating submodules. * edid-decode changed from f56f329 to dcc8b83 * dcc8b83 - makefile: also honor LDFLAGS * litedram changed from 48bc3cb to 45da365 * 45da365 - phy/kusddrphy: add odelaye3 on all outputs (to have identical delays on all outputs before software dq/dqs delay configuration) * f905fda - phy/kusddrphy: use IOBUFDSE3 on dqs to be able to apply ODT=RTT_40 constraint * e6a99d9 - phy/kusddrphy: revert dqs preamble/postamble since not working for continous transfer, will need a proper implementation * 66d99a3 - phy/kusddrphy: add dqs preamble/postamble instead of always toggling on oe_dqs * da4651f - phy/kusddrphy: add comment * 0d7a7a9 - phy/kusddrphy: store dqs taps init value in csr at startup * b885f58 - phy/kusddrphy: operate delays in time mode (to be able to specify 500ps delay on dqs) and add workaround to allow software to get number of taps for 500ps at init. * 459060e - phy/kusddrphy: add en_vtc control * litepcie changed from 6b147e1 to 8bc328f * 8bc328f - frontend/dma: set loop_count to 0 for the first loop, generate irq when descriptor is done * 35e133e - frontend/dma: ensure we finish current TLP when we receive last data from stream * litevideo changed from 7b755d5 to 9b4169d * 9b4169d - input/clocking/S7Clocking: fix case when split_clocking=False * litex changed from 3e7cc255 to b7f7c8d1 * b7f7c8d1 - build/xilinx/common/XilinxDDROutputImplS6: DDR_ALIGNMENT="C0" requires SRTYPE to be "ASYNC" * 4324c6f6 - bios/sdram: update kuddrphy initialization procedure * 90dcd45f - soc/software/main: go to new line at startup * 6706b241 - software/bios/main: add missing space * 2a50a802 - soc/integration/soc_core: improve error message for missing csrs * c02b127e - Merge pull request #68 from mithro/improve-csr-missing-error-message * 5ef34500 - Improving error message when csr name is not found. * migen changed from 0.6.dev-91-g27beffe to 0.6.dev-99-g881741b * 881741b - build/xilinx/common/XilinxDDROutputImplS6: DDR_ALIGNMENT="C0" requires SRTYPE to be "ASYNC" * 1f82faa - ku: fix IDDRE1 clocking * 96f2fa6 - sayma_amc/ddram: use same io constraints than what is used in MIG * 90e4101 - fifo: make din/dout reset_less * 7d3afa4 - kasli: merge v1.0 and v1.1 * 72f43f7 - kasli_v1_1: add platform * 9812a07 - kasli: add misc vivado properties ans speed up load * 8fcd67a - sayma_amc: take bitstream options from artiq, speed up load Full submodule status -- dcc8b8346ee4bb541c0637f3cb38349296231616 edid-decode (remotes/origin/HEAD) a628956da7dc794e6e3c95b31ff9ce3af58bc763 flash_proxies (remotes/origin/HEAD) 45da365b7f3bdfccb759038d0b76b7c62c1233e1 litedram (remotes/origin/HEAD) 33afda74f77f7bafa3e4e19641b9043320c47e4e liteeth (remotes/origin/HEAD) 8bc328f723c5923835c16671ac764a5060f79ba2 litepcie (remotes/origin/HEAD) a559afb2c53932f29ecc4cec8aa394d1004377c1 litesata (remotes/origin/HEAD) 9d5e605df3e5f1d54609acc5a2f10764045127e9 litescope (remotes/origin/HEAD) 23d6a6840d4276f8d1a7f31bafb8d0aaaecff6d1 liteusb (remotes/origin/HEAD) 9b4169d5d1e2c400a86ea0cbdb800730d84dc40b litevideo (remotes/origin/HEAD) b7f7c8d159a53be0dbb713b86c658c3b79e023cb litex (remotes/origin/HEAD) 881741be6c1920e21821168298ed2bf13c3e651b migen (0.6.dev-99-g881741b) --- third_party/edid-decode | 2 +- third_party/litedram | 2 +- third_party/litepcie | 2 +- third_party/litevideo | 2 +- third_party/litex | 2 +- third_party/migen | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/third_party/edid-decode b/third_party/edid-decode index f56f329e..dcc8b834 160000 --- a/third_party/edid-decode +++ b/third_party/edid-decode @@ -1 +1 @@ -Subproject commit f56f329ed23a25d002352dedba1e8f092a47286f +Subproject commit dcc8b8346ee4bb541c0637f3cb38349296231616 diff --git a/third_party/litedram b/third_party/litedram index 48bc3cb1..45da365b 160000 --- a/third_party/litedram +++ b/third_party/litedram @@ -1 +1 @@ -Subproject commit 48bc3cb15d17202a19e621acd83d2733190285b2 +Subproject commit 45da365b7f3bdfccb759038d0b76b7c62c1233e1 diff --git a/third_party/litepcie b/third_party/litepcie index 6b147e1d..8bc328f7 160000 --- a/third_party/litepcie +++ b/third_party/litepcie @@ -1 +1 @@ -Subproject commit 6b147e1d120a3a062cf2c85e950d358b39edb8eb +Subproject commit 8bc328f723c5923835c16671ac764a5060f79ba2 diff --git a/third_party/litevideo b/third_party/litevideo index 7b755d59..9b4169d5 160000 --- a/third_party/litevideo +++ b/third_party/litevideo @@ -1 +1 @@ -Subproject commit 7b755d596315e359793ccfc7be802a7f0286d96b +Subproject commit 9b4169d5d1e2c400a86ea0cbdb800730d84dc40b diff --git a/third_party/litex b/third_party/litex index 3e7cc255..b7f7c8d1 160000 --- a/third_party/litex +++ b/third_party/litex @@ -1 +1 @@ -Subproject commit 3e7cc2554b7dcc578ca86fd881d3523625b888f8 +Subproject commit b7f7c8d159a53be0dbb713b86c658c3b79e023cb diff --git a/third_party/migen b/third_party/migen index 27beffe7..881741be 160000 --- a/third_party/migen +++ b/third_party/migen @@ -1 +1 @@ -Subproject commit 27beffe7aa2ae21faad9ad06db5983e87b1e8f37 +Subproject commit 881741be6c1920e21821168298ed2bf13c3e651b From 0c523cf3d5dece4b6c9b395fe2713ac65ee3e0dc Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Mon, 12 Mar 2018 14:27:30 -0700 Subject: [PATCH 156/219] travis: Disable netv2 target for now. --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a90222e4..36adc797 100644 --- a/.travis.yml +++ b/.travis.yml @@ -113,8 +113,8 @@ jobs: - stage: Targets - Video env: C=lm32 P=atlys T="video" - - stage: Targets - Video - env: C=lm32 P=netv2 T="video" + #- stage: Targets - Video + # env: C=lm32 P=netv2 T="video" - stage: Targets - Video env: C=lm32 P=nexys_video T="video" From 8e473f3d58b5edde935b95a2e4221237b27371a1 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Wed, 14 Mar 2018 14:13:40 -0700 Subject: [PATCH 157/219] travis: Refactor the download-prebuilt script a bit. Should fix #417. --- .travis/download-prebuilt.sh | 71 ++++++++++++++++++++++++------------ 1 file changed, 48 insertions(+), 23 deletions(-) diff --git a/.travis/download-prebuilt.sh b/.travis/download-prebuilt.sh index f4650718..73a3d4a9 100755 --- a/.travis/download-prebuilt.sh +++ b/.travis/download-prebuilt.sh @@ -1,33 +1,63 @@ #!/bin/bash -# Clone prebuilt repo to copy results into -if [ ! -z "$TRAVIS_PULL_REQUEST" -a "$TRAVIS_PULL_REQUEST" != "false" ]; then - # Don't do prebuilt for a pull request. - echo "" - echo "" - echo "" - echo "- Pull request, so no prebuilt pushing." +# Script to clone prebuilt repo to copy results into. + +if [ ! -z "$TRAVIS" -a "$TRAVIS" = "true" ]; then + # Don't clone prebuilt on a pull request. + if [ ! -z "$TRAVIS_PULL_REQUEST" -a "$TRAVIS_PULL_REQUEST" != "false" ]; then + echo "" + echo "" + echo "" + echo "- Pull request, so no prebuilt pushing." + + # Don't clone if no github authentication + elif [ -z "$GH_TOKEN" ]; then + echo "" + echo "" + echo "" + echo "- No Github token (GH_TOKEN) so unable to push built files" + + # Don't clone if we don't know which branch we are on + elif [ -z "$TRAVIS_BRANCH" ]; then + echo "" + echo "" + echo "" + echo "- No branch name (\$TRAVIS_BRANCH), unable to copy built files" + + # Don't clone if we don't know which repo we are using + elif [ -z "$TRAVIS_REPO_SLUG" ]; then + echo "" + echo "" + echo "" + echo "- No repo slug name (\$TRAVIS_REPO_SLUG), unable to copy built files" + + else + # Look at repo we are running in to determine where to try pushing to if in a fork + PREBUILT_REPO=HDMI2USB-firmware-prebuilt + PREBUILT_REPO_OWNER=$(echo $TRAVIS_REPO_SLUG|awk -F'/' '{print $1}') + fi +fi + - # Only if run by travis display error -elif [ -z "$GH_TOKEN" -a -z "$TRAVIS_BUILD_NUMBER" ]; then +if [ -z "$PREBUILT_DIR" ]; then echo "" echo "" echo "" - echo "- No Github token so unable to copy built files" -elif [ -z "$TRAVIS_BRANCH" ]; then + echo "- No PREBUILT_DIR value found." + +elif [ -z "$PREBUILT_REPO" ]; then echo "" echo "" echo "" - echo "- No branch name (\$TRAVIS_BRANCH), unable to copy built files" -elif [ -z "$TRAVIS_REPO_SLUG" ]; then + echo "- No PREBUILT_REPO value found." + +elif [ -z "$PREBUILT_REPO_OWNER" ]; then echo "" echo "" echo "" - echo "- No repo slug name (\$TRAVIS_REPO_SLUG), unable to copy built files" -elif [ ! -z "$PREBUILT_DIR" ]; then - # Look at repo we are running in to determine where to try pushing to if in a fork - PREBUILT_REPO=HDMI2USB-firmware-prebuilt - PREBUILT_REPO_OWNER=$(echo $TRAVIS_REPO_SLUG|awk -F'/' '{print $1}') + echo "- No PREBUILT_REPO_OWNER value found." + +else echo "" echo "" echo "" @@ -54,9 +84,4 @@ elif [ ! -z "$PREBUILT_DIR" ]; then ls -l $PREBUILT_DIR/archive ) echo "=============================================" -else - echo "" - echo "" - echo "" - echo "- No PREBUILT_DIR value found." fi From 025a4c257078145e41837986572cb0bde1372921 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Fri, 16 Mar 2018 21:10:04 -0700 Subject: [PATCH 158/219] scripts: Setup better git config for submodules. --- scripts/download-env.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/download-env.sh b/scripts/download-env.sh index fe9e512f..fe039190 100755 --- a/scripts/download-env.sh +++ b/scripts/download-env.sh @@ -322,7 +322,18 @@ echo "Installing HDMI2USB-mode-switch (flashing and config tool)" pip install --upgrade git+https://github.com/timvideos/HDMI2USB-mode-switch.git check_import_version hdmi2usb.modeswitch $HDMI2USB_MODESWITCH_VERSION -# git submodules +# git commands +echo "" +echo "Updating git config" +echo "-----------------------" +( + git config status.submodulesummary 1 + git config push.recurseSubmodules check + git config diff.submodule = log + git config checkout.recurseSubmodules 1 + git config alias.sdiff '!'"git diff && git submodule foreach 'git diff'" + git config alias.spush 'push --recurse-submodules=on-demand' +) echo "" echo "Updating git submodules" echo "-----------------------" From 37161eb9703d0ec073ed12a0c5ad436631fb16dd Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Fri, 16 Mar 2018 21:13:05 -0700 Subject: [PATCH 159/219] travis: Small fix to add-local-submodule script. --- .travis/add-local-submodule.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.travis/add-local-submodule.sh b/.travis/add-local-submodule.sh index ed035537..1d839b36 100755 --- a/.travis/add-local-submodule.sh +++ b/.travis/add-local-submodule.sh @@ -17,7 +17,7 @@ USER_SLUG="$1" SUBMODULE="$2" REV=$(git rev-parse HEAD) -echo "Submodule $SUBMODULE @ $REV" +echo "Submodule $SUBMODULE" # Get the pull request info REQUEST_USER="$(echo $USER_SLUG | perl -pe 's|^([^/]*)/.*|\1|')" @@ -49,13 +49,15 @@ USER_URL="git://github.com/$REQUEST_USER/$ORIGIN_REPO.git" echo "Users repo would be '$USER_URL'" +# If submodule doesn't exist, clone directly from the users repo if [ ! -e $SUBMODULE/.git ]; then - echo "Successfully cloned from user repo '$USER_URL'" + echo "Will clone '$ORIGIN_REPO' from user repo '$USER_URL'" $(which git) clone $USER_URL $SUBMODULE --origin user || true if [ -d $SUBMODULE/.git ]; then echo "Successfully cloned from user repo '$ORIGIN_REPO'" fi fi +# If the submodule does exist, add a new remote. if [ -e $SUBMODULE/.git ]; then ( cd $SUBMODULE @@ -68,6 +70,7 @@ if [ -e $SUBMODULE/.git ]; then ) fi +# Checkout the submodule at the right revision git submodule update --init $SUBMODULE # Call ourselves recursively. From df46dcefd5b50e51c366c203a94f7071c64e9ff8 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Fri, 16 Mar 2018 21:40:54 -0700 Subject: [PATCH 160/219] travis: Prevent git from asking for passwords. --- .travis/fixup-git.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.travis/fixup-git.sh b/.travis/fixup-git.sh index f03fbdfe..31684c44 100755 --- a/.travis/fixup-git.sh +++ b/.travis/fixup-git.sh @@ -2,6 +2,18 @@ set -e +# Disable prompting for passwords - works with git version 2.3 or above +export GIT_TERMINAL_PROMPT=0 +# Harder core version of disabling the username/password prompt. +GIT_CREDENTIAL_HELPER=$PWD/.git/git-credential-stop +cat > $GIT_CREDENTIAL_HELPER < Date: Fri, 16 Mar 2018 21:49:55 -0700 Subject: [PATCH 161/219] travis: Rework the add-local-submodule script a bit. --- .travis/add-local-submodule.sh | 43 +++++++++++++++++----------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/.travis/add-local-submodule.sh b/.travis/add-local-submodule.sh index 1d839b36..0ebaeb61 100755 --- a/.travis/add-local-submodule.sh +++ b/.travis/add-local-submodule.sh @@ -27,16 +27,16 @@ echo "Request user is '$REQUEST_USER'". echo "Request repo is '$REQUEST_REPO'". # Get current origin from git -ORIGIN="$(git config -f .gitmodules submodule.$SUBMODULE.url)" -#ORIGIN="$(git remote get-url origin)" -if echo $ORIGIN | grep -q "github.com"; then +ORIGIN_URL="$(git config -f .gitmodules submodule.$SUBMODULE.url)" +#ORIGIN_URL="$(git remote get-url origin)" +if echo $ORIGIN_URL | grep -q "github.com"; then echo "Found github" else echo "Did not find github, skipping" exit 0 fi -ORIGIN_SLUG=$(echo $ORIGIN | perl -pe 's|.*github.com/(.*?)(.git)?$|\1|') +ORIGIN_SLUG=$(echo $ORIGIN_URL | perl -pe 's|.*github.com/(.*?)(.git)?$|\1|') echo "Origin slug is '$ORIGIN_SLUG'" ORIGIN_USER="$(echo $ORIGIN_SLUG | perl -pe 's|^([^/]*)/.*|\1|')" @@ -47,28 +47,29 @@ echo "Origin repo is '$ORIGIN_REPO'" USER_URL="git://github.com/$REQUEST_USER/$ORIGIN_REPO.git" -echo "Users repo would be '$USER_URL'" +# Check if the user's repo exists +echo -n "User's repo would be '$USER_URL' " +if git ls-remote --exit-code --heads "$USER_URL" > /dev/null; then + echo "which exists!" +else + echo "which does *not* exist!" + USER_URL="$ORIGIN_URL" +fi # If submodule doesn't exist, clone directly from the users repo if [ ! -e $SUBMODULE/.git ]; then - echo "Will clone '$ORIGIN_REPO' from user repo '$USER_URL'" - $(which git) clone $USER_URL $SUBMODULE --origin user || true - if [ -d $SUBMODULE/.git ]; then - echo "Successfully cloned from user repo '$ORIGIN_REPO'" - fi + echo "Cloning '$ORIGIN_REPO' from repo '$USER_URL'" + $(which git) clone $USER_URL $SUBMODULE --origin user fi # If the submodule does exist, add a new remote. -if [ -e $SUBMODULE/.git ]; then - ( - cd $SUBMODULE - git remote add user $USER_URL || git remote set-url user $USER_URL - $(which git) fetch user || git remote rm user - - git rm origin || true - git remote add origin $ORIGIN || git remote set-url origin $ORIGIN - $(which git) fetch origin - ) -fi +( + cd $SUBMODULE + git remote add user $USER_URL || git remote set-url user $USER_URL + $(which git) fetch user + + git remote add origin $ORIGIN_URL || git remote set-url origin $ORIGIN_URL + $(which git) fetch origin +) # Checkout the submodule at the right revision git submodule update --init $SUBMODULE From 4bc0253515fc903710bbe459f3734beb81e4bc25 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Fri, 16 Mar 2018 21:52:22 -0700 Subject: [PATCH 162/219] travis: Make the repo check quieter. --- .travis/add-local-submodule.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.travis/add-local-submodule.sh b/.travis/add-local-submodule.sh index 0ebaeb61..404623e7 100755 --- a/.travis/add-local-submodule.sh +++ b/.travis/add-local-submodule.sh @@ -49,7 +49,7 @@ USER_URL="git://github.com/$REQUEST_USER/$ORIGIN_REPO.git" # Check if the user's repo exists echo -n "User's repo would be '$USER_URL' " -if git ls-remote --exit-code --heads "$USER_URL" > /dev/null; then +if git ls-remote --exit-code --heads "$USER_URL" > /dev/null 2>&1; then echo "which exists!" else echo "which does *not* exist!" @@ -64,10 +64,12 @@ fi # If the submodule does exist, add a new remote. ( cd $SUBMODULE - git remote add user $USER_URL || git remote set-url user $USER_URL + git remote rm user >/dev/null 2>&1 || true + git remote add user $USER_URL $(which git) fetch user - git remote add origin $ORIGIN_URL || git remote set-url origin $ORIGIN_URL + git remote rm origin >/dev/null 2>&1 || true + git remote add origin $ORIGIN_URL $(which git) fetch origin ) From 53b29203e61bd4e1e2387379592d055f1d24d971 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Fri, 16 Mar 2018 22:01:07 -0700 Subject: [PATCH 163/219] travis: Output submodule status information. --- .travis/fixup-git.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis/fixup-git.sh b/.travis/fixup-git.sh index 31684c44..efa91a23 100755 --- a/.travis/fixup-git.sh +++ b/.travis/fixup-git.sh @@ -88,7 +88,7 @@ if [ z"$TRAVIS_REPO_SLUG" != z ]; then fi echo "---------------------------------------------" -git show-ref +git submodule status --recursive echo "---------------------------------------------" if [ z"$TRAVIS_BRANCH" != z ]; then From 7333514505ce81bb2c674d00f0a2031a8d561591 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Fri, 16 Mar 2018 22:02:13 -0700 Subject: [PATCH 164/219] scripts: Fixing syntax of git config command. --- scripts/download-env.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/download-env.sh b/scripts/download-env.sh index fe039190..f18c5e3e 100755 --- a/scripts/download-env.sh +++ b/scripts/download-env.sh @@ -329,7 +329,7 @@ echo "-----------------------" ( git config status.submodulesummary 1 git config push.recurseSubmodules check - git config diff.submodule = log + git config diff.submodule log git config checkout.recurseSubmodules 1 git config alias.sdiff '!'"git diff && git submodule foreach 'git diff'" git config alias.spush 'push --recurse-submodules=on-demand' From 20d11fdd8acf80677deb7e2894f20998048dfb24 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Fri, 16 Mar 2018 22:06:25 -0700 Subject: [PATCH 165/219] travis: More small changes to add-local-submodule Use git command directly rather than $(which git). Remove user repo if it is the same as origin. --- .travis/add-local-submodule.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.travis/add-local-submodule.sh b/.travis/add-local-submodule.sh index 404623e7..906057ee 100755 --- a/.travis/add-local-submodule.sh +++ b/.travis/add-local-submodule.sh @@ -59,18 +59,21 @@ fi # If submodule doesn't exist, clone directly from the users repo if [ ! -e $SUBMODULE/.git ]; then echo "Cloning '$ORIGIN_REPO' from repo '$USER_URL'" - $(which git) clone $USER_URL $SUBMODULE --origin user + git clone $USER_URL $SUBMODULE --origin user fi # If the submodule does exist, add a new remote. ( cd $SUBMODULE + git remote rm user >/dev/null 2>&1 || true - git remote add user $USER_URL - $(which git) fetch user + if [ "$USER_URL" != "$ORIGIN_URL" ]; then + git remote add user $USER_URL + git fetch user + fi git remote rm origin >/dev/null 2>&1 || true git remote add origin $ORIGIN_URL - $(which git) fetch origin + git fetch origin ) # Checkout the submodule at the right revision From 6a7463a8a9df5c089dd3ddb679b2587a2807ee23 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sat, 17 Mar 2018 15:42:21 -0700 Subject: [PATCH 166/219] scripts: Change the check for Xilinx toolchains. --- scripts/enter-env.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/enter-env.sh b/scripts/enter-env.sh index b2d74023..1ef8c3da 100755 --- a/scripts/enter-env.sh +++ b/scripts/enter-env.sh @@ -91,10 +91,13 @@ if [ ! -d $BUILD_DIR ]; then return 1 fi -# Xilinx ISE +SETTINGS_ISE='/opt/Xilinx/*/ISE_DS/settings64.sh' +SETTINGS_VIVADO='/opt/Xilinx/Vivado/*/settings64.sh' + if [ -z "$XILINX_DIR" ]; then LOCAL_XILINX_DIR=$BUILD_DIR/Xilinx - if [ -f "$LOCAL_XILINX_DIR/opt/Xilinx/14.7/ISE_DS/ISE/bin/lin64/xreport" ]; then + + if [ -f "$LOCAL_XILINX_DIR/$SETTINGS_ISE" -o -f "$LOCAL_XILINX_DIR/$SETTINGS_VIVADO" ]; then # Reserved MAC address from documentation block, see # http://www.iana.org/assignments/ethernet-numbers/ethernet-numbers.xhtml export XILINXD_LICENSE_FILE=$LOCAL_XILINX_DIR @@ -110,6 +113,12 @@ if [ ! -z "$XILINX_DIR" ]; then export MISOC_EXTRA_CMDLINE="-Ob toolchain_path $XILINX_DIR/opt/Xilinx/" fi echo " Xilinx directory is: $XILINX_DIR/opt/Xilinx/" +if [ -f $XILINX_DIR/$SETTINGS_ISE ]; then + echo " - Xilinx ISE toolchain found!" +fi +if [ -f $XILINX_DIR/$SETTINGS_VIVADO ]; then + echo " - Xilinx Vivado toolchain found!" +fi function check_exists { TOOL=$1 From 449b0cf551d77c7cdfa82ac56ffa97b15dcce7f7 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sat, 17 Mar 2018 15:46:41 -0700 Subject: [PATCH 167/219] travis: Move Xilinx toolchain check from build.sh into enter-env.sh --- .travis/build.sh | 10 ---------- scripts/enter-env.sh | 11 +++++++++++ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.travis/build.sh b/.travis/build.sh index 3ffe7aab..f08e85f1 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -11,16 +11,6 @@ elif [ -x /usr/bin/timelimit ]; then export GATEWARE_TIMEOUT_CMD="/usr/bin/timelimit -T $GATEWARE_KILLOUT -t $GATEWARE_TIMEOUT" fi -# Check for the Xilinx toolchain being downloaded -XILINX_DOWNLOAD_DIR=build/Xilinx/opt/Xilinx -ls -l . -ls -l $XILINX_DOWNLOAD_DIR -if [ -d $XILINX_DOWNLOAD_DIR ]; then - export HAVE_XILINX_TOOLCHAIN=1 -else - export HAVE_XILINX_TOOLCHAIN=0 -fi - GIT_REVISION=$TRAVIS_BRANCH/$(git describe) ORIG_COMMITTER_NAME=$(git log -1 --pretty=%an) ORIG_COMMITTER_EMAIL=$(git log -1 --pretty=%ae) diff --git a/scripts/enter-env.sh b/scripts/enter-env.sh index 1ef8c3da..5be095aa 100755 --- a/scripts/enter-env.sh +++ b/scripts/enter-env.sh @@ -115,9 +115,20 @@ fi echo " Xilinx directory is: $XILINX_DIR/opt/Xilinx/" if [ -f $XILINX_DIR/$SETTINGS_ISE ]; then echo " - Xilinx ISE toolchain found!" + HAVE_XILINX_ISE=1 +else + HAVE_XILINX_ISE=0 fi if [ -f $XILINX_DIR/$SETTINGS_VIVADO ]; then echo " - Xilinx Vivado toolchain found!" + HAVE_XILINX_VIVADO=1 +else + HAVE_XILINX_VIVADO=0 +fi +if [ $HAVE_XILINX_ISE -eq 1 -o $HAVE_XILINX_VIVADO -eq 1 ]; then + HAVE_XILINX_TOOLCHAIN=1 +else + HAVE_XILINX_TOOLCHAIN=0 fi function check_exists { From a86e021763fb61192b2af0c44512a3e6cfb5675e Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sat, 17 Mar 2018 16:04:26 -0700 Subject: [PATCH 168/219] scripts: Rework Xilinx toolchain checking a little. --- scripts/download-env.sh | 78 +++++++++++++++++++++++++++++++------ scripts/enter-env.sh | 85 +++++++++++++++++++++++------------------ 2 files changed, 113 insertions(+), 50 deletions(-) diff --git a/scripts/download-env.sh b/scripts/download-env.sh index f18c5e3e..3e9e2bde 100755 --- a/scripts/download-env.sh +++ b/scripts/download-env.sh @@ -63,7 +63,8 @@ if [ ! -z "$XILINX_PASSPHRASE" ]; then echo $XILINX_PASSPHRASE >> $XILINX_PASSPHRASE_FILE # Need gpg to do the unencryption - XILINX_DIR=$BUILD_DIR/Xilinx + export XILINX_DIR=$BUILD_DIR/Xilinx + export LIKELY_XILINX_LICENSE_DIR=$XILINX_DIR if [ ! -d "$XILINX_DIR" -o ! -d "$XILINX_DIR/opt" ]; then ( cd $BUILD_DIR @@ -104,20 +105,73 @@ if [ ! -z "$XILINX_PASSPHRASE" ]; then #make ) fi - export MISOC_EXTRA_CMDLINE="-Ob toolchain_path $XILINX_DIR/opt/Xilinx/" - # Reserved MAC address from documentation block, see - # http://www.iana.org/assignments/ethernet-numbers/ethernet-numbers.xhtml - export XILINXD_LICENSE_FILE=$XILINX_DIR - export MACADDR=90:10:00:00:00:01 - #export LD_PRELOAD=$XILINX_DIR/impersonate_macaddress/impersonate_macaddress.so - #ls -l $LD_PRELOAD - rm $XILINX_PASSPHRASE_FILE trap - EXIT -elif [ -z "$XILINX_DIR" ]; then - XILINX_DIR=/ fi +if [ -z "$LIKELY_XILINX_LICENSE_DIR" ]; then + LIKELY_XILINX_LICENSE_DIR="$HOME/.Xilinx" +fi + +XILINX_SETTINGS_ISE='/opt/Xilinx/*/ISE_DS/settings64.sh' +XILINX_SETTINGS_VIVADO='/opt/Xilinx/Vivado/*/settings64.sh' + +if [ -z "$XILINX_DIR" ]; then + LOCAL_XILINX_DIR=$BUILD_DIR/Xilinx + if [ -d "$LOCAL_XILINX_DIR/opt/Xilinx/" ]; then + # Reserved MAC address from documentation block, see + # http://www.iana.org/assignments/ethernet-numbers/ethernet-numbers.xhtml + export LIKELY_XILINX_LICENSE_DIR=$LOCAL_XILINX_DIR + export MACADDR=90:10:00:00:00:01 + #export LD_PRELOAD=$XILINX_DIR/impersonate_macaddress/impersonate_macaddress.so + #ls -l $LD_PRELOAD + export XILINX_DIR=$LOCAL_XILINX_DIR + fi +fi +if [ -z "$LIKELY_XILINX_LICENSE_DIR" ]; then + LIKELY_XILINX_LICENSE_DIR="$HOME/.Xilinx" +fi + echo " Xilinx directory is: $XILINX_DIR/opt/Xilinx/" +XILINX_SETTINGS_ISE=($XILINX_DIR/$XILINX_SETTINGS_ISE) +if [ ${#XILINX_SETTINGS_ISE[@]} -gt 0 ]; then + echo -n " - Xilinx ISE toolchain found!" + if [ ${#XILINX_SETTINGS_ISE[@]} -gt 1 ]; then + echo -n " (${#XILINX_SETTINGS_ISE[@]} versions)" + fi + echo "" + export HAVE_XILINX_ISE=1 +else + export HAVE_XILINX_ISE=0 +fi +XILINX_SETTINGS_VIVADO=($XILINX_DIR/$XILINX_SETTINGS_VIVADO) +if [ ${#XILINX_SETTINGS_VIVADO[@]} -gt 0 ]; then + echo -n " - Xilinx Vivado toolchain found!" + if [ ${#XILINX_SETTINGS_VIVADO[@]} -gt 1 ]; then + echo -n " (${#XILINX_SETTINGS_VIVADO[@]} versions)" + fi + echo "" + export HAVE_XILINX_VIVADO=1 +else + export HAVE_XILINX_VIVADO=0 +fi +if [ $HAVE_XILINX_ISE -eq 1 -o $HAVE_XILINX_VIVADO -eq 1 ]; then + export HAVE_XILINX_TOOLCHAIN=1 +else + export HAVE_XILINX_TOOLCHAIN=0 +fi +if [ $HAVE_XILINX_TOOLCHAIN -eq 1 ]; then + export MISOC_EXTRA_CMDLINE="-Ob toolchain_path $XILINX_DIR/opt/Xilinx/" +fi + +# Detect a likely lack of license early, but just warn if it's missing +# just in case they've set it up elsewhere. +if [ ! -e $LIKELY_XILINX_LICENSE_DIR/Xilinx.lic ]; then + echo "(WARNING) Please ensure you have installed Xilinx and have a license." + echo "(WARNING) Copy your Xilinx license to Xilinx.lic in $LIKELY_XILINX_LICENSE_DIR to suppress this warning." +else + echo " Xilinx license in: $LIKELY_XILINX_LICENSE_DIR" + XILINXD_LICENSE_FILE=$LIKELY_XILINX_LICENSE_DIR +fi function check_exists { TOOL=$1 @@ -342,7 +396,7 @@ echo "-----------------------" git submodule update --recursive --init git submodule foreach \ git submodule update --recursive --init - git status + git submodule status --recursive ) # lite diff --git a/scripts/enter-env.sh b/scripts/enter-env.sh index 5be095aa..4f7a789a 100755 --- a/scripts/enter-env.sh +++ b/scripts/enter-env.sh @@ -12,7 +12,6 @@ CALLED=$_ SETUP_SRC="$(realpath ${BASH_SOURCE[0]})" SETUP_DIR="$(dirname "${SETUP_SRC}")" TOP_DIR="$(realpath "${SETUP_DIR}/..")" -LIKELY_XILINX_LICENSE_LOCATION="$HOME/.Xilinx/Xilinx.lic" if [ $SOURCED = 0 ]; then echo "You must source this script, rather than try and run it." @@ -65,25 +64,12 @@ else return 1 fi -# Detect a likely lack of license early, but just warn if it's missing -# just in case they've set it up elsewhere. -license_found=0 -if [ ! -e $LIKELY_XILINX_LICENSE_LOCATION ]; then - echo "(WARNING) Please ensure you have installed Xilinx and have a license." - echo "(WARNING) Copy your Xilinx license to $LIKELY_XILINX_LICENSE_LOCATION to suppress this warning." -else - license_found=1 -fi - . $SETUP_DIR/settings.sh echo " This script is: $SETUP_SRC" echo " Firmware directory: $TOP_DIR" echo " Build directory is: $BUILD_DIR" echo " 3rd party directory is: $THIRD_DIR" -if [ $license_found == 1 ]; then - echo " Xilinx license in: $LIKELY_XILINX_LICENSE_LOCATION" -fi # Check the build dir if [ ! -d $BUILD_DIR ]; then @@ -91,44 +77,65 @@ if [ ! -d $BUILD_DIR ]; then return 1 fi -SETTINGS_ISE='/opt/Xilinx/*/ISE_DS/settings64.sh' -SETTINGS_VIVADO='/opt/Xilinx/Vivado/*/settings64.sh' +XILINX_SETTINGS_ISE='/opt/Xilinx/*/ISE_DS/settings64.sh' +XILINX_SETTINGS_VIVADO='/opt/Xilinx/Vivado/*/settings64.sh' if [ -z "$XILINX_DIR" ]; then LOCAL_XILINX_DIR=$BUILD_DIR/Xilinx - - if [ -f "$LOCAL_XILINX_DIR/$SETTINGS_ISE" -o -f "$LOCAL_XILINX_DIR/$SETTINGS_VIVADO" ]; then + if [ -d "$LOCAL_XILINX_DIR/opt/Xilinx/" ]; then # Reserved MAC address from documentation block, see # http://www.iana.org/assignments/ethernet-numbers/ethernet-numbers.xhtml - export XILINXD_LICENSE_FILE=$LOCAL_XILINX_DIR + export LIKELY_XILINX_LICENSE_DIR=$LOCAL_XILINX_DIR export MACADDR=90:10:00:00:00:01 #export LD_PRELOAD=$XILINX_DIR/impersonate_macaddress/impersonate_macaddress.so #ls -l $LD_PRELOAD export XILINX_DIR=$LOCAL_XILINX_DIR - else - XILINX_DIR=/ fi fi -if [ ! -z "$XILINX_DIR" ]; then - export MISOC_EXTRA_CMDLINE="-Ob toolchain_path $XILINX_DIR/opt/Xilinx/" +if [ -z "$LIKELY_XILINX_LICENSE_DIR" ]; then + LIKELY_XILINX_LICENSE_DIR="$HOME/.Xilinx" fi + echo " Xilinx directory is: $XILINX_DIR/opt/Xilinx/" -if [ -f $XILINX_DIR/$SETTINGS_ISE ]; then - echo " - Xilinx ISE toolchain found!" - HAVE_XILINX_ISE=1 +XILINX_SETTINGS_ISE=($XILINX_DIR/$XILINX_SETTINGS_ISE) +if [ ${#XILINX_SETTINGS_ISE[@]} -gt 0 ]; then + echo -n " - Xilinx ISE toolchain found!" + if [ ${#XILINX_SETTINGS_ISE[@]} -gt 1 ]; then + echo -n " (${#XILINX_SETTINGS_ISE[@]} versions)" + fi + echo "" + export HAVE_XILINX_ISE=1 else - HAVE_XILINX_ISE=0 + export HAVE_XILINX_ISE=0 fi -if [ -f $XILINX_DIR/$SETTINGS_VIVADO ]; then - echo " - Xilinx Vivado toolchain found!" - HAVE_XILINX_VIVADO=1 +XILINX_SETTINGS_VIVADO=($XILINX_DIR/$XILINX_SETTINGS_VIVADO) +if [ ${#XILINX_SETTINGS_VIVADO[@]} -gt 0 ]; then + echo -n " - Xilinx Vivado toolchain found!" + if [ ${#XILINX_SETTINGS_VIVADO[@]} -gt 1 ]; then + echo -n " (${#XILINX_SETTINGS_VIVADO[@]} versions)" + fi + echo "" + export HAVE_XILINX_VIVADO=1 else - HAVE_XILINX_VIVADO=0 + export HAVE_XILINX_VIVADO=0 fi if [ $HAVE_XILINX_ISE -eq 1 -o $HAVE_XILINX_VIVADO -eq 1 ]; then - HAVE_XILINX_TOOLCHAIN=1 + export HAVE_XILINX_TOOLCHAIN=1 else - HAVE_XILINX_TOOLCHAIN=0 + export HAVE_XILINX_TOOLCHAIN=0 +fi +if [ $HAVE_XILINX_TOOLCHAIN -eq 1 ]; then + export MISOC_EXTRA_CMDLINE="-Ob toolchain_path $XILINX_DIR/opt/Xilinx/" +fi + +# Detect a likely lack of license early, but just warn if it's missing +# just in case they've set it up elsewhere. +if [ ! -e $LIKELY_XILINX_LICENSE_DIR/Xilinx.lic ]; then + echo "(WARNING) Please ensure you have installed Xilinx and have a license." + echo "(WARNING) Copy your Xilinx license to Xilinx.lic in $LIKELY_XILINX_LICENSE_DIR to suppress this warning." +else + echo " Xilinx license in: $LIKELY_XILINX_LICENSE_DIR" + XILINXD_LICENSE_FILE=$LIKELY_XILINX_LICENSE_DIR fi function check_exists { @@ -187,7 +194,7 @@ echo "" echo "Checking environment" echo "---------------------------------" # Install and setup conda for downloading packages -export PATH=$CONDA_DIR/bin:$PATH +export PATH=$CONDA_DIR/bin:$PATH:/sbin eval $(cd $TOP_DIR; export HDMI2USB_ENV=1; make env || return 1) || return 1 ( @@ -197,6 +204,8 @@ eval $(cd $TOP_DIR; export HDMI2USB_ENV=1; make env || return 1) || return 1 echo ) || return 1 + + # Check the Python version @@ -210,8 +219,8 @@ echo "---------------------------------" # fxload if [ "$PLATFORM" == "opsis" -o "$PLATFORM" == "atlys" ]; then - # check sbin for fxload as well - export PATH=$PATH:/sbin + + check_exists fxload || return 1 fi @@ -298,7 +307,7 @@ check_import_version hexfile $HEXFILE_VERSION || return 1 check_import_version hdmi2usb.modeswitch $HDMI2USB_MODESWITCH_VERSION || return 1 -# git submodules +# git commands echo "" echo "Checking git submodules" echo "-----------------------" @@ -307,7 +316,7 @@ echo "-----------------------" - git status + git submodule status --recursive ) # lite From 98890778d84019e9c1076ee6a4a0ce35e1eb54e1 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sat, 17 Mar 2018 16:50:33 -0700 Subject: [PATCH 169/219] scripts: Export XILINXD_LICENSE_FILE. --- scripts/download-env.sh | 2 +- scripts/enter-env.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/download-env.sh b/scripts/download-env.sh index 3e9e2bde..b9260e86 100755 --- a/scripts/download-env.sh +++ b/scripts/download-env.sh @@ -170,7 +170,7 @@ if [ ! -e $LIKELY_XILINX_LICENSE_DIR/Xilinx.lic ]; then echo "(WARNING) Copy your Xilinx license to Xilinx.lic in $LIKELY_XILINX_LICENSE_DIR to suppress this warning." else echo " Xilinx license in: $LIKELY_XILINX_LICENSE_DIR" - XILINXD_LICENSE_FILE=$LIKELY_XILINX_LICENSE_DIR + export XILINXD_LICENSE_FILE=$LIKELY_XILINX_LICENSE_DIR fi function check_exists { diff --git a/scripts/enter-env.sh b/scripts/enter-env.sh index 4f7a789a..0e4cfd52 100755 --- a/scripts/enter-env.sh +++ b/scripts/enter-env.sh @@ -135,7 +135,7 @@ if [ ! -e $LIKELY_XILINX_LICENSE_DIR/Xilinx.lic ]; then echo "(WARNING) Copy your Xilinx license to Xilinx.lic in $LIKELY_XILINX_LICENSE_DIR to suppress this warning." else echo " Xilinx license in: $LIKELY_XILINX_LICENSE_DIR" - XILINXD_LICENSE_FILE=$LIKELY_XILINX_LICENSE_DIR + export XILINXD_LICENSE_FILE=$LIKELY_XILINX_LICENSE_DIR fi function check_exists { From e073ec76a42f3edba551d1d0acf056644ac7313d Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sat, 17 Mar 2018 18:09:52 -0700 Subject: [PATCH 170/219] scripts: Setting XILINX_LOCAL_USER_DATA=no - https://www.xilinx.com/support/answers/62945.html --- scripts/download-env.sh | 1 + scripts/enter-env.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/scripts/download-env.sh b/scripts/download-env.sh index b9260e86..daf31d94 100755 --- a/scripts/download-env.sh +++ b/scripts/download-env.sh @@ -125,6 +125,7 @@ if [ -z "$XILINX_DIR" ]; then #export LD_PRELOAD=$XILINX_DIR/impersonate_macaddress/impersonate_macaddress.so #ls -l $LD_PRELOAD export XILINX_DIR=$LOCAL_XILINX_DIR + export XILINX_LOCAL_USER_DATA=no fi fi if [ -z "$LIKELY_XILINX_LICENSE_DIR" ]; then diff --git a/scripts/enter-env.sh b/scripts/enter-env.sh index 0e4cfd52..b343045d 100755 --- a/scripts/enter-env.sh +++ b/scripts/enter-env.sh @@ -90,6 +90,7 @@ if [ -z "$XILINX_DIR" ]; then #export LD_PRELOAD=$XILINX_DIR/impersonate_macaddress/impersonate_macaddress.so #ls -l $LD_PRELOAD export XILINX_DIR=$LOCAL_XILINX_DIR + export XILINX_LOCAL_USER_DATA=no fi fi if [ -z "$LIKELY_XILINX_LICENSE_DIR" ]; then From bb7a91b2d103cd1a1bd56137e347c8502fd744cb Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Wed, 14 Mar 2018 22:59:57 +0100 Subject: [PATCH 171/219] travis: Fix sorting of index file. --- .travis/package-xilinx-step3-upload.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis/package-xilinx-step3-upload.sh b/.travis/package-xilinx-step3-upload.sh index 6950719c..aece070f 100755 --- a/.travis/package-xilinx-step3-upload.sh +++ b/.travis/package-xilinx-step3-upload.sh @@ -27,7 +27,7 @@ mkdir -p $BASE # Upload the tar bz $TB_COMMAND -s . --sync --pattern-match ".*\.gpg" # Upload the index file - md5sum *.gpg | sort -t- -k4,5n > index.txt + md5sum *.gpg | sort -t- -k3,3V -k4,4n > index.txt cat index.txt $TB_COMMAND -s . --sync --pattern-match "index.txt" ) From a6ccd4141b0b2e34f6cb49cb06c1d3d999a096f7 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Wed, 14 Mar 2018 23:01:21 +0100 Subject: [PATCH 172/219] travis: Rework copying files for Xilinx tarball. --- .travis/copy-files.py | 27 ++++++++++++++++++++++ .travis/package-xilinx-step2-create-tar.sh | 13 +++++++---- 2 files changed, 35 insertions(+), 5 deletions(-) create mode 100755 .travis/copy-files.py diff --git a/.travis/copy-files.py b/.travis/copy-files.py new file mode 100755 index 00000000..a209b752 --- /dev/null +++ b/.travis/copy-files.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 + +import os.path +import shutil +import sys + +d = sys.argv[1] +assert d, d + +for l in sys.stdin.readlines(): + src = l.strip() + assert src, src + assert src.startswith('/'), src + out = os.path.join(d, src[1:]) + outdir = os.path.dirname(out) + src = src.replace('/opt/Xilinx/', '/opt/Xilinx.real/') + if not os.path.exists(outdir): + os.makedirs(outdir) + print("New pdir {}".format(outdir)) + + if os.path.isdir(src): + os.makedirs(out, exist_ok=False) + shutil.copystat(src, out) + print("New dir {}".format(out)) + else: + shutil.copy2(src, out, follow_symlinks=False) + print("New file {} -> {}".format(src, out)) diff --git a/.travis/package-xilinx-step2-create-tar.sh b/.travis/package-xilinx-step2-create-tar.sh index ecba0d6e..f4426a1c 100755 --- a/.travis/package-xilinx-step2-create-tar.sh +++ b/.travis/package-xilinx-step2-create-tar.sh @@ -31,20 +31,23 @@ if [ ! -f $STRACE_LOG ]; then fi STRACE_FILES=$BASE/strace.files.log -#cat $STRACE_LOG | python $SETUP_DIR/package-xilinx-filter-strace.py $PREFIX > $STRACE_FILES -$SETUP_DIR/package-xilinx-cluefs-filter.py $STRACE_LOG > $STRACE_FILES +if [ ! -f $STRACE_LOG ]; then + #cat $STRACE_LOG | python $SETUP_DIR/package-xilinx-filter-strace.py $PREFIX > $STRACE_FILES + $SETUP_DIR/package-xilinx-cluefs-filter.py $STRACE_LOG > $STRACE_FILES +fi XILINX_DIR=$BASE/xilinx-stripped if [ -d $XILINX_DIR ]; then - rm -rf $XILINX_DIR + rm -rf $XILINX_DIR fi echo "" echo "Creating directories" echo "--------------------------------------" mkdir -p $XILINX_DIR -cat $STRACE_FILES | xargs -d '\n' \ - cp -v --parents --no-dereference --preserve=all -t $XILINX_DIR || true +#cat $STRACE_FILES | xargs -d '\n' \ +# cp -v --parents --no-dereference --preserve=all -t $XILINX_DIR || true +cat $STRACE_FILES | $TOP_DIR/.travis/copy-files.py $XILINX_DIR echo "--------------------------------------" FILENAME="$BASE/xilinx-tools-$(git describe).tar.bz2" From 4224f224167472ce7d7da93a336fd719800ce7ce Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sun, 18 Mar 2018 02:32:37 +0100 Subject: [PATCH 173/219] travis: Set XILINX_LOCAL_USER_DATA=no when using BUILD. --- .travis/build.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis/build.sh b/.travis/build.sh index f08e85f1..043beb6d 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -11,6 +11,9 @@ elif [ -x /usr/bin/timelimit ]; then export GATEWARE_TIMEOUT_CMD="/usr/bin/timelimit -T $GATEWARE_KILLOUT -t $GATEWARE_TIMEOUT" fi +# Check for the Xilinx toolchain being downloaded +export XILINX_LOCAL_USER_DATA=no + GIT_REVISION=$TRAVIS_BRANCH/$(git describe) ORIG_COMMITTER_NAME=$(git log -1 --pretty=%an) ORIG_COMMITTER_EMAIL=$(git log -1 --pretty=%ae) From 0155cb9c1620e66aa88f82db38eb9d5eb5d1ba13 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sat, 17 Mar 2018 21:12:23 -0700 Subject: [PATCH 174/219] scripts: globing should have null result. --- scripts/download-env.sh | 1 + scripts/enter-env.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/scripts/download-env.sh b/scripts/download-env.sh index daf31d94..29309ad7 100755 --- a/scripts/download-env.sh +++ b/scripts/download-env.sh @@ -131,6 +131,7 @@ fi if [ -z "$LIKELY_XILINX_LICENSE_DIR" ]; then LIKELY_XILINX_LICENSE_DIR="$HOME/.Xilinx" fi +shopt -s nullglob echo " Xilinx directory is: $XILINX_DIR/opt/Xilinx/" XILINX_SETTINGS_ISE=($XILINX_DIR/$XILINX_SETTINGS_ISE) diff --git a/scripts/enter-env.sh b/scripts/enter-env.sh index b343045d..1b1bea8c 100755 --- a/scripts/enter-env.sh +++ b/scripts/enter-env.sh @@ -96,6 +96,7 @@ fi if [ -z "$LIKELY_XILINX_LICENSE_DIR" ]; then LIKELY_XILINX_LICENSE_DIR="$HOME/.Xilinx" fi +shopt -s nullglob echo " Xilinx directory is: $XILINX_DIR/opt/Xilinx/" XILINX_SETTINGS_ISE=($XILINX_DIR/$XILINX_SETTINGS_ISE) From d70a2db8233e195d884c152b7d729b707d48bacb Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sun, 18 Mar 2018 21:59:22 +0100 Subject: [PATCH 175/219] travis: Fixing generate-prebuilt-list Allow extra columns to be added to the spreadsheet. --- .travis/generate-prebuilt-list.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.travis/generate-prebuilt-list.py b/.travis/generate-prebuilt-list.py index e86e224b..0eeb23c2 100755 --- a/.travis/generate-prebuilt-list.py +++ b/.travis/generate-prebuilt-list.py @@ -95,11 +95,8 @@ def get_channel_spreadsheet(): continue if i[0] != "GitHub": continue - if len(i) != 6: - print("Skipping row %s" % i) - continue - _, _, rev, name, conf, _ = i + _, _, rev, name, conf, *_ = i if not name: continue assert name not in rev_names, "{} is listed multiple times!".format( From 2f752afa2dcff8f338fccc6395ed7b3f65d1dfe9 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sun, 18 Mar 2018 18:26:29 -0700 Subject: [PATCH 176/219] scripts: Restore the nullglob setting. Otherwise it breaks the SAVE code in .travis/build.sh https://github.com/timvideos/HDMI2USB-litex-firmware/blob/master/.travis/build.sh#L223-L236 --- scripts/download-env.sh | 5 +++-- scripts/enter-env.sh | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/download-env.sh b/scripts/download-env.sh index 29309ad7..e083ec99 100755 --- a/scripts/download-env.sh +++ b/scripts/download-env.sh @@ -132,9 +132,11 @@ if [ -z "$LIKELY_XILINX_LICENSE_DIR" ]; then LIKELY_XILINX_LICENSE_DIR="$HOME/.Xilinx" fi shopt -s nullglob +XILINX_SETTINGS_ISE=($XILINX_DIR/$XILINX_SETTINGS_ISE) +XILINX_SETTINGS_VIVADO=($XILINX_DIR/$XILINX_SETTINGS_VIVADO) +shopt -u nullglob echo " Xilinx directory is: $XILINX_DIR/opt/Xilinx/" -XILINX_SETTINGS_ISE=($XILINX_DIR/$XILINX_SETTINGS_ISE) if [ ${#XILINX_SETTINGS_ISE[@]} -gt 0 ]; then echo -n " - Xilinx ISE toolchain found!" if [ ${#XILINX_SETTINGS_ISE[@]} -gt 1 ]; then @@ -145,7 +147,6 @@ if [ ${#XILINX_SETTINGS_ISE[@]} -gt 0 ]; then else export HAVE_XILINX_ISE=0 fi -XILINX_SETTINGS_VIVADO=($XILINX_DIR/$XILINX_SETTINGS_VIVADO) if [ ${#XILINX_SETTINGS_VIVADO[@]} -gt 0 ]; then echo -n " - Xilinx Vivado toolchain found!" if [ ${#XILINX_SETTINGS_VIVADO[@]} -gt 1 ]; then diff --git a/scripts/enter-env.sh b/scripts/enter-env.sh index 1b1bea8c..706440cb 100755 --- a/scripts/enter-env.sh +++ b/scripts/enter-env.sh @@ -96,10 +96,15 @@ fi if [ -z "$LIKELY_XILINX_LICENSE_DIR" ]; then LIKELY_XILINX_LICENSE_DIR="$HOME/.Xilinx" fi + +# Find Xilinx toolchain versions... shopt -s nullglob +XILINX_SETTINGS_ISE=($XILINX_DIR/$XILINX_SETTINGS_ISE) +XILINX_SETTINGS_VIVADO=($XILINX_DIR/$XILINX_SETTINGS_VIVADO) +shopt -u nullglob +# Tell user what we found... echo " Xilinx directory is: $XILINX_DIR/opt/Xilinx/" -XILINX_SETTINGS_ISE=($XILINX_DIR/$XILINX_SETTINGS_ISE) if [ ${#XILINX_SETTINGS_ISE[@]} -gt 0 ]; then echo -n " - Xilinx ISE toolchain found!" if [ ${#XILINX_SETTINGS_ISE[@]} -gt 1 ]; then @@ -110,7 +115,6 @@ if [ ${#XILINX_SETTINGS_ISE[@]} -gt 0 ]; then else export HAVE_XILINX_ISE=0 fi -XILINX_SETTINGS_VIVADO=($XILINX_DIR/$XILINX_SETTINGS_VIVADO) if [ ${#XILINX_SETTINGS_VIVADO[@]} -gt 0 ]; then echo -n " - Xilinx Vivado toolchain found!" if [ ${#XILINX_SETTINGS_VIVADO[@]} -gt 1 ]; then From a6c42b60b22eaf667acf145e0ca2b66bf9dbdf0f Mon Sep 17 00:00:00 2001 From: Shivam Aggarwal Date: Sun, 1 Apr 2018 18:56:06 +0530 Subject: [PATCH 177/219] update-debug-edid --- firmware/ci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/firmware/ci.c b/firmware/ci.c index fa6277c2..4eef6d4b 100644 --- a/firmware/ci.c +++ b/firmware/ci.c @@ -173,7 +173,7 @@ static void help_debug(void) wputs(" debug ddr - show DDR bandwidth"); #endif wputs(" debug dna - show Board's DNA"); - wputs(" debug edid - dump monitor EDID"); + wputs(" debug edid - dump monitor EDID"); #ifdef CSR_CAS_BASE wputs(" debug cas leds - change the status LEDs"); wputs(" debug cas switches - read the control switches status"); @@ -1300,7 +1300,7 @@ void ci_service(void) } #endif if(found == 0) - wprintf("%s port has no EDID capabilities\n", token); + wprintf("no such port\n"); #ifdef CSR_CAS_BASE } else if(strcmp(token, "cas") == 0) { token = get_token(&str); From f53f1ad393d2749e12260b7c666c572d62738c7b Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sat, 7 Apr 2018 17:32:40 -0700 Subject: [PATCH 178/219] flash: Fix end address for firmware. Fixes #425. --- flash.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/flash.py b/flash.py index 376bd61f..9605d642 100755 --- a/flash.py +++ b/flash.py @@ -41,12 +41,12 @@ def main(): filename = make.get_firmware(builddir, "flash") address_start = platform.gateware_size + make.BIOS_SIZE - address_end = platform.gateware_size + address_end = platform.spiflash_total_size elif args.mode == 'other': filename = args.other address_start = args.address - address_end = platform.gateware_size + address_end = platform.spiflash_total_size else: assert False, "Unknown flashing mode." @@ -60,8 +60,8 @@ def main(): file_size = len(open(filepath, 'rb').read()) file_end = address_start+file_size - assert file_end < address_end, "File is too big!\n%s file doesn't fit in %s space." % ( - address_end - address_start, file_size) + assert file_end < address_end, "File is too big!\n%s file doesn't fit in %s space (%s extra bytes)." % ( + filename, file_size, address_end - address_start) prog = make.get_prog(args, platform) prog.flash(address_start, filepath) From d12a56665870234d17e0d980293431fd33749b40 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sun, 8 Apr 2018 10:18:59 -0700 Subject: [PATCH 179/219] flash: Fixing other mode. --- flash.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flash.py b/flash.py index 9605d642..3ec2ed14 100755 --- a/flash.py +++ b/flash.py @@ -44,7 +44,7 @@ def main(): address_end = platform.spiflash_total_size elif args.mode == 'other': - filename = args.other + filename = args.other_file address_start = args.address address_end = platform.spiflash_total_size From 3888e6170a9f66f3bbcd3c9638352e6fe0ea716a Mon Sep 17 00:00:00 2001 From: Kyle Robbertze Date: Fri, 13 Apr 2018 11:42:41 +0200 Subject: [PATCH 180/219] Add version to help prompt --- firmware/ci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/firmware/ci.c b/firmware/ci.c index fa6277c2..c843a8e3 100644 --- a/firmware/ci.c +++ b/firmware/ci.c @@ -191,6 +191,7 @@ static void ci_help(void) wputs("mdio_status - show mdio status"); #endif wputs("pattern (p) - select next pattern"); + wputs("version - show firmware version"); wputs(""); help_status(); wputs(""); From 05f0c7608d688ee0880bc656b05757b62e50e14b Mon Sep 17 00:00:00 2001 From: Kyle Robbertze Date: Tue, 17 Apr 2018 18:34:55 +0200 Subject: [PATCH 181/219] Add XILINX_DIR notes --- doc/notes.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/notes.md b/doc/notes.md index a880c2aa..c7269f0f 100644 --- a/doc/notes.md +++ b/doc/notes.md @@ -41,7 +41,7 @@ Bunch of packages are needed; * Libraries for talking to USB - libftdi, libusb, fxload - + * udev rules. * Kernel modules for some boards. Mostly not needed.... @@ -77,7 +77,9 @@ directory will totally remove the installed environment. ### Step 4 - Enter self contained environment & set environment variables. - + * If you installed Xilinx to anywhere other than `/opt/Xilinx/`, run + `export XILINX_DIR=`. This must be set before entering the + environment, as it is not updated from within it. * `source scripts/enter-env.sh` - enter-env checks that your environment is setup correctly and contains all the dependencies you need. From 7c28ad41d6bbc70e6d6e88505dc6729625dea9c8 Mon Sep 17 00:00:00 2001 From: Kyle Robbertze Date: Wed, 25 Apr 2018 21:54:43 +0200 Subject: [PATCH 182/219] Link to current Opsis supplier page --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 37b4ad6b..dac52c01 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ conferences; ![Digilent Atlys Picture](https://hdmi2usb.tv/img/digilent-atlys-small.jpg) - * [Numato Opsis](https://hdmi2usb.tv/numato-opsis/) - `PLATFORM=opsis` - https://crowdsupply.com/numato-lab/opsis + * [Numato Opsis](https://hdmi2usb.tv/numato-opsis/) - `PLATFORM=opsis` - https://numato.com/product/numato-opsis-fpga-based-open-video-platform The first production board made in conjunction with TimVideos.us project. From afd3b958b7b667c5612539a3241d8a7826d8f937 Mon Sep 17 00:00:00 2001 From: FelixVi Date: Sat, 9 Dec 2017 15:16:09 -0700 Subject: [PATCH 183/219] saturn: adding platform and base target Support for the Numato Saturn (LX45 version) http://numato.com/product/saturn-spartan-6-fpga-development-board-with-ddr-sdram) Board comes with DDR SDRAM, USB-FIFO and lots of GPIO on 100mil headers Max frequency can be further optimized --- platforms/saturn.py | 151 ++++++++++++++++++++++++++++ targets/saturn/base.py | 220 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 371 insertions(+) create mode 100644 platforms/saturn.py create mode 100644 targets/saturn/base.py diff --git a/platforms/saturn.py b/platforms/saturn.py new file mode 100644 index 00000000..fd21513e --- /dev/null +++ b/platforms/saturn.py @@ -0,0 +1,151 @@ +# Support for the Numato Saturn (http://numato.com/product/saturn-spartan-6-fpga-development-board-with-ddr-sdram) +from litex.build.generic_platform import * +from litex.build.xilinx import XilinxPlatform + +#FIXME: +#this is for the LX45 version +#check on "no connect pins" for LX9 and LX25 + +_io = [ + ("clk100", 0, Pins("V10"), IOStandard("LVTTL")), + + ("serial", 0, + Subsignal("tx", Pins("L18")), + Subsignal("rx", Pins("L17"), Misc("PULLUP")), + Subsignal("cts", Pins("M16"), Misc("PULLUP")), + Subsignal("rts", Pins("M18"), Misc("PULLUP")), + IOStandard("LVTTL") + ), + + #the board has a FTDI FT2232H + ("usb_fifo", 0, + Subsignal("data", Pins("L17 L18 M16 M18 N17 N18 P17 P18")), + Subsignal("rxf_n", Pins("K18")), + Subsignal("txe_n", Pins("K17")), + Subsignal("rd_n", Pins("J18")), + Subsignal("wr_n", Pins("J16")), + Subsignal("siwua", Pins("H18")), + IOStandard("LVTTL"), + ), + + ("spiflash", 0, + Subsignal("cs_n", Pins("V3")), + Subsignal("clk", Pins("R15")), + Subsignal("mosi", Pins("R13")), + Subsignal("miso", Pins("T13"), Misc("PULLUP")), + IOStandard("LVCMOS33"), Misc("SLEW=FAST") + ), + + ("ddram_clock", 0, + Subsignal("p", Pins("G3")), + Subsignal("n", Pins("G1")), + IOStandard("MOBILE_DDR") + ), + + ("ddram", 0, + Subsignal("a", Pins("J7 J6 H5 L7 F3 H4 H3 H6 D2 D1 F4 D3 G6")), + Subsignal("ba", Pins("F2 F1")), + Subsignal("cke", Pins("H7")), + Subsignal("ras_n", Pins("L5")), + Subsignal("cas_n", Pins("K5")), + Subsignal("we_n", Pins("E3")), + Subsignal("dq", Pins("L2 L1 K2 K1 H2 H1 J3 J1 M3 M1 N2 N1 T2 T1 U2 U1")), + Subsignal("dqs", Pins("L4 P2")), + Subsignal("dm", Pins("K3 K4")), + IOStandard("MOBILE_DDR") + ) +] + +_connectors = [ + ("P3", "G13 H12 K14 J13 H16 H15 H14 H13 G14 F14 G18 G16 F16 F15 F18" #15 pins + "F17 E18 E16 D18 D17 C18 C17 A16 B16 A15 C15 C14 D14 A14 B14" #15 pins + "E13 F13 A13 C13 A12 B12 C11 D11 A11 B11 A10 C10 F9 G9 C9 D9" #16 pins + "A9 B9 C8 D8 A8 B8 A7 C7 A6 B6 C6 D6 A5 C5 A4 B4 A3 B3 A2 B2" #20 pins + ), + + ("P2", "K12 K13 L14 M13 M14 N14 L12 L13 L15 L16 K15 K16 N15 N16 T17" #15 pins + "T18 P15 P16 U16 V16 U17 U18 T14 V14 U15 V15 T12 V12 U13 V13" #15 pins + "R11 T11 M11 N11 N10 P11 U11 V11 R10 T10 M10 N9 T9 V9 R8 T8" #16 pins + "N7 P8 M8 N8 U7 V7 U8 V8 R7 T7 N6 P7 N5 P6 T6 V6 R5 T5 U5" #19 pins + "V5 R3 T3 T4 V4" # 5 pins + ) +] + +# FPGA P3 _connector "P3" FPGA P2 _connector P2 +# 5 0 G13 7 0 K12 +# 6 1 H12 8 1 K13 +# 7 2 K14 11 2 L14 +# 8 3 J13 12 3 M13 +# 9 4 H16 15 4 M14 +# 10 5 H15 16 5 N14 +# 11 6 H14 17 6 L12 +# 12 7 H13 18 7 L13 +# 13 8 G14 19 8 L15 +# 14 9 F14 20 9 L16 +# 15 10 G18 21 10 K15 +# 16 11 G16 22 11 K16 +# 17 12 F16 23 12 N15 +# 18 13 F15 24 13 N16 +# 19 14 F18 25 14 T17 +# 20 15 F17 26 15 T18 +# 21 16 E18 27 16 P15 +# 22 17 E16 28 17 P16 +# 23 18 D18 29 18 U16 +# 24 19 D17 30 19 V16 +# 25 20 C18 31 20 U17 +# 26 21 C17 32 21 U18 +# 27 22 A16 33 22 T14 +# 28 23 B16 34 23 V14 +# 29 24 A15 35 24 U15 +# 30 25 C15 36 25 V15 +# 31 26 C14 37 26 T12 +# 32 27 D14 38 27 V12 +# 33 28 A14 39 28 U13 +# 34 29 B14 40 29 V13 +# 35 30 E13 41 30 R11 +# 36 31 F13 42 31 T11 +# 37 32 A13 43 32 M11 +# 38 33 C13 44 33 N11 +# 43 34 A12 53 34 N10 +# 44 35 B12 54 35 P11 +# 47 36 C11 55 36 U11 +# 48 37 D11 56 37 V11 +# 55 38 A11 57 38 R10 +# 56 39 B11 58 39 T10 +# 57 40 A10 59 40 M10 +# 58 41 C10 60 41 N9 +# 59 42 F9 61 42 T9 +# 60 43 G9 62 43 V9 +# 61 44 C9 63 44 R8 +# 62 45 D9 64 45 T8 +# 63 46 A9 65 46 N7 +# 64 47 B9 66 47 P8 +# 69 48 C8 67 48 M8 +# 70 49 D8 68 49 N8 +# 71 50 A8 69 50 U7 +# 72 51 B8 70 51 V7 +# 75 52 A7 71 52 U8 +# 76 53 C7 72 53 V8 +# 77 54 A6 73 54 R7 +# 78 55 B6 74 55 T7 +# 79 56 C6 75 56 N6 +# 80 57 D6 76 57 P7 +# 81 58 A5 77 58 N5 +# 82 59 C5 78 59 P6 +# 83 60 A4 79 60 T6 +# 84 61 B4 80 61 V6 +# 85 62 A3 81 62 R5 +# 86 63 B3 82 63 T5 +# 87 64 A2 83 64 U5 +# 88 65 B2 84 65 V5 +# 85 66 R3 +# 86 67 T3 +# 87 68 T4 +# 88 69 V4 + +class Platform(XilinxPlatform): + default_clk_name = "clk100" + default_clk_period = 10.00 + + def __init__(self): + XilinxPlatform.__init__(self, "xc6slx45-2csg324", _io, _connectors) diff --git a/targets/saturn/base.py b/targets/saturn/base.py new file mode 100644 index 00000000..c66c4b44 --- /dev/null +++ b/targets/saturn/base.py @@ -0,0 +1,220 @@ +# Support for the Numato Saturn (http://numato.com/product/saturn-spartan-6-fpga-development-board-with-ddr-sdram) + +from fractions import Fraction + +from litex.gen import * +from litex.gen.genlib.resetsync import AsyncResetSynchronizer + +from litex.build.generic_platform import * + +from litex.soc.integration.soc_sdram import * +from litex.soc.integration.builder import * + +from litedram.modules import MT46H32M16 +from litedram.phy import s6ddrphy +from litedram.core import ControllerSettings + +from targets.utils import csr_map_update + + +class _CRG(Module): + def __init__(self, platform, clk_freq): + # Clock domains for the system (soft CPU and related components run at). + self.clock_domains.cd_sys = ClockDomain() + # Clock domains for the DDR interface. + self.clock_domains.cd_sdram_half = ClockDomain() + self.clock_domains.cd_sdram_full_wr = ClockDomain() + self.clock_domains.cd_sdram_full_rd = ClockDomain() + + # Input 100MHz clock + f0 = Fraction(100, 1)*1000000 + clk100 = platform.request("clk100") + clk100a = Signal() + # Input 100MHz clock (buffered) + self.specials += Instance( + "IBUFG", + i_I=clk100, + o_O=clk100a + ) + + clk100b = Signal() + + self.specials += Instance( + "BUFIO2", + p_DIVIDE=1, + p_DIVIDE_BYPASS="TRUE", p_I_INVERT="FALSE", + i_I=clk100a, + o_DIVCLK=clk100b + ) + + #PLL parameters + f = Fraction(10, 1) + n, d = f.numerator, f.denominator + p = 8 + + assert f0*n/d/p/2 == clk_freq + assert 19e6 <= f0/d <= 500e6 # pfd + assert 400e6 <= f0*n/d <= 1000e6 # vco + + # Unbuffered output signals from the PLL. They need to be buffered + # before feeding into the fabric. + unbuf_sdram_full = Signal() + unbuf_sdram_half_a = Signal() + unbuf_sdram_half_b = Signal() + unbuf_unused_a = Signal() + unbuf_unused_b = Signal() + unbuf_sys = Signal() + + # PLL signals + pll_lckd = Signal() + pll_fb = Signal() + self.specials.pll = Instance( + "PLL_ADV", + name="crg_pll_adv", + p_SIM_DEVICE="SPARTAN6", p_BANDWIDTH="OPTIMIZED", p_COMPENSATION="INTERNAL", + p_REF_JITTER=.01, + i_DADDR=0, i_DCLK=0, i_DEN=0, i_DI=0, i_DWE=0, i_RST=0, i_REL=0, + p_DIVCLK_DIVIDE=d, + # Input Clocks (100MHz) + i_CLKIN1=clk100b, + p_CLKIN1_PERIOD=1e9/f0, + i_CLKIN2=0, + p_CLKIN2_PERIOD=0., + i_CLKINSEL=1, + # Feedback + i_CLKFBIN=pll_fb, o_CLKFBOUT=pll_fb, o_LOCKED=pll_lckd, + p_CLK_FEEDBACK="CLKFBOUT", + p_CLKFBOUT_MULT=n, p_CLKFBOUT_PHASE=0., + # Outputs + # (125 MHz) sdram wr rd + o_CLKOUT0=unbuf_sdram_full, p_CLKOUT0_DUTY_CYCLE=.5, + p_CLKOUT0_PHASE=0., p_CLKOUT0_DIVIDE=p, + # (125 MHz) unused + o_CLKOUT1=unbuf_unused_a, p_CLKOUT1_DUTY_CYCLE=.5, + p_CLKOUT1_PHASE=0., p_CLKOUT1_DIVIDE=p, + # (62.5 MHz) sdram_half - sdram dqs adr ctrl + o_CLKOUT2=unbuf_sdram_half_a, p_CLKOUT2_DUTY_CYCLE=.5, + p_CLKOUT2_PHASE=270., p_CLKOUT2_DIVIDE=(p*2), + # (62.5 MHz) off-chip ddr + o_CLKOUT3=unbuf_sdram_half_b, p_CLKOUT3_DUTY_CYCLE=.5, + p_CLKOUT3_PHASE=270., p_CLKOUT3_DIVIDE=(p*2), + # (31.25 MHz) unused + o_CLKOUT4=unbuf_unused_b, p_CLKOUT4_DUTY_CYCLE=.5, + p_CLKOUT4_PHASE=0., p_CLKOUT4_DIVIDE=(p*4), + # (31.25 MHz) sysclk + o_CLKOUT5=unbuf_sys, p_CLKOUT5_DUTY_CYCLE=.5, + p_CLKOUT5_PHASE=0., p_CLKOUT5_DIVIDE=(p*4), + ) + + #power on reset? + reset_pin = [("reset", 0, Pins("P2:0")), ] + platform.add_extension(reset_pin) + reset = platform.request("reset") + self.clock_domains.cd_por = ClockDomain() + por = Signal(max=1 << 11, reset=(1 << 11) - 1) + self.sync.por += If(por != 0, por.eq(por - 1)) + self.specials += AsyncResetSynchronizer(self.cd_por, reset) + + #System clock + self.specials += Instance("BUFG", i_I=unbuf_sys, o_O=self.cd_sys.clk) + self.comb += self.cd_por.clk.eq(self.cd_sys.clk) + self.specials += AsyncResetSynchronizer(self.cd_sys, ~pll_lckd | (por > 0)) + + # SDRAM clocks + # ------------------------------------------------------------------------------ + self.clk4x_wr_strb = Signal() + self.clk4x_rd_strb = Signal() + + # sdram_full + self.specials += Instance( + "BUFPLL", + p_DIVIDE=4, + i_PLLIN=unbuf_sdram_full, + i_GCLK=self.cd_sys.clk, + i_LOCKED=pll_lckd, + o_IOCLK=self.cd_sdram_full_wr.clk, + o_SERDESSTROBE=self.clk4x_wr_strb + ) + + self.comb += [ + self.cd_sdram_full_rd.clk.eq(self.cd_sdram_full_wr.clk), + self.clk4x_rd_strb.eq(self.clk4x_wr_strb), + ] + + # sdram_half + self.specials += Instance( + "BUFG", + i_I=unbuf_sdram_half_a, + o_O=self.cd_sdram_half.clk + ) + + clk_sdram_half_shifted = Signal() + self.specials += Instance( + "BUFG", + i_I=unbuf_sdram_half_b, + o_O=clk_sdram_half_shifted + ) + + clk = platform.request("ddram_clock") + self.specials += Instance( + "ODDR2", + p_DDR_ALIGNMENT="NONE", + p_INIT=0, p_SRTYPE="SYNC", + i_D0=1, i_D1=0, i_S=0, i_R=0, i_CE=1, + i_C0=clk_sdram_half_shifted, + i_C1=~clk_sdram_half_shifted, + o_Q=clk.p + ) + + self.specials += Instance( + "ODDR2", + p_DDR_ALIGNMENT="NONE", + p_INIT=0, p_SRTYPE="SYNC", + i_D0=0, i_D1=1, i_S=0, i_R=0, i_CE=1, + i_C0=clk_sdram_half_shifted, + i_C1=~clk_sdram_half_shifted, + o_Q=clk.n + ) + +class BaseSoC(SoCSDRAM): + csr_peripherals = ( + "ddrphy", + ) + csr_map_update(SoCSDRAM.csr_map, csr_peripherals) + + def __init__(self, platform, **kwargs): + clk_freq=(31 + Fraction(1, 4))*1000*1000 + + SoCSDRAM.__init__(self, platform, clk_freq, + integrated_rom_size = 0x8000, + integrated_sram_size = 0x4000, + **kwargs + ) + self.submodules.crg = _CRG(platform, clk_freq) + + # sdram + sdram_module = MT46H32M16(self.clk_freq, "1:2") + self.submodules.ddrphy = s6ddrphy.S6HalfRateDDRPHY( + platform.request("ddram"), + sdram_module.memtype, + rd_bitslip=2, + wr_bitslip=3, + dqs_ddr_alignment="C1" + ) + + controller_settings = ControllerSettings( + with_bandwidth=True + ) + + self.register_sdram(self.ddrphy, + sdram_module.geom_settings, + sdram_module.timing_settings, + controller_settings=controller_settings + ) + + self.comb += [ + self.ddrphy.clk4x_wr_strb.eq(self.crg.clk4x_wr_strb), + self.ddrphy.clk4x_rd_strb.eq(self.crg.clk4x_rd_strb), + ] + +SoC = BaseSoC From 3122301d942d852f5a22fab5f22fbb25b299b5e3 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sun, 29 Oct 2017 22:56:43 -0700 Subject: [PATCH 184/219] targets/cmod_a7: Adding Digilent Cmod A7 board. --- platforms/cmod_a7.py | 186 ++++++++++++++++++++++++++++++++++++ targets/cmod_a7/Makefile.mk | 57 +++++++++++ targets/cmod_a7/base.py | 162 +++++++++++++++++++++++++++++++ 3 files changed, 405 insertions(+) create mode 100644 platforms/cmod_a7.py create mode 100644 targets/cmod_a7/Makefile.mk create mode 100755 targets/cmod_a7/base.py diff --git a/platforms/cmod_a7.py b/platforms/cmod_a7.py new file mode 100644 index 00000000..b4dc0402 --- /dev/null +++ b/platforms/cmod_a7.py @@ -0,0 +1,186 @@ +# This file is Copyright (c) 2017 Tim 'mithro' Ansell +# License: BSD + +from litex.build.generic_platform import * +from litex.build.openocd import OpenOCD +from litex.build.xilinx import XilinxPlatform, XC3SProg, VivadoProgrammer + +_io = [ + + ## LEDs + #set_property -dict { PACKAGE_PIN A17 IOSTANDARD LVCMOS33 } [get_ports { led[0] }]; #IO_L12N_T1_MRCC_16 Sch=led[1] + #set_property -dict { PACKAGE_PIN C16 IOSTANDARD LVCMOS33 } [get_ports { led[1] }]; #IO_L13P_T2_MRCC_16 Sch=led[2] + ("user_led", 0, Pins("H5"), IOStandard("LVCMOS33")), + ("user_led", 1, Pins("J5"), IOStandard("LVCMOS33")), + ("user_led", 2, Pins("T9"), IOStandard("LVCMOS33")), + ("user_led", 3, Pins("T10"), IOStandard("LVCMOS33")), + + #set_property -dict { PACKAGE_PIN B17 IOSTANDARD LVCMOS33 } [get_ports { led0_b }]; #IO_L14N_T2_SRCC_16 Sch=led0_b + #set_property -dict { PACKAGE_PIN B16 IOSTANDARD LVCMOS33 } [get_ports { led0_g }]; #IO_L13N_T2_MRCC_16 Sch=led0_g + #set_property -dict { PACKAGE_PIN C17 IOSTANDARD LVCMOS33 } [get_ports { led0_r }]; #IO_L14P_T2_SRCC_16 Sch=led0_r + ("rgb_leds", 0, + Subsignal("r", Pins("G6 G3 J3 K1")), + Subsignal("g", Pins("F6 J4 J2 H6")), + Subsignal("b", Pins("E1 G4 H4 K2")), + IOStandard("LVCMOS33") + ), + + ("user_sw", 0, Pins("A8"), IOStandard("LVCMOS33")), + ("user_sw", 1, Pins("C11"), IOStandard("LVCMOS33")), + ("user_sw", 2, Pins("C10"), IOStandard("LVCMOS33")), + ("user_sw", 3, Pins("A10"), IOStandard("LVCMOS33")), + + ## Buttons + #set_property -dict { PACKAGE_PIN A18 IOSTANDARD LVCMOS33 } [get_ports { btn[0] }]; #IO_L19N_T3_VREF_16 Sch=btn[0] + #set_property -dict { PACKAGE_PIN B18 IOSTANDARD LVCMOS33 } [get_ports { btn[1] }]; #IO_L19P_T3_16 Sch=btn[1] + ("user_btn", 0, Pins("A18"), IOStandard("LVCMOS33")), + ("user_btn", 1, Pins("B18"), IOStandard("LVCMOS33")), + + ## Clock signal 12 MHz + #set_property -dict { PACKAGE_PIN L17 IOSTANDARD LVCMOS33 } [get_ports { sysclk }]; #IO_L12P_T1_MRCC_14 Sch=gclk + #create_clock -add -name sys_clk_pin -period 83.33 -waveform {0 41.66} [get_ports {sysclk}]; + ("clk12", 0, Pins("L17"), IOStandard("LVCMOS33")), + + ("cpu_reset", 0, Pins("C2"), IOStandard("LVCMOS33")), + + ## UART + #set_property -dict { PACKAGE_PIN J18 IOSTANDARD LVCMOS33 } [get_ports { uart_rxd_out }]; #IO_L7N_T1_D10_14 Sch=uart_rxd_out + #set_property -dict { PACKAGE_PIN J17 IOSTANDARD LVCMOS33 } [get_ports { uart_txd_in }]; #IO_L7P_T1_D09_14 Sch=uart_txd_in + ("serial", 0, + Subsignal("tx", Pins("D10")), + Subsignal("rx", Pins("A9")), + IOStandard("LVCMOS33")), + + ## QSPI - N25Q032A13EF440F + #set_property -dict { PACKAGE_PIN K19 IOSTANDARD LVCMOS33 } [get_ports { qspi_cs }]; #IO_L6P_T0_FCS_B_14 Sch=qspi_cs + #set_property -dict { PACKAGE_PIN D18 IOSTANDARD LVCMOS33 } [get_ports { qspi_dq[0] }]; #IO_L1P_T0_D00_MOSI_14 Sch=qspi_dq[0] + #set_property -dict { PACKAGE_PIN D19 IOSTANDARD LVCMOS33 } [get_ports { qspi_dq[1] }]; #IO_L1N_T0_D01_DIN_14 Sch=qspi_dq[1] + #set_property -dict { PACKAGE_PIN G18 IOSTANDARD LVCMOS33 } [get_ports { qspi_dq[2] }]; #IO_L2P_T0_D02_14 Sch=qspi_dq[2] + #set_property -dict { PACKAGE_PIN F18 IOSTANDARD LVCMOS33 } [get_ports { qspi_dq[3] }]; #IO_L2N_T0_D03_14 Sch=qspi_dq[3] + ("spiflash_4x", 0, # clock needs to be accessed through STARTUPE2 + Subsignal("cs_n", Pins("K19")), + Subsignal("dq", Pins("D18", "D19", "G18", "F18")), + IOStandard("LVCMOS33") + ), + ("spiflash_1x", 0, # clock needs to be accessed through STARTUPE2 + Subsignal("cs_n", Pins("K19")), + Subsignal("mosi", Pins("D18")), # DQ0 + Subsignal("miso", Pins("D19")), # DQ1 + Subsignal("wp", Pins("G18")), # DQ2 + Subsignal("hold", Pins("F18")), # DQ3 + IOStandard("LVCMOS33") + ), + + ## SRAM + ## 512KB SRAM with an 8-bit bus and 8ns access times + #set_property -dict { PACKAGE_PIN M18 IOSTANDARD LVCMOS33 } [get_ports { MemAdr[0] }]; #IO_L11P_T1_SRCC_14 Sch=sram- a[0] + #set_property -dict { PACKAGE_PIN M19 IOSTANDARD LVCMOS33 } [get_ports { MemAdr[1] }]; #IO_L11N_T1_SRCC_14 Sch=sram- a[1] + #set_property -dict { PACKAGE_PIN K17 IOSTANDARD LVCMOS33 } [get_ports { MemAdr[2] }]; #IO_L12N_T1_MRCC_14 Sch=sram- a[2] + #set_property -dict { PACKAGE_PIN N17 IOSTANDARD LVCMOS33 } [get_ports { MemAdr[3] }]; #IO_L13P_T2_MRCC_14 Sch=sram- a[3] + #set_property -dict { PACKAGE_PIN P17 IOSTANDARD LVCMOS33 } [get_ports { MemAdr[4] }]; #IO_L13N_T2_MRCC_14 Sch=sram- a[4] + #set_property -dict { PACKAGE_PIN P18 IOSTANDARD LVCMOS33 } [get_ports { MemAdr[5] }]; #IO_L14P_T2_SRCC_14 Sch=sram- a[5] + #set_property -dict { PACKAGE_PIN R18 IOSTANDARD LVCMOS33 } [get_ports { MemAdr[6] }]; #IO_L14N_T2_SRCC_14 Sch=sram- a[6] + #set_property -dict { PACKAGE_PIN W19 IOSTANDARD LVCMOS33 } [get_ports { MemAdr[7] }]; #IO_L16N_T2_A15_D31_14 Sch=sram- a[7] + #set_property -dict { PACKAGE_PIN U19 IOSTANDARD LVCMOS33 } [get_ports { MemAdr[8] }]; #IO_L15P_T2_DQS_RDWR_B_14 Sch=sram- a[8] + #set_property -dict { PACKAGE_PIN V19 IOSTANDARD LVCMOS33 } [get_ports { MemAdr[9] }]; #IO_L15N_T2_DQS_DOUT_CSO_B_14 Sch=sram- a[9] + #set_property -dict { PACKAGE_PIN W18 IOSTANDARD LVCMOS33 } [get_ports { MemAdr[10] }]; #IO_L16P_T2_CSI_B_14 Sch=sram- a[10] + #set_property -dict { PACKAGE_PIN T17 IOSTANDARD LVCMOS33 } [get_ports { MemAdr[11] }]; #IO_L17P_T2_A14_D30_14 Sch=sram- a[11] + #set_property -dict { PACKAGE_PIN T18 IOSTANDARD LVCMOS33 } [get_ports { MemAdr[12] }]; #IO_L17N_T2_A13_D29_14 Sch=sram- a[12] + #set_property -dict { PACKAGE_PIN U17 IOSTANDARD LVCMOS33 } [get_ports { MemAdr[13] }]; #IO_L18P_T2_A12_D28_14 Sch=sram- a[13] + #set_property -dict { PACKAGE_PIN U18 IOSTANDARD LVCMOS33 } [get_ports { MemAdr[14] }]; #IO_L18N_T2_A11_D27_14 Sch=sram- a[14] + #set_property -dict { PACKAGE_PIN V16 IOSTANDARD LVCMOS33 } [get_ports { MemAdr[15] }]; #IO_L19P_T3_A10_D26_14 Sch=sram- a[15] + #set_property -dict { PACKAGE_PIN W16 IOSTANDARD LVCMOS33 } [get_ports { MemAdr[16] }]; #IO_L20P_T3_A08_D24_14 Sch=sram- a[16] + #set_property -dict { PACKAGE_PIN W17 IOSTANDARD LVCMOS33 } [get_ports { MemAdr[17] }]; #IO_L20N_T3_A07_D23_14 Sch=sram- a[17] + #set_property -dict { PACKAGE_PIN V15 IOSTANDARD LVCMOS33 } [get_ports { MemAdr[18] }]; #IO_L21P_T3_DQS_14 Sch=sram- a[18] + #set_property -dict { PACKAGE_PIN W15 IOSTANDARD LVCMOS33 } [get_ports { MemDB[0] }]; #IO_L21N_T3_DQS_A06_D22_14 Sch=sram-dq[0] + #set_property -dict { PACKAGE_PIN W13 IOSTANDARD LVCMOS33 } [get_ports { MemDB[1] }]; #IO_L22P_T3_A05_D21_14 Sch=sram-dq[1] + #set_property -dict { PACKAGE_PIN W14 IOSTANDARD LVCMOS33 } [get_ports { MemDB[2] }]; #IO_L22N_T3_A04_D20_14 Sch=sram-dq[2] + #set_property -dict { PACKAGE_PIN U15 IOSTANDARD LVCMOS33 } [get_ports { MemDB[3] }]; #IO_L23P_T3_A03_D19_14 Sch=sram-dq[3] + #set_property -dict { PACKAGE_PIN U16 IOSTANDARD LVCMOS33 } [get_ports { MemDB[4] }]; #IO_L23N_T3_A02_D18_14 Sch=sram-dq[4] + #set_property -dict { PACKAGE_PIN V13 IOSTANDARD LVCMOS33 } [get_ports { MemDB[5] }]; #IO_L24P_T3_A01_D17_14 Sch=sram-dq[5] + #set_property -dict { PACKAGE_PIN V14 IOSTANDARD LVCMOS33 } [get_ports { MemDB[6] }]; #IO_L24N_T3_A00_D16_14 Sch=sram-dq[6] + #set_property -dict { PACKAGE_PIN U14 IOSTANDARD LVCMOS33 } [get_ports { MemDB[7] }]; #IO_25_14 Sch=sram-dq[7] + #set_property -dict { PACKAGE_PIN P19 IOSTANDARD LVCMOS33 } [get_ports { RamOEn }]; #IO_L10P_T1_D14_14 Sch=sram-oe + #set_property -dict { PACKAGE_PIN R19 IOSTANDARD LVCMOS33 } [get_ports { RamWEn }]; #IO_L10N_T1_D15_14 Sch=sram-we + #set_property -dict { PACKAGE_PIN N19 IOSTANDARD LVCMOS33 } [get_ports { RamCEn }]; #IO_L9N_T1_DQS_D13_14 Sch=sram-ce + ("sram", 0, + Subsignal( + "a", + Pins("M18 M19 K17 N17 P17 P18 R18 W19", + "U19 V19 W18 T17 T18 U17 U18 V16", + "W16 W17 V15"), + IOStandard("LVCMOS33")), + Subsignal( + "dq", + Pins("W15 W13 W14 U15 U16 V13 V14 U14"), + IOStandard("LVCMOS33")), + Subsignal("oe_n", Pins("R19"), IOStandard("LVCMOS33")), + Subsignal("we_n", Pins("R19"), IOStandard("LVCMOS33")), + Subsignal("ce_n", Pins("N19"), IOStandard("LVCMOS33")), + Misc("SLEW=FAST"), + ), + + ## Analog XADC Pins + ## Only declare these if you want to use pins 15 and 16 as single ended analog inputs. pin 15 -> vaux4, pin16 -> vaux12 + #set_property -dict { PACKAGE_PIN G2 IOSTANDARD LVCMOS33 } [get_ports { xa_n[0] }]; #IO_L1N_T0_AD4N_35 Sch=ain_n[15] + #set_property -dict { PACKAGE_PIN G3 IOSTANDARD LVCMOS33 } [get_ports { xa_p[0] }]; #IO_L1P_T0_AD4P_35 Sch=ain_p[15] + #set_property -dict { PACKAGE_PIN J2 IOSTANDARD LVCMOS33 } [get_ports { xa_n[1] }]; #IO_L2N_T0_AD12N_35 Sch=ain_n[16] + #set_property -dict { PACKAGE_PIN H2 IOSTANDARD LVCMOS33 } [get_ports { xa_p[1] }]; #IO_L2P_T0_AD12P_35 Sch=ain_p[16] + + ## Crypto 1 Wire Interface - ATSHA204A-MAHCZ-T + #set_property -dict { PACKAGE_PIN D17 IOSTANDARD LVCMOS33 } [get_ports { crypto_sda }]; #IO_0_14 Sch=crypto_sda + + ## Pmod Header JA + #set_property -dict { PACKAGE_PIN G17 IOSTANDARD LVCMOS33 } [get_ports { ja[0] }]; #IO_L5N_T0_D07_14 Sch=ja[1] + #set_property -dict { PACKAGE_PIN G19 IOSTANDARD LVCMOS33 } [get_ports { ja[1] }]; #IO_L4N_T0_D05_14 Sch=ja[2] + #set_property -dict { PACKAGE_PIN N18 IOSTANDARD LVCMOS33 } [get_ports { ja[2] }]; #IO_L9P_T1_DQS_14 Sch=ja[3] + #set_property -dict { PACKAGE_PIN L18 IOSTANDARD LVCMOS33 } [get_ports { ja[3] }]; #IO_L8P_T1_D11_14 Sch=ja[4] + #set_property -dict { PACKAGE_PIN H17 IOSTANDARD LVCMOS33 } [get_ports { ja[4] }]; #IO_L5P_T0_D06_14 Sch=ja[7] + #set_property -dict { PACKAGE_PIN H19 IOSTANDARD LVCMOS33 } [get_ports { ja[5] }]; #IO_L4P_T0_D04_14 Sch=ja[8] + #set_property -dict { PACKAGE_PIN J19 IOSTANDARD LVCMOS33 } [get_ports { ja[6] }]; #IO_L6N_T0_D08_VREF_14 Sch=ja[9] + #set_property -dict { PACKAGE_PIN K18 IOSTANDARD LVCMOS33 } [get_ports { ja[7] }]; #IO_L8N_T1_D12_14 Sch=ja[10] +] + + +class Platform(XilinxPlatform): + name = "cmod_a7" + default_clk_name = "clk12" + default_clk_period = 1e9/12e6 + + # From https://www.xilinx.com/support/documentation/user_guides/ug470_7Series_Config.pdf + # 17536096 bits == 2192012 == 0x21728c -- Therefore 0x220000 + gateware_size = 0x220000 + + # Micron N25Q032A13EF440F (ID 0x0016ba20) + # 3V, Multiple I/O, 4KB Sector Erase + # 108 MHz (MAX) clock frequency + # FIXME: Create a "spi flash module" object in the same way we have SDRAM + # module objects. + spiflash_model = "n25q32" + spiflash_read_dummy_bits = 10 + spiflash_clock_div = 4 + spiflash_total_size = int((32/8)*1024*1024) # 32MMbit + spiflash_page_size = 256 + spiflash_sector_size = 0x10000 + + def __init__(self, toolchain="vivado", programmer="openocd"): + XilinxPlatform.__init__(self, "xc7a35t-csg236-1", _io, + toolchain=toolchain) + self.toolchain.bitstream_commands = \ + ["set_property BITSTREAM.CONFIG.SPI_BUSWIDTH 4 [current_design]"] + self.toolchain.additional_commands = \ + ["write_cfgmem -force -format bin -interface spix4 -size 16 " + "-loadbit \"up 0x0 {build_name}.bit\" -file {build_name}.bin"] + self.programmer = programmer + self.add_platform_command("set_property INTERNAL_VREF 0.750 [get_iobanks 34]") + + def create_programmer(self): + if self.programmer == "openocd": + proxy="bscan_spi_{}.bit".format(self.device.split('-')[0]) + return OpenOCD(config="board/digilent_cmod_a7.cfg", flash_proxy_basename=proxy) + elif self.programmer == "vivado": + # n25q32-3.3v-spi-x1_x2_x4 + return VivadoProgrammer(flash_part="n25q32-3.3v-spi-x1_x2_x4") + else: + raise ValueError( + "{} programmer is not supported".format(self.programmer)) diff --git a/targets/cmod_a7/Makefile.mk b/targets/cmod_a7/Makefile.mk new file mode 100644 index 00000000..5f9060f7 --- /dev/null +++ b/targets/cmod_a7/Makefile.mk @@ -0,0 +1,57 @@ +# cmod_a7 targets + +ifneq ($(PLATFORM),cmod_a7) + $(error "Platform should be cmod_a7 when using this file!?") +endif + +# Settings +DEFAULT_TARGET = net +TARGET ?= $(DEFAULT_TARGET) + +PROG_PORT ?= /dev/ttyUSB0 +COMM_PORT ?= /dev/ttyUSB1 +BAUD ?= 115200 + +# Image +image-flash-$(PLATFORM): image-flash-py + @true + +.PHONY: image-flash-$(PLATFORM) + +# Gateware +gateware-load-$(PLATFORM): + openocd -f board/digilent_$(PLATFORM).cfg -c "init; pld load 0 $(TARGET_BUILD_DIR)/gateware/top.bit; exit" + +gateware-flash-$(PLATFORM): gateware-flash-py + @true + +.PHONY: gateware-load-$(PLATFORM) gateware-flash-$(PLATFORM) + +# Firmware +firmware-load-$(PLATFORM): + flterm --port=$(COMM_PORT) --kernel=$(TARGET_BUILD_DIR)/software/firmware/firmware.bin --speed=$(BAUD) + +firmware-flash-$(PLATFORM): firmwage-flash-py + @true + +firmware-connect-$(PLATFORM): + flterm --port=$(COMM_PORT) --speed=$(BAUD) + +.PHONY: firmware-load-$(PLATFORM) firmware-flash-$(PLATFORM) firmware-connect-$(PLATFORM) + +# Bios +bios-flash-$(PLATFORM): + @echo "Unsupported." + @false + +.PHONY: bios-flash-$(PLATFORM) + +# Extra commands +help-$(PLATFORM): + @true + +reset-$(PLATFORM): + @echo "Unsupported." + @false + +.PHONY: help-$(PLATFORM) reset-$(PLATFORM) diff --git a/targets/cmod_a7/base.py b/targets/cmod_a7/base.py new file mode 100755 index 00000000..b9062701 --- /dev/null +++ b/targets/cmod_a7/base.py @@ -0,0 +1,162 @@ +# Support for the Digilent Cmod A7 Board +from litex.gen import * +from litex.gen.genlib.resetsync import AsyncResetSynchronizer + +from litex.soc.integration.soc_core import mem_decoder +from litex.soc.integration.soc_sdram import * +from litex.soc.integration.builder import * + +from litedram.modules import MT41K128M16 +from litedram.phy import a7ddrphy +from litedram.core import ControllerSettings + +from gateware import info +from gateware import led +from gateware import spi_flash + +from targets.utils import csr_map_update, period_ns + + +class _CRG(Module): + def __init__(self, platform): + self.clock_domains.cd_sys = ClockDomain() + self.clock_domains.cd_sys4x = ClockDomain(reset_less=True) + self.clock_domains.cd_sys4x_dqs = ClockDomain(reset_less=True) + self.clock_domains.cd_clk200 = ClockDomain() + self.clock_domains.cd_clk50 = ClockDomain() + + clk100 = platform.request("clk100") + rst = platform.request("cpu_reset") + + pll_locked = Signal() + pll_fb = Signal() + self.pll_sys = Signal() + pll_sys4x = Signal() + pll_sys4x_dqs = Signal() + pll_clk200 = Signal() + pll_clk50 = Signal() + self.specials += [ + Instance("PLLE2_BASE", + p_STARTUP_WAIT="FALSE", o_LOCKED=pll_locked, + + # VCO @ 1600 MHz + p_REF_JITTER1=0.01, p_CLKIN1_PERIOD=10.0, + p_CLKFBOUT_MULT=16, p_DIVCLK_DIVIDE=1, + i_CLKIN1=clk100, i_CLKFBIN=pll_fb, o_CLKFBOUT=pll_fb, + + # 100 MHz + p_CLKOUT0_DIVIDE=16, p_CLKOUT0_PHASE=0.0, + o_CLKOUT0=self.pll_sys, + + # 400 MHz + p_CLKOUT1_DIVIDE=4, p_CLKOUT1_PHASE=0.0, + o_CLKOUT1=pll_sys4x, + + # 400 MHz dqs + p_CLKOUT2_DIVIDE=4, p_CLKOUT2_PHASE=90.0, + o_CLKOUT2=pll_sys4x_dqs, + + # 200 MHz + p_CLKOUT3_DIVIDE=8, p_CLKOUT3_PHASE=0.0, + o_CLKOUT3=pll_clk200, + + # 50MHz + p_CLKOUT4_DIVIDE=32, p_CLKOUT4_PHASE=0.0, + o_CLKOUT4=pll_clk50 + ), + Instance("BUFG", i_I=self.pll_sys, o_O=self.cd_sys.clk), + Instance("BUFG", i_I=pll_sys4x, o_O=self.cd_sys4x.clk), + Instance("BUFG", i_I=pll_sys4x_dqs, o_O=self.cd_sys4x_dqs.clk), + Instance("BUFG", i_I=pll_clk200, o_O=self.cd_clk200.clk), + Instance("BUFG", i_I=pll_clk50, o_O=self.cd_clk50.clk), + AsyncResetSynchronizer(self.cd_sys, ~pll_locked | ~rst), + AsyncResetSynchronizer(self.cd_clk200, ~pll_locked | rst), + AsyncResetSynchronizer(self.cd_clk50, ~pll_locked | ~rst), + ] + + reset_counter = Signal(4, reset=15) + ic_reset = Signal(reset=1) + self.sync.clk200 += \ + If(reset_counter != 0, + reset_counter.eq(reset_counter - 1) + ).Else( + ic_reset.eq(0) + ) + self.specials += Instance("IDELAYCTRL", i_REFCLK=ClockSignal("clk200"), i_RST=ic_reset) + + # 25MHz clock for Ethernet + eth_clk = Signal() + self.specials += [ + Instance("BUFR", p_BUFR_DIVIDE="4", i_CE=1, i_CLR=0, i_I=clk100, o_O=eth_clk), + Instance("BUFG", i_I=eth_clk, o_O=platform.request("eth_ref_clk")), + ] + + +class BaseSoC(SoCSDRAM): + csr_peripherals = ( + "spiflash", + "ddrphy", + "info", + "leds", + "rgb_leds", + ) + csr_map_update(SoCSDRAM.csr_map, csr_peripherals) + + mem_map = { + "spiflash": 0x20000000, # (default shadow @0xa0000000) + } + mem_map.update(SoCSDRAM.mem_map) + + def __init__(self, platform, spiflash="spiflash_1x", **kwargs): + clk_freq = int(100e6) + SoCSDRAM.__init__(self, platform, clk_freq, + integrated_rom_size=0x8000, + integrated_sram_size=0x8000, + **kwargs) + + self.submodules.crg = _CRG(platform) + self.crg.cd_sys.clk.attr.add("keep") + self.platform.add_period_constraint(self.crg.cd_sys.clk, period_ns(clk_freq)) + + # Basic peripherals + self.submodules.info = info.Info(platform, self.__class__.__name__) + self.submodules.leds = led.ClassicLed(Cat(platform.request("user_led", i) for i in range(4))) + self.submodules.rgb_leds = led.RGBLed(platform.request("rgb_leds")) + + # spi flash + spiflash_pads = platform.request(spiflash) + spiflash_pads.clk = Signal() + self.specials += Instance("STARTUPE2", + i_CLK=0, i_GSR=0, i_GTS=0, i_KEYCLEARB=0, i_PACK=0, + i_USRCCLKO=spiflash_pads.clk, i_USRCCLKTS=0, i_USRDONEO=1, i_USRDONETS=1) + spiflash_dummy = { + "spiflash_1x": 9, + "spiflash_4x": 11, + } + self.submodules.spiflash = spi_flash.SpiFlash( + spiflash_pads, + dummy=spiflash_dummy[spiflash], + div=2) + self.add_constant("SPIFLASH_PAGE_SIZE", 256) + self.add_constant("SPIFLASH_SECTOR_SIZE", 0x10000) + self.add_wb_slave(mem_decoder(self.mem_map["spiflash"]), self.spiflash.bus) + self.add_memory_region( + "spiflash", self.mem_map["spiflash"] | self.shadow_base, 16*1024*1024) + + + # sdram + sdram_module = MT41K128M16(self.clk_freq, "1:4") + self.submodules.ddrphy = a7ddrphy.A7DDRPHY( + platform.request("ddram")) + self.add_constant("A7DDRPHY_BITSLIP", 2) + self.add_constant("A7DDRPHY_DELAY", 6) + controller_settings = ControllerSettings( + with_bandwidth=True, + cmd_buffer_depth=8, + with_refresh=True) + self.register_sdram(self.ddrphy, + sdram_module.geom_settings, + sdram_module.timing_settings, + controller_settings=controller_settings) + +SoC = BaseSoC From 80d61f61b19d6d1a5ed7564477b08e5d04286c75 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sun, 29 Oct 2017 23:58:21 -0700 Subject: [PATCH 185/219] platforms: Adding PicoEVB platform. --- platforms/picoevb.py | 135 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 platforms/picoevb.py diff --git a/platforms/picoevb.py b/platforms/picoevb.py new file mode 100644 index 00000000..e1d97aa1 --- /dev/null +++ b/platforms/picoevb.py @@ -0,0 +1,135 @@ +from litex.build.generic_platform import * +from litex.build.xilinx import XilinxPlatform, VivadoProgrammer + +_io = [ + # SYS clock 100 MHz (input) signal. The sys_clk_p and sys_clk_n + # signals are the PCI Express reference clock. + #set_property PACKAGE_PIN B6 [get_ports sys_clk_p] + ("clk100", 0, Pins("B6"), IOStandard("LVCMOS33")), + + #set_property PACKAGE_PIN V14 [get_ports {status_leds[3]}] + #set_property PACKAGE_PIN V13 [get_ports {status_leds[2]}] + #set_property PACKAGE_PIN V11 [get_ports {status_leds[1]}] + #set_property PACKAGE_PIN V12 [get_ports {status_leds[0]}] + #set_property IOSTANDARD LVCMOS33 [get_ports {status_leds[3]}] + #set_property IOSTANDARD LVCMOS33 [get_ports {status_leds[2]}] + #set_property IOSTANDARD LVCMOS33 [get_ports {status_leds[1]}] + #set_property IOSTANDARD LVCMOS33 [get_ports {status_leds[0]}] + #set_property PULLUP true [get_ports {status_leds[3]}] + #set_property PULLUP true [get_ports {status_leds[2]}] + #set_property PULLUP true [get_ports {status_leds[1]}] + #set_property PULLUP true [get_ports {status_leds[0]}] + #set_property DRIVE 8 [get_ports {status_leds[3]}] + #set_property DRIVE 8 [get_ports {status_leds[2]}] + #set_property DRIVE 8 [get_ports {status_leds[1]}] + #set_property DRIVE 8 [get_ports {status_leds[0]}] + ("user_led", 0, Pins("V12"), IOStandard("LVCMOS33"), Drive(8), Misc("PULLUP")), + ("user_led", 1, Pins("V11"), IOStandard("LVCMOS33"), Drive(8), Misc("PULLUP")), + ("user_led", 2, Pins("V13"), IOStandard("LVCMOS33"), Drive(8), Misc("PULLUP")), + ("user_led", 3, Pins("V14"), IOStandard("LVCMOS33"), Drive(8), Misc("PULLUP")), + + ## Serial input/output + ## Available on NanoEVB only! + #set_property IOSTANDARD LVCMOS33 [get_ports RxD] + #set_property IOSTANDARD LVCMOS33 [get_ports TxD] + #set_property PACKAGE_PIN V17 [get_ports RxD] + #set_property PACKAGE_PIN V16 [get_ports TxD] + #set_property PULLUP true [get_ports RxD] + #set_property OFFCHIP_TERM NONE [get_ports TxD] + ("serial", 0, + Subsignal("tx", Pins("V16")), # MCU_RX + Subsignal("rx", Pins("V17")), # MCU_TX + IOStandard("LVCMOS33"), + ), + + ## SYS reset (input) signal. The sys_reset_n signal is generated + ## by the PCI Express interface (PERST#). + #set_property PACKAGE_PIN A10 [get_ports sys_rst_n] + #set_property IOSTANDARD LVCMOS33 [get_ports sys_rst_n] + #set_property PULLDOWN true [get_ports sys_rst_n] + + ## PCIe x1 link + #set_property PACKAGE_PIN G4 [get_ports pcie_mgt_rxp] + #set_property PACKAGE_PIN G3 [get_ports pcie_mgt_rxn] + #set_property PACKAGE_PIN B2 [get_ports pcie_mgt_txp] + #set_property PACKAGE_PIN B1 [get_ports pcie_mgt_txn] + ("pcie_x1", 0, + Subsignal("rst_n", Pins("A10"), IOStandard("LVCMOS33"), Misc("PULLDOWN")), + Subsignal("clk_p", Pins("D6")), + Subsignal("clk_n", Pins("D5")), + Subsignal("rx_p", Pins("G4")), + Subsignal("rx_n", Pins("G3")), + Subsignal("tx_p", Pins("B2")), + Subsignal("tx_n", Pins("B1")) + ), + + ## clkreq_l is active low clock request for M.2 card to + ## request PCI Express reference clock + #set_property PACKAGE_PIN A9 [get_ports clkreq_l] + #set_property IOSTANDARD LVCMOS33 [get_ports clkreq_l] + #set_property PULLDOWN true [get_ports clkreq_l] + + ## High-speed configuration so FPGA is up in time to negotiate with PCIe root complex + #set_property BITSTREAM.CONFIG.CONFIGRATE 33 [current_design] + #set_property BITSTREAM.CONFIG.SPI_BUSWIDTH 4 [current_design] + #set_property CONFIG_MODE SPIx4 [current_design] + #set_property BITSTREAM.CONFIG.SPI_FALL_EDGE YES [current_design] + #set_property BITSTREAM.GENERAL.COMPRESS TRUE [current_design] +] + + +class Platform(XilinxPlatform): + name = "picoevb" + default_clk_name = "clk100" + default_clk_period = 10.0 + + # From https://www.xilinx.com/support/documentation/user_guides/ug470_7Series_Config.pdf + # 17536096 bits == 2192012 == 0x21728c -- Therefore 0x220000 + gateware_size = 0x220000 + + # ??? + # FIXME: Create a "spi flash module" object in the same way we have SDRAM + # module objects. + spiflash_read_dummy_bits = 10 + spiflash_clock_div = 4 + spiflash_total_size = int((256/8)*1024*1024) # 256Mbit + spiflash_page_size = 256 + spiflash_sector_size = 0x10000 + spiflash_model = "n25q128" + + def __init__(self, toolchain="vivado", programmer="vivado"): + XilinxPlatform.__init__(self, "xc7a50t-csg325-2", _io, + toolchain=toolchain) + + self.add_platform_command( + "set_property CONFIG_VOLTAGE 1.5 [current_design]") + self.add_platform_command( + "set_property CFGBVS GND [current_design]") + self.add_platform_command( + "set_property BITSTREAM.CONFIG.CONFIGRATE 22 [current_design]") + self.add_platform_command( + "set_property BITSTREAM.CONFIG.SPI_BUSWIDTH 1 [current_design]") + self.toolchain.bitstream_commands = [ + "set_property CONFIG_VOLTAGE 1.5 [current_design]", + "set_property CFGBVS GND [current_design]", + "set_property BITSTREAM.CONFIG.CONFIGRATE 22 [current_design]", + "set_property BITSTREAM.CONFIG.SPI_BUSWIDTH 1 [current_design]", + ] + self.toolchain.additional_commands = \ + ["write_cfgmem -verbose -force -format bin -interface spix1 -size 64 " + "-loadbit \"up 0x0 {build_name}.bit\" -file {build_name}.bin"] + self.programmer = programmer + + self.add_platform_command(""" +create_clock -name pcie_phy_clk -period 10.0 [get_pins {{pcie_phy/pcie_support_i/pcie_i/inst/inst/gt_top_i/pipe_wrapper_i/pipe_lane[0].gt_wrapper_i/gtp_channel.gtpe2_channel_i/TXOUTCLK}}] +""") + + def create_programmer(self): + if self.programmer == "vivado": + return VivadoProgrammer(flash_part="n25q128-3.3v-spi-x1_x2_x4") + else: + raise ValueError("{} programmer is not supported" + .format(self.programmer)) + + def do_finalize(self, fragment): + XilinxPlatform.do_finalize(self, fragment) From 24d9aaba768bb0dcbc59ab4fc6d79ecceee0a0c3 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Wed, 17 Jan 2018 12:14:16 +1100 Subject: [PATCH 186/219] platforms: Starting to add Numato Galatea board. --- platforms/galatea.py | 519 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 519 insertions(+) create mode 100644 platforms/galatea.py diff --git a/platforms/galatea.py b/platforms/galatea.py new file mode 100644 index 00000000..8cda36a1 --- /dev/null +++ b/platforms/galatea.py @@ -0,0 +1,519 @@ +# Support for the Numato Galatea - PCI Express Spartan 6 Development Board +# https://numato.com/product/galatea-pci-express-spartan-6-fpga-development-board + +from collections import OrderedDict + +from litex.build.generic_platform import * +from litex.build.xilinx import XilinxPlatform, iMPACT + + +_io = [ + # Clock U18 - 100MHz - CMOS Crystal Oscillator + #NET "CLK1" LOC = "G9" | IOSTANDARD = "LVCMOS33" | Period = 100 MHz; # Bank = 0 + ("clk100", 0, Pins("AB13"), IOStandard("LVCMOS33")), + # Clock U19 - 100MHz - CMOS Crystal Oscillator + #NET "CLK2" LOC = "Y13" | IOSTANDARD = "LVCMOS33" | Period = 100 MHz; # Bank = 2 + ("clk2", 0, Pins("AB13"), IOStandard("LVCMOS33")), + # Clock U17 - 100MHz - CMOS Crystal Oscillator + #NET "CLK3" LOC = "AB13" | IOSTANDARD = "LVCMOS33" | Period = 100 MHz; # Bank = 2 + ("clk3", 0, Pins("AB13"), IOStandard("LVCMOS33")), + + # Clock U21 SMA Clock + #NET "EXT_CLK1" LOC = "U12" | IOSTANDARD = "LVCMOS33"; # Bank = 2 + + # Clock U6 SMA Clock + #NET "EXT_CLK2" LOC = "T12" | IOSTANDARD = "LVCMOS33"; # Bank = 2 + + # SW1 Switch + + ## SW_PUSH - component SW1 + # Connected to Bank 3 - 1.5V bank + #NET "RST_N" LOC = "AB19" | IOSTANDARD = "LVCMOS33" | PULLUP ; # Bank = 2 + ("cpu_reset", 0, Pins("AB19"), IOStandard("LVCMOS15"), Misc("PULLUP")), + + ######################################################################################################################################################## + # UART # + ######################################################################################################################################################## + + #NET "UART_TX" LOC = "V17" | IOSTANDARD = "LVCMOS33"; # Bank = 2 + #NET "UART_RX" LOC = "W18" | IOSTANDARD = "LVCMOS33"; # Bank = 2 + + ######################################################################################################################################################## + # SPI Flash # + ######################################################################################################################################################## + + #NET "SPI_Flash_SCK" LOC = "Y20" | IOSTANDARD = "LVCMOS33"; # Bank = 2 + #NET "SPI_Flash_MISO" LOC = "T14" | IOSTANDARD = "LVCMOS33"; # Bank = 2 + #NET "SPI_Flash_MOSI" LOC = "AB20" | IOSTANDARD = "LVCMOS33"; # Bank = 2 + #NET "SPI_Flash_SS" LOC = "AA3" | IOSTANDARD = "LVCMOS33"; # Bank = 2 + + ## onBoard Quad-SPI Flash + ## N25Q128A13ESE40E - 128 Mb QSPI flash memory + + #QSPI_FLASH_SCLK Y20 LVCMOS33 16 FAST + #QSPI_FLASH_IO0 AB20 LVCMOS33 16 FAST + #QSPI_FLASH_IO1 AA20 LVCMOS33 16 FAST + #QSPI_FLASH_IO2 R13 LVCMOS33 16 FAST + #QSPI_FLASH_IO3 T14 LVCMOS33 16 FAST + #QSPI_FLASH_SS AA3 LVCMOS33 16 FAST + + + ("spiflash1x", 0, + #NET "SPI_Flash_SCK" LOC = "Y20" | IOSTANDARD = "LVCMOS33"; # Bank = 2 + Subsignal("clk", Pins("Y20")), + #NET "SPI_Flash_SS" LOC = "AA3" | IOSTANDARD = "LVCMOS33"; # Bank = 2 + Subsignal("cs_n", Pins("AA3")), + #NET "SPI_Flash_MISO" LOC = "T14" | IOSTANDARD = "LVCMOS33"; # Bank = 2 + #NET "SPI_Flash_MOSI" LOC = "AB20" | IOSTANDARD = "LVCMOS33"; # Bank = 2 + #Subsignal("dq", Pins("AB20", "AA20", "R13", "T14")), + IOStandard("LVCMOS33"), Misc("SLEW=FAST") + ), + + ## onBoard Leds + # NET "Led<0>" LOC = "U18"; # Bank = 1, Pin name = IO_L52N_M1DQ15, Sch name = LD0 + #("user_led", 0, Pins("U18")), + + # frontend switches / leds + ("hdled", 0, Pins("J7"), IOStandard("LVCMOS15")), + ("pwled", 0, Pins("H8"), IOStandard("LVCMOS15")), #pwled+ connected to 3.3V + ("pwrsw", 0, Pins("F5"), IOStandard("LVCMOS15")), + + ## TEMAC Ethernet MAC - FIXME + # 10/100/1000 Ethernet PHY + ## RTL8211E-VL - component U20 - RGMII + ("eth_clocks", 0, + Subsignal("tx", Pins("AB12")), + Subsignal("rx", Pins("AA12")), + IOStandard("LVCMOS33") + ), + ("eth", 0, + Subsignal("rst_n", Pins("U8")), + Subsignal("int_n", Pins("V9")), + Subsignal("mdio", Pins("T8")), + Subsignal("mdc", Pins("V7")), + Subsignal("rx_ctl", Pins("U9")), + Subsignal("rx_data", Pins("R9 R8 W6 Y6")), + Subsignal("tx_ctl", Pins("W8")), + Subsignal("tx_data", Pins("W9 Y8 AA6 AB6")), + IOStandard("LVCMOS33") + ), + + ## Opsis I2C Bus + # Connected to both the EEPROM and the FX2. + # + ## 24AA02E48 - component U23 + # 2 Kbit Electrically Erasable PROM + # Pre-programmed Globally Unique, 48-bit Node Address + # The device is organized as two blocks of 128 x 8-bit memory with a 2-wire serial interface. + ## \/ Strongly pulled (2k) to VCC3V3 via R34 + #NET "eeprom_scl" LOC = "G6" |IOSTANDARD = I2C; # (/Ethernet/MAC_SCL) + #NET "eeprom_sda" LOC = "C1" |IOSTANDARD = I2C; # (/Ethernet/MAC_SDA) + ("opsis_i2c", 0, + Subsignal("scl", Pins("G6"), IOStandard("I2C")), + Subsignal("sda", Pins("C1"), IOStandard("I2C")), + ), + + ## DDR3 + # MT41J128M16JT-125:K - 16 Meg x 16 x 8 Banks - DDR3-1600 11-11-11 + # FBGA Code: D9PSL, Part Number: MT41J128M16 - http://www.micron.com/support/fbga + ("ddram_clock", 0, + Subsignal("p", Pins("K4")), + Subsignal("n", Pins("K3")), + IOStandard("DIFF_SSTL15_II"), Misc("IN_TERM=NONE") + ), + ("ddram", 0, + Subsignal("cke", Pins("F2"), IOStandard("SSTL15_II")), + Subsignal("ras_n", Pins("M5"), IOStandard("SSTL15_II")), + Subsignal("cas_n", Pins("M4"), IOStandard("SSTL15_II")), + Subsignal("we_n", Pins("H2"), IOStandard("SSTL15_II")), + Subsignal("ba", Pins("J3 J1 H1"), IOStandard("SSTL15_II")), + Subsignal("a", Pins("K2 K1 K5 M6 H3 L4 M3 K6 G3 G1 J4 E1 F1 J6 H5"), IOStandard("SSTL15_II")), + Subsignal("dq", Pins( + "R3 R1 P2 P1 L3 L1 M2 M1", + "T2 T1 U3 U1 W3 W1 Y2 Y1"), IOStandard("SSTL15_II")), + Subsignal("dqs", Pins("N3 V2"), IOStandard("DIFF_SSTL15_II")), + Subsignal("dqs_n", Pins("N1 V1"), IOStandard("DIFF_SSTL15_II")), + Subsignal("dm", Pins("N4 P3"), IOStandard("SSTL15_II")), + Subsignal("odt", Pins("L6"), IOStandard("SSTL15_II")), + Subsignal("reset_n", Pins("E3"), IOStandard("LVCMOS15")), + Misc("SLEW=FAST"), + Misc("VCCAUX_IO=HIGH") + ), + + ## onboard HDMI IN1 + ## HDMI - connector J5 - Direction RX + ("hdmi_in", 0, + Subsignal("clk_p", Pins("L20"), IOStandard("TMDS_33")), + Subsignal("clk_n", Pins("L22"), IOStandard("TMDS_33")), + Subsignal("data0_p", Pins("M21"), IOStandard("TMDS_33")), + Subsignal("data0_n", Pins("M22"), IOStandard("TMDS_33")), + Subsignal("data1_p", Pins("N20"), IOStandard("TMDS_33")), + Subsignal("data1_n", Pins("N22"), IOStandard("TMDS_33")), + Subsignal("data2_p", Pins("P21"), IOStandard("TMDS_33")), + Subsignal("data2_n", Pins("P22"), IOStandard("TMDS_33")), + Subsignal("scl", Pins("T21"), IOStandard("LVCMOS33")), + Subsignal("sda", Pins("R22"), IOStandard("LVCMOS33")), + Subsignal("hpd_en", Pins("R20"), IOStandard("LVCMOS33")) + ), + + ## onboard HDMI IN2 + ## HDMI - connector J4 - Direction RX + ("hdmi_in", 1, + Subsignal("clk_p", Pins("M20"), IOStandard("TMDS_33")), + Subsignal("clk_n", Pins("M19"), IOStandard("TMDS_33")), + Subsignal("data0_p", Pins("J20"), IOStandard("TMDS_33")), + Subsignal("data0_n", Pins("J22"), IOStandard("TMDS_33")), + Subsignal("data1_p", Pins("H21"), IOStandard("TMDS_33")), + Subsignal("data1_n", Pins("H22"), IOStandard("TMDS_33")), + Subsignal("data2_p", Pins("K20"), IOStandard("TMDS_33")), + Subsignal("data2_n", Pins("L19"), IOStandard("TMDS_33")), + Subsignal("scl", Pins("L17"), IOStandard("LVCMOS33")), + Subsignal("sda", Pins("T18"), IOStandard("LVCMOS33")), + Subsignal("hpd_en", Pins("V19"), IOStandard("LVCMOS33")) + ), + + # Debug header? + #("debug", 0, Pins("AA2"), IOStandard("LVCMOS15")), # (/FPGA_Bank_0_3/DEBUG_IO0) + + ## onboard HDMI OUT1 + ## HDMI - connector J3 - Direction TX + ("hdmi_out", 0, + Subsignal("clk_p", Pins("Y11"), IOStandard("TMDS_33")), + Subsignal("clk_n", Pins("AB11"), IOStandard("TMDS_33")), + Subsignal("data0_p", Pins("W12"), IOStandard("TMDS_33")), + Subsignal("data0_n", Pins("Y12"), IOStandard("TMDS_33")), + Subsignal("data1_p", Pins("AA10"), IOStandard("TMDS_33")), + Subsignal("data1_n", Pins("AB10"), IOStandard("TMDS_33")), + Subsignal("data2_p", Pins("Y9"), IOStandard("TMDS_33")), + Subsignal("data2_n", Pins("AB9"), IOStandard("TMDS_33")), + Subsignal("scl", Pins("Y7"), IOStandard("I2C")), + Subsignal("sda", Pins("Y10"), IOStandard("I2C")), + Subsignal("hpd_notif", Pins("AB7"), IOStandard("LVCMOS33")) + ), + + ## onboard HDMI OUT2 + ## HDMI - connector J2 - Direction TX + ("hdmi_out", 1, + Subsignal("clk_p", Pins("T12"), IOStandard("TMDS_33")), + Subsignal("clk_n", Pins("U12"), IOStandard("TMDS_33")), + Subsignal("data0_p", Pins("Y15"), IOStandard("TMDS_33")), + Subsignal("data0_n", Pins("AB15"), IOStandard("TMDS_33")), + Subsignal("data1_p", Pins("AA16"), IOStandard("TMDS_33")), + Subsignal("data1_n", Pins("AB16"), IOStandard("TMDS_33")), + Subsignal("data2_p", Pins("U14"), IOStandard("TMDS_33")), + Subsignal("data2_n", Pins("U13"), IOStandard("TMDS_33")), + Subsignal("scl", Pins("Y17"), IOStandard("I2C")), + Subsignal("sda", Pins("AB17"), IOStandard("I2C")), + Subsignal("hpd_notif", Pins("AB18"), IOStandard("LVCMOS33")) + ), + + # FX2 USB Interface + # CY7C68013A_100AC - component U2 + ("fx2", 0, + #NET "fx2_ifclk" LOC = "P20" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY-IFCLK) + Subsignal("ifclk", Pins("P20"), IOStandard("LVCMOS33")), + #NET "fx2_fd<0>" LOC = "C20" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_FD0) + #NET "fx2_fd<1>" LOC = "C22" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_FD1) + #NET "fx2_fd<2>" LOC = "L15" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_FD2) + #NET "fx2_fd<3>" LOC = "K16" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_FD3) + #NET "fx2_fd<4>" LOC = "D21" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_FD4) + #NET "fx2_fd<5>" LOC = "D22" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_FD5) + #NET "fx2_fd<6>" LOC = "G19" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_FD6) + #NET "fx2_fd<7>" LOC = "F20" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_FD7) + #NET "fx2_fd<8>" LOC = "H18" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_FD8) + #NET "fx2_fd<9>" LOC = "H19" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_FD9) + #NET "fx2_fd<10>" LOC = "F21" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_FD10) + #NET "fx2_fd<11>" LOC = "F22" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_FD11) + #NET "fx2_fd<12>" LOC = "E20" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_FD12) + #NET "fx2_fd<13>" LOC = "E22" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_FD13) + #NET "fx2_fd<14>" LOC = "J19" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_FD14) + #NET "fx2_fd<15>" LOC = "H20" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_FD15) + Subsignal("data", Pins("C20 C22 L15 K16 D21 D22 G19 F20 H18 H19 F21 F22 E20 E22 J19 H20"), IOStandard("LVCMOS33")), + #NET "fx2_fifoadr<0>" LOC = "B21" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_PA4) + #NET "fx2_fifoadr<1>" LOC = "B22" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_PA5) + Subsignal("addr", Pins("B21 B22"), IOStandard("LVCMOS33"), Misc("DRIVE=12")), + #NET "fx2_flaga" LOC = "N16" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_CTL0) + #NET "fx2_flagb" LOC = "P16" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_CTL1) + #NET "fx2_flagc" LOC = "R15" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_CTL2) + Subsignal("flaga", Pins("N16"), IOStandard("LVCMOS33"), Misc("DRIVE=12")), + Subsignal("flagb", Pins("P16"), IOStandard("LVCMOS33"), Misc("DRIVE=12")), + Subsignal("flagc", Pins("R15"), IOStandard("LVCMOS33"), Misc("DRIVE=12")), + #NET "fx2_flagd/slcs_n" LOC = "J17" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_PA7) + Subsignal("cs_n", Pins("J17"), IOStandard("LVCMOS33"), Misc("DRIVE=12")), + #NET "fx2_slrd" LOC = "P19" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_RD0) + Subsignal("rd_n", Pins("P19"), IOStandard("LVCMOS33"), Misc("DRIVE=12")), + #NET "fx2_slwr" LOC = "R19" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_RD1) + Subsignal("wr_n", Pins("R19"), IOStandard("LVCMOS33")), + #NET "fx2_sloe" LOC = "H16" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_PA2) + Subsignal("oe_n", Pins("H16"), IOStandard("LVCMOS33"), Misc("DRIVE=12")), + #NET "fx2_pktend" LOC = "J16" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_PA6) + Subsignal("pktend_n", Pins("J16"), IOStandard("LVCMOS33"), Misc("DRIVE=12")), + + #NET "fx2_ctl<3>" LOC = "M18" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_CTL3) + #NET "fx2_ctl<4>" LOC = "M17" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_CTL4) + #NET "fx2_ctl<5>" LOC = "R16" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_CTL5) + #NET "fx2_init5_n" LOC = "T19" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_INT5) + #NET "fx2_int<0>" LOC = "F18" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_PA0) + #NET "fx2_int<1>" LOC = "F19" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_PA1) + #NET "fx2_wu<2>" LOC = "H17" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_PA3) + #NET "fx2_gpifadr<0>" LOC = "U20" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_PC0) + #NET "fx2_gpifadr<1>" LOC = "U22" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_PC1) + #NET "fx2_gpifadr<2>" LOC = "V21" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_PC2) + #NET "fx2_gpifadr<3>" LOC = "V22" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_PC3) + #NET "fx2_gpifadr<4>" LOC = "W20" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_PC4) + #NET "fx2_gpifadr<5>" LOC = "W22" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_PC5) + #NET "fx2_gpifadr<6>" LOC = "Y21" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_PC6) + #NET "fx2_gpifadr<7>" LOC = "Y22" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_PC7) + #NET "fx2_gpifadr<8>" LOC = "AB21" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Power/DONE | Net-(R28-Pad1)) + # Timers + #NET "fx2_t<0>" LOC = "G17" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/SPI_Flash/TDO-FPGA/TDO-JTAG | Net-(P3-Pad8) | Net-(R14-Pad1)) + ## \/ Strongly pulled (4k) to VCC3V3 via R56 + #NET "fx2_t<1>" LOC = "AB2" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Power/PROG_B | Net-(R15-Pad1)) + #NET "fx2_t<2>" LOC = "E18" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/SPI_Flash/TDO-USB/TDI-FPGA | Net-(P3-Pad10) | Net-(R23-Pad1)) + #NET "fx2_rd_n" LOC = "K19" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_RD) + #NET "fx2_rdy<2>" LOC = "M16" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_RD2) + #NET "fx2_rdy<3>" LOC = "N15" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_RD3) + #NET "fx2_rdy<4>" LOC = "U19" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_RD4) + #NET "fx2_rdy<5>" LOC = "T20" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_RD5) + ## UART0 + #NET "fx2_rxd0" LOC = "P18" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_RXD1) + #NET "fx2_txd0" LOC = "T17" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_TXD1) + ## UART1 + #NET "fx2_rxd1" LOC = "P17" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_RXD0) + #NET "fx2_txd1" LOC = "R17" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_TXD0) + # + #NET "fx2_t0" LOC = "G20" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_T0) + #NET "fx2_wr_n" LOC = "K18" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_WR) + # JTAG + # - TMS? + #NET "fx2_rxd<0>" LOC = "D20" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Power/TMS | Net-(P3-Pad4) | Net-(R24-Pad1)) + # - TCK + #NET "fx2_rxd<1>" LOC = "A21" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Power/TCK | Net-(P3-Pad6) | Net-(R26-Pad1)) + ## \/ Strongly pulled (4k) to VCC3V3 via R52 + #NET "fx2_t<2>" LOC = "Y4" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/INIT_B | Net-(R27-Pad1)) + + ## Same pins as the EEPROM + ## \/ Strongly pulled (2k) to VCC3V3 via R34 + #NET "fx2_scl" LOC = "G6" |IOSTANDARD = I2C; # (/Ethernet/MAC_SCL) + #Subsignal("scl", Pins("G6"), IOStandard("I2C")), + #NET "fx2_sda" LOC = "C1" |IOSTANDARD = I2C; # (/Ethernet/MAC_SDA) + #Subsignal("sda", Pins("C1"), IOStandard("I2C")), + ), + ("fx2_reset", 0, Pins("G22"), IOStandard("LVCMOS33"), Misc("PULLUP"), Misc("DRIVE=24"), Misc("SLEW=SLOW")), + + # To Cypress FX2 UART0 + # WARNING: This was labelled incorrectly - https://github.com/timvideos/HDMI2USB-numato-opsis-hardware/issues/13 + # Can be accessed via `opsis-mode-switch --mode=serial` + # FIXME: Will be supported by `opsis-mode-switch --mode=jtag` longer term. + ("fx2_serial", 0, + # CY_RXD1 - P18 - Cypress RXD0 + Subsignal("tx", Pins("P18"), IOStandard("LVCMOS33")), + # CY_TXD1 - T17 - Cypress TXD0 + Subsignal("rx", Pins("T17"), IOStandard("LVCMOS33"), Misc("PULLUP")), + ), + # To Cypress FX2 UART1 + #("serial", 1, + # Subsignal("rx", Pins("A16"), IOStandard("LVCMOS33")), + # Subsignal("tx", Pins("B16"), IOStandard("LVCMOS33")), + #), + # + + # FIXME: This assumes a TOFE LowSpeedIO board is currently connected. + # ----------------------------------- + ("tofe", 0, + Subsignal("rst", Pins(tofe_pin("pcie_reset")), IOStandard("I2C"), Misc("PULLUP")), + Subsignal("scl", Pins(tofe_pin("smclk")), IOStandard("I2C")), + Subsignal("sda", Pins(tofe_pin("smdat")), IOStandard("I2C")), + ), + + ("tofe_io", + Subsignal("a_io_p", Pins(" ".join(p for n, p in sorted(_tofe_io.items()) if n.endswith('p') and 'io_a' in n))), + Subsignal("a_io_n", Pins(" ".join(p for n, p in sorted(_tofe_io.items()) if n.endswith('n') and 'io_a' in n))), + Subsignal("b_io_p", Pins(" ".join(p for n, p in sorted(_tofe_io.items()) if n.endswith('p') and 'io_b' in n))), + Subsignal("b_io_n", Pins(" ".join(p for n, p in sorted(_tofe_io.items()) if n.endswith('n') and 'io_b' in n))), + ), + + # serial + ("tofe_lsio_serial", 0, + Subsignal("tx", Pins(tofe_pin(tofe_low_speed_io("rx")))), + Subsignal("rx", Pins(tofe_pin(tofe_low_speed_io("tx"))), Misc("PULLUP")), + IOStandard("LVCMOS33") + ), + + # user leds + ("tofe_lsio_user_led", 0, Pins(tofe_pin(tofe_low_speed_io("led1"))), IOStandard("LVCMOS33"), Misc("DRIVE=12")), + ("tofe_lsio_user_led", 1, Pins(tofe_pin(tofe_low_speed_io("led2"))), IOStandard("LVCMOS33"), Misc("DRIVE=12")), + ("tofe_lsio_user_led", 2, Pins(tofe_pin(tofe_low_speed_io("led3"))), IOStandard("LVCMOS33"), Misc("DRIVE=12")), + ("tofe_lsio_user_led", 3, Pins(tofe_pin(tofe_low_speed_io("led4"))), IOStandard("LVCMOS33"), Misc("DRIVE=12")), + + # push buttons + ("tofe_lsio_user_sw", 0, Pins(tofe_pin(tofe_low_speed_io("sw1"))), IOStandard("LVCMOS33"), Misc("PULLUP")), + ("tofe_lsio_user_sw", 1, Pins(tofe_pin(tofe_low_speed_io("sw2"))), IOStandard("LVCMOS33"), Misc("PULLUP")), + ("tofe_lsio_user_sw", 2, Pins(tofe_pin(tofe_low_speed_io("sw3"))), IOStandard("LVCMOS33"), Misc("PULLUP")), + ("tofe_lsio_user_sw", 3, Pins(tofe_pin(tofe_low_speed_io("sw4"))), IOStandard("LVCMOS33"), Misc("PULLUP")), + + # PmodUSBUART or similar device connected to the "p3" Pmod connector. + ("tofe_lsio_pmod_serial", 0, + # PmodUSBUART - Pmod Type4 - UART + # Pin 1 - CTS - In - Peripheral can transmit + # Pin 2 - TXD - Out - Data - Host to peripheral + # Pin 3 - RXD - In - Data - Peripheral to host + # Pin 4 - RTS - Out - Peripheral ready for data + # Pin 5 - GND + # Pin 6 - VCC + Subsignal("tx", Pins(tofe_pin(tofe_low_speed_pmod_io('p3', 2)))), + Subsignal("rx", Pins(tofe_pin(tofe_low_speed_pmod_io('p3', 3))), Misc("PULLUP")), + IOStandard("LVCMOS33") + ), +] + +pt = None +tofe_signals = [[], []] +for n, v in _tofe_io.items(): + if not n.startswith("diff"): + continue + + _, t, p = n.split('_') + + if t != pt: + assert len(tofe_signals[-1]) == len(tofe_signals[-2]) + + tofe_signals.append(["{}_{}_{}".format(t, p[0], 'n')]) + tofe_signals.append(["{}_{}_{}".format(t, p[0], 'p')]) + pt = t + + if p.endswith('n'): + tofe_signals[-2].append(n) + elif p.endswith('p'): + tofe_signals[-1].append(n) + + +## import pprint +## pprint.pprint(tofe_signals) +## +## pprint.pprint(list( +## (i[0], (" ".join(_tofe_io[p] for p in i[1:])), IOStandard("LVCMOS33")) for i in tofe_signals[2:])) + +_io.append(["tofe", 0]+[ + Subsignal(i[0], Pins(" ".join(_tofe_io[p] for p in i[1:])), IOStandard("LVCMOS33")) for i in tofe_signals[2:] + ] +) + + +_connectors = [ +] + +_hdmi_infos = { + "HDMI_OUT0_MNEMONIC": "TX1", + "HDMI_OUT0_DESCRIPTION" : ( + " The *first* HDMI port from the left.\\r\\n" + " Labeled J3 and HDMI Out 1.\\r\\n" + ), + + "HDMI_OUT1_MNEMONIC": "TX2", + "HDMI_OUT1_DESCRIPTION" : ( + " The *second* HDMI port from the left.\\r\\n" + " Labeled J2 and HDMI Out 2.\\r\\n" + ), + + "HDMI_IN0_MNEMONIC": "RX1", + "HDMI_IN0_DESCRIPTION" : ( + " The *third* HDMI port from the left.\\r\\n" + " Labeled J5 and HDMI In 1.\\r\\n" + ), + + "HDMI_IN1_MNEMONIC": "RX2", + "HDMI_IN1_DESCRIPTION" : ( + " The *fourth* HDMI port from the left. (Closest to the USB.)\\r\\n" + " Labeled J4 and HDMI In 2.\\r\\n" + ), +} + + +class Platform(XilinxPlatform): + name = "opsis" + default_clk_name = "clk100" + default_clk_period = 10.0 + hdmi_infos = _hdmi_infos + + # W25Q128FVEIG - component U3 + # 128M (16M x 8) - 104MHz + # Pretends to be a Micron N25Q128 (ID 0x0018ba20) + # FIXME: Create a "spi flash module" object in the same way we have SDRAM + # module objects. + spiflash_model = "n25q128" + spiflash_read_dummy_bits = 10 + spiflash_clock_div = 4 + spiflash_total_size = int((128/8)*1024*1024) # 128Mbit + spiflash_page_size = 256 + spiflash_sector_size = 0x10000 + + # The Opsis has a XC6SLX45 which bitstream takes up ~12Mbit (1484472 bytes) + # 0x200000 offset (16Mbit) gives plenty of space + gateware_size = 0x200000 + + def __init__(self, programmer="openocd"): + # XC6SLX45T-3FGG484C + XilinxPlatform.__init__(self, "xc6slx45t-fgg484-3", _io, _connectors) + self.programmer = programmer + + pins = { + 'ProgPin': 'PullUp', + 'DonePin': 'PullUp', + 'TckPin': 'PullNone', + 'TdiPin': 'PullNone', + 'TdoPin': 'PullNone', + 'TmsPin': 'PullNone', + 'UnusedPin': 'PullNone', + } + for pin, config in pins.items(): + self.toolchain.bitgen_opt += " -g %s:%s " % (pin, config) + + # FPGA AUX is connected to the 3.3V supply + self.add_platform_command("""CONFIG VCCAUX="3.3";""") + + def create_programmer(self): + # Preferred programmer - Needs ixo-usb-jtag and latest openocd. + proxy="bscan_spi_{}.bit".format(self.device.split('-')[0]) + if self.programmer == "openocd": + return OpenOCD(config="board/numato_opsis.cfg", flash_proxy_basename=proxy) + # Alternative programmers - not regularly tested. + elif self.programmer == "urjtag": + return UrJTAG(cable="USBBlaster") + elif self.programmer == "impact": + return iMPACT() + else: + raise ValueError("{} programmer is not supported".format(self.programmer)) + + def do_finalize(self, fragment): + XilinxPlatform.do_finalize(self, fragment) + + # The oscillator clock sources. + try: + self.add_period_constraint(self.lookup_request("clk100"), 10.0) + except ConstraintError: + pass + + try: + self.add_period_constraint(self.lookup_request("clk27"), 37.0) + except ConstraintError: + pass + + # HDMI input clock pins. + for i in range(2): + try: + self.add_period_constraint(self.lookup_request("hdmi_in", i).clk_p, 12) + except ConstraintError: + pass + + # Ethernet input clock pins. + try: + self.add_period_constraint(self.lookup_request("eth_clocks").rx, 8.0) + except ConstraintError: + pass + + # USB input clock pins. + try: + self.add_period_constraint(self.lookup_request("fx2").ifclk, 10) + except ConstraintError: + pass From 0052a51ccc0c5721e83e3c11ec67a44d0453bd82 Mon Sep 17 00:00:00 2001 From: Joe User Date: Wed, 17 Jan 2018 19:32:44 +1100 Subject: [PATCH 187/219] platforms: Add prelimiary support for Numato Galatea --- platforms/galatea.py | 459 ++++++------------------------------------- 1 file changed, 60 insertions(+), 399 deletions(-) diff --git a/platforms/galatea.py b/platforms/galatea.py index 8cda36a1..7b6b6f42 100644 --- a/platforms/galatea.py +++ b/platforms/galatea.py @@ -6,114 +6,65 @@ from litex.build.generic_platform import * from litex.build.xilinx import XilinxPlatform, iMPACT +from third_party.litex.litex.build.xilinx.programmer import XC3SProg _io = [ + # ---------------------- Clocks --------------------------- # Clock U18 - 100MHz - CMOS Crystal Oscillator - #NET "CLK1" LOC = "G9" | IOSTANDARD = "LVCMOS33" | Period = 100 MHz; # Bank = 0 - ("clk100", 0, Pins("AB13"), IOStandard("LVCMOS33")), + # NET "CLK1" LOC = "AB13" | IOSTANDARD = "LVCMOS33" | Period = 100 MHz; # Bank = 0 + ("clk100", 0, Pins("G9"), IOStandard("LVCMOS33")), # Clock U19 - 100MHz - CMOS Crystal Oscillator - #NET "CLK2" LOC = "Y13" | IOSTANDARD = "LVCMOS33" | Period = 100 MHz; # Bank = 2 - ("clk2", 0, Pins("AB13"), IOStandard("LVCMOS33")), + # NET "CLK2" LOC = "Y13" | IOSTANDARD = "LVCMOS33" | Period = 100 MHz; # Bank = 2 + ("clk2", 0, Pins("Y13"), IOStandard("LVCMOS33")), # Clock U17 - 100MHz - CMOS Crystal Oscillator - #NET "CLK3" LOC = "AB13" | IOSTANDARD = "LVCMOS33" | Period = 100 MHz; # Bank = 2 + # NET "CLK3" LOC = "AB13" | IOSTANDARD = "LVCMOS33" | Period = 100 MHz; # Bank = 2 ("clk3", 0, Pins("AB13"), IOStandard("LVCMOS33")), # Clock U21 SMA Clock - #NET "EXT_CLK1" LOC = "U12" | IOSTANDARD = "LVCMOS33"; # Bank = 2 + # NET "EXT_CLK1" LOC = "U12" | IOSTANDARD = "LVCMOS33"; # Bank = 2 # Clock U6 SMA Clock - #NET "EXT_CLK2" LOC = "T12" | IOSTANDARD = "LVCMOS33"; # Bank = 2 + # NET "EXT_CLK2" LOC = "T12" | IOSTANDARD = "LVCMOS33"; # Bank = 2 - # SW1 Switch + # SW1 + #NET "RST_N" LOC = "AB19" | IOSTANDARD = "LVCMOS33" | PULLUP ; # Bank = 2 + ("cpu_reset", 0, Pins("AB19"), IOStandard("LVCMOS33"), Misc("PULLUP")), - ## SW_PUSH - component SW1 - # Connected to Bank 3 - 1.5V bank - #NET "RST_N" LOC = "AB19" | IOSTANDARD = "LVCMOS33" | PULLUP ; # Bank = 2 - ("cpu_reset", 0, Pins("AB19"), IOStandard("LVCMOS15"), Misc("PULLUP")), - - ######################################################################################################################################################## - # UART # - ######################################################################################################################################################## - - #NET "UART_TX" LOC = "V17" | IOSTANDARD = "LVCMOS33"; # Bank = 2 - #NET "UART_RX" LOC = "W18" | IOSTANDARD = "LVCMOS33"; # Bank = 2 - - ######################################################################################################################################################## + # ---------------------- UART ----------------------------- + #NET "UART_RX" LOC = "V17" | IOSTANDARD = "LVCMOS33"; # Bank = 2 + #NET "UART_TX" LOC = "W18" | IOSTANDARD = "LVCMOS33"; # Bank = 2 + ("serial", 0, + Subsignal("rx", Pins("V17"), IOStandard("LVCMOS33")), + Subsignal("tx", Pins("W18"), IOStandard("LVCMOS33")), + ), # SPI Flash # - ######################################################################################################################################################## - - #NET "SPI_Flash_SCK" LOC = "Y20" | IOSTANDARD = "LVCMOS33"; # Bank = 2 - #NET "SPI_Flash_MISO" LOC = "T14" | IOSTANDARD = "LVCMOS33"; # Bank = 2 - #NET "SPI_Flash_MOSI" LOC = "AB20" | IOSTANDARD = "LVCMOS33"; # Bank = 2 - #NET "SPI_Flash_SS" LOC = "AA3" | IOSTANDARD = "LVCMOS33"; # Bank = 2 + #NET "SPI_Flash_SCK" LOC = "Y20" | IOSTANDARD = "LVCMOS33"; # Bank = 2 + #NET "SPI_Flash_MISO" LOC = "T14" | IOSTANDARD = "LVCMOS33"; # Bank = 2 + #NET "SPI_Flash_MOSI" LOC = "AB20" | IOSTANDARD = "LVCMOS33"; # Bank = 2 + #NET "SPI_Flash_SS" LOC = "AA3" | IOSTANDARD = "LVCMOS33"; # Bank = 2 ## onBoard Quad-SPI Flash ## N25Q128A13ESE40E - 128 Mb QSPI flash memory - #QSPI_FLASH_SCLK Y20 LVCMOS33 16 FAST + #QSPI_FLASH_SCLK Y20 LVCMOS33 16 FAST #QSPI_FLASH_IO0 AB20 LVCMOS33 16 FAST #QSPI_FLASH_IO1 AA20 LVCMOS33 16 FAST #QSPI_FLASH_IO2 R13 LVCMOS33 16 FAST #QSPI_FLASH_IO3 T14 LVCMOS33 16 FAST #QSPI_FLASH_SS AA3 LVCMOS33 16 FAST - ("spiflash1x", 0, - #NET "SPI_Flash_SCK" LOC = "Y20" | IOSTANDARD = "LVCMOS33"; # Bank = 2 + #NET "SPI_Flash_SCK" LOC = "Y20" | IOSTANDARD = "LVCMOS33"; # Bank = 2 Subsignal("clk", Pins("Y20")), - #NET "SPI_Flash_SS" LOC = "AA3" | IOSTANDARD = "LVCMOS33"; # Bank = 2 + #NET "SPI_Flash_SS" LOC = "AA3" | IOSTANDARD = "LVCMOS33"; # Bank = 2 Subsignal("cs_n", Pins("AA3")), - #NET "SPI_Flash_MISO" LOC = "T14" | IOSTANDARD = "LVCMOS33"; # Bank = 2 - #NET "SPI_Flash_MOSI" LOC = "AB20" | IOSTANDARD = "LVCMOS33"; # Bank = 2 + #NET "SPI_Flash_MISO" LOC = "T14" | IOSTANDARD = "LVCMOS33"; # Bank = 2 + #NET "SPI_Flash_MOSI" LOC = "AB20" | IOSTANDARD = "LVCMOS33"; # Bank = 2 #Subsignal("dq", Pins("AB20", "AA20", "R13", "T14")), IOStandard("LVCMOS33"), Misc("SLEW=FAST") ), - ## onBoard Leds - # NET "Led<0>" LOC = "U18"; # Bank = 1, Pin name = IO_L52N_M1DQ15, Sch name = LD0 - #("user_led", 0, Pins("U18")), - - # frontend switches / leds - ("hdled", 0, Pins("J7"), IOStandard("LVCMOS15")), - ("pwled", 0, Pins("H8"), IOStandard("LVCMOS15")), #pwled+ connected to 3.3V - ("pwrsw", 0, Pins("F5"), IOStandard("LVCMOS15")), - - ## TEMAC Ethernet MAC - FIXME - # 10/100/1000 Ethernet PHY - ## RTL8211E-VL - component U20 - RGMII - ("eth_clocks", 0, - Subsignal("tx", Pins("AB12")), - Subsignal("rx", Pins("AA12")), - IOStandard("LVCMOS33") - ), - ("eth", 0, - Subsignal("rst_n", Pins("U8")), - Subsignal("int_n", Pins("V9")), - Subsignal("mdio", Pins("T8")), - Subsignal("mdc", Pins("V7")), - Subsignal("rx_ctl", Pins("U9")), - Subsignal("rx_data", Pins("R9 R8 W6 Y6")), - Subsignal("tx_ctl", Pins("W8")), - Subsignal("tx_data", Pins("W9 Y8 AA6 AB6")), - IOStandard("LVCMOS33") - ), - - ## Opsis I2C Bus - # Connected to both the EEPROM and the FX2. - # - ## 24AA02E48 - component U23 - # 2 Kbit Electrically Erasable PROM - # Pre-programmed Globally Unique, 48-bit Node Address - # The device is organized as two blocks of 128 x 8-bit memory with a 2-wire serial interface. - ## \/ Strongly pulled (2k) to VCC3V3 via R34 - #NET "eeprom_scl" LOC = "G6" |IOSTANDARD = I2C; # (/Ethernet/MAC_SCL) - #NET "eeprom_sda" LOC = "C1" |IOSTANDARD = I2C; # (/Ethernet/MAC_SDA) - ("opsis_i2c", 0, - Subsignal("scl", Pins("G6"), IOStandard("I2C")), - Subsignal("sda", Pins("C1"), IOStandard("I2C")), - ), - - ## DDR3 + ## DDR3 Chip:0 # MT41J128M16JT-125:K - 16 Meg x 16 x 8 Banks - DDR3-1600 11-11-11 # FBGA Code: D9PSL, Part Number: MT41J128M16 - http://www.micron.com/support/fbga ("ddram_clock", 0, @@ -140,301 +91,40 @@ Misc("VCCAUX_IO=HIGH") ), - ## onboard HDMI IN1 - ## HDMI - connector J5 - Direction RX - ("hdmi_in", 0, - Subsignal("clk_p", Pins("L20"), IOStandard("TMDS_33")), - Subsignal("clk_n", Pins("L22"), IOStandard("TMDS_33")), - Subsignal("data0_p", Pins("M21"), IOStandard("TMDS_33")), - Subsignal("data0_n", Pins("M22"), IOStandard("TMDS_33")), - Subsignal("data1_p", Pins("N20"), IOStandard("TMDS_33")), - Subsignal("data1_n", Pins("N22"), IOStandard("TMDS_33")), - Subsignal("data2_p", Pins("P21"), IOStandard("TMDS_33")), - Subsignal("data2_n", Pins("P22"), IOStandard("TMDS_33")), - Subsignal("scl", Pins("T21"), IOStandard("LVCMOS33")), - Subsignal("sda", Pins("R22"), IOStandard("LVCMOS33")), - Subsignal("hpd_en", Pins("R20"), IOStandard("LVCMOS33")) - ), - - ## onboard HDMI IN2 - ## HDMI - connector J4 - Direction RX - ("hdmi_in", 1, - Subsignal("clk_p", Pins("M20"), IOStandard("TMDS_33")), - Subsignal("clk_n", Pins("M19"), IOStandard("TMDS_33")), - Subsignal("data0_p", Pins("J20"), IOStandard("TMDS_33")), - Subsignal("data0_n", Pins("J22"), IOStandard("TMDS_33")), - Subsignal("data1_p", Pins("H21"), IOStandard("TMDS_33")), - Subsignal("data1_n", Pins("H22"), IOStandard("TMDS_33")), - Subsignal("data2_p", Pins("K20"), IOStandard("TMDS_33")), - Subsignal("data2_n", Pins("L19"), IOStandard("TMDS_33")), - Subsignal("scl", Pins("L17"), IOStandard("LVCMOS33")), - Subsignal("sda", Pins("T18"), IOStandard("LVCMOS33")), - Subsignal("hpd_en", Pins("V19"), IOStandard("LVCMOS33")) - ), - - # Debug header? - #("debug", 0, Pins("AA2"), IOStandard("LVCMOS15")), # (/FPGA_Bank_0_3/DEBUG_IO0) - - ## onboard HDMI OUT1 - ## HDMI - connector J3 - Direction TX - ("hdmi_out", 0, - Subsignal("clk_p", Pins("Y11"), IOStandard("TMDS_33")), - Subsignal("clk_n", Pins("AB11"), IOStandard("TMDS_33")), - Subsignal("data0_p", Pins("W12"), IOStandard("TMDS_33")), - Subsignal("data0_n", Pins("Y12"), IOStandard("TMDS_33")), - Subsignal("data1_p", Pins("AA10"), IOStandard("TMDS_33")), - Subsignal("data1_n", Pins("AB10"), IOStandard("TMDS_33")), - Subsignal("data2_p", Pins("Y9"), IOStandard("TMDS_33")), - Subsignal("data2_n", Pins("AB9"), IOStandard("TMDS_33")), - Subsignal("scl", Pins("Y7"), IOStandard("I2C")), - Subsignal("sda", Pins("Y10"), IOStandard("I2C")), - Subsignal("hpd_notif", Pins("AB7"), IOStandard("LVCMOS33")) - ), - - ## onboard HDMI OUT2 - ## HDMI - connector J2 - Direction TX - ("hdmi_out", 1, - Subsignal("clk_p", Pins("T12"), IOStandard("TMDS_33")), - Subsignal("clk_n", Pins("U12"), IOStandard("TMDS_33")), - Subsignal("data0_p", Pins("Y15"), IOStandard("TMDS_33")), - Subsignal("data0_n", Pins("AB15"), IOStandard("TMDS_33")), - Subsignal("data1_p", Pins("AA16"), IOStandard("TMDS_33")), - Subsignal("data1_n", Pins("AB16"), IOStandard("TMDS_33")), - Subsignal("data2_p", Pins("U14"), IOStandard("TMDS_33")), - Subsignal("data2_n", Pins("U13"), IOStandard("TMDS_33")), - Subsignal("scl", Pins("Y17"), IOStandard("I2C")), - Subsignal("sda", Pins("AB17"), IOStandard("I2C")), - Subsignal("hpd_notif", Pins("AB18"), IOStandard("LVCMOS33")) - ), - - # FX2 USB Interface - # CY7C68013A_100AC - component U2 - ("fx2", 0, - #NET "fx2_ifclk" LOC = "P20" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY-IFCLK) - Subsignal("ifclk", Pins("P20"), IOStandard("LVCMOS33")), - #NET "fx2_fd<0>" LOC = "C20" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_FD0) - #NET "fx2_fd<1>" LOC = "C22" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_FD1) - #NET "fx2_fd<2>" LOC = "L15" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_FD2) - #NET "fx2_fd<3>" LOC = "K16" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_FD3) - #NET "fx2_fd<4>" LOC = "D21" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_FD4) - #NET "fx2_fd<5>" LOC = "D22" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_FD5) - #NET "fx2_fd<6>" LOC = "G19" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_FD6) - #NET "fx2_fd<7>" LOC = "F20" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_FD7) - #NET "fx2_fd<8>" LOC = "H18" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_FD8) - #NET "fx2_fd<9>" LOC = "H19" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_FD9) - #NET "fx2_fd<10>" LOC = "F21" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_FD10) - #NET "fx2_fd<11>" LOC = "F22" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_FD11) - #NET "fx2_fd<12>" LOC = "E20" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_FD12) - #NET "fx2_fd<13>" LOC = "E22" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_FD13) - #NET "fx2_fd<14>" LOC = "J19" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_FD14) - #NET "fx2_fd<15>" LOC = "H20" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_FD15) - Subsignal("data", Pins("C20 C22 L15 K16 D21 D22 G19 F20 H18 H19 F21 F22 E20 E22 J19 H20"), IOStandard("LVCMOS33")), - #NET "fx2_fifoadr<0>" LOC = "B21" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_PA4) - #NET "fx2_fifoadr<1>" LOC = "B22" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_PA5) - Subsignal("addr", Pins("B21 B22"), IOStandard("LVCMOS33"), Misc("DRIVE=12")), - #NET "fx2_flaga" LOC = "N16" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_CTL0) - #NET "fx2_flagb" LOC = "P16" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_CTL1) - #NET "fx2_flagc" LOC = "R15" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_CTL2) - Subsignal("flaga", Pins("N16"), IOStandard("LVCMOS33"), Misc("DRIVE=12")), - Subsignal("flagb", Pins("P16"), IOStandard("LVCMOS33"), Misc("DRIVE=12")), - Subsignal("flagc", Pins("R15"), IOStandard("LVCMOS33"), Misc("DRIVE=12")), - #NET "fx2_flagd/slcs_n" LOC = "J17" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_PA7) - Subsignal("cs_n", Pins("J17"), IOStandard("LVCMOS33"), Misc("DRIVE=12")), - #NET "fx2_slrd" LOC = "P19" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_RD0) - Subsignal("rd_n", Pins("P19"), IOStandard("LVCMOS33"), Misc("DRIVE=12")), - #NET "fx2_slwr" LOC = "R19" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_RD1) - Subsignal("wr_n", Pins("R19"), IOStandard("LVCMOS33")), - #NET "fx2_sloe" LOC = "H16" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_PA2) - Subsignal("oe_n", Pins("H16"), IOStandard("LVCMOS33"), Misc("DRIVE=12")), - #NET "fx2_pktend" LOC = "J16" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_PA6) - Subsignal("pktend_n", Pins("J16"), IOStandard("LVCMOS33"), Misc("DRIVE=12")), - - #NET "fx2_ctl<3>" LOC = "M18" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_CTL3) - #NET "fx2_ctl<4>" LOC = "M17" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_CTL4) - #NET "fx2_ctl<5>" LOC = "R16" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_CTL5) - #NET "fx2_init5_n" LOC = "T19" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_INT5) - #NET "fx2_int<0>" LOC = "F18" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_PA0) - #NET "fx2_int<1>" LOC = "F19" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_PA1) - #NET "fx2_wu<2>" LOC = "H17" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_PA3) - #NET "fx2_gpifadr<0>" LOC = "U20" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_PC0) - #NET "fx2_gpifadr<1>" LOC = "U22" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_PC1) - #NET "fx2_gpifadr<2>" LOC = "V21" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_PC2) - #NET "fx2_gpifadr<3>" LOC = "V22" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_PC3) - #NET "fx2_gpifadr<4>" LOC = "W20" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_PC4) - #NET "fx2_gpifadr<5>" LOC = "W22" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_PC5) - #NET "fx2_gpifadr<6>" LOC = "Y21" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_PC6) - #NET "fx2_gpifadr<7>" LOC = "Y22" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_PC7) - #NET "fx2_gpifadr<8>" LOC = "AB21" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Power/DONE | Net-(R28-Pad1)) - # Timers - #NET "fx2_t<0>" LOC = "G17" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/SPI_Flash/TDO-FPGA/TDO-JTAG | Net-(P3-Pad8) | Net-(R14-Pad1)) - ## \/ Strongly pulled (4k) to VCC3V3 via R56 - #NET "fx2_t<1>" LOC = "AB2" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Power/PROG_B | Net-(R15-Pad1)) - #NET "fx2_t<2>" LOC = "E18" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/SPI_Flash/TDO-USB/TDI-FPGA | Net-(P3-Pad10) | Net-(R23-Pad1)) - #NET "fx2_rd_n" LOC = "K19" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_RD) - #NET "fx2_rdy<2>" LOC = "M16" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_RD2) - #NET "fx2_rdy<3>" LOC = "N15" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_RD3) - #NET "fx2_rdy<4>" LOC = "U19" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_RD4) - #NET "fx2_rdy<5>" LOC = "T20" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_RD5) - ## UART0 - #NET "fx2_rxd0" LOC = "P18" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_RXD1) - #NET "fx2_txd0" LOC = "T17" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_TXD1) - ## UART1 - #NET "fx2_rxd1" LOC = "P17" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_RXD0) - #NET "fx2_txd1" LOC = "R17" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_TXD0) - # - #NET "fx2_t0" LOC = "G20" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_T0) - #NET "fx2_wr_n" LOC = "K18" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/CY_WR) - # JTAG - # - TMS? - #NET "fx2_rxd<0>" LOC = "D20" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Power/TMS | Net-(P3-Pad4) | Net-(R24-Pad1)) - # - TCK - #NET "fx2_rxd<1>" LOC = "A21" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Power/TCK | Net-(P3-Pad6) | Net-(R26-Pad1)) - ## \/ Strongly pulled (4k) to VCC3V3 via R52 - #NET "fx2_t<2>" LOC = "Y4" |IOSTANDARD = LVCMOS33 |SLEW=SLOW |DRIVE=12 ; # (/FPGA_Bank_1_2/INIT_B | Net-(R27-Pad1)) - - ## Same pins as the EEPROM - ## \/ Strongly pulled (2k) to VCC3V3 via R34 - #NET "fx2_scl" LOC = "G6" |IOSTANDARD = I2C; # (/Ethernet/MAC_SCL) - #Subsignal("scl", Pins("G6"), IOStandard("I2C")), - #NET "fx2_sda" LOC = "C1" |IOSTANDARD = I2C; # (/Ethernet/MAC_SDA) - #Subsignal("sda", Pins("C1"), IOStandard("I2C")), - ), - ("fx2_reset", 0, Pins("G22"), IOStandard("LVCMOS33"), Misc("PULLUP"), Misc("DRIVE=24"), Misc("SLEW=SLOW")), - - # To Cypress FX2 UART0 - # WARNING: This was labelled incorrectly - https://github.com/timvideos/HDMI2USB-numato-opsis-hardware/issues/13 - # Can be accessed via `opsis-mode-switch --mode=serial` - # FIXME: Will be supported by `opsis-mode-switch --mode=jtag` longer term. - ("fx2_serial", 0, - # CY_RXD1 - P18 - Cypress RXD0 - Subsignal("tx", Pins("P18"), IOStandard("LVCMOS33")), - # CY_TXD1 - T17 - Cypress TXD0 - Subsignal("rx", Pins("T17"), IOStandard("LVCMOS33"), Misc("PULLUP")), - ), - # To Cypress FX2 UART1 - #("serial", 1, - # Subsignal("rx", Pins("A16"), IOStandard("LVCMOS33")), - # Subsignal("tx", Pins("B16"), IOStandard("LVCMOS33")), - #), - # - - # FIXME: This assumes a TOFE LowSpeedIO board is currently connected. - # ----------------------------------- - ("tofe", 0, - Subsignal("rst", Pins(tofe_pin("pcie_reset")), IOStandard("I2C"), Misc("PULLUP")), - Subsignal("scl", Pins(tofe_pin("smclk")), IOStandard("I2C")), - Subsignal("sda", Pins(tofe_pin("smdat")), IOStandard("I2C")), - ), - - ("tofe_io", - Subsignal("a_io_p", Pins(" ".join(p for n, p in sorted(_tofe_io.items()) if n.endswith('p') and 'io_a' in n))), - Subsignal("a_io_n", Pins(" ".join(p for n, p in sorted(_tofe_io.items()) if n.endswith('n') and 'io_a' in n))), - Subsignal("b_io_p", Pins(" ".join(p for n, p in sorted(_tofe_io.items()) if n.endswith('p') and 'io_b' in n))), - Subsignal("b_io_n", Pins(" ".join(p for n, p in sorted(_tofe_io.items()) if n.endswith('n') and 'io_b' in n))), - ), - - # serial - ("tofe_lsio_serial", 0, - Subsignal("tx", Pins(tofe_pin(tofe_low_speed_io("rx")))), - Subsignal("rx", Pins(tofe_pin(tofe_low_speed_io("tx"))), Misc("PULLUP")), - IOStandard("LVCMOS33") - ), - - # user leds - ("tofe_lsio_user_led", 0, Pins(tofe_pin(tofe_low_speed_io("led1"))), IOStandard("LVCMOS33"), Misc("DRIVE=12")), - ("tofe_lsio_user_led", 1, Pins(tofe_pin(tofe_low_speed_io("led2"))), IOStandard("LVCMOS33"), Misc("DRIVE=12")), - ("tofe_lsio_user_led", 2, Pins(tofe_pin(tofe_low_speed_io("led3"))), IOStandard("LVCMOS33"), Misc("DRIVE=12")), - ("tofe_lsio_user_led", 3, Pins(tofe_pin(tofe_low_speed_io("led4"))), IOStandard("LVCMOS33"), Misc("DRIVE=12")), - - # push buttons - ("tofe_lsio_user_sw", 0, Pins(tofe_pin(tofe_low_speed_io("sw1"))), IOStandard("LVCMOS33"), Misc("PULLUP")), - ("tofe_lsio_user_sw", 1, Pins(tofe_pin(tofe_low_speed_io("sw2"))), IOStandard("LVCMOS33"), Misc("PULLUP")), - ("tofe_lsio_user_sw", 2, Pins(tofe_pin(tofe_low_speed_io("sw3"))), IOStandard("LVCMOS33"), Misc("PULLUP")), - ("tofe_lsio_user_sw", 3, Pins(tofe_pin(tofe_low_speed_io("sw4"))), IOStandard("LVCMOS33"), Misc("PULLUP")), - - # PmodUSBUART or similar device connected to the "p3" Pmod connector. - ("tofe_lsio_pmod_serial", 0, - # PmodUSBUART - Pmod Type4 - UART - # Pin 1 - CTS - In - Peripheral can transmit - # Pin 2 - TXD - Out - Data - Host to peripheral - # Pin 3 - RXD - In - Data - Peripheral to host - # Pin 4 - RTS - Out - Peripheral ready for data - # Pin 5 - GND - # Pin 6 - VCC - Subsignal("tx", Pins(tofe_pin(tofe_low_speed_pmod_io('p3', 2)))), - Subsignal("rx", Pins(tofe_pin(tofe_low_speed_pmod_io('p3', 3))), Misc("PULLUP")), - IOStandard("LVCMOS33") - ), -] - -pt = None -tofe_signals = [[], []] -for n, v in _tofe_io.items(): - if not n.startswith("diff"): - continue - - _, t, p = n.split('_') - - if t != pt: - assert len(tofe_signals[-1]) == len(tofe_signals[-2]) - - tofe_signals.append(["{}_{}_{}".format(t, p[0], 'n')]) - tofe_signals.append(["{}_{}_{}".format(t, p[0], 'p')]) - pt = t - - if p.endswith('n'): - tofe_signals[-2].append(n) - elif p.endswith('p'): - tofe_signals[-1].append(n) - - -## import pprint -## pprint.pprint(tofe_signals) -## -## pprint.pprint(list( -## (i[0], (" ".join(_tofe_io[p] for p in i[1:])), IOStandard("LVCMOS33")) for i in tofe_signals[2:])) - -_io.append(["tofe", 0]+[ - Subsignal(i[0], Pins(" ".join(_tofe_io[p] for p in i[1:])), IOStandard("LVCMOS33")) for i in tofe_signals[2:] - ] -) - - -_connectors = [ + ## DDR3 Chip:1 + # MT41J128M16JT-125:K - 16 Meg x 16 x 8 Banks - DDR3-1600 11-11-11 + # FBGA Code: D9PSL, Part Number: MT41J128M16 - http://www.micron.com/support/fbga + ("ddram_clock", 1, + Subsignal("p", Pins("K20")), + Subsignal("n", Pins("L19")), + IOStandard("DIFF_SSTL15_II"), Misc("IN_TERM=NONE") + ), + ("ddram", 1, + Subsignal("cke", Pins("F21"), IOStandard("SSTL15_II")), + Subsignal("ras_n", Pins("K21"), IOStandard("SSTL15_II")), + Subsignal("cas_n", Pins("K22"), IOStandard("SSTL15_II")), + Subsignal("we_n", Pins("K19"), IOStandard("SSTL15_II")), + Subsignal("ba", Pins("K17 L17 K18"), IOStandard("SSTL15_II")), + Subsignal("a", Pins("H21 H22 G22 J20 H20 M20 M19 G20 E20 E22 J19 H19 F22 G19 F20"), IOStandard("SSTL15_II")), + Subsignal("dq", Pins( + "R20 R22 P21 P22 L20 L22 M21 M22", + "T21 T22 U20 U22 W20 W22 Y21 Y22"), IOStandard("SSTL15_II")), + Subsignal("dqs", Pins("N20 V21"), IOStandard("DIFF_SSTL15_II")), + Subsignal("dqs_n", Pins("N22 V22"), IOStandard("DIFF_SSTL15_II")), + Subsignal("dm", Pins("N19 P20"), IOStandard("SSTL15_II")), + Subsignal("odt", Pins("J22"), IOStandard("SSTL15_II")), + Subsignal("reset_n", Pins("H18"), IOStandard("LVCMOS15")), + Misc("SLEW=FAST"), + Misc("VCCAUX_IO=HIGH") + ), ] -_hdmi_infos = { - "HDMI_OUT0_MNEMONIC": "TX1", - "HDMI_OUT0_DESCRIPTION" : ( - " The *first* HDMI port from the left.\\r\\n" - " Labeled J3 and HDMI Out 1.\\r\\n" - ), - - "HDMI_OUT1_MNEMONIC": "TX2", - "HDMI_OUT1_DESCRIPTION" : ( - " The *second* HDMI port from the left.\\r\\n" - " Labeled J2 and HDMI Out 2.\\r\\n" - ), - - "HDMI_IN0_MNEMONIC": "RX1", - "HDMI_IN0_DESCRIPTION" : ( - " The *third* HDMI port from the left.\\r\\n" - " Labeled J5 and HDMI In 1.\\r\\n" - ), - - "HDMI_IN1_MNEMONIC": "RX2", - "HDMI_IN1_DESCRIPTION" : ( - " The *fourth* HDMI port from the left. (Closest to the USB.)\\r\\n" - " Labeled J4 and HDMI In 2.\\r\\n" - ), -} - +_connectors = [] class Platform(XilinxPlatform): - name = "opsis" + name = "galatea" default_clk_name = "clk100" default_clk_period = 10.0 - hdmi_infos = _hdmi_infos # W25Q128FVEIG - component U3 # 128M (16M x 8) - 104MHz @@ -448,7 +138,7 @@ class Platform(XilinxPlatform): spiflash_page_size = 256 spiflash_sector_size = 0x10000 - # The Opsis has a XC6SLX45 which bitstream takes up ~12Mbit (1484472 bytes) + # The Galatea has a XC6SLX45 which bitstream takes up ~12Mbit (1484472 bytes) # 0x200000 offset (16Mbit) gives plenty of space gateware_size = 0x200000 @@ -473,13 +163,8 @@ def __init__(self, programmer="openocd"): self.add_platform_command("""CONFIG VCCAUX="3.3";""") def create_programmer(self): - # Preferred programmer - Needs ixo-usb-jtag and latest openocd. - proxy="bscan_spi_{}.bit".format(self.device.split('-')[0]) - if self.programmer == "openocd": - return OpenOCD(config="board/numato_opsis.cfg", flash_proxy_basename=proxy) - # Alternative programmers - not regularly tested. - elif self.programmer == "urjtag": - return UrJTAG(cable="USBBlaster") + if self.programmer == "xc3sprog": + return XC3SProg(cable='xpc') elif self.programmer == "impact": return iMPACT() else: @@ -493,27 +178,3 @@ def do_finalize(self, fragment): self.add_period_constraint(self.lookup_request("clk100"), 10.0) except ConstraintError: pass - - try: - self.add_period_constraint(self.lookup_request("clk27"), 37.0) - except ConstraintError: - pass - - # HDMI input clock pins. - for i in range(2): - try: - self.add_period_constraint(self.lookup_request("hdmi_in", i).clk_p, 12) - except ConstraintError: - pass - - # Ethernet input clock pins. - try: - self.add_period_constraint(self.lookup_request("eth_clocks").rx, 8.0) - except ConstraintError: - pass - - # USB input clock pins. - try: - self.add_period_constraint(self.lookup_request("fx2").ifclk, 10) - except ConstraintError: - pass From 392cf59997eadab69120157ebe415836b13ce306 Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Wed, 17 Jan 2018 20:38:32 +1100 Subject: [PATCH 188/219] platforms/galatea: add base target --- targets/galatea/Makefile.mk | 52 +++++++++ targets/galatea/base.py | 222 ++++++++++++++++++++++++++++++++++++ 2 files changed, 274 insertions(+) create mode 100644 targets/galatea/Makefile.mk create mode 100644 targets/galatea/base.py diff --git a/targets/galatea/Makefile.mk b/targets/galatea/Makefile.mk new file mode 100644 index 00000000..cd357ead --- /dev/null +++ b/targets/galatea/Makefile.mk @@ -0,0 +1,52 @@ +# opsis targets + +ifneq ($(PLATFORM),galatea) + $(error "Platform should be galatea when using this file!?") +endif + +# Settings +DEFAULT_TARGET = base +TARGET ?= $(DEFAULT_TARGET) + +# Image +image-flash-$(PLATFORM): + $(PLATFORM)-mode-switch --verbose --flash-gateware=$(IMAGE_FILE) + $(PLATFORM)-mode-switch --verbose --reset-gateware + +# Gateware +gateware-load-$(PLATFORM): + $(PLATFORM)-mode-switch --verbose --load-gateware $(GATEWARE_FILEBASE).bit + $(PLATFORM)-mode-switch --verbose --reset-gateware + +gateware-flash-$(PLATFORM): + $(PLATFORM)-mode-switch --verbose --flash-gateware=$(GATEWARE_FILEBASE).bin + $(PLATFORM)-mode-switch --verbose --reset-gateware + +# Firmware +firmware-load-$(PLATFORM): + $(PLATFORM)-mode-switch --verbose --mode=serial + flterm --port=$$($(PLATFORM)-mode-switch --get-serial-dev) --kernel=$(FIRMWARE_FILEBASE).bin + +firmware-flash-$(PLATFORM): + $(PLATFORM)-mode-switch --verbose --flash-softcpu-firmware=$(FIRMWARE_FILEBASE).fbi + $(PLATFORM)-mode-switch --verbose --reset-gateware + +firmware-connect-$(PLATFORM): + flterm --port=$$($(PLATFORM)-mode-switch --get-serial-dev) + +firmware-clear-$(PLATFORM): + $(PLATFORM)-mode-switch --verbose --clear-softcpu-firmware + +# Bios +bios-flash-$(PLATFORM): + $(PLATFORM)-mode-switch --verbose --flash-softcpu-bios=$(BIOS_FILE) + $(PLATFORM)-mode-switch --verbose --reset-gateware + +# Extra commands +help-$(PLATFORM): + @true + +reset-$(PLATFORM): + $(PLATFORM)-mode-switch --verbose --mode=serial + $(PLATFORM)-mode-switch --verbose --mode=jtag + $(PLATFORM)-mode-switch --verbose --mode=serial diff --git a/targets/galatea/base.py b/targets/galatea/base.py new file mode 100644 index 00000000..91d35352 --- /dev/null +++ b/targets/galatea/base.py @@ -0,0 +1,222 @@ +# Support for Numato Galatea - https://numato.com/product/galatea-pci-express-spartan-6-fpga-development-board +from fractions import Fraction + +from litex.gen import * +from litex.gen.genlib.resetsync import AsyncResetSynchronizer +from litex.gen.genlib.misc import WaitTimer + +from litex.soc.integration.soc_sdram import * +from litex.soc.integration.builder import * +from litex.soc.cores.gpio import GPIOIn, GPIOOut +from litex.soc.interconnect.csr import AutoCSR + +from litedram.modules import MT41J128M16 +from litedram.phy import s6ddrphy +from litedram.core import ControllerSettings + +from gateware import i2c +from gateware import info +from gateware import opsis_i2c +from gateware import shared_uart +from gateware import tofe +from gateware import spi_flash + +from targets.utils import csr_map_update + +class _CRG(Module): + def __init__(self, platform, clk_freq): + # Clock domains for the system (soft CPU and related components run at). + self.clock_domains.cd_sys = ClockDomain() + self.clock_domains.cd_sys2x = ClockDomain() + # Clock domains for the DDR interface. + self.clock_domains.cd_sdram_half = ClockDomain() + self.clock_domains.cd_sdram_full_wr = ClockDomain() + self.clock_domains.cd_sdram_full_rd = ClockDomain() + # Clock domain for peripherals (such as HDMI output). + self.clock_domains.cd_base50 = ClockDomain() + + self.reset = Signal() + + # Input 100MHz clock + f0 = 100*1000000 + clk100 = platform.request("clk100") + clk100a = Signal() + # Input 100MHz clock (buffered) + self.specials += Instance("IBUFG", i_I=clk100, o_O=clk100a) + clk100b = Signal() + self.specials += Instance( + "BUFIO2", p_DIVIDE=1, + p_DIVIDE_BYPASS="TRUE", p_I_INVERT="FALSE", + i_I=clk100a, o_DIVCLK=clk100b) + + f = Fraction(int(clk_freq), int(f0)) + n, m = f.denominator, f.numerator + assert f0/n*m == clk_freq + p = 8 + + # Unbuffered output signals from the PLL. They need to be buffered + # before feeding into the fabric. + unbuf_sdram_full = Signal() + unbuf_sdram_half_a = Signal() + unbuf_sdram_half_b = Signal() + unbuf_encoder = Signal() + unbuf_sys = Signal() + unbuf_sys2x = Signal() + + # PLL signals + pll_lckd = Signal() + pll_fb = Signal() + self.specials.pll = Instance( + "PLL_ADV", + name="crg_pll_adv", + p_SIM_DEVICE="SPARTAN6", p_BANDWIDTH="OPTIMIZED", p_COMPENSATION="INTERNAL", + p_REF_JITTER=.01, + i_DADDR=0, i_DCLK=0, i_DEN=0, i_DI=0, i_DWE=0, i_RST=0, i_REL=0, + p_DIVCLK_DIVIDE=1, + # Input Clocks (100MHz) + i_CLKIN1=clk100b, + p_CLKIN1_PERIOD=1e9/f0, + i_CLKIN2=0, + p_CLKIN2_PERIOD=0., + i_CLKINSEL=1, + # Feedback + i_CLKFBIN=pll_fb, o_CLKFBOUT=pll_fb, o_LOCKED=pll_lckd, + p_CLK_FEEDBACK="CLKFBOUT", + p_CLKFBOUT_MULT=m*p//n, p_CLKFBOUT_PHASE=0., + # (400MHz) ddr3 wr/rd full clock + o_CLKOUT0=unbuf_sdram_full, p_CLKOUT0_DUTY_CYCLE=.5, + p_CLKOUT0_PHASE=0., p_CLKOUT0_DIVIDE=p//8, + # ( 66MHz) encoder + o_CLKOUT1=unbuf_encoder, p_CLKOUT1_DUTY_CYCLE=.5, + p_CLKOUT1_PHASE=0., p_CLKOUT1_DIVIDE=6, + # (200MHz) sdram_half - ddr3 dqs adr ctrl off-chip + o_CLKOUT2=unbuf_sdram_half_a, p_CLKOUT2_DUTY_CYCLE=.5, + p_CLKOUT2_PHASE=230., p_CLKOUT2_DIVIDE=p//4, + # (200MHz) off-chip ddr - ddr3 half clock + o_CLKOUT3=unbuf_sdram_half_b, p_CLKOUT3_DUTY_CYCLE=.5, + p_CLKOUT3_PHASE=210., p_CLKOUT3_DIVIDE=p//4, + # (100MHz) sys2x - 2x system clock + o_CLKOUT4=unbuf_sys2x, p_CLKOUT4_DUTY_CYCLE=.5, + p_CLKOUT4_PHASE=0., p_CLKOUT4_DIVIDE=p//2, + # ( 50MHz) periph / sys - system clock + o_CLKOUT5=unbuf_sys, p_CLKOUT5_DUTY_CYCLE=.5, + p_CLKOUT5_PHASE=0., p_CLKOUT5_DIVIDE=p//1, + ) + + + # power on reset? + reset = ~platform.request("cpu_reset") | self.reset + self.clock_domains.cd_por = ClockDomain() + por = Signal(max=1 << 11, reset=(1 << 11) - 1) + self.sync.por += If(por != 0, por.eq(por - 1)) + self.specials += AsyncResetSynchronizer(self.cd_por, reset) + + # System clock - 50MHz + self.specials += Instance("BUFG", name="sys_bufg", i_I=unbuf_sys, o_O=self.cd_sys.clk) + self.comb += self.cd_por.clk.eq(self.cd_sys.clk) + self.specials += AsyncResetSynchronizer(self.cd_sys, ~pll_lckd | (por > 0)) + + # sys2x + self.specials += Instance("BUFG", name="sys2x_bufg", i_I=unbuf_sys2x, o_O=self.cd_sys2x.clk) + self.specials += AsyncResetSynchronizer(self.cd_sys2x, ~pll_lckd | (por > 0)) + + # SDRAM clocks + # ------------------------------------------------------------------------------ + self.clk8x_wr_strb = Signal() + self.clk8x_rd_strb = Signal() + + # sdram_full + self.specials += Instance("BUFPLL", name="sdram_full_bufpll", + p_DIVIDE=4, + i_PLLIN=unbuf_sdram_full, i_GCLK=self.cd_sys2x.clk, + i_LOCKED=pll_lckd, + o_IOCLK=self.cd_sdram_full_wr.clk, + o_SERDESSTROBE=self.clk8x_wr_strb) + self.comb += [ + self.cd_sdram_full_rd.clk.eq(self.cd_sdram_full_wr.clk), + self.clk8x_rd_strb.eq(self.clk8x_wr_strb), + ] + # sdram_half + self.specials += Instance("BUFG", name="sdram_half_a_bufpll", i_I=unbuf_sdram_half_a, o_O=self.cd_sdram_half.clk) + clk_sdram_half_shifted = Signal() + self.specials += Instance("BUFG", name="sdram_half_b_bufpll", i_I=unbuf_sdram_half_b, o_O=clk_sdram_half_shifted) + + output_clk = Signal() + clk = platform.request("ddram_clock") + self.specials += Instance("ODDR2", p_DDR_ALIGNMENT="NONE", + p_INIT=0, p_SRTYPE="SYNC", + i_D0=1, i_D1=0, i_S=0, i_R=0, i_CE=1, + i_C0=clk_sdram_half_shifted, + i_C1=~clk_sdram_half_shifted, + o_Q=output_clk) + self.specials += Instance("OBUFDS", i_I=output_clk, o_O=clk.p, o_OB=clk.n) + + # Peripheral clock - 50MHz + # ------------------------------------------------------------------------------ + # The peripheral clock is kept separate from the system clock to allow + # the system clock to be increased in the future. + dcm_base50_locked = Signal() + self.specials += [ + Instance("DCM_CLKGEN", name="crg_periph_dcm_clkgen", + p_CLKIN_PERIOD=10.0, + p_CLKFX_MULTIPLY=2, + p_CLKFX_DIVIDE=4, + p_CLKFX_MD_MAX=0.5, # CLKFX_MULTIPLY/CLKFX_DIVIDE + p_CLKFXDV_DIVIDE=2, + p_SPREAD_SPECTRUM="NONE", + p_STARTUP_WAIT="FALSE", + + i_CLKIN=clk100a, + o_CLKFX=self.cd_base50.clk, + o_LOCKED=dcm_base50_locked, + i_FREEZEDCM=0, + i_RST=ResetSignal(), + ), + AsyncResetSynchronizer(self.cd_base50, + self.cd_sys.rst | ~dcm_base50_locked) + ] + platform.add_period_constraint(self.cd_base50.clk, 20) + + +class BaseSoC(SoCSDRAM): + csr_peripherals = ( + "spiflash", + "ddrphy", + ) + csr_map_update(SoCSDRAM.csr_map, csr_peripherals) + + def __init__(self, platform, **kwargs): + clk_freq = 50*1000000 + + if 'expansion' in kwargs: + tofe_board_name = kwargs.get('expansion') + del kwargs['expansion'] + else: + tofe_board_name = None + + SoCSDRAM.__init__(self, platform, clk_freq, + integrated_rom_size=0x8000, + integrated_sram_size=0x4000, + with_uart=True, + **kwargs) + self.submodules.crg = _CRG(platform, clk_freq) + self.platform.add_period_constraint(self.crg.cd_sys.clk, 1e9/clk_freq) + + # sdram + sdram_module = MT41J128M16(self.clk_freq, "1:4") + self.submodules.ddrphy = s6ddrphy.S6QuarterRateDDRPHY( + platform.request("ddram"), + rd_bitslip=0, + wr_bitslip=4, + dqs_ddr_alignment="C0") + controller_settings = ControllerSettings(with_bandwidth=True) + self.register_sdram(self.ddrphy, + sdram_module.geom_settings, + sdram_module.timing_settings, + controller_settings=controller_settings) + self.comb += [ + self.ddrphy.clk8x_wr_strb.eq(self.crg.clk8x_wr_strb), + self.ddrphy.clk8x_rd_strb.eq(self.crg.clk8x_rd_strb), + ] + +SoC = BaseSoC From 71d241f4c45f140d516e1ab8ebb6621a23b46f35 Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Thu, 18 Jan 2018 13:47:54 +1100 Subject: [PATCH 189/219] galatea: fix makefile to be similar to nexys_video's --- targets/galatea/Makefile.mk | 39 +++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/targets/galatea/Makefile.mk b/targets/galatea/Makefile.mk index cd357ead..776a6acd 100644 --- a/targets/galatea/Makefile.mk +++ b/targets/galatea/Makefile.mk @@ -1,4 +1,4 @@ -# opsis targets +# galatea targets ifneq ($(PLATFORM),galatea) $(error "Platform should be galatea when using this file!?") @@ -9,44 +9,41 @@ DEFAULT_TARGET = base TARGET ?= $(DEFAULT_TARGET) # Image -image-flash-$(PLATFORM): - $(PLATFORM)-mode-switch --verbose --flash-gateware=$(IMAGE_FILE) - $(PLATFORM)-mode-switch --verbose --reset-gateware +image-flash-$(PLATFORM): image-flash-py + @true # Gateware gateware-load-$(PLATFORM): - $(PLATFORM)-mode-switch --verbose --load-gateware $(GATEWARE_FILEBASE).bit - $(PLATFORM)-mode-switch --verbose --reset-gateware + @echo "Unsupported." + @false -gateware-flash-$(PLATFORM): - $(PLATFORM)-mode-switch --verbose --flash-gateware=$(GATEWARE_FILEBASE).bin - $(PLATFORM)-mode-switch --verbose --reset-gateware +gateware-flash-$(PLATFORM): gateware-flash-py + @true # Firmware firmware-load-$(PLATFORM): - $(PLATFORM)-mode-switch --verbose --mode=serial - flterm --port=$$($(PLATFORM)-mode-switch --get-serial-dev) --kernel=$(FIRMWARE_FILEBASE).bin + @echo "Unsupported." + @false -firmware-flash-$(PLATFORM): - $(PLATFORM)-mode-switch --verbose --flash-softcpu-firmware=$(FIRMWARE_FILEBASE).fbi - $(PLATFORM)-mode-switch --verbose --reset-gateware +firmware-flash-$(PLATFORM): firmwage-flash-py + @true firmware-connect-$(PLATFORM): - flterm --port=$$($(PLATFORM)-mode-switch --get-serial-dev) + flterm --port=$(COMM_PORT) --speed=$(BAUD) firmware-clear-$(PLATFORM): - $(PLATFORM)-mode-switch --verbose --clear-softcpu-firmware + @echo "FIXME: Unsupported?." + @false # Bios bios-flash-$(PLATFORM): - $(PLATFORM)-mode-switch --verbose --flash-softcpu-bios=$(BIOS_FILE) - $(PLATFORM)-mode-switch --verbose --reset-gateware + @echo "Unsupported." + @false # Extra commands help-$(PLATFORM): @true reset-$(PLATFORM): - $(PLATFORM)-mode-switch --verbose --mode=serial - $(PLATFORM)-mode-switch --verbose --mode=jtag - $(PLATFORM)-mode-switch --verbose --mode=serial + @echo "Unsupported." + @false From efbe68b1724df0ed4ea941b87c81da21f6503b7a Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Thu, 18 Jan 2018 23:14:05 +1100 Subject: [PATCH 190/219] saturn: Add Makefile.mk --- targets/saturn/Makefile.mk | 53 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 targets/saturn/Makefile.mk diff --git a/targets/saturn/Makefile.mk b/targets/saturn/Makefile.mk new file mode 100644 index 00000000..2b929115 --- /dev/null +++ b/targets/saturn/Makefile.mk @@ -0,0 +1,53 @@ +# saturn targets + +ifneq ($(PLATFORM),saturn) + $(error "Platform should be arty when using this file!?") +endif + +# Settings +DEFAULT_TARGET = net +TARGET ?= $(DEFAULT_TARGET) + +PROG_PORT ?= /dev/ttyUSB0 +COMM_PORT ?= /dev/ttyUSB1 +BAUD ?= 115200 + +# Image +image-flash-$(PLATFORM): image-flash-py + @true + +# Gateware +gateware-load-$(PLATFORM): + @echo "Unsupported." + @false + +gateware-flash-$(PLATFORM): gateware-flash-py + @true + +# Firmware +firmware-load-$(PLATFORM): + @echo "Unsupported." + @false + +firmware-flash-$(PLATFORM): firmwage-flash-py + @true + +firmware-connect-$(PLATFORM): + flterm --port=$(COMM_PORT) --speed=$(BAUD) + +firmware-clear-$(PLATFORM): + @echo "FIXME: Unsupported?." + @false + +# Bios +bios-flash-$(PLATFORM): + @echo "Unsupported." + @false + +# Extra commands +help-$(PLATFORM): + @true + +reset-$(PLATFORM): + @echo "Unsupported." + @false From 7b06918e08bb2f45496181f82843413bf1c3aedb Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Thu, 18 Jan 2018 23:17:09 +1100 Subject: [PATCH 191/219] saturn/base: fix divisor since sys_clk is 31.25MHz --- targets/saturn/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/targets/saturn/base.py b/targets/saturn/base.py index c66c4b44..03ae7e12 100644 --- a/targets/saturn/base.py +++ b/targets/saturn/base.py @@ -52,7 +52,7 @@ def __init__(self, platform, clk_freq): n, d = f.numerator, f.denominator p = 8 - assert f0*n/d/p/2 == clk_freq + assert f0*n/d/p/4 == clk_freq assert 19e6 <= f0/d <= 500e6 # pfd assert 400e6 <= f0*n/d <= 1000e6 # vco From a06a5cb09f3a5dd37c79d0e05de9fc21214bb2ff Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Thu, 18 Jan 2018 23:19:17 +1100 Subject: [PATCH 192/219] saturn: update Makefile.mk --- targets/saturn/Makefile.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/targets/saturn/Makefile.mk b/targets/saturn/Makefile.mk index 2b929115..ac1e3cd8 100644 --- a/targets/saturn/Makefile.mk +++ b/targets/saturn/Makefile.mk @@ -1,11 +1,11 @@ # saturn targets ifneq ($(PLATFORM),saturn) - $(error "Platform should be arty when using this file!?") + $(error "Platform should be saturn when using this file!?") endif # Settings -DEFAULT_TARGET = net +DEFAULT_TARGET = base TARGET ?= $(DEFAULT_TARGET) PROG_PORT ?= /dev/ttyUSB0 From 60e2a149147dffc905e5969b1a30426b0f1a8fe4 Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Thu, 18 Jan 2018 23:27:25 +1100 Subject: [PATCH 193/219] neso: Add initial support with basesoc target --- targets/neso/Makefile.mk | 53 +++++++++++++ targets/neso/base.py | 155 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 208 insertions(+) create mode 100644 targets/neso/Makefile.mk create mode 100755 targets/neso/base.py diff --git a/targets/neso/Makefile.mk b/targets/neso/Makefile.mk new file mode 100644 index 00000000..20a4340e --- /dev/null +++ b/targets/neso/Makefile.mk @@ -0,0 +1,53 @@ +# neso targets + +ifneq ($(PLATFORM),neso) + $(error "Platform should be neso when using this file!?") +endif + +# Settings +DEFAULT_TARGET = base +TARGET ?= $(DEFAULT_TARGET) + +PROG_PORT ?= /dev/ttyUSB0 +COMM_PORT ?= /dev/ttyUSB1 +BAUD ?= 115200 + +# Image +image-flash-$(PLATFORM): image-flash-py + @true + +# Gateware +gateware-load-$(PLATFORM): + @echo "Unsupported." + @false + +gateware-flash-$(PLATFORM): gateware-flash-py + @true + +# Firmware +firmware-load-$(PLATFORM): + @echo "Unsupported." + @false + +firmware-flash-$(PLATFORM): firmwage-flash-py + @true + +firmware-connect-$(PLATFORM): + flterm --port=$(COMM_PORT) --speed=$(BAUD) + +firmware-clear-$(PLATFORM): + @echo "FIXME: Unsupported?." + @false + +# Bios +bios-flash-$(PLATFORM): + @echo "Unsupported." + @false + +# Extra commands +help-$(PLATFORM): + @true + +reset-$(PLATFORM): + @echo "Unsupported." + @false diff --git a/targets/neso/base.py b/targets/neso/base.py new file mode 100755 index 00000000..086603e9 --- /dev/null +++ b/targets/neso/base.py @@ -0,0 +1,155 @@ +# Support for the Numato Neso Artix 7 100T Board +from litex.gen import * +from litex.gen.genlib.resetsync import AsyncResetSynchronizer + +from litex.soc.integration.soc_core import mem_decoder +from litex.soc.integration.soc_sdram import * +from litex.soc.integration.builder import * + +from litedram.modules import MT41K128M16 +from litedram.phy import a7ddrphy +from litedram.core import ControllerSettings + +from gateware import info +from gateware import spi_flash + +from targets.utils import csr_map_update, period_ns + + +class _CRG(Module): + def __init__(self, platform): + self.clock_domains.cd_sys = ClockDomain() + self.clock_domains.cd_sys4x = ClockDomain(reset_less=True) + self.clock_domains.cd_sys4x_dqs = ClockDomain(reset_less=True) + self.clock_domains.cd_clk200 = ClockDomain() + self.clock_domains.cd_clk50 = ClockDomain() + + clk100 = platform.request("clk100") + rst = ~platform.request("cpu_reset") + + pll_locked = Signal() + pll_fb = Signal() + self.pll_sys = Signal() + pll_sys4x = Signal() + pll_sys4x_dqs = Signal() + pll_clk200 = Signal() + pll_clk50 = Signal() + self.specials += [ + Instance("PLLE2_BASE", + p_STARTUP_WAIT="FALSE", o_LOCKED=pll_locked, + + # VCO @ 1600 MHz + p_REF_JITTER1=0.01, p_CLKIN1_PERIOD=10.0, + p_CLKFBOUT_MULT=16, p_DIVCLK_DIVIDE=1, + i_CLKIN1=clk100, i_CLKFBIN=pll_fb, o_CLKFBOUT=pll_fb, + + # 100 MHz + p_CLKOUT0_DIVIDE=16, p_CLKOUT0_PHASE=0.0, + o_CLKOUT0=self.pll_sys, + + # 400 MHz + p_CLKOUT1_DIVIDE=4, p_CLKOUT1_PHASE=0.0, + o_CLKOUT1=pll_sys4x, + + # 400 MHz dqs + p_CLKOUT2_DIVIDE=4, p_CLKOUT2_PHASE=90.0, + o_CLKOUT2=pll_sys4x_dqs, + + # 200 MHz + p_CLKOUT3_DIVIDE=8, p_CLKOUT3_PHASE=0.0, + o_CLKOUT3=pll_clk200, + + # 50MHz + p_CLKOUT4_DIVIDE=32, p_CLKOUT4_PHASE=0.0, + o_CLKOUT4=pll_clk50 + ), + Instance("BUFG", i_I=self.pll_sys, o_O=self.cd_sys.clk), + Instance("BUFG", i_I=pll_sys4x, o_O=self.cd_sys4x.clk), + Instance("BUFG", i_I=pll_sys4x_dqs, o_O=self.cd_sys4x_dqs.clk), + Instance("BUFG", i_I=pll_clk200, o_O=self.cd_clk200.clk), + Instance("BUFG", i_I=pll_clk50, o_O=self.cd_clk50.clk), + AsyncResetSynchronizer(self.cd_sys, ~pll_locked | rst), + AsyncResetSynchronizer(self.cd_clk200, ~pll_locked | rst), + AsyncResetSynchronizer(self.cd_clk50, ~pll_locked | rst), + ] + + reset_counter = Signal(4, reset=15) + ic_reset = Signal(reset=1) + self.sync.clk200 += \ + If(reset_counter != 0, + reset_counter.eq(reset_counter - 1) + ).Else( + ic_reset.eq(0) + ) + self.specials += Instance("IDELAYCTRL", i_REFCLK=ClockSignal("clk200"), i_RST=ic_reset) + + +class BaseSoC(SoCSDRAM): + csr_peripherals = ( + "spiflash", + "ddrphy", + "info", +# "leds", +# "rgb_leds", + ) + csr_map_update(SoCSDRAM.csr_map, csr_peripherals) + + mem_map = { + "spiflash": 0x20000000, # (default shadow @0xa0000000) + } + mem_map.update(SoCSDRAM.mem_map) + + def __init__(self, platform, spiflash="spiflash_1x", **kwargs): + clk_freq = int(100e6) + SoCSDRAM.__init__(self, platform, clk_freq, + integrated_rom_size=0x8000, + integrated_sram_size=0x8000, + **kwargs) + + self.submodules.crg = _CRG(platform) + self.crg.cd_sys.clk.attr.add("keep") + self.platform.add_period_constraint(self.crg.cd_sys.clk, period_ns(clk_freq)) + + # Basic peripherals + self.submodules.info = info.Info(platform, self.__class__.__name__) +# self.submodules.leds = led.ClassicLed(Cat(platform.request("user_led", i) for i in range(4))) +# self.submodules.rgb_leds = led.RGBLed(platform.request("rgb_leds")) + + # spi flash + spiflash_pads = platform.request(spiflash) + spiflash_pads.clk = Signal() + self.specials += Instance("STARTUPE2", + i_CLK=0, i_GSR=0, i_GTS=0, i_KEYCLEARB=0, i_PACK=0, + i_USRCCLKO=spiflash_pads.clk, i_USRCCLKTS=0, i_USRDONEO=1, i_USRDONETS=1) + spiflash_dummy = { + "spiflash_1x": 9, + "spiflash_4x": 11, + } + self.submodules.spiflash = spi_flash.SpiFlash( + spiflash_pads, + dummy=spiflash_dummy[spiflash], + div=2) + self.add_constant("SPIFLASH_PAGE_SIZE", 256) + self.add_constant("SPIFLASH_SECTOR_SIZE", 0x10000) + self.add_wb_slave(mem_decoder(self.mem_map["spiflash"]), self.spiflash.bus) + self.add_memory_region( + "spiflash", self.mem_map["spiflash"] | self.shadow_base, 16*1024*1024) + + + # sdram + sdram_module = MT41K128M16(self.clk_freq, "1:4") + self.submodules.ddrphy = a7ddrphy.A7DDRPHY( + platform.request("ddram")) + self.add_constant("READ_LEVELING_BITSLIP", 3) + self.add_constant("READ_LEVELING_DELAY", 14) + controller_settings = ControllerSettings( + with_bandwidth=True, + cmd_buffer_depth=8, + with_refresh=True) + self.register_sdram(self.ddrphy, + sdram_module.geom_settings, + sdram_module.timing_settings, + controller_settings=controller_settings) + + +SoC = BaseSoC From 8fdc3a015906d2ffc7ec8d0e05342c673877bbf3 Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Fri, 19 Jan 2018 01:06:01 +1100 Subject: [PATCH 194/219] neso/Makefile: add firmware-load target --- targets/neso/Makefile.mk | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/targets/neso/Makefile.mk b/targets/neso/Makefile.mk index 20a4340e..82fea51e 100644 --- a/targets/neso/Makefile.mk +++ b/targets/neso/Makefile.mk @@ -26,8 +26,7 @@ gateware-flash-$(PLATFORM): gateware-flash-py # Firmware firmware-load-$(PLATFORM): - @echo "Unsupported." - @false + flterm --port=$(COMM_PORT) --kernel=$(FIRMWARE_FILEBASE).bin --speed=$(BAUD) firmware-flash-$(PLATFORM): firmwage-flash-py @true From a038f54ad7664f7aeb45d06d4a0b886d3ad1d6a5 Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Sat, 20 Jan 2018 18:49:34 +1100 Subject: [PATCH 195/219] neso/base: remove external reset --- targets/neso/base.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/targets/neso/base.py b/targets/neso/base.py index 086603e9..8c782b89 100755 --- a/targets/neso/base.py +++ b/targets/neso/base.py @@ -25,7 +25,6 @@ def __init__(self, platform): self.clock_domains.cd_clk50 = ClockDomain() clk100 = platform.request("clk100") - rst = ~platform.request("cpu_reset") pll_locked = Signal() pll_fb = Signal() @@ -68,9 +67,9 @@ def __init__(self, platform): Instance("BUFG", i_I=pll_sys4x_dqs, o_O=self.cd_sys4x_dqs.clk), Instance("BUFG", i_I=pll_clk200, o_O=self.cd_clk200.clk), Instance("BUFG", i_I=pll_clk50, o_O=self.cd_clk50.clk), - AsyncResetSynchronizer(self.cd_sys, ~pll_locked | rst), - AsyncResetSynchronizer(self.cd_clk200, ~pll_locked | rst), - AsyncResetSynchronizer(self.cd_clk50, ~pll_locked | rst), + AsyncResetSynchronizer(self.cd_sys, ~pll_locked), + AsyncResetSynchronizer(self.cd_clk200, ~pll_locked), + AsyncResetSynchronizer(self.cd_clk50, ~pll_locked), ] reset_counter = Signal(4, reset=15) @@ -89,8 +88,6 @@ class BaseSoC(SoCSDRAM): "spiflash", "ddrphy", "info", -# "leds", -# "rgb_leds", ) csr_map_update(SoCSDRAM.csr_map, csr_peripherals) @@ -112,8 +109,6 @@ def __init__(self, platform, spiflash="spiflash_1x", **kwargs): # Basic peripherals self.submodules.info = info.Info(platform, self.__class__.__name__) -# self.submodules.leds = led.ClassicLed(Cat(platform.request("user_led", i) for i in range(4))) -# self.submodules.rgb_leds = led.RGBLed(platform.request("rgb_leds")) # spi flash spiflash_pads = platform.request(spiflash) From c751d87cb42dffaaf55ed84a376737c5e468ebb4 Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Sat, 20 Jan 2018 18:50:50 +1100 Subject: [PATCH 196/219] neso/Makefile: add gateware-load support using openocd --- targets/neso/Makefile.mk | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/targets/neso/Makefile.mk b/targets/neso/Makefile.mk index 82fea51e..bbbc34f5 100644 --- a/targets/neso/Makefile.mk +++ b/targets/neso/Makefile.mk @@ -18,8 +18,7 @@ image-flash-$(PLATFORM): image-flash-py # Gateware gateware-load-$(PLATFORM): - @echo "Unsupported." - @false + openocd -f board/numato_$(PLATFORM).cfg -c "init; pld load 0 $(TARGET_BUILD_DIR)/gateware/top.bit; exit" gateware-flash-$(PLATFORM): gateware-flash-py @true From 2331d570925050e30554e29404b734c8d4c06d88 Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Sat, 20 Jan 2018 18:51:52 +1100 Subject: [PATCH 197/219] platforms/neso: add platform for neso --- platforms/neso.py | 99 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 platforms/neso.py diff --git a/platforms/neso.py b/platforms/neso.py new file mode 100644 index 00000000..31d14cd7 --- /dev/null +++ b/platforms/neso.py @@ -0,0 +1,99 @@ +# This file is Copyright (c) 2018 TimVideos +# License: BSD + +from litex.build.generic_platform import * +from litex.build.openocd import OpenOCD +from litex.build.xilinx import XilinxPlatform, XC3SProg, VivadoProgrammer + +_io = [ + + ("clk100", 0, Pins("F4"), IOStandard("LVCMOS33")), + + ("serial", 0, + Subsignal("tx", Pins("B18")), + Subsignal("rx", Pins("A18")), + IOStandard("LVCMOS33")), + + ("spiflash_4x", 0, # clock needs to be accessed through STARTUPE2 + Subsignal("cs_n", Pins("L13")), + Subsignal("dq", Pins("K17", "K18", "L14", "M14")), + IOStandard("LVCMOS33") + ), + ("spiflash_1x", 0, # clock needs to be accessed through STARTUPE2 + Subsignal("cs_n", Pins("L13")), + Subsignal("mosi", Pins("K17")), + Subsignal("miso", Pins("K18")), + Subsignal("wp", Pins("L14")), + Subsignal("hold", Pins("M14")), + IOStandard("LVCMOS33") + ), + + ("ddram", 0, + Subsignal("a", Pins( + "M4 P4 M6 T1 L3 P5 M2 N1", + "L4 N5 R2 K5 N6 K3"), + IOStandard("SSTL15")), + Subsignal("ba", Pins("P2 P3 R1"), IOStandard("SSTL15")), + Subsignal("ras_n", Pins("N4"), IOStandard("SSTL15")), + Subsignal("cas_n", Pins("L1"), IOStandard("SSTL15")), + Subsignal("we_n", Pins("N2"), IOStandard("SSTL15")), + Subsignal("cs_n", Pins("K6"), IOStandard("SSTL15")), + Subsignal("dm", Pins("T6 U1"), IOStandard("SSTL15")), + Subsignal("dq", Pins( + "R7 V6 R8 U7 V7 R6 U6 R5", + "T5 U3 V5 U4 V4 T4 V1 T3"), + IOStandard("SSTL15"), + Misc("IN_TERM=UNTUNED_SPLIT_40")), + Subsignal("dqs_p", Pins("U9 U2"), IOStandard("DIFF_SSTL15")), + Subsignal("dqs_n", Pins("V9 V2"), IOStandard("DIFF_SSTL15")), + Subsignal("clk_p", Pins("L6"), IOStandard("DIFF_SSTL15")), + Subsignal("clk_n", Pins("L5"), IOStandard("DIFF_SSTL15")), + Subsignal("cke", Pins("M1"), IOStandard("SSTL15")), + Subsignal("odt", Pins("M3"), IOStandard("SSTL15")), + Subsignal("reset_n", Pins("U8"), IOStandard("SSTL15")), + Misc("SLEW=FAST"), + ), +] + + +class Platform(XilinxPlatform): + name = "neso" + default_clk_name = "clk100" + default_clk_period = 10.0 + + # From https://www.xilinx.com/support/documentation/user_guides/ug470_7Series_Config.pdf + # 17536096 bits == 2192012 == 0x21728c -- Therefore 0x220000 + gateware_size = 0x220000 + + # Micron N25Q128A13ESF40 (ID 0x0018ba20) + # FIXME: Create a "spi flash module" object in the same way we have SDRAM + # module objects. + spiflash_model = "n25q128a13" + spiflash_read_dummy_bits = 10 + spiflash_clock_div = 4 + spiflash_total_size = int((128/8)*1024*1024) # 128Mbit + spiflash_page_size = 256 + spiflash_sector_size = 0x10000 + + def __init__(self, toolchain="vivado", programmer="openocd"): + XilinxPlatform.__init__(self, "xc7a100t-csg324-1", _io, + toolchain=toolchain) + self.toolchain.bitstream_commands = \ + ["set_property BITSTREAM.CONFIG.SPI_BUSWIDTH 4 [current_design]"] + self.toolchain.additional_commands = \ + ["write_cfgmem -force -format bin -interface spix4 -size 16 " + "-loadbit \"up 0x0 {build_name}.bit\" -file {build_name}.bin"] + self.programmer = programmer + self.add_platform_command("set_property INTERNAL_VREF 0.750 [get_iobanks 34]") + + def create_programmer(self): + if self.programmer == "openocd": + proxy="bscan_spi_{}.bit".format(self.device.split('-')[0]) + return OpenOCD(config="board/numato_neso.cfg", flash_proxy_basename=proxy) + elif self.programmer == "xc3sprog": + return XC3SProg("saturn") + elif self.programmer == "vivado": + return VivadoProgrammer(flash_part="n25q128-3.3v-spi-x1_x2_x4") + else: + raise ValueError("{} programmer is not supported" + .format(self.programmer)) From aa479a80f58e9b946c57a0a14916f232ed8588dd Mon Sep 17 00:00:00 2001 From: Ewen McNeill Date: Fri, 19 Jan 2018 12:42:59 +1100 Subject: [PATCH 198/219] firmware: stub-out framebuffer/pattern if no main ram On systems without external SDRAM (eg, Numato Elbert v2), there is no MAIN_RAM_BASE, and we cannot hold a frame buffer as we have only small amounts of in-FPGA SRAM. This should be cleaned up to avoid even compiling the framebuffer / pattern when there is no main ram / MAIN_RAM_BASE, but for now we have stubbed out everything referring to main ram or L2 cache (since the L2 cache is over the external SDRAM). In theory this should still work on systems with MAIN RAM, but currently untested. --- firmware/framebuffer.h | 7 +++++++ firmware/pattern.c | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/firmware/framebuffer.h b/firmware/framebuffer.h index adbfd595..9fae2018 100644 --- a/firmware/framebuffer.h +++ b/firmware/framebuffer.h @@ -14,6 +14,7 @@ #ifndef __FRAMEBUFFER_H #define __FRAMEBUFFER_H +#include #include #include "generated/mem.h" @@ -62,7 +63,13 @@ typedef unsigned int fb_ptrdiff_t; // FIXME: typedef uint16_t framebuffer_t[FRAMEBUFFER_SIZE]; inline unsigned int *fb_ptrdiff_to_main_ram(fb_ptrdiff_t p) { +#ifdef MAIN_RAM_BASE return (unsigned int *)(MAIN_RAM_BASE + p); +#else +/* FIXME! Should be unreachable if we have no main ram! */ + assert(0); + return (unsigned int *)(0); +#endif } #endif /* __FRAMEBUFFER_H */ diff --git a/firmware/pattern.c b/firmware/pattern.c index 828c3f87..1e7a8a4b 100644 --- a/firmware/pattern.c +++ b/firmware/pattern.c @@ -132,6 +132,7 @@ static int inc_color(int color) { } static void pattern_draw_text_color(int x, int y, char *ptr, long background_color, long text_color) { +#ifdef MAIN_RAM_BASE int i, j, k; int adr; volatile unsigned int *framebuffer = (unsigned int *)(MAIN_RAM_BASE + pattern_framebuffer_base()); @@ -149,6 +150,8 @@ static void pattern_draw_text_color(int x, int y, char *ptr, long background_col } } } +/* FIXME: Framebuffer Should not even be compiled if no MAIN RAM */ +#endif } static void pattern_draw_text(int x, int y, char *ptr) { @@ -164,6 +167,7 @@ void pattern_next(void) { void pattern_fill_framebuffer(int h_active, int w_active) { +#ifdef MAIN_RAM_BASE int i, j; int color; flush_l2_cache(); @@ -242,10 +246,13 @@ void pattern_fill_framebuffer(int h_active, int w_active) #endif flush_l2_cache(); +/* FIXME: Framebuffer Should not even be compiled if no MAIN RAM */ +#endif } void pattern_service(void) { +#ifdef MAIN_RAM_BASE static int last_event; static char buffer[16]; @@ -254,4 +261,6 @@ void pattern_service(void) pattern_draw_text(1, 1, buffer); } flush_l2_cache(); +/* FIXME: Framebuffer Should not even be compiled if no MAIN RAM */ +#endif } From 7fd4ca3d7554b9c8675faa58f91dc260602dfa1d Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Mon, 22 Jan 2018 11:09:33 +1100 Subject: [PATCH 199/219] cmod_a7: modify cmod_a7 platform and base target --- platforms/cmod_a7.py | 27 ++++------- targets/cmod_a7/base.py | 102 ++++------------------------------------ 2 files changed, 18 insertions(+), 111 deletions(-) diff --git a/platforms/cmod_a7.py b/platforms/cmod_a7.py index b4dc0402..e0451e37 100644 --- a/platforms/cmod_a7.py +++ b/platforms/cmod_a7.py @@ -3,33 +3,26 @@ from litex.build.generic_platform import * from litex.build.openocd import OpenOCD -from litex.build.xilinx import XilinxPlatform, XC3SProg, VivadoProgrammer +from litex.build.xilinx import XilinxPlatform, VivadoProgrammer _io = [ ## LEDs #set_property -dict { PACKAGE_PIN A17 IOSTANDARD LVCMOS33 } [get_ports { led[0] }]; #IO_L12N_T1_MRCC_16 Sch=led[1] #set_property -dict { PACKAGE_PIN C16 IOSTANDARD LVCMOS33 } [get_ports { led[1] }]; #IO_L13P_T2_MRCC_16 Sch=led[2] - ("user_led", 0, Pins("H5"), IOStandard("LVCMOS33")), - ("user_led", 1, Pins("J5"), IOStandard("LVCMOS33")), - ("user_led", 2, Pins("T9"), IOStandard("LVCMOS33")), - ("user_led", 3, Pins("T10"), IOStandard("LVCMOS33")), + ("user_led", 0, Pins("A17"), IOStandard("LVCMOS33")), + ("user_led", 1, Pins("C16"), IOStandard("LVCMOS33")), #set_property -dict { PACKAGE_PIN B17 IOSTANDARD LVCMOS33 } [get_ports { led0_b }]; #IO_L14N_T2_SRCC_16 Sch=led0_b #set_property -dict { PACKAGE_PIN B16 IOSTANDARD LVCMOS33 } [get_ports { led0_g }]; #IO_L13N_T2_MRCC_16 Sch=led0_g #set_property -dict { PACKAGE_PIN C17 IOSTANDARD LVCMOS33 } [get_ports { led0_r }]; #IO_L14P_T2_SRCC_16 Sch=led0_r ("rgb_leds", 0, - Subsignal("r", Pins("G6 G3 J3 K1")), - Subsignal("g", Pins("F6 J4 J2 H6")), - Subsignal("b", Pins("E1 G4 H4 K2")), + Subsignal("r", Pins("C17")), + Subsignal("g", Pins("B16")), + Subsignal("b", Pins("B17")), IOStandard("LVCMOS33") ), - ("user_sw", 0, Pins("A8"), IOStandard("LVCMOS33")), - ("user_sw", 1, Pins("C11"), IOStandard("LVCMOS33")), - ("user_sw", 2, Pins("C10"), IOStandard("LVCMOS33")), - ("user_sw", 3, Pins("A10"), IOStandard("LVCMOS33")), - ## Buttons #set_property -dict { PACKAGE_PIN A18 IOSTANDARD LVCMOS33 } [get_ports { btn[0] }]; #IO_L19N_T3_VREF_16 Sch=btn[0] #set_property -dict { PACKAGE_PIN B18 IOSTANDARD LVCMOS33 } [get_ports { btn[1] }]; #IO_L19P_T3_16 Sch=btn[1] @@ -41,14 +34,12 @@ #create_clock -add -name sys_clk_pin -period 83.33 -waveform {0 41.66} [get_ports {sysclk}]; ("clk12", 0, Pins("L17"), IOStandard("LVCMOS33")), - ("cpu_reset", 0, Pins("C2"), IOStandard("LVCMOS33")), - ## UART #set_property -dict { PACKAGE_PIN J18 IOSTANDARD LVCMOS33 } [get_ports { uart_rxd_out }]; #IO_L7N_T1_D10_14 Sch=uart_rxd_out #set_property -dict { PACKAGE_PIN J17 IOSTANDARD LVCMOS33 } [get_ports { uart_txd_in }]; #IO_L7P_T1_D09_14 Sch=uart_txd_in ("serial", 0, - Subsignal("tx", Pins("D10")), - Subsignal("rx", Pins("A9")), + Subsignal("tx", Pins("J18")), + Subsignal("rx", Pins("J17")), IOStandard("LVCMOS33")), ## QSPI - N25Q032A13EF440F @@ -164,7 +155,7 @@ class Platform(XilinxPlatform): spiflash_sector_size = 0x10000 def __init__(self, toolchain="vivado", programmer="openocd"): - XilinxPlatform.__init__(self, "xc7a35t-csg236-1", _io, + XilinxPlatform.__init__(self, "xc7a35t-cpg236-1", _io, toolchain=toolchain) self.toolchain.bitstream_commands = \ ["set_property BITSTREAM.CONFIG.SPI_BUSWIDTH 4 [current_design]"] diff --git a/targets/cmod_a7/base.py b/targets/cmod_a7/base.py index b9062701..a9ee8d93 100755 --- a/targets/cmod_a7/base.py +++ b/targets/cmod_a7/base.py @@ -2,8 +2,7 @@ from litex.gen import * from litex.gen.genlib.resetsync import AsyncResetSynchronizer -from litex.soc.integration.soc_core import mem_decoder -from litex.soc.integration.soc_sdram import * +from litex.soc.integration.soc_core import * from litex.soc.integration.builder import * from litedram.modules import MT41K128M16 @@ -20,96 +19,30 @@ class _CRG(Module): def __init__(self, platform): self.clock_domains.cd_sys = ClockDomain() - self.clock_domains.cd_sys4x = ClockDomain(reset_less=True) - self.clock_domains.cd_sys4x_dqs = ClockDomain(reset_less=True) self.clock_domains.cd_clk200 = ClockDomain() - self.clock_domains.cd_clk50 = ClockDomain() - - clk100 = platform.request("clk100") - rst = platform.request("cpu_reset") - - pll_locked = Signal() - pll_fb = Signal() - self.pll_sys = Signal() - pll_sys4x = Signal() - pll_sys4x_dqs = Signal() - pll_clk200 = Signal() - pll_clk50 = Signal() + clk12 = platform.request("clk12") + rst = platform.request("user_btn", 0) self.specials += [ - Instance("PLLE2_BASE", - p_STARTUP_WAIT="FALSE", o_LOCKED=pll_locked, - - # VCO @ 1600 MHz - p_REF_JITTER1=0.01, p_CLKIN1_PERIOD=10.0, - p_CLKFBOUT_MULT=16, p_DIVCLK_DIVIDE=1, - i_CLKIN1=clk100, i_CLKFBIN=pll_fb, o_CLKFBOUT=pll_fb, - - # 100 MHz - p_CLKOUT0_DIVIDE=16, p_CLKOUT0_PHASE=0.0, - o_CLKOUT0=self.pll_sys, - - # 400 MHz - p_CLKOUT1_DIVIDE=4, p_CLKOUT1_PHASE=0.0, - o_CLKOUT1=pll_sys4x, - - # 400 MHz dqs - p_CLKOUT2_DIVIDE=4, p_CLKOUT2_PHASE=90.0, - o_CLKOUT2=pll_sys4x_dqs, - - # 200 MHz - p_CLKOUT3_DIVIDE=8, p_CLKOUT3_PHASE=0.0, - o_CLKOUT3=pll_clk200, - - # 50MHz - p_CLKOUT4_DIVIDE=32, p_CLKOUT4_PHASE=0.0, - o_CLKOUT4=pll_clk50 - ), - Instance("BUFG", i_I=self.pll_sys, o_O=self.cd_sys.clk), - Instance("BUFG", i_I=pll_sys4x, o_O=self.cd_sys4x.clk), - Instance("BUFG", i_I=pll_sys4x_dqs, o_O=self.cd_sys4x_dqs.clk), - Instance("BUFG", i_I=pll_clk200, o_O=self.cd_clk200.clk), - Instance("BUFG", i_I=pll_clk50, o_O=self.cd_clk50.clk), - AsyncResetSynchronizer(self.cd_sys, ~pll_locked | ~rst), - AsyncResetSynchronizer(self.cd_clk200, ~pll_locked | rst), - AsyncResetSynchronizer(self.cd_clk50, ~pll_locked | ~rst), - ] - - reset_counter = Signal(4, reset=15) - ic_reset = Signal(reset=1) - self.sync.clk200 += \ - If(reset_counter != 0, - reset_counter.eq(reset_counter - 1) - ).Else( - ic_reset.eq(0) - ) - self.specials += Instance("IDELAYCTRL", i_REFCLK=ClockSignal("clk200"), i_RST=ic_reset) - - # 25MHz clock for Ethernet - eth_clk = Signal() - self.specials += [ - Instance("BUFR", p_BUFR_DIVIDE="4", i_CE=1, i_CLR=0, i_I=clk100, o_O=eth_clk), - Instance("BUFG", i_I=eth_clk, o_O=platform.request("eth_ref_clk")), + Instance("BUFG", i_I=clk12, o_O=self.cd_sys.clk), + AsyncResetSynchronizer(self.cd_sys, rst), ] -class BaseSoC(SoCSDRAM): +class BaseSoC(SoCCore): csr_peripherals = ( "spiflash", - "ddrphy", "info", - "leds", - "rgb_leds", ) - csr_map_update(SoCSDRAM.csr_map, csr_peripherals) + csr_map_update(SoCCore.csr_map, csr_peripherals) mem_map = { "spiflash": 0x20000000, # (default shadow @0xa0000000) } - mem_map.update(SoCSDRAM.mem_map) + mem_map.update(SoCCore.mem_map) def __init__(self, platform, spiflash="spiflash_1x", **kwargs): clk_freq = int(100e6) - SoCSDRAM.__init__(self, platform, clk_freq, + SoCCore.__init__(self, platform, clk_freq, integrated_rom_size=0x8000, integrated_sram_size=0x8000, **kwargs) @@ -120,8 +53,6 @@ def __init__(self, platform, spiflash="spiflash_1x", **kwargs): # Basic peripherals self.submodules.info = info.Info(platform, self.__class__.__name__) - self.submodules.leds = led.ClassicLed(Cat(platform.request("user_led", i) for i in range(4))) - self.submodules.rgb_leds = led.RGBLed(platform.request("rgb_leds")) # spi flash spiflash_pads = platform.request(spiflash) @@ -144,19 +75,4 @@ def __init__(self, platform, spiflash="spiflash_1x", **kwargs): "spiflash", self.mem_map["spiflash"] | self.shadow_base, 16*1024*1024) - # sdram - sdram_module = MT41K128M16(self.clk_freq, "1:4") - self.submodules.ddrphy = a7ddrphy.A7DDRPHY( - platform.request("ddram")) - self.add_constant("A7DDRPHY_BITSLIP", 2) - self.add_constant("A7DDRPHY_DELAY", 6) - controller_settings = ControllerSettings( - with_bandwidth=True, - cmd_buffer_depth=8, - with_refresh=True) - self.register_sdram(self.ddrphy, - sdram_module.geom_settings, - sdram_module.timing_settings, - controller_settings=controller_settings) - SoC = BaseSoC From b32d5e33c7844a408b9c2a3a908b03e5e083612c Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Fri, 26 Jan 2018 12:13:54 +1100 Subject: [PATCH 200/219] platforms: add Numato Waxwing support --- platforms/waxwing.py | 172 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 platforms/waxwing.py diff --git a/platforms/waxwing.py b/platforms/waxwing.py new file mode 100644 index 00000000..158e83f1 --- /dev/null +++ b/platforms/waxwing.py @@ -0,0 +1,172 @@ +# Support for the Numato Waxwing Spartan 6 Development Module +# https://numato.com/product/waxwing-spartan-6-fpga-development-board + +from litex.build.generic_platform import * +from litex.build.xilinx import XilinxPlatform + + +_io = [ + ("clk100", 0, Pins("V10"), IOStandard("LVTTL")), + + ("serial", 0, + Subsignal("tx", Pins("L18")), + Subsignal("rx", Pins("L17"), Misc("PULLUP")), + Subsignal("cts", Pins("M16"), Misc("PULLUP")), + Subsignal("rts", Pins("M18"), Misc("PULLUP")), + IOStandard("LVTTL") + ), + + #the board has a FTDI FT2232H + ("usb_fifo", 0, + Subsignal("data", Pins("L17 L18 M16 M18 N17 N18 P17 P18")), + Subsignal("rxf_n", Pins("K18")), + Subsignal("txe_n", Pins("K17")), + Subsignal("rd_n", Pins("J18")), + Subsignal("wr_n", Pins("J16")), + Subsignal("siwua", Pins("H18")), + IOStandard("LVTTL"), + ), + + ("spiflash", 0, + Subsignal("cs_n", Pins("V3")), + Subsignal("clk", Pins("R15")), + Subsignal("mosi", Pins("R13")), + Subsignal("miso", Pins("T13"), Misc("PULLUP")), + IOStandard("LVCMOS33"), Misc("SLEW=FAST") + ), + + ("ddram_clock", 0, + Subsignal("p", Pins("G3")), + Subsignal("n", Pins("G1")), + IOStandard("MOBILE_DDR") + ), + + ("ddram", 0, + Subsignal("a", Pins("J7 J6 H5 L7 F3 H4 H3 H6 D2 D1 F4 D3 G6")), + Subsignal("ba", Pins("F2 F1")), + Subsignal("cke", Pins("H7")), + Subsignal("ras_n", Pins("L5")), + Subsignal("cas_n", Pins("K5")), + Subsignal("we_n", Pins("E3")), + Subsignal("dq", Pins("L2 L1 K2 K1 H2 H1 J3 J1 M3 M1 N2 N1 T2 T1 U2 U1")), + Subsignal("dqs", Pins("L4 P2")), + Subsignal("dm", Pins("K3 K4")), + IOStandard("MOBILE_DDR") + ), + + # Small DIP switches + # DP1 (user_sw:0) -> DP8 (user_sw:7) + ("user_sw", 0, Pins("L17"), IOStandard("LVCMOS33"), Misc("PULLUP")), + ("user_sw", 1, Pins("C18"), IOStandard("LVCMOS33"), Misc("PULLUP")), + ("user_sw", 2, Pins("C17"), IOStandard("LVCMOS33"), Misc("PULLUP")), + ("user_sw", 3, Pins("G14"), IOStandard("LVCMOS33"), Misc("PULLUP")), + + ("user_btn", 0, Pins("F14"), IOStandard("LVCMOS33"), Misc("PULLUP")), + ("user_btn", 1, Pins("A14"), IOStandard("LVCMOS33"), Misc("PULLUP")), + ("user_btn", 2, Pins("T6"), IOStandard("LVCMOS33"), Misc("PULLUP")), + ("user_btn", 3, Pins("R5"), IOStandard("LVCMOS33"), Misc("PULLUP")), + ("user_btn", 4, Pins("B14"), IOStandard("LVCMOS33"), Misc("PULLUP")), + ("user_btn", 5, Pins("V6"), IOStandard("LVCMOS33"), Misc("PULLUP")), + ("user_btn", 6, Pins("T5"), IOStandard("LVCMOS33"), Misc("PULLUP")), + + # TODO: Check and confirm pin maps below are correct or not + # + ("vga_out", 0, + Subsignal("hsync_n", Pins("T18"), IOStandard("LVCMOS33"), + Misc("SLEW=FAST")), + Subsignal("vsync_n", Pins("U16"), IOStandard("LVCMOS33"), + Misc("SLEW=FAST")), + Subsignal("r", Pins("P18 U18 U17"), IOStandard("LVCMOS33"), + Misc("SLEW=FAST")), + Subsignal("g", Pins("N15 N16 N14"), IOStandard("LVCMOS33"), + Misc("SLEW=FAST")), + Subsignal("b", Pins("V16 P17"), IOStandard("LVCMOS33"), + Misc("SLEW=FAST"))), + + ("sevenseg", 0, + Subsignal("segment7", Pins("G16"), IOStandard("LVCMOS33")), # A + Subsignal("segment6", Pins("L15"), IOStandard("LVCMOS33")), # B + Subsignal("segment5", Pins("L16"), IOStandard("LVCMOS33")), # C + Subsignal("segment4", Pins("K13"), IOStandard("LVCMOS33")), # D + Subsignal("segment3", Pins("K12"), IOStandard("LVCMOS33")), # E + Subsignal("segment2", Pins("G18"), IOStandard("LVCMOS33")), # F + Subsignal("segment1", Pins("F18"), IOStandard("LVCMOS33")), # G + Subsignal("segment0", Pins("L18"), IOStandard("LVCMOS33")), # Dot + Subsignal("enable0", Pins("F17"), IOStandard("LVCMOS33")), # EN0 + Subsignal("enable1", Pins("L14"), IOStandard("LVCMOS33")), # EN1 + Subsignal("enable2", Pins("M13"), IOStandard("LVCMOS33"))), # EN2 + + ("mmc", 0, + Subsignal("dat", Pins("N10 P11 R8 T8"), IOStandard("LVCMOS33"), + Misc("SLEW=FAST")), + + Subsignal("cmd", Pins("T9"), IOStandard("LVCMOS33"), + Misc("SLEW=FAST")), + + Subsignal("clk", Pins("V9"), IOStandard("LVCMOS33"), + Misc("SLEW=FAST"))), + + ("eth_clocks", 0, + Subsignal("tx", Pins("R10")), + Subsignal("rx", Pins("T10")), + IOStandard("LVCMOS33") + ), + ("eth", 0, + Subsignal("rst_n", Pins("P18")), + Subsignal("mdio", Pins("V16")), + Subsignal("mdc", Pins("T18")), + Subsignal("dv", Pins("N14")), + Subsignal("rx_er", Pins("P16")), + Subsignal("rx_data", Pins("U17 U18 M18 M16")), + Subsignal("tx_en", Pins("M14")), + Subsignal("tx_data", Pins("N16 N15 V12 T12")), + Subsignal("col", Pins("U16")), + Subsignal("crs", Pins("P17")), + IOStandard("LVCMOS33") + ), + + ("hdmi_out", 0, + Subsignal("clk_p", Pins("C10"), IOStandard("TMDS_33")), + Subsignal("clk_n", Pins("A10"), IOStandard("TMDS_33")), + Subsignal("data0_p", Pins("C7"), IOStandard("TMDS_33")), + Subsignal("data0_n", Pins("A7"), IOStandard("TMDS_33")), + Subsignal("data1_p", Pins("B8"), IOStandard("TMDS_33")), + Subsignal("data1_n", Pins("A8"), IOStandard("TMDS_33")), + Subsignal("data2_p", Pins("D8"), IOStandard("TMDS_33")), + Subsignal("data2_n", Pins("C8"), IOStandard("TMDS_33")), + Subsignal("scl", Pins("C6"), IOStandard("I2C")), + Subsignal("sda", Pins("D6"), IOStandard("I2C")), + Subsignal("hpd_notif", Pins("D14"), IOStandard("LVCMOS33")) + ), + + ("ac97", 0, + Subsignal("sdo", Pins("B9"), IOStandard("LVCMOS33")), + Subsignal("bit_clk", Pins("C9"), IOStandard("LVCMOS33")), + Subsignal("sdi", Pins("A9"), IOStandard("LVCMOS33")), + Subsignal("sync", Pins("D9"), IOStandard("LVCMOS33")), + Subsignal("reset", Pins("C13"), IOStandard("LVCMOS33")), + ), +] + +_connectors = [ + ("P3", "G13 H12 K14 J13 H16 H15 H14 H13 G14 F14 G18 G16 F16 F15 F18" #15 pins + "F17 E18 E16 D18 D17 C18 C17 A16 B16 A15 C15 C14 D14 A14 B14" #15 pins + "E13 F13 A13 C13 A12 B12 C11 D11 A11 B11 A10 C10 F9 G9 C9 D9" #16 pins + "A9 B9 C8 D8 A8 B8 A7 C7 A6 B6 C6 D6 A5 C5 A4 B4 A3 B3 A2 B2" #20 pins + ), + + ("P2", "K12 K13 L14 M13 M14 N14 L12 L13 L15 L16 K15 K16 N15 N16 T17" #15 pins + "T18 P15 P16 U16 V16 U17 U18 T14 V14 U15 V15 T12 V12 U13 V13" #15 pins + "R11 T11 M11 N11 N10 P11 U11 V11 R10 T10 M10 N9 T9 V9 R8 T8" #16 pins + "N7 P8 M8 N8 U7 V7 U8 V8 R7 T7 N6 P7 N5 P6 T6 V6 R5 T5 U5" #19 pins + "V5 R3 T3 T4 V4" # 5 pins + ) +] + + +class Platform(XilinxPlatform): + default_clk_name = "clk100" + default_clk_period = 10.00 + + def __init__(self): + XilinxPlatform.__init__(self, "xc6slx45-2csg324", _io, _connectors) From 3618b61142beb15a41070d838b924c36b3ae629b Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Fri, 26 Jan 2018 12:14:43 +1100 Subject: [PATCH 201/219] targets: add Numato Waxwing base target and Makefile --- targets/waxwing/Makefile.mk | 51 +++++++++ targets/waxwing/base.py | 218 ++++++++++++++++++++++++++++++++++++ 2 files changed, 269 insertions(+) create mode 100644 targets/waxwing/Makefile.mk create mode 100644 targets/waxwing/base.py diff --git a/targets/waxwing/Makefile.mk b/targets/waxwing/Makefile.mk new file mode 100644 index 00000000..4ab9b6df --- /dev/null +++ b/targets/waxwing/Makefile.mk @@ -0,0 +1,51 @@ +# waxwing targets + +ifneq ($(PLATFORM),waxwing) + $(error "Platform should be saturn when using this file!?") +endif + +# Settings +DEFAULT_TARGET = base +TARGET ?= $(DEFAULT_TARGET) + +PROG_PORT ?= /dev/ttyUSB0 +COMM_PORT ?= /dev/ttyUSB1 +BAUD ?= 115200 + +# Image +image-flash-$(PLATFORM): image-flash-py + @true + +# Gateware +gateware-load-$(PLATFORM): + openocd -f board/numato_$(PLATFORM).cfg -c "init; pld load 0 $(TARGET_BUILD_DIR)/gateware/top.bit; exit" + +gateware-flash-$(PLATFORM): gateware-flash-py + @true + +# Firmware +firmware-load-$(PLATFORM): + flterm --port=$(COMM_PORT) --kernel=$(FIRMWARE_FILEBASE).bin --speed=$(BAUD) + +firmware-flash-$(PLATFORM): firmwage-flash-py + @true + +firmware-connect-$(PLATFORM): + flterm --port=$(COMM_PORT) --speed=$(BAUD) + +firmware-clear-$(PLATFORM): + @echo "FIXME: Unsupported?." + @false + +# Bios +bios-flash-$(PLATFORM): + @echo "Unsupported." + @false + +# Extra commands +help-$(PLATFORM): + @true + +reset-$(PLATFORM): + @echo "Unsupported." + @false diff --git a/targets/waxwing/base.py b/targets/waxwing/base.py new file mode 100644 index 00000000..5bcbb8ec --- /dev/null +++ b/targets/waxwing/base.py @@ -0,0 +1,218 @@ +# Support for the Numato Saturn (http://numato.com/product/saturn-spartan-6-fpga-development-board-with-ddr-sdram) + +from fractions import Fraction + +from litex.gen import * +from litex.gen.genlib.resetsync import AsyncResetSynchronizer + +from litex.build.generic_platform import * + +from litex.soc.integration.soc_sdram import * +from litex.soc.integration.builder import * + +from litedram.modules import MT46H32M16 +from litedram.phy import s6ddrphy +from litedram.core import ControllerSettings + +from targets.utils import csr_map_update + + +class _CRG(Module): + def __init__(self, platform, clk_freq): + # Clock domains for the system (soft CPU and related components run at). + self.clock_domains.cd_sys = ClockDomain() + # Clock domains for the DDR interface. + self.clock_domains.cd_sdram_half = ClockDomain() + self.clock_domains.cd_sdram_full_wr = ClockDomain() + self.clock_domains.cd_sdram_full_rd = ClockDomain() + + # Input 100MHz clock + f0 = Fraction(100, 1)*1000000 + clk100 = platform.request("clk100") + clk100a = Signal() + # Input 100MHz clock (buffered) + self.specials += Instance( + "IBUFG", + i_I=clk100, + o_O=clk100a + ) + + clk100b = Signal() + + self.specials += Instance( + "BUFIO2", + p_DIVIDE=1, + p_DIVIDE_BYPASS="TRUE", p_I_INVERT="FALSE", + i_I=clk100a, + o_DIVCLK=clk100b + ) + + #PLL parameters + f = Fraction(10, 1) + n, d = f.numerator, f.denominator + p = 8 + + assert f0*n/d/p/4 == clk_freq + assert 19e6 <= f0/d <= 500e6 # pfd + assert 400e6 <= f0*n/d <= 1000e6 # vco + + # Unbuffered output signals from the PLL. They need to be buffered + # before feeding into the fabric. + unbuf_sdram_full = Signal() + unbuf_sdram_half_a = Signal() + unbuf_sdram_half_b = Signal() + unbuf_unused_a = Signal() + unbuf_unused_b = Signal() + unbuf_sys = Signal() + + # PLL signals + pll_lckd = Signal() + pll_fb = Signal() + self.specials.pll = Instance( + "PLL_ADV", + name="crg_pll_adv", + p_SIM_DEVICE="SPARTAN6", p_BANDWIDTH="OPTIMIZED", p_COMPENSATION="INTERNAL", + p_REF_JITTER=.01, + i_DADDR=0, i_DCLK=0, i_DEN=0, i_DI=0, i_DWE=0, i_RST=0, i_REL=0, + p_DIVCLK_DIVIDE=d, + # Input Clocks (100MHz) + i_CLKIN1=clk100b, + p_CLKIN1_PERIOD=1e9/f0, + i_CLKIN2=0, + p_CLKIN2_PERIOD=0., + i_CLKINSEL=1, + # Feedback + i_CLKFBIN=pll_fb, o_CLKFBOUT=pll_fb, o_LOCKED=pll_lckd, + p_CLK_FEEDBACK="CLKFBOUT", + p_CLKFBOUT_MULT=n, p_CLKFBOUT_PHASE=0., + # Outputs + # (125 MHz) sdram wr rd + o_CLKOUT0=unbuf_sdram_full, p_CLKOUT0_DUTY_CYCLE=.5, + p_CLKOUT0_PHASE=0., p_CLKOUT0_DIVIDE=p, + # (125 MHz) unused + o_CLKOUT1=unbuf_unused_a, p_CLKOUT1_DUTY_CYCLE=.5, + p_CLKOUT1_PHASE=0., p_CLKOUT1_DIVIDE=p, + # (62.5 MHz) sdram_half - sdram dqs adr ctrl + o_CLKOUT2=unbuf_sdram_half_a, p_CLKOUT2_DUTY_CYCLE=.5, + p_CLKOUT2_PHASE=270., p_CLKOUT2_DIVIDE=(p*2), + # (62.5 MHz) off-chip ddr + o_CLKOUT3=unbuf_sdram_half_b, p_CLKOUT3_DUTY_CYCLE=.5, + p_CLKOUT3_PHASE=270., p_CLKOUT3_DIVIDE=(p*2), + # (31.25 MHz) unused + o_CLKOUT4=unbuf_unused_b, p_CLKOUT4_DUTY_CYCLE=.5, + p_CLKOUT4_PHASE=0., p_CLKOUT4_DIVIDE=(p*4), + # (31.25 MHz) sysclk + o_CLKOUT5=unbuf_sys, p_CLKOUT5_DUTY_CYCLE=.5, + p_CLKOUT5_PHASE=0., p_CLKOUT5_DIVIDE=(p*4), + ) + + #power on reset? + reset = ~platform.request("user_btn", 0) + self.clock_domains.cd_por = ClockDomain() + por = Signal(max=1 << 11, reset=(1 << 11) - 1) + self.sync.por += If(por != 0, por.eq(por - 1)) + self.specials += AsyncResetSynchronizer(self.cd_por, reset) + + #System clock + self.specials += Instance("BUFG", i_I=unbuf_sys, o_O=self.cd_sys.clk) + self.comb += self.cd_por.clk.eq(self.cd_sys.clk) + self.specials += AsyncResetSynchronizer(self.cd_sys, ~pll_lckd | (por > 0)) + + # SDRAM clocks + # ------------------------------------------------------------------------------ + self.clk4x_wr_strb = Signal() + self.clk4x_rd_strb = Signal() + + # sdram_full + self.specials += Instance( + "BUFPLL", + p_DIVIDE=4, + i_PLLIN=unbuf_sdram_full, + i_GCLK=self.cd_sys.clk, + i_LOCKED=pll_lckd, + o_IOCLK=self.cd_sdram_full_wr.clk, + o_SERDESSTROBE=self.clk4x_wr_strb + ) + + self.comb += [ + self.cd_sdram_full_rd.clk.eq(self.cd_sdram_full_wr.clk), + self.clk4x_rd_strb.eq(self.clk4x_wr_strb), + ] + + # sdram_half + self.specials += Instance( + "BUFG", + i_I=unbuf_sdram_half_a, + o_O=self.cd_sdram_half.clk + ) + + clk_sdram_half_shifted = Signal() + self.specials += Instance( + "BUFG", + i_I=unbuf_sdram_half_b, + o_O=clk_sdram_half_shifted + ) + + clk = platform.request("ddram_clock") + self.specials += Instance( + "ODDR2", + p_DDR_ALIGNMENT="NONE", + p_INIT=0, p_SRTYPE="SYNC", + i_D0=1, i_D1=0, i_S=0, i_R=0, i_CE=1, + i_C0=clk_sdram_half_shifted, + i_C1=~clk_sdram_half_shifted, + o_Q=clk.p + ) + + self.specials += Instance( + "ODDR2", + p_DDR_ALIGNMENT="NONE", + p_INIT=0, p_SRTYPE="SYNC", + i_D0=0, i_D1=1, i_S=0, i_R=0, i_CE=1, + i_C0=clk_sdram_half_shifted, + i_C1=~clk_sdram_half_shifted, + o_Q=clk.n + ) + +class BaseSoC(SoCSDRAM): + csr_peripherals = ( + "ddrphy", + ) + csr_map_update(SoCSDRAM.csr_map, csr_peripherals) + + def __init__(self, platform, **kwargs): + clk_freq=(31 + Fraction(1, 4))*1000*1000 + + SoCSDRAM.__init__(self, platform, clk_freq, + integrated_rom_size = 0x8000, + integrated_sram_size = 0x4000, + **kwargs + ) + self.submodules.crg = _CRG(platform, clk_freq) + + # sdram + sdram_module = MT46H32M16(self.clk_freq, "1:2") + self.submodules.ddrphy = s6ddrphy.S6HalfRateDDRPHY( + platform.request("ddram"), + sdram_module.memtype, + rd_bitslip=2, + wr_bitslip=3, + dqs_ddr_alignment="C1" + ) + + controller_settings = ControllerSettings( + with_bandwidth=True + ) + + self.register_sdram(self.ddrphy, + sdram_module.geom_settings, + sdram_module.timing_settings, + controller_settings=controller_settings + ) + + self.comb += [ + self.ddrphy.clk4x_wr_strb.eq(self.crg.clk4x_wr_strb), + self.ddrphy.clk4x_rd_strb.eq(self.crg.clk4x_rd_strb), + ] + +SoC = BaseSoC From c15321da4f52f95f96793b3fd2853cdda9a60678 Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Fri, 26 Jan 2018 12:18:21 +1100 Subject: [PATCH 202/219] platforms: Add Basys3 support --- platforms/basys3.py | 113 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 platforms/basys3.py diff --git a/platforms/basys3.py b/platforms/basys3.py new file mode 100644 index 00000000..698d4815 --- /dev/null +++ b/platforms/basys3.py @@ -0,0 +1,113 @@ +# This file is Copyright (c) 2015 Yann Sionneau +# This file is Copyright (c) 2015 Florent Kermarrec +# License: BSD + +from litex.build.generic_platform import * +from litex.build.openocd import OpenOCD +from litex.build.xilinx import XilinxPlatform, XC3SProg, VivadoProgrammer + +_io = [ + ("user_led", 0, Pins("U16"), IOStandard("LVCMOS33")), + ("user_led", 1, Pins("E19"), IOStandard("LVCMOS33")), + ("user_led", 2, Pins("U19"), IOStandard("LVCMOS33")), + ("user_led", 3, Pins("V19"), IOStandard("LVCMOS33")), + ("user_led", 4, Pins("W18"), IOStandard("LVCMOS33")), + ("user_led", 5, Pins("U15"), IOStandard("LVCMOS33")), + ("user_led", 6, Pins("U14"), IOStandard("LVCMOS33")), + ("user_led", 7, Pins("V14"), IOStandard("LVCMOS33")), + ("user_led", 8, Pins("V13"), IOStandard("LVCMOS33")), + ("user_led", 9, Pins("V3"), IOStandard("LVCMOS33")), + ("user_led", 10, Pins("W3"), IOStandard("LVCMOS33")), + ("user_led", 11, Pins("U3"), IOStandard("LVCMOS33")), + ("user_led", 12, Pins("P3"), IOStandard("LVCMOS33")), + ("user_led", 13, Pins("N3"), IOStandard("LVCMOS33")), + ("user_led", 14, Pins("P1"), IOStandard("LVCMOS33")), + ("user_led", 15, Pins("L1"), IOStandard("LVCMOS33")), + + ("user_sw", 0, Pins("V17"), IOStandard("LVCMOS33")), + ("user_sw", 1, Pins("V16"), IOStandard("LVCMOS33")), + ("user_sw", 2, Pins("W16"), IOStandard("LVCMOS33")), + ("user_sw", 3, Pins("W17"), IOStandard("LVCMOS33")), + ("user_sw", 4, Pins("W15"), IOStandard("LVCMOS33")), + ("user_sw", 5, Pins("V15"), IOStandard("LVCMOS33")), + ("user_sw", 6, Pins("W14"), IOStandard("LVCMOS33")), + ("user_sw", 7, Pins("W13"), IOStandard("LVCMOS33")), + ("user_sw", 8, Pins("V2"), IOStandard("LVCMOS33")), + ("user_sw", 9, Pins("T3"), IOStandard("LVCMOS33")), + ("user_sw", 10, Pins("T2"), IOStandard("LVCMOS33")), + ("user_sw", 11, Pins("R3"), IOStandard("LVCMOS33")), + ("user_sw", 12, Pins("W2"), IOStandard("LVCMOS33")), + ("user_sw", 13, Pins("U1"), IOStandard("LVCMOS33")), + ("user_sw", 14, Pins("T1"), IOStandard("LVCMOS33")), + ("user_sw", 15, Pins("R2"), IOStandard("LVCMOS33")), + + ("user_btn", 0, Pins("W19"), IOStandard("LVCMOS33")), + ("user_btn", 1, Pins("T17"), IOStandard("LVCMOS33")), + ("user_btn", 2, Pins("T18"), IOStandard("LVCMOS33")), + ("user_btn", 3, Pins("U17"), IOStandard("LVCMOS33")), + ("user_btn", 4, Pins("U18"), IOStandard("LVCMOS33")), + + ("clk100", 0, Pins("W5"), IOStandard("LVCMOS33")), + + ("serial", 0, + Subsignal("tx", Pins("A18")), + Subsignal("rx", Pins("B18")), + IOStandard("LVCMOS33")), + + ("spiflash_4x", 0, # clock needs to be accessed through STARTUPE2 + Subsignal("cs_n", Pins("K19")), + Subsignal("dq", Pins("D18", "D19", "G18", "F18")), + IOStandard("LVCMOS33") + ), + ("spiflash_1x", 0, # clock needs to be accessed through STARTUPE2 + Subsignal("cs_n", Pins("K19")), + Subsignal("mosi", Pins("D18")), + Subsignal("miso", Pins("D19")), + Subsignal("wp", Pins("G18")), + Subsignal("hold", Pins("F18")), + IOStandard("LVCMOS33") + ), +] + + +class Platform(XilinxPlatform): + name = "arty" + default_clk_name = "clk100" + default_clk_period = 10.0 + + # From https://www.xilinx.com/support/documentation/user_guides/ug470_7Series_Config.pdf + # 17536096 bits == 2192012 == 0x21728c -- Therefore 0x220000 + gateware_size = 0x220000 + + # Micron N25Q128A13ESF40 (ID 0x0018ba20) + # FIXME: Create a "spi flash module" object in the same way we have SDRAM + # module objects. + spiflash_model = "n25q128a13" + spiflash_read_dummy_bits = 10 + spiflash_clock_div = 4 + spiflash_total_size = int((128/8)*1024*1024) # 128Mbit + spiflash_page_size = 256 + spiflash_sector_size = 0x10000 + + def __init__(self, toolchain="vivado", programmer="openocd"): + XilinxPlatform.__init__(self, "xc7a35t-cpg236-1", _io, + toolchain=toolchain) + self.toolchain.bitstream_commands = \ + ["set_property BITSTREAM.CONFIG.SPI_BUSWIDTH 4 [current_design]"] + self.toolchain.additional_commands = \ + ["write_cfgmem -force -format bin -interface spix4 -size 16 " + "-loadbit \"up 0x0 {build_name}.bit\" -file {build_name}.bin"] + self.programmer = programmer + self.add_platform_command("set_property INTERNAL_VREF 0.750 [get_iobanks 34]") + + def create_programmer(self): + if self.programmer == "openocd": + proxy="bscan_spi_{}.bit".format(self.device.split('-')[0]) + return OpenOCD(config="board/digilent_arty.cfg", flash_proxy_basename=proxy) + elif self.programmer == "xc3sprog": + return XC3SProg("nexys4") + elif self.programmer == "vivado": + return VivadoProgrammer(flash_part="n25q128-3.3v-spi-x1_x2_x4") + else: + raise ValueError("{} programmer is not supported" + .format(self.programmer)) From 45185208e57fe207521b00a436ef986e7137b25a Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Fri, 26 Jan 2018 12:18:56 +1100 Subject: [PATCH 203/219] targets: Add basys3 base target and Makefile --- targets/basys3/Makefile.mk | 48 ++++++++++++++++++ targets/basys3/base.py | 99 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 147 insertions(+) create mode 100644 targets/basys3/Makefile.mk create mode 100755 targets/basys3/base.py diff --git a/targets/basys3/Makefile.mk b/targets/basys3/Makefile.mk new file mode 100644 index 00000000..6635620a --- /dev/null +++ b/targets/basys3/Makefile.mk @@ -0,0 +1,48 @@ +# basys3 targets + +ifneq ($(PLATFORM),basys3) + $(error "Platform should be arty when using this file!?") +endif + +# Settings +DEFAULT_TARGET = net +TARGET ?= $(DEFAULT_TARGET) + +PROG_PORT ?= /dev/ttyUSB0 +COMM_PORT ?= /dev/ttyUSB1 +BAUD ?= 115200 + +# Image +image-flash-$(PLATFORM): image-flash-py + @true + +# Gateware +gateware-load-$(PLATFORM): + openocd -f board/digilent_$(PLATFORM).cfg -c "init; pld load 0 $(TARGET_BUILD_DIR)/gateware/top.bit; exit" + +gateware-flash-$(PLATFORM): gateware-flash-py + @true + +# Firmware +firmware-load-$(PLATFORM): + flterm --port=$(COMM_PORT) --kernel=$(FIRMWARE_FILEBASE).bin --speed=$(BAUD) + + +firmware-flash-$(PLATFORM): firmwage-flash-py + @true + +firmware-connect-$(PLATFORM): + flterm --port=$(COMM_PORT) --speed=$(BAUD) + +# Bios +bios-flash-$(PLATFORM): + @echo "Unsupported." + @false + +# Extra commands +help-$(PLATFORM): + @true + +reset-$(PLATFORM): + @echo "Unsupported." + @false diff --git a/targets/basys3/base.py b/targets/basys3/base.py new file mode 100755 index 00000000..39f5bf36 --- /dev/null +++ b/targets/basys3/base.py @@ -0,0 +1,99 @@ +# Support for the Digilent Arty Board +from litex.gen import * +from litex.gen.genlib.resetsync import AsyncResetSynchronizer + +from litex.soc.integration.soc_core import * +from litex.soc.integration.soc_sdram import * +from litex.soc.integration.builder import * + +from litedram.modules import MT41K128M16 +from litedram.phy import a7ddrphy +from litedram.core import ControllerSettings + +from gateware import info +from gateware import led +from gateware import spi_flash + +from targets.utils import csr_map_update, period_ns + + +class _CRG(Module): + def __init__(self, platform): + self.clock_domains.cd_sys = ClockDomain() + self.clock_domains.cd_sys4x = ClockDomain(reset_less=True) + self.clock_domains.cd_sys4x_dqs = ClockDomain(reset_less=True) + self.clock_domains.cd_clk200 = ClockDomain() + self.clock_domains.cd_clk50 = ClockDomain() + + clk100 = platform.request("clk100") + rst = platform.request("user_btn") + + pll_locked = Signal() + pll_fb = Signal() + self.pll_sys = Signal() + self.specials += [ + Instance("PLLE2_BASE", + p_STARTUP_WAIT="FALSE", o_LOCKED=pll_locked, + + # VCO @ 1600 MHz + p_REF_JITTER1=0.01, p_CLKIN1_PERIOD=10.0, + p_CLKFBOUT_MULT=16, p_DIVCLK_DIVIDE=1, + i_CLKIN1=clk100, i_CLKFBIN=pll_fb, o_CLKFBOUT=pll_fb, + + # 100 MHz + p_CLKOUT0_DIVIDE=16, p_CLKOUT0_PHASE=0.0, + o_CLKOUT0=self.pll_sys, + ), + Instance("BUFG", i_I=self.pll_sys, o_O=self.cd_sys.clk), + AsyncResetSynchronizer(self.cd_sys, ~pll_locked | rst), + ] + + +class BaseSoC(SoCCore): + csr_peripherals = ( + "spiflash", + "info", + ) + csr_map_update(SoCCore.csr_map, csr_peripherals) + + mem_map = { + "spiflash": 0x20000000, # (default shadow @0xa0000000) + } + mem_map.update(SoCCore.mem_map) + + def __init__(self, platform, spiflash="spiflash_1x", **kwargs): + clk_freq = int(100e6) + SoCCore.__init__(self, platform, clk_freq, + integrated_rom_size=0x8000, + integrated_sram_size=0x8000, + **kwargs) + + self.submodules.crg = _CRG(platform) + self.crg.cd_sys.clk.attr.add("keep") + self.platform.add_period_constraint(self.crg.cd_sys.clk, period_ns(clk_freq)) + + # Basic peripherals + self.submodules.info = info.Info(platform, self.__class__.__name__) + + # spi flash + spiflash_pads = platform.request(spiflash) + spiflash_pads.clk = Signal() + self.specials += Instance("STARTUPE2", + i_CLK=0, i_GSR=0, i_GTS=0, i_KEYCLEARB=0, i_PACK=0, + i_USRCCLKO=spiflash_pads.clk, i_USRCCLKTS=0, i_USRDONEO=1, i_USRDONETS=1) + spiflash_dummy = { + "spiflash_1x": 9, + "spiflash_4x": 11, + } + self.submodules.spiflash = spi_flash.SpiFlash( + spiflash_pads, + dummy=spiflash_dummy[spiflash], + div=2) + self.add_constant("SPIFLASH_PAGE_SIZE", 256) + self.add_constant("SPIFLASH_SECTOR_SIZE", 0x10000) + self.add_wb_slave(mem_decoder(self.mem_map["spiflash"]), self.spiflash.bus) + self.add_memory_region( + "spiflash", self.mem_map["spiflash"] | self.shadow_base, 16*1024*1024) + + +SoC = BaseSoC From f75b6b42464bd6dc5fca579a6c8ab1209476855d Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Fri, 26 Jan 2018 12:42:35 +1100 Subject: [PATCH 204/219] Add new platforms to travis --- .travis.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.travis.yml b/.travis.yml index 36adc797..6ac5ea37 100644 --- a/.travis.yml +++ b/.travis.yml @@ -86,6 +86,24 @@ jobs: - stage: Targets - Base env: C=lm32 P=pipistrello T="base" + - stage: Targets - Base + env: C=lm32 P=saturn T="base" + + - stage: Targets - Base + env: C=lm32 P=galatea T="base" + + - stage: Targets - Base + env: C=lm32 P=neso T="base" + + - stage: Targets - Base + env: C=lm32 P=waxwing T="base" + + - stage: Targets - Base + env: C=lm32 P=basys3 T="base" + + - stage: Targets - Base + env: C=lm32 P=cmod_a7 T="base" + # or1k base targets - stage: Targets - Base env: C=or1k P=arty T="base net" From fbbf31fbdff7fc57a8e3b5e55d157e923959b355 Mon Sep 17 00:00:00 2001 From: Rohit Kumar Singh Date: Sun, 18 Feb 2018 10:28:03 +0530 Subject: [PATCH 205/219] targets/basys3: Change arty to basys3 in makefile's error string --- targets/basys3/Makefile.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/targets/basys3/Makefile.mk b/targets/basys3/Makefile.mk index 6635620a..c23f85fb 100644 --- a/targets/basys3/Makefile.mk +++ b/targets/basys3/Makefile.mk @@ -1,7 +1,7 @@ # basys3 targets ifneq ($(PLATFORM),basys3) - $(error "Platform should be arty when using this file!?") + $(error "Platform should be basys3 when using this file!?") endif # Settings From 82237d0e5f733a46b37279691d974c518e9ef817 Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Fri, 18 May 2018 23:37:14 +0530 Subject: [PATCH 206/219] saturn/base: replace litex.gen with migen --- targets/saturn/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/targets/saturn/base.py b/targets/saturn/base.py index 03ae7e12..5a4a079c 100644 --- a/targets/saturn/base.py +++ b/targets/saturn/base.py @@ -2,8 +2,8 @@ from fractions import Fraction -from litex.gen import * -from litex.gen.genlib.resetsync import AsyncResetSynchronizer +from migen import * +from migen.genlib.resetsync import AsyncResetSynchronizer from litex.build.generic_platform import * From 5052592f62e3c5c581c3460a3b5f588f00522f99 Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Fri, 18 May 2018 23:43:02 +0530 Subject: [PATCH 207/219] cmod_a7/base: change litex.gen to migen --- targets/cmod_a7/base.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/targets/cmod_a7/base.py b/targets/cmod_a7/base.py index a9ee8d93..3de458f7 100755 --- a/targets/cmod_a7/base.py +++ b/targets/cmod_a7/base.py @@ -1,14 +1,10 @@ # Support for the Digilent Cmod A7 Board -from litex.gen import * -from litex.gen.genlib.resetsync import AsyncResetSynchronizer +from migen import * +from migen.genlib.resetsync import AsyncResetSynchronizer from litex.soc.integration.soc_core import * from litex.soc.integration.builder import * -from litedram.modules import MT41K128M16 -from litedram.phy import a7ddrphy -from litedram.core import ControllerSettings - from gateware import info from gateware import led from gateware import spi_flash From 2df87c0d6532d33ab76bfd5c6f1b96ec66d81481 Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Fri, 18 May 2018 23:50:36 +0530 Subject: [PATCH 208/219] galatea/base: change litex.gen to migen, remove unnecessary imports --- targets/galatea/base.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/targets/galatea/base.py b/targets/galatea/base.py index 91d35352..d555a481 100644 --- a/targets/galatea/base.py +++ b/targets/galatea/base.py @@ -1,28 +1,19 @@ # Support for Numato Galatea - https://numato.com/product/galatea-pci-express-spartan-6-fpga-development-board from fractions import Fraction -from litex.gen import * -from litex.gen.genlib.resetsync import AsyncResetSynchronizer -from litex.gen.genlib.misc import WaitTimer +from migen import * +from migen.genlib.resetsync import AsyncResetSynchronizer from litex.soc.integration.soc_sdram import * from litex.soc.integration.builder import * -from litex.soc.cores.gpio import GPIOIn, GPIOOut -from litex.soc.interconnect.csr import AutoCSR from litedram.modules import MT41J128M16 from litedram.phy import s6ddrphy from litedram.core import ControllerSettings -from gateware import i2c -from gateware import info -from gateware import opsis_i2c -from gateware import shared_uart -from gateware import tofe -from gateware import spi_flash - from targets.utils import csr_map_update + class _CRG(Module): def __init__(self, platform, clk_freq): # Clock domains for the system (soft CPU and related components run at). From 598e393698e6590a1ae466f6b17ff73fe004bf1c Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Fri, 18 May 2018 23:53:36 +0530 Subject: [PATCH 209/219] neso/base: change litex.gen to migen --- targets/neso/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/targets/neso/base.py b/targets/neso/base.py index 8c782b89..206ca8e5 100755 --- a/targets/neso/base.py +++ b/targets/neso/base.py @@ -1,6 +1,6 @@ # Support for the Numato Neso Artix 7 100T Board -from litex.gen import * -from litex.gen.genlib.resetsync import AsyncResetSynchronizer +from migen import * +from migen.genlib.resetsync import AsyncResetSynchronizer from litex.soc.integration.soc_core import mem_decoder from litex.soc.integration.soc_sdram import * From 58f9931ec33aaffc839eeb87c36445e37ede4c53 Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Fri, 18 May 2018 23:57:03 +0530 Subject: [PATCH 210/219] waxwing/base: change litex.gen to migen --- targets/waxwing/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/targets/waxwing/base.py b/targets/waxwing/base.py index 5bcbb8ec..4d979388 100644 --- a/targets/waxwing/base.py +++ b/targets/waxwing/base.py @@ -2,8 +2,8 @@ from fractions import Fraction -from litex.gen import * -from litex.gen.genlib.resetsync import AsyncResetSynchronizer +from migen import * +from migen.genlib.resetsync import AsyncResetSynchronizer from litex.build.generic_platform import * From e7ef03709a82a9f96298499be6b68c93223bdb25 Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Sat, 19 May 2018 00:06:10 +0530 Subject: [PATCH 211/219] basys3/base: change litex.gen to migen --- targets/basys3/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/targets/basys3/base.py b/targets/basys3/base.py index 39f5bf36..460277fc 100755 --- a/targets/basys3/base.py +++ b/targets/basys3/base.py @@ -1,6 +1,6 @@ # Support for the Digilent Arty Board -from litex.gen import * -from litex.gen.genlib.resetsync import AsyncResetSynchronizer +from migen import * +from migen.genlib.resetsync import AsyncResetSynchronizer from litex.soc.integration.soc_core import * from litex.soc.integration.soc_sdram import * From 88fb1b68a9d0375288e1cb6a9649f178e5264f90 Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Sat, 19 May 2018 00:25:35 +0530 Subject: [PATCH 212/219] platforms/waxwing: review pinouts and resolve TODO --- platforms/waxwing.py | 43 ++++++++++++++++--------------------------- 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/platforms/waxwing.py b/platforms/waxwing.py index 158e83f1..3035669c 100644 --- a/platforms/waxwing.py +++ b/platforms/waxwing.py @@ -69,29 +69,27 @@ ("user_btn", 5, Pins("V6"), IOStandard("LVCMOS33"), Misc("PULLUP")), ("user_btn", 6, Pins("T5"), IOStandard("LVCMOS33"), Misc("PULLUP")), - # TODO: Check and confirm pin maps below are correct or not - # ("vga_out", 0, - Subsignal("hsync_n", Pins("T18"), IOStandard("LVCMOS33"), + Subsignal("hsync_n", Pins("U8"), IOStandard("LVCMOS33"), Misc("SLEW=FAST")), - Subsignal("vsync_n", Pins("U16"), IOStandard("LVCMOS33"), + Subsignal("vsync_n", Pins("V8"), IOStandard("LVCMOS33"), Misc("SLEW=FAST")), - Subsignal("r", Pins("P18 U18 U17"), IOStandard("LVCMOS33"), + Subsignal("r", Pins("M8 R11 T11"), IOStandard("LVCMOS33"), Misc("SLEW=FAST")), - Subsignal("g", Pins("N15 N16 N14"), IOStandard("LVCMOS33"), + Subsignal("g", Pins("N7 P8 N8"), IOStandard("LVCMOS33"), Misc("SLEW=FAST")), - Subsignal("b", Pins("V16 P17"), IOStandard("LVCMOS33"), + Subsignal("b", Pins("P7 N6"), IOStandard("LVCMOS33"), Misc("SLEW=FAST"))), ("sevenseg", 0, - Subsignal("segment7", Pins("G16"), IOStandard("LVCMOS33")), # A - Subsignal("segment6", Pins("L15"), IOStandard("LVCMOS33")), # B - Subsignal("segment5", Pins("L16"), IOStandard("LVCMOS33")), # C - Subsignal("segment4", Pins("K13"), IOStandard("LVCMOS33")), # D - Subsignal("segment3", Pins("K12"), IOStandard("LVCMOS33")), # E - Subsignal("segment2", Pins("G18"), IOStandard("LVCMOS33")), # F - Subsignal("segment1", Pins("F18"), IOStandard("LVCMOS33")), # G - Subsignal("segment0", Pins("L18"), IOStandard("LVCMOS33")), # Dot + Subsignal("segment7", Pins("L18"), IOStandard("LVCMOS33")), # A + Subsignal("segment6", Pins("F18"), IOStandard("LVCMOS33")), # B + Subsignal("segment5", Pins("G18"), IOStandard("LVCMOS33")), # C + Subsignal("segment4", Pins("K12"), IOStandard("LVCMOS33")), # D + Subsignal("segment3", Pins("K13"), IOStandard("LVCMOS33")), # E + Subsignal("segment2", Pins("L16"), IOStandard("LVCMOS33")), # F + Subsignal("segment1", Pins("L15"), IOStandard("LVCMOS33")), # G + Subsignal("segment0", Pins("G16"), IOStandard("LVCMOS33")), # Dot Subsignal("enable0", Pins("F17"), IOStandard("LVCMOS33")), # EN0 Subsignal("enable1", Pins("L14"), IOStandard("LVCMOS33")), # EN1 Subsignal("enable2", Pins("M13"), IOStandard("LVCMOS33"))), # EN2 @@ -149,18 +147,9 @@ ] _connectors = [ - ("P3", "G13 H12 K14 J13 H16 H15 H14 H13 G14 F14 G18 G16 F16 F15 F18" #15 pins - "F17 E18 E16 D18 D17 C18 C17 A16 B16 A15 C15 C14 D14 A14 B14" #15 pins - "E13 F13 A13 C13 A12 B12 C11 D11 A11 B11 A10 C10 F9 G9 C9 D9" #16 pins - "A9 B9 C8 D8 A8 B8 A7 C7 A6 B6 C6 D6 A5 C5 A4 B4 A3 B3 A2 B2" #20 pins - ), - - ("P2", "K12 K13 L14 M13 M14 N14 L12 L13 L15 L16 K15 K16 N15 N16 T17" #15 pins - "T18 P15 P16 U16 V16 U17 U18 T14 V14 U15 V15 T12 V12 U13 V13" #15 pins - "R11 T11 M11 N11 N10 P11 U11 V11 R10 T10 M10 N9 T9 V9 R8 T8" #16 pins - "N7 P8 M8 N8 U7 V7 U8 V8 R7 T7 N6 P7 N5 P6 T6 V6 R5 T5 U5" #19 pins - "V5 R3 T3 T4 V4" # 5 pins - ) + ("P3", "F15 F16 E16 E18 B12 A12 B11 A11"), + ("P4", "B6 A6 D11 C11 H15 H16 F13 E13"), + ("P5", "B4 A4 C5 A5 B3 A3 B2 A2"), ] From c50c6ec3bc57a8729c0188d9e27165f502626448 Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Sat, 19 May 2018 00:27:52 +0530 Subject: [PATCH 213/219] platforms/basys3: fix platform name to basys3 --- platforms/basys3.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platforms/basys3.py b/platforms/basys3.py index 698d4815..10c0067a 100644 --- a/platforms/basys3.py +++ b/platforms/basys3.py @@ -71,7 +71,7 @@ class Platform(XilinxPlatform): - name = "arty" + name = "basys3" default_clk_name = "clk100" default_clk_period = 10.0 From d1d9291abc4523545b62ba5dd5ba5df7a89cf33f Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Fri, 18 May 2018 13:34:42 -0700 Subject: [PATCH 214/219] basys3: Fixing default target. --- targets/basys3/Makefile.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/targets/basys3/Makefile.mk b/targets/basys3/Makefile.mk index c23f85fb..bc6e7af0 100644 --- a/targets/basys3/Makefile.mk +++ b/targets/basys3/Makefile.mk @@ -5,7 +5,7 @@ ifneq ($(PLATFORM),basys3) endif # Settings -DEFAULT_TARGET = net +DEFAULT_TARGET = base TARGET ?= $(DEFAULT_TARGET) PROG_PORT ?= /dev/ttyUSB0 From d7ef6b2c01c4de63def3068e03a6f23e7c82f4c5 Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Sat, 19 May 2018 10:57:39 +0530 Subject: [PATCH 215/219] cmod_a7: Fixing default target. --- targets/cmod_a7/Makefile.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/targets/cmod_a7/Makefile.mk b/targets/cmod_a7/Makefile.mk index 5f9060f7..806d2ae6 100644 --- a/targets/cmod_a7/Makefile.mk +++ b/targets/cmod_a7/Makefile.mk @@ -5,7 +5,7 @@ ifneq ($(PLATFORM),cmod_a7) endif # Settings -DEFAULT_TARGET = net +DEFAULT_TARGET = base TARGET ?= $(DEFAULT_TARGET) PROG_PORT ?= /dev/ttyUSB0 From df738247ec3fcc3f5263f5e74e01d707a6712b4c Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sat, 19 May 2018 11:50:19 -0700 Subject: [PATCH 216/219] github: Adding autolabelling for the new boards. --- .github/autolabeler.yml | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/.github/autolabeler.yml b/.github/autolabeler.yml index 2c6ab692..2391bac4 100644 --- a/.github/autolabeler.yml +++ b/.github/autolabeler.yml @@ -1,14 +1,37 @@ board-arty: ["targets/arty", "platforms/arty.py"] board-atlys: ["targets/atlys", "platforms/atlys.py"] +board-basys3: ["targets/basys3", "platforms/basys3.py"] +board-cmod_a7: ["targets/cmod_a7", "platforms/cmod_a7.py"] +board-galatea: ["targets/galatea", "platforms/galatea.py"] board-mimasv2: ["targets/mimasv2", "platforms/mimasv2.py"] board-minispartan6: ["targets/minispartan6", "platforms/minispartan6.py"] +board-neso: ["targets/neso", "platforms/neso.py"] board-netv2: ["targets/netv2", "platforms/netv2.py"] board-nexys-video: ["targets/nexys-video", "platforms/nexys-video.py"] board-opsis: ["targets/opsis", "platforms/opsis.py", "platforms/tofe_*.py"] -board-pipstrello: ["targets/pipstrello", "platforms/pipstrello.py"] +board-pipistrello: ["targets/pipistrello", "platforms/pipistrello.py"] +board-saturn: ["targets/saturn", "platforms/saturn.py"] +board-sim: ["targets/sim", "platforms/sim.py"] +board-waxwing: ["targets/waxwing", "platforms/waxwing.py"] boards-all: ["targets/common/"] -boards-artix7: ["targets/arty", "platforms/arty.py", "targets/netv2", "platforms/netv2.py", "targets/nexys-video", "platforms/nexys-video.py"] -boards-spartan6: ["targets/atlys", "platforms/atlys.py", "targets/mimasv2", "platforms/mimasv2.py", "targets/minispartan6", "platforms/minispartan6.py", "targets/opsis", "platforms/opsis.py", "targets/pipstrello", "platforms/pipstrello.py"] +boards-artix7: [ + "targets/arty", "platforms/arty.py", + "targets/basys3", "platforms/basys3.py", + "targets/cmod_a7", "platforms/cmod_a7.py", + "targets/neso", "platforms/neso.py", + "targets/netv2", "platforms/netv2.py", + "targets/nexys-video", "platforms/nexys-video.py" + ] +boards-spartan6: [ + "targets/atlys", "platforms/atlys.py", + "targets/galatea", "platforms/galatea.py", + "targets/mimasv2", "platforms/mimasv2.py", + "targets/minispartan6", "platforms/minispartan6.py", + "targets/opsis", "platforms/opsis.py", + "targets/pipstrello", "platforms/pipstrello.py", + "targets/saturn", "platforms/saturn.py", + "targets/waxwing", "platforms/waxwing.py" + ] firmware-fpga: ["gateware/"] firmware-softcpu: ["firmware/"] hdmi2ethernet: ["targets/*/net.py", "targets/*/hdmi2eth.py", "firmware/uip/", "third_party/libuip/"] From 5fdefa6b7e7a23ec2183b482ab6f02473ef5e490 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sun, 20 May 2018 16:49:51 -0700 Subject: [PATCH 217/219] travis: Adding update as travis suggested. ``` Running apt-get update by default has been disabled. You can opt into running apt-get update by setting this in your .travis.yml file: addons: apt: update: true ``` --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 6ac5ea37..293b8006 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ compiler: sudo: false addons: apt: + update: true packages: - build-essential - fxload From 55923babab45ee03a9fd07bb3291cbb38b659eff Mon Sep 17 00:00:00 2001 From: Nancy Date: Thu, 31 May 2018 10:56:26 +0530 Subject: [PATCH 218/219] Update getting-started.md Addition in Test loading the gateware $make gateware-load $make firmware-load BIOS>serialboot $make firmware-connect --- getting-started.md | 50 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/getting-started.md b/getting-started.md index a7a943ee..00a87bbf 100644 --- a/getting-started.md +++ b/getting-started.md @@ -312,6 +312,56 @@ to switch to serial mode and then back to the jtag mode like this; ``` hdmi2usb-mode-switch --mode=serial hdmi2usb-mode-switch --mode=jtag +``` +Load the firmware +``` +make firmware-load + +``` +If you see no output, press ‘Enter’ a few times. You can then kick off the firmware loading process again: +``` +BIOS> serialboot +Booting from serial... +Press Q or ESC to abort boot completely. +sL5DdSMmkekro +[FLTERM] Received firmware download request from the device. +[FLTERM] Uploading kernel (86484 bytes)... +[FLTERM] Upload complete (10.6KB/s). +[FLTERM] Booting the device. +[FLTERM] Done. +Executing booted program at 0x40000000 +HDMI2USB firmware booting... + +opsis_eeprom: Init...finished. + +hardware version info +=============================================== + DNA: 0137be87d98719f0 + MAC: d8:80:39:57:04:94 + +gateware version info +=============================================== + platform: opsis + target: video + revision: 5f07955beabcf9cebe0e896c4e51242075566cb6 + +firmware version info +=============================================== + platform: opsis + target: video + git commit: 5f07955beabcf9cebe0e896c4e51242075566cb6 + git branch: master + git describe: v0.0.4-203-g5f07955 + git status: + -- + ?? ../../../../HDMI2USB-mode-switch/ + -- + + built: May 31 2018 10:43:25 + uptime: 00:00:00 +----------------------------------------------- +MDIO mode: 1000Mbps / link: down + ``` ## 5) Testing From 1e7dbe248cb7d1024fcc4642310772dbc405ac71 Mon Sep 17 00:00:00 2001 From: nano Date: Sat, 21 Jul 2018 21:58:22 +0530 Subject: [PATCH 219/219] Adding example docs commands to getting-started doc (#446) Show how to enable the outputs. --- getting-started.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/getting-started.md b/getting-started.md index 00a87bbf..b6a34d35 100644 --- a/getting-started.md +++ b/getting-started.md @@ -386,6 +386,21 @@ video_matrix connect input1 output1 video_matrix connect input1 encoder ``` +The following commands are an example to view the video output on monitor +``` +H2U 00:01:28>i0 on +Enabling input0 +H2U 00:02:24>i1 on +Enabling input1 +H2U 00:02:26>o0 on +Enabling output0 +H2U 00:02:30>o1 on +Enabling output +H2U 00:04:20>x c pattern output0 # You should see the pattern on the monitor +Connecting pattern to output0 +H2U 00:04:48>x c input0 output0 # You should see your desktop on the monior +Connecting input0 to output0 +``` View the video output on your computer with your preferred tool. The scripts/view-hdmi2usb.sh script will try and find a suitable tool to display.