Skip to content

Commit

Permalink
Merge pull request #15 from mithro/master
Browse files Browse the repository at this point in the history
Random collection of fixes.
  • Loading branch information
mithro committed Jan 21, 2018
2 parents 96d8586 + d2f7eeb commit e423776
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 27 deletions.
23 changes: 14 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down Expand Up @@ -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 \
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -481,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
Expand Down
4 changes: 2 additions & 2 deletions firmware/hdmi_in.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down
4 changes: 2 additions & 2 deletions firmware/version_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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:]')"
Expand Down
5 changes: 1 addition & 4 deletions scripts/build-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
65 changes: 55 additions & 10 deletions scripts/build-qemu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
(
Expand All @@ -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 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
fi
)
fi

TARGET_QEMU_BUILD_DIR=$TARGET_BUILD_DIR/qemu
Expand Down Expand Up @@ -116,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")
;;

Expand All @@ -160,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'"
;;
Expand Down

0 comments on commit e423776

Please sign in to comment.