Skip to content

Commit

Permalink
Merge pull request #52 from CarlFK/master
Browse files Browse the repository at this point in the history
Fixing the scripts/build-qemu.sh script.
  • Loading branch information
mithro committed Sep 11, 2018
2 parents 0315225 + 7f79c95 commit b175a69
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 30 deletions.
2 changes: 1 addition & 1 deletion make.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def get_args(parser, platform='opsis', target='hdmi2usb'):

soc_sdram_args(parser)
parser.set_defaults(cpu_type=os.environ.get('CPU', 'lm32'))
parser.set_defaults(cpu_variant=os.environ.get('CPU_VARIANT', None))
parser.set_defaults(cpu_variant=os.environ.get('CPU_VARIANT', None) or None)

parser.add_argument("--iprange", default="192.168.100")

Expand Down
63 changes: 34 additions & 29 deletions scripts/build-qemu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

if [ "`whoami`" = "root" ]
then
echo "Running the script as root is not permitted"
exit 1
echo "Running the script as root is not permitted"
exit 1
fi

CALLED=$_
Expand All @@ -14,16 +14,16 @@ 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
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 "You appear to not be inside the HDMI2USB environment."
echo "Please enter environment with:"
echo " source scripts/enter-env.sh"
exit 1
exit 1
fi

# Imports TARGET, PLATFORM, CPU and TARGET_BUILD_DIR from Makefile
Expand All @@ -34,38 +34,38 @@ set -x
set -e

QEMU_REMOTE="${QEMU_REMOTE:-https://github.com/timvideos/qemu-litex.git}"
QEMU_BRANCH=${QEMU_BRANCH:-master}
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
(
cd $(dirname $QEMU_SRC_DIR)
git clone https://github.com/timvideos/qemu-litex.git
git clone ${QEMU_REMOTE} qemu-litex
cd $QEMU_SRC_DIR
git submodule update --init dtc
)
else
(
cd $QEMU_SRC_DIR
fi

# 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
(
cd $QEMU_SRC_DIR

# Get any new data
git fetch $CURRENT_QEMU_REMOTE_NAME
# 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

# 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
# Get any new data
git fetch $CURRENT_QEMU_REMOTE_NAME $QEMU_BRANCH

# Checkout master branch if 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
)

TARGET_QEMU_BUILD_DIR=$TARGET_BUILD_DIR/qemu

Expand All @@ -74,7 +74,7 @@ case $CPU in
QEMU_CPU=lm32
;;
or1k)
QEMU_CPU=or32
QEMU_CPU=or1k
;;
*)
echo "CPU $CPU isn't supported at the moment."
Expand All @@ -91,7 +91,12 @@ if [ ! -f "$TARGET_QEMU_BUILD_DIR/Makefile" ]; then
mkdir -p $TARGET_QEMU_BUILD_DIR
(
cd $TARGET_QEMU_BUILD_DIR
CFLAGS="-Wno-error" $QEMU_SRC_DIR/configure \
CFLAGS="\
$CFLAGS \
-Wno-error \
-I$TOP_DIR/third_party/litex/litex/soc/software/include \
" \
$QEMU_SRC_DIR/configure \
--target-list=$QEMU_ARCH \
--python=/usr/bin/python2 \
--enable-fdt \
Expand Down

0 comments on commit b175a69

Please sign in to comment.