Skip to content

Commit

Permalink
Merge pull request #312 from mithro/master
Browse files Browse the repository at this point in the history
Improving QEmu support
  • Loading branch information
mithro committed Mar 22, 2017
2 parents c0a7546 + e2acf8e commit cba56bb
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ outgoing
build
*~
*.png
third_party/qemu-litex
4 changes: 3 additions & 1 deletion firmware/mdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ int mdio_read(int phyadr, int reg)
raw_write(phyadr, 5);
raw_write(reg, 5);
raw_turnaround();
r = raw_read();
raw_turnaround();
r = raw_read();

return r;
}
Expand All @@ -94,6 +94,8 @@ void mdio_dump(void) {

int mdio_status(void) {
int status;
mdio_dump();

status = mdio_read(0, 17);

wprintf("MDIO ");
Expand Down
64 changes: 49 additions & 15 deletions scripts/build-qemu.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
#!/bin/bash

set -x
set -e
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 "$PLATFORM" ]; then
echo "Please set PLATFORM"
Expand All @@ -16,30 +32,48 @@ if [ -z "$CPU" ]; then
exit 1
fi

if [ ! -d build/qemu ]; then
git clone https://github.com/mithro/qemu-litex.git
set -x
set -e

QEMU_SRC_DIR=$TOP_DIR/third_party/qemu-litex
if [ ! -d "$QEMU_SRC_DIR" ]; then
(
cd $(dirname $QEMU_SRC_DIR)
git clone https://github.com/timvideos/qemu-litex.git
cd $QEMU_SRC_DIR
git submodule update --init dtc
)
fi

TARGET_BUILD_DIR=$(realpath build)/${PLATFORM}_${TARGET}_${CPU}/
TARGET_QEMU_BUILD_DIR=$TARGET_BUILD_DIR/qemu

if [ ! -d $TARET_BUILD_DIR/software/include/generated ]; then
if [ ! -d $TARGET_BUILD_DIR/software/include/generated ]; then
make firmware
fi

QEMU_BUILD_DIR=$TARGET_BUILD_DIR/qemu
if [ ! -f "$QEMU_BUILD_DIR/Makefile" ]; then
mkdir -p $QEMU_BUILD_DIR
if [ ! -f "$TARGET_QEMU_BUILD_DIR/Makefile" ]; then
mkdir -p $TARGET_QEMU_BUILD_DIR
(
cd $QEMU_BUILD_DIR
../../qemu/configure --target-list=$CPU-softmmu --python=/usr/bin/python2
cd $TARGET_QEMU_BUILD_DIR
$QEMU_SRC_DIR/configure \
--target-list=$CPU-softmmu \
--python=/usr/bin/python2 \
--enable-fdt \
--disable-kvm \
--disable-xen \
--enable-debug \
--enable-debug-info

ln -s $(realpath $PWD/../software/include/generated) generated
)
fi

(
cd $QEMU_BUILD_DIR
make -j128
)

OLD_DIR=$PWD
cd $TARGET_QEMU_BUILD_DIR
make -j8
cd $OLD_DIR

/usr/bin/env python mkimage.py --output-file=qemu.bin --override-gateware=none

Expand All @@ -60,7 +94,7 @@ if [ $HAS_LITEETH -eq 1 ]; then
make tftp
fi

$QEMU_BUILD_DIR/$CPU-softmmu/qemu-system-$CPU \
$TARGET_QEMU_BUILD_DIR/$CPU-softmmu/qemu-system-$CPU \
-M litex \
-nographic -nodefaults \
-monitor pty \
Expand Down

0 comments on commit cba56bb

Please sign in to comment.