...
 
Commits (8)
BuildScripts.tar.gz
21.03.19 - XC Installation process complete and documented
11.03.19 - MPSoC build scripts added
07.03.19 - Cross compiler build scripts added
#!/usr/bin/env bash
#
# Version: 0.2.0 - Alpha
#
# Changelog:
# 0.2.4 - 21.03.19: Default installation path changed to /opt
# 0.2.3 - 21.03.19: Missing dependency download script call added to 2nd stage GCC build
# 0.2.2 - 21.03.19: --with-newlib added to Cortex-A9 2nd stage GCC compilation flags
# 0.2.1 - 21.03.19: Exit if user is root
# 0.2.0 - 07.03.19: Build ARM Cortex-A9 Cross Compiler
# 0.1.0 - 06.03.19: Build MicroBlaze Cross Compiler
#
# Contributors:
# Ralf Stemmer - ralf.stemmer@uni-oldenburg.de
#
# This directory is used to download the source code and build the Compiler.
# After installation, this directory can be removed.
TMPDIR="$HOME/.bstemp"
MBXCINSTALLPATH="/opt/mbxc"
A9XCINSTALLPATH="/opt/armxc"
#GCC_VERSION="6.3.0"
GCC_VERSION="8.2.0"
#BINUTILS_VERSION="2.27"
BINUTILS_VERSION="2.31.1"
NEWLIB_VERSION="3.1.0"
# TODO: Make user do this:
#su
#mkdir /opt/mbxc
#chown -R ralf:ralf /opt/mbxc
#exit
# TODO: Check permissions - no run for root
if [ "$(id -u)" == 0 ] ; then
echo -e "\e[1;31mThis script shall not be executed with root permissions!\e[0m"
exit 1
fi
# Create temporary director for building the compiler
mkdir -p $TMPDIR
CURDIR="$pwd"
function ExtractArchive { # Archive-file Extracted-directory-name
ARCHIVE=$1
DIRNAME=$2
echo -e -n "\e[1;34mExtracting \e[0;36m$ARCHIVE\e[0m "
if [ ! -f "$ARCHIVE" ]; then
echo -e "\e[1;31m✘\e[1;30m (File \"$ARCHIVE\" missing)\e[0m"
exit 1
fi
if [ -d "$DIRNAME" ]; then
echo -e "\e[1;33m✔\e[1;30m (Directory \"$DIRNAME\" already existing)\e[0m"
return
fi
tar xf $ARCHIVE
if [ ! -d "$DIRNAME" ]; then
echo -e "\e[1;31m✘\e[1;30m (Directory \"$DIRNAME\" not unpacked)\e[0m"
exit 1
fi
echo -e "\e[1;32m✔\e[0m"
}
function DownloadArchive { # URL(without archive name) ARCHIVE
URL=$1/$2
FILENAME=$2
echo -e -n "\e[1;34mDownloading \e[0;36m$FILENAME\e[0m "
if [ -f "$FILENAME" ]; then
echo -e "\e[1;33m✔\e[1;30m (File \"$FILENAME\" already downloaded)\e[0m"
return
fi
wget -o ./wget.log $URL
if [ ! -f "$FILENAME" ]; then
echo -e "\e[1;31m✘\e[1;30m (Downloading \"$FILENAME\" failed. See wget.log)\e[0m"
exit 1
fi
echo -e "\e[1;32m✔\e[0m"
rm ./wget.log # on success, the log file is not needed anymore
}
function DownloadSourceCode {
cd $TMPDIR
DownloadArchive ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-$GCC_VERSION gcc-$GCC_VERSION.tar.gz
DownloadArchive ftp://sourceware.org/pub/newlib newlib-$NEWLIB_VERSION.tar.gz
DownloadArchive http://ftp.gnu.org/gnu/binutils binutils-$BINUTILS_VERSION.tar.gz
cd $CURDIR
}
function BuildBinutils { # target:"MicroBlaze","Cortex-A9"
TARGETID="$1"
# Check if already installed
cd $TMPDIR
if [ -f ./binutils.$TARGETID.flag ]; then
echo -e "\e[1;33mbinutis already installed\e[0m"
return
fi
ExtractArchive binutils-$BINUTILS_VERSION.tar.gz binutils-$BINUTILS_VERSION
cd $TMPDIR/binutils-$BINUTILS_VERSION
# Prepare configuration
echo -e -n "Preparing configuration "
if [ "$TARGETID" = "MicroBlaze" ] ; then
PREFIX=$MBXCINSTALLPATH
PPREFIX="mb-"
TARGET="microblazeel-xilinx-elf"
elif [ "$TARGETID" = "Cortex-A9" ] ; then
PREFIX=$A9XCINSTALLPATH
PPREFIX="arm-none-eabi-"
TARGET="arm-none-eabi"
else
echo -e "\e[1;31m✘\e[1;30m (Invalid Target \"$TARGETID\". Valid: \"MicroBlaze\", \"Cortex-A9\")\e[0m"
exit 1
fi
echo -e "\e[1;32m✔\e[0m"
# Run build process
echo -e "Configuring source code"
./configure --prefix=$PREFIX --program-prefix=$PPREFIX --target=$TARGET
if [ $? -ne 0 ] ; then
echo -e "\e[1;31mfailed! \e[1;30m(Install missing dependencies and rerun this script)\e[0m"
fi
make
make install
make clean
# Flag as complete
cd $TMPDIR
touch ./binutils.$TARGETID.flag
rm -rf binutils-$BINUTILS_VERSION
cd $CURDIR
echo -e "\e[1;32mbinutils successfully installed.\e[0m"
}
function BuildGCCStage1 {
TARGETID="$1"
# Check if already installed
cd $TMPDIR
if [ -f ./gccstage1.$TARGETID.flag ]; then
echo -e "\e[1;33mGCC Stage 1 already installed\e[0m"
return
fi
ExtractArchive gcc-$GCC_VERSION.tar.gz gcc-$GCC_VERSION
# Prepare configuration
echo -e -n "\e[1;34mPreparing configuration \e[0m"
if [ "$TARGETID" = "MicroBlaze" ] ; then
PREFIX=$MBXCINSTALLPATH
PPREFIX="mb-"
TARGET="microblazeel-xilinx-elf"
FLAGS="--enable-languages=c --disable-nls --without-headers --disable-multilib --disable-libssp --with-newlib"
elif [ "$TARGETID" = "Cortex-A9" ] ; then
PREFIX=$A9XCINSTALLPATH
PPREFIX="arm-none-eabi-"
TARGET="arm-none-eabi"
FLAGS="--without-headers --enable-boostrap --enable-languages=c --disable-threads --enable-__cxa_atexit --disable-libmudflap --with-gnu-ld --with-gnu-as --disable-libssp --disable-libgomp --disable-nls --disable-shared --with-arch=armv7-a --with-tune=cortex-a9 --with-fpu=neon --with-float=hard"
# Source: http://ibuzzlog.blogspot.com/2014/12/how-to-build-gcc-arm-cross-compiler-for.html
else
echo -e "\e[1;31m✘\e[1;30m (Invalid Target \"$TARGETID\". Valid: \"MicroBlaze\", \"Cortex-A9\")\e[0m"
exit 1
fi
echo -e "\e[1;32m✔\e[0m"
cd $TMPDIR/gcc-$GCC_VERSION
./contrib/download_prerequisites
mkdir build
cd build/
../configure --prefix=$PREFIX --program-prefix=$PPREFIX --target=$TARGET $FLAGS
make all-host
make install-host
# FOR ARM?
#make -j4 -k all-target-libgcc
#make -i install-target-libgcc
make clean
cd ..
rm -r build
# Flag as complete
cd $TMPDIR
touch ./gccstage1.$TARGETID.flag
rm -rf gcc-$GCC_VERSION
cd $CURDIR
echo -e "\e[1;32mGCC successfully installed.\e[0m"
}
function BuildNewlib {
TARGETID="$1"
# Check if already installed
cd $TMPDIR
if [ -f ./newlib.$TARGETID.flag ]; then
echo -e "\e[1;33mGCC Stage 1 already installed\e[0m"
return
fi
ExtractArchive newlib-$NEWLIB_VERSION.tar.gz newlib-$NEWLIB_VERSION
# Prepare configuration
echo -e -n "\e[1;34mPreparing configuration \e[0m"
if [ "$TARGETID" = "MicroBlaze" ] ; then
PREFIX=$MBXCINSTALLPATH
PPREFIX="mb-"
TARGET="microblazeel-xilinx-elf"
FLAGS="--enable-newlib-hw-fp"
elif [ "$TARGETID" = "Cortex-A9" ] ; then
PREFIX=$A9XCINSTALLPATH
PPREFIX="arm-none-eabi-"
TARGET="arm-none-eabi"
FLAGS="--enable-newlib-hw-fp --disable-newlib-supplied-syscalls"
else
echo -e "\e[1;31m✘\e[1;30m (Invalid Target \"$TARGETID\". Valid: \"MicroBlaze\", \"Cortex-A9\")\e[0m"
exit 1
fi
echo -e "\e[1;32m✔\e[0m"
cd $TMPDIR/newlib-$NEWLIB_VERSION
export CC_FOR_TARGET="$PREFIX/bin/$PPREFIX"gcc
export CXX_FOR_TARGET="$PREFIX/bin/$PPREFIX"g++
export GCC_FOR_TARGET="$PREFIX/bin/$PPREFIX"gcc
export AR_FOR_TARGET="$PREFIX/bin/$PPREFIX"ar
export AS_FOR_TARGET="$PREFIX/bin/$PPREFIX"as
export LD_FOR_TARGET="$PREFIX/bin/$PPREFIX"ld
export NM_FOR_TARGET="$PREFIX/bin/$PPREFIX"nm
export RANLIB_FOR_TARGET="$PREFIX/bin/$PPREFIX"ranlib
export STRIP_FOR_TARGET="$PREFIX/bin/$PPREFIX"strip
mkdir build
cd build
../configure --prefix=$PREFIX --target=$TARGET $FLAGS
make
make install
make clean
cd ..
rm -r build
unset CC_FOR_TARGET
unset CXX_FOR_TARGET
unset GCC_FOR_TARGET
unset AS_FOR_TARGET
unset AR_FOR_TARGET
unset LD_FOR_TARGET
unset NM_FOR_TARGET
unset STRIP_FOR_TARGET
unset RANLIB_FOR_TARGET
# Flag as complete
cd $TMPDIR
touch ./newlib.$TARGETID.flag
rm -rf newlib-$NEWLIB_VERSION
cd $CURDIR
echo -e "\e[1;32mnewlib successfully installed.\e[0m"
}
function BuildGCCStage2 {
TARGETID="$1"
# Check if already installed
cd $TMPDIR
if [ -f ./gccstage2.$TARGETID.flag ]; then
echo -e "\e[1;33mGCC Stage 2 already installed\e[0m"
return
fi
ExtractArchive gcc-$GCC_VERSION.tar.gz gcc-$GCC_VERSION
# Prepare configuration
echo -e -n "\e[1;34mPreparing configuration \e[0m"
if [ "$TARGETID" = "MicroBlaze" ] ; then
PREFIX=$MBXCINSTALLPATH
PPREFIX="mb-"
TARGET="microblazeel-xilinx-elf"
FLAGS="--enable-languages=c,c++ --disable-nls --without-headers --disable-multilib --disable-libssp --with-newlib"
elif [ "$TARGETID" = "Cortex-A9" ] ; then
PREFIX=$A9XCINSTALLPATH
PPREFIX="arm-none-eabi-"
TARGET="arm-none-eabi"
FLAGS="--enable-languages=c,c++ --without-headers --disable-multilib --with-float=soft --disable-sjlj-exceptions --disable-nls --disable-libmudflap --disable-libssp --enable-long-longx --enable-libgomp --with-arch=armv7-a --with-tune=cortex-a9 --with-fpu=neon --with-float=hard --with-newlib"
else
echo -e "\e[1;31m✘\e[1;30m (Invalid Target \"$TARGETID\". Valid: \"MicroBlaze\", \"Cortex-A9\")\e[0m"
exit 1
fi
echo -e "\e[1;32m✔\e[0m"
cd $TMPDIR/gcc-$GCC_VERSION
./contrib/download_prerequisites
mkdir build
cd build/
../configure --prefix=$PREFIX --program-prefix=$PPREFIX --target=$TARGET $FLAGS
make all
make install all
make clean
cd ..
rm -r build
# Flag as complete
cd $TMPDIR
touch ./gccstage2.$TARGETID.flag
rm -rf gcc-$GCC_VERSION
cd $CURDIR
echo -e "\e[1;32mGCC successfully installed.\e[0m"
}
echo -e "\e[1;37mPreparing Source Files\e[0m"
DownloadSourceCode
echo -e "\e[1;37mInstalling binutils\e[0m"
BuildBinutils "MicroBlaze"
echo -e "\e[1;37mInstalling gcc stage 1\e[0m"
BuildGCCStage1 "MicroBlaze"
echo -e "\e[1;37mInstalling newlib\e[0m"
BuildNewlib "MicroBlaze"
echo -e "\e[1;37mInstalling gcc stage 2\e[0m"
BuildGCCStage2 "MicroBlaze"
echo -e "\e[1;37mInstalling binutils\e[0m"
BuildBinutils "Cortex-A9"
echo -e "\e[1;37mInstalling gcc stage 1\e[0m"
BuildGCCStage1 "Cortex-A9"
echo -e "\e[1;37mInstalling newlib\e[0m"
BuildNewlib "Cortex-A9"
echo -e "\e[1;37mInstalling gcc stage 2\e[0m"
BuildGCCStage2 "Cortex-A9"
#!/usr/bin/env bash
cd ./src
tar -cf ../BuildScripts.tar *
cd ..
gzip BuildScripts.tar
# Build Scripts
This repository contains build and automation scripts I use for my research.
The `InstallCrossCompiler.sh` script installs a MicroBlaze and an ARM cross compiler for bare metal application.
The `MakeBuildScriptsArchive.sh` creates an archive (.tar.gz) with a set of build scripts.
This archive must be extracted inside the workspace directory it shall be used.
A documentation of the individual scripts follows in the (far) future.
= Introduction =
The InstallCrossCompiler.sh script downloads, builds and installs all cross compilers needed for our MPSoC Systems.
This process is split into several steps.
The scripts creates a temporary directory at ~/.bstemp which is used for the build process of the compilers.
After each step, a files gets stored at this directory with the file extension ".flag".
The existing of such a file signals the script, that the corresponding step was successfully completed.
When a later process fails, the script can be restarted and it will skip all previous steps and tries to restart the failed step directly.
If you want to rerun a successful step, just remove that file.
The temporary directory can be removed after all compilers were successfully installed.
The compilers for the following architectures will be installed:
* MicroBlaze (litte endian)
* ARM (Cortex A9)
= Using the script =
The script does most of the work automatically.
Never the less there are some manual steps that are explained in the following subsections.
== Create Installation directory ==
# As root, replace $USER with your user name
mkdir /opt/mbxc && chown $USER:$USER /opt/mbxc
mkdir /opt/armxc && chown $USER:$USER /opt/armxc
== Install dependencies ==
Install at least the following packages.
When the build process fails, install the missing packages as well.
== Execute the script ==
# As user!
./InstallCorssCompiler.sh
# Most of the steps take a long time, up to multiple hours!
== Update the PATH variable ==
To be able to execute the compilers, there installation path must be added to the PATH variable.
To make this automatically, copy the xcpaths.sh script to /etc/profile.d and make it executable:
# As root
cp resources/xcpaths.sh /etc/profile.d/.
chmod +x /etc/profile.d/xcpaths.sh
export PATH="$PATH:/opt/mbxc:/opt/armxc"
#!/usr/bin/env bash
#
# Version: 1.0.0
#
# Changelog:
# 1.0.0 - 11.03.19: First release
#
# Contributors:
# Ralf Stemmer - ralf.stemmer@uni-oldenburg.de
#
source ./scripts/settings.sh
LIBPATHS="-L$SDKDIR/lib"
INCLUDEPATHS="-I$SDKDIR/include"
CFLAGS="-O0 -c -Wall -fmessage-length=0 -mcpu=cortex-a9 -mfpu=vfpv3 -mfloat-abi=hard -DFSBL_DEBUG -DFSBL_DEBUG_INFO"
LFLAGS="-mcpu=cortex-a9 -mfpu=vfpv3 -mfloat-abi=hard -Wl,-build-id=none"
GCC=arm-none-eabi-gcc
if [ -d "$SW_BUILDDIR" ] ; then
echo -e -n "\e[1;34mRemoving old object-files: "
find "$SW_BUILDDIR" -type f -name "*.o" -delete
echo -e "\e[1;32m✔\e[0m"
fi
mkdir -p $SW_BUILDDIR
function CompileForProcessor
{
# Compile
echo -e "\e[1;36mCompiling for ARM CortexA9 $1 \e[0;36m…\e[0m"
echo -e -n "\e[1;34m$SDKDIR/include/arm$1: "
if [ ! -d "$SDKDIR/include/arm$1" ] ; then
echo -e "\e[1;31m$SDKDIR/include/arm$1 missing! Rebuild SDK or check ARM number!"
exit 1
else
echo -e "\e[1;32m✔\e[0m"
fi
mkdir -p $SW_BUILDDIR/arm$1
SOURCES=$(find $SW_SRCDIR/arm$1 -type f -name "*.[c,S]")
for s in $SOURCES ;
do
echo -e -n "\e[1;34m - $s\e[0m "
FILENAME="${s##*/}"
OBJFILE="${FILENAME%.*}.o"
$GCC $CFLAGS $LIBPATHS $INCLUDEPATHS -I$SDKDIR/include/arm$1 -I$SW_SRCDIR/arm$1 -I$SW_SRCDIR/share -c -o "$SW_BUILDDIR/arm$1/$OBJFILE" $s
if [ $? -ne 0 ] ; then
echo -e "\e[1;31m$GCC FAILED!\e[0m"
exit 1
else
echo -e "\e[1;32m✔\e[0m"
fi
done
}
# Get ARM cores
ARCHITECTURE=$(echo 'cat //Project/SYSTEMINFO/@ARCH' | xmllint --shell "$SDK_SYSTEMDEF" | grep ARCH | grep -v cat | cut -d "\"" -f 2)
if [ "$ARCHITECTURE" == "zynq" ] ; then
ARMCOUNT=2
else
echo -e "\e[1;33mThere are no ARM cores on the $ARCHITECTURE plattform!"
exit 0
fi
# Compile firmware for each ARM
for ARMNR in $(seq 0 $((ARMCOUNT - 1)) ) ; do
# Only compile if there is source code
if [ ! -d "$SW_SRCDIR/arm$ARMNR" ] ; then
echo -e "\e[1;33mThere is no source code for ARM$ARMNR! \e[1;30m(Skipping)\e[0m"
continue
fi
CompileForProcessor $ARMNR
done
# Linken
function LinkFirmwareForProcessor
{
SOURCEDIR="$SW_SRCDIR/arm$1"
PROCSOURCES=$(find $SW_BUILDDIR/arm$1 -type f -name "*.o")
FIRMWARE="$OUTPUTDIR/firmware_arm$1.elf"
# prefere explicit linker script. Use SDK generated as fallback
if [ -f $SOURCEDIR/ldscript.ld ] ; then
LINKSCRIPT="$SOURCEDIR/ldscript.ld"
elif [ -f $SOURCEDIR/lscript.ld ] ; then # SDK uses lscript as name
LINKSCRIPT="$SOURCEDIR/lscript.ld"
else
LINKSCRIPT="$SDKDIR/ldscript_arm$1.ld"
fi
echo -e "\e[1;36mLinking \e[0;36m$SW_FIRMWARE\e[1;34m: "
echo -e -n "\e[1;34m$LINKSCRIPT: "
if [ ! -f "$LINKSCRIPT" ] ; then
echo -e "\e[1;31m$LINKSCRIPT missing! Rebuild SDK or check ARM number!"
exit 1
else
echo -e "\e[1;32m✔\e[0m"
fi
echo -e -n "\e[1;34m$SDKDIR/lib/arm$1: "
if [ ! -d "$SDKDIR/lib/arm$1" ] ; then
echo -e "\e[1;31m$SDKDIR/lib/arm$1 missing! Rebuild SDK or check ARM number!"
exit 1
else
echo -e "\e[1;32m✔\e[0m"
fi
echo -e -n "\e[1;34mLinking… "
$GCC -Wl,-T -Wl,$LINKSCRIPT $LFLAGS $LIBPATHS -L$SDKDIR/lib/arm$1 -o $FIRMWARE $PROCSOURCES -lps7init \
-Wl,--start-group,-lxil,-lgcc,-lc,--end-group \
-Wl,--start-group,-lxilffs,-lxil,-lgcc,-lc,--end-group
if [ $? -ne 0 ] ; then
echo -e "\e[1;31mFAILED!\e[0m"
exit 1
else
echo -e "\e[1;32m✔\e[0m"
fi
chmod -x $FIRMWARE
}
# Link firmware for each microblaze
for ARMNR in $(seq 0 $((ARMCOUNT - 1)) ) ; do
# Only compile if there is source code
if [ ! -d "$SW_SRCDIR/arm$ARMNR" ] ; then
echo -e "\e[1;33mThere is no source code for ARM$ARMNR! \e[1;30m(Skipping)\e[0m"
continue
fi
LinkFirmwareForProcessor $ARMNR
done
echo -e "\e[1;32mNew ARM binary built.\e[0m"
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
#!/usr/bin/env bash
#
# Version: 1.0.0
#
# Changelog:
# 1.0.0 - 11.03.19: First release
#
# Contributors:
# Ralf Stemmer - ralf.stemmer@uni-oldenburg.de
#
source ./scripts/settings.sh
LIBPATHS="-L$SDKDIR/lib"
LIBS="-lxil -lgloss -lgcc -lc"
INCLUDEPATHS="-I$SDKDIR/include"
CFLAGS="-O0 -c -mcpu=v9.6 -mlittle-endian -mxl-soft-mul"
LFLAGS="-Wl,--no-relax -mcpu=v9.6 -mlittle-endian -mxl-soft-mul"
GCC=mb-gcc
OBJCOPY=mb-objcopy
if [ -f "$SW_SRCDIR/setup.sh" ] ; then
echo -e -n "\e[1;34mLoading software specific setup: "
source $SW_SRCDIR/setup.sh
echo -e "\e[1;32m✔\e[0m"
fi
if [ -d "$SW_BUILDDIR" ] ; then
echo -e -n "\e[1;34mRemoving old object-files: "
find "$SW_BUILDDIR" -type f -name "*.o" -delete
echo -e "\e[1;32m✔\e[0m"
fi
mkdir -p $SW_BUILDDIR
# Compile shared code
echo -e "\e[1;36mCompiling shared code \e[0;36m…\e[0m"
mkdir -p $SW_BUILDDIR/share
SOURCES=$(find $SW_SRCDIR/share -type f -name "*.c")
for s in $SOURCES ;
do
echo -e -n "\e[1;34m - $s\e[0m "
FILENAME="${s##*/}"
OBJFILE="${FILENAME%.*}.o"
$GCC $CFLAGS $LIBPATHS $INCLUDEPATHS -I$SW_SRCDIR/share -c -o "$SW_BUILDDIR/share/$OBJFILE" $s
if [ $? -ne 0 ] ; then
echo -e "\e[1;31m$GCC FAILED!\e[0m"
exit 1
else
echo -e "\e[1;32m✔\e[0m"
fi
done
# First argument must be the number of the processor ("0", "1", …)
# Second argument can be an address with a dot as prefix (".4000000", ".C0000000")
function CompileForProcessor
{
MBNUM=${1}
ADDRESS=${2:-""}
SDKINCLUDE="$SDKDIR/include/mb$MBNUM"
if [ -z $ADDRESS ] ; then
SOURCEDIR="$SW_SRCDIR/mb${MBNUM}"
BUILDDIR="$SW_BUILDDIR/mb${MBNUM}"
else
SOURCEDIR="$SW_SRCDIR/mb${MBNUM}.${ADDRESS}" # leads to …/mb0.40000000
BUILDDIR="$SW_BUILDDIR/mb${MBNUM}.${ADDRESS}"
fi
echo -e "\e[1;36mCompiling for MicroBlaze $MBNUM \e[1;35m$ADDRESS\e[0m"
# Check environment
echo -e "\e[1;34mChecking source environment"
echo -e -n "\t\e[1;34m$SDKINCLUDE: "
if [ ! -d "$SDKINCLUDE" ] ; then
echo -e "\e[1;31m$SDKINCLUDE missing! Rebuild SDK or check MicroBlaze number!"
exit 1
else
echo -e "\e[1;32m✔\e[0m"
fi
echo -e -n "\t\e[1;34m$SOURCEDIR: "
if [ ! -d "$SOURCEDIR" ] ; then
echo -e "\e[1;31m$SOURCEDIR missing! Check MicroBlaze number and/or address!"
exit 1
else
echo -e "\e[1;32m✔\e[0m"
fi
mkdir -p $BUILDDIR
# Compile
SOURCES=$(find $SOURCEDIR -type f -name "*.c")
for s in $SOURCES ;
do
echo -e -n "\e[1;34m - $s\e[0m "
FILENAME="${s##*/}"
OBJFILE="${FILENAME%.*}.o"
$GCC $CFLAGS $LIBPATHS $INCLUDEPATHS -I$SDKINCLUDE -I$SOURCEDIR -I$SW_SRCDIR/share -c -o "$BUILDDIR/$OBJFILE" $s
if [ $? -ne 0 ] ; then
echo -e "\e[1;31m$GCC FAILED!\e[0m"
exit 1
else
echo -e "\e[1;32m✔\e[0m"
fi
done
}
# Linken
# First argument must be the number of the processor ("0", "1", …)
# Second argument can be an address with a dot as prefix (".4000000", ".C0000000")
function LinkFirmwareForProcessor
{
MBNUM=${1}
ADDRESS=${2:-""}
#SDKINCLUDE="$SDKDIR/include/mb$MBNUM"
if [ -z $ADDRESS ] ; then
SOURCEDIR="$SW_SRCDIR/mb${MBNUM}"
BUILDDIR="$SW_BUILDDIR/mb${MBNUM}"
FIRMWARE="$OUTPUTDIR/firmware_mb${MBNUM}.elf"
# prefere explicit linker script. Use SDK generated as fallback
if [ -f $SOURCEDIR/ldscript.ld ] ; then
LINKSCRIPT="$SOURCEDIR/ldscript.ld"
else
LINKSCRIPT="$SDKDIR/ldscript_mb$MBNUM.ld"
fi
else
SOURCEDIR="$SW_SRCDIR/mb${MBNUM}.${ADDRESS}" # leads …/mb0.40000000
BUILDDIR="$SW_BUILDDIR/mb${MBNUM}.${ADDRESS}"
FIRMWARE="$OUTPUTDIR/firmware_mb${MBNUM}.${ADDRESS}.elf"
LINKSCRIPT="$SOURCEDIR/ldscript.ld"
fi
PROCSOURCES=$(find $BUILDDIR -type f -name "*.o")
SHARSOURCES=$(find $SW_BUILDDIR/share -type f -name "*.o")
echo -e "\e[1;36mLinking \e[0;36m$FIRMWARE\e[1;34m: "
# Check environment
echo -e "\e[1;34mChecking source environment"
echo -e -n "\t\e[1;34mLinker script $LINKSCRIPT: "
if [ ! -f "$LINKSCRIPT" ] ; then
echo -e "\e[1;31m$LINKSCRIPT missing! Rebuild SDK or check MicroBlaze number!"
exit 1
else
echo -e "\e[1;32m✔\e[0m"
fi
echo -e -n "\t\e[1;34mHAL $SDKDIR/lib/mb$MBNUM: "
if [ ! -d "$SDKDIR/lib/mb$MBNUM" ] ; then
echo -e "\e[1;31m$SDKDIR/lib/mb$MBNUM missing! Rebuild SDK or check MicroBlaze number!"
exit 1
else
echo -e "\e[1;32m✔\e[0m"
fi
echo -e -n "\e[1;34mLinking "
$GCC -Wl,-T -Wl,$LINKSCRIPT $LFLAGS $LIBPATHS -L$SDKDIR/lib/mb$MBNUM -o $FIRMWARE $PROCSOURCES $SHARSOURCES $LIBS
if [ $? -ne 0 ] ; then
echo -e "\e[1;31mFAILED!\e[0m"
exit 1
else
echo -e "\e[1;32m✔\e[0m"
fi
$OBJCOPY -O binary $FIRMWARE ${FIRMWARE%.*}.bin
chmod -x $FIRMWARE
chmod -x ${FIRMWARE%.*}.bin
}
# Count microblazes
MICROBLAZECOUNT=$( grep InstPath $SDK_MEMORYINFO | grep -i microblaze | wc -l )
# Build main firmware for each MicroBlaze
for MBNR in $(seq 0 $((MICROBLAZECOUNT - 1)) ) ; do
CompileForProcessor $MBNR
LinkFirmwareForProcessor $MBNR
done
# Now scan source directory for additional firmware mapped to different memory
MAPPINGS=$(find $SW_SRCDIR -type d -name "mb*.*" -printf "%f\n")
for m in $MAPPINGS ; do
MB=${m%.*}
MB=${MB:2}
ADDR=${m:4}
CompileForProcessor $MB $ADDR
LinkFirmwareForProcessor $MB $ADDR
done
echo -e "\e[1;32mNew System built.\e[0m"
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
#!/usr/bin/env python3
#
# Version: 1.0.0
#
# Changelog:
# 1.0.0 - 11.03.19: First release
#
# Contributors:
# Ralf Stemmer - ralf.stemmer@uni-oldenburg.de
#
import sys
import os
import time
import argparse
import binascii
try:
from serial import *
except:
print("\033[1;31mModule \033[1;37mpyserial \033[1;31mmissing!")
print("\033[1;34m Try \033[1;36mpip\033[1;30m3\033[1;36m install pyserial\033[1;34m as root to install it.\033[1;30m")
exit(1)
ShutdownReceiver = False
cli = argparse.ArgumentParser(
description="Reader for SDF time measurement values.",
formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
cli.add_argument("-s", "--silent", default=False, action="store_true",
help="Do not show progress")
cli.add_argument("datadevice", type=str, action="store",
help="Path to the serial communication device for reading measurement data.")
cli.add_argument("n", type=str, action="store",
help="Number of measurements.")
cli.add_argument("outfile", type=str, action="store",
help="Path where the measured data will be stored.")
class HEADER(object):
def __init__(self, headerbyte):
if type(headerbyte) != bytes:
raise TypeError("Header-Byte should be of type bytes as returned by uart.read(1)!")
header = int.from_bytes(headerbyte, byteorder="little", signed=False)
self.sync = (header >> 7) & 1
self.first = (header >> 6) & 1
self.zero = (header >> 5) & 1
self.overflow = (header >> 4) & 1
self.tmberror = (header >> 3) & 1
self.tmcerror = (header >> 2) & 1
self.size = (header >> 0) & 3
def isValid(self):
if self.sync != 1:
return False
if self.zero != 0:
return False
return True
def hasErrorFlags(self):
if self.overflow == 1:
return True
if self.tmberror == 1:
return True
if self.tmcerror == 1:
return True
return False
def GetDataSize(self):
return self.size + 1
class PACKET(object):
def __init__(self, header):
if type(header) != HEADER:
raise TypeError("header must be an instance of class HEADER!")
self.header = header
self.data = 0
def AddByte(self, position, byte):
if type(position) != int:
raise TypeError("position must be of type int")
if type(byte) != bytes:
raise TypeError("byte must be of type bytes")
byte = int.from_bytes(byte, byteorder="little", signed=False)
if (byte >> 7) == 1:
raise ValueError("Invalid Sync-Bit. Bit is set to 1 but should be 0 for data bytes!")
if position >= self.header.GetDataSize():
raise ValueError("Position of byte exceeds range of expected bytes regarding packet header")
self.data |= (int(byte&0x7F) << (position*7))
def ReadPacket(uart):
# 1.: Read Header (Skip byte if not header)
header = None
while True:
try:
byte = uart.read(1)
except Exception as e:
print("\033[1;31mReading byte from UART failed!\033[0m")
raise(e)
header = HEADER(byte)
if header.isValid():
break
print("\033[1;33mInvalid Header \033[1;35m%s\033[1;33m: "%(byte.hex()), end="")
if header.sync == 0:
print("\033[1;33mSync-Bit is 0 \033[1;30m(This is a data-byte. Will be dropped.)")
continue
if header.zero != 0:
print("\033[1;31mSync-Bit and Zero-Bit are 1 \033[1;30m(This should never happen! Physical error?)")
raise ValueError("Sync-Bit and Zero-Bit are 1")
packet = PACKET(header)
# 2.: Read data bytes
for i in range(header.GetDataSize()):
try:
byte = uart.read(1)
except Exception as e:
print("\033[1;31mReading byte from UART failed!\033[0m")
raise(e)
try:
packet.AddByte(i, byte)
except Exception as e:
print("\033[1;31mAdding byte to time value failed with error %s!\033[0m"%(str(e)))
raise(e)
return packet
if __name__ == '__main__':
# handle command line arguments
args = cli.parse_args()
DATADEVICE = args.datadevice
OUTFILE = args.outfile
N = int(args.n)
SILENT = bool(args.silent)
# Open terminal device
try:
datauart = Serial(
port = DATADEVICE,
baudrate= 115200,
xonxoff = 0,
rtscts = 0,
interCharTimeout=None
)
except Exception as e:
print("\033[1;31mAccessing \033[1;37m" + DEVICE + " \033[1;31mfailed with the following excpetion:\033[0m")
print(e)
exit(1)
try:
outfile = open(OUTFILE, "w")
except Exception as e:
print("\033[1;31mAccessing \033[1;37m" + OUTFILE + " \033[1;31mfailed with the following excpetion:\033[0m")
print(e)
exit(1)
fails = 0
for i in range(N+1):
# Check fails-state
if fails > 100:
print("\033[1;33mUnexpected high error rate of %i times in a row!\033[0m"%(fails))
print("\033[1;31mExiting...\033[0m")
datauart.close()
outfile.close()
exit(2)
# Show progress
if not SILENT:
print("\033[1;30mGetTime: \033[1;34m[\033[0;36m%2i%%\033[1;30m %7i\033[1;34m]\033[0m"%(int((i*100)/(N+1)), i), end=" ")
# Read Packet
try:
packet = ReadPacket(datauart)
except Exception as e:
fails += 1
if not SILENT:
print("\033[1;31m(%s)\033[0m"%(str(e)))
continue
# Create file entry
header = packet.header
value = packet.data
if header.hasErrorFlags():
errorlist = list()
if header.overflow:
errorlist.append("overflow")
if header.tmberror:
errorlist.append("tmberror")
if header.tmcerror:
errorlist.append("tmcerror")
fails += 1
line = ",".join(errorlist) + "\n"
else:
fails = 0
line = str(value) + "\n"
if not SILENT:
value = packet.data
print("\033[1;30m0x%X\033[1;35m -> \033[1;37m%i\033[0m"%(value, value), end="")
if header.first:
print(" \033[1;33mFirst Packet", end="")
sys.stdout.flush()
outfile.write(line)
if not SILENT:
print("\033[0m")
time.sleep(0.1);
datauart.close()
outfile.close()
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
#!/usr/bin/env bash
#
# Version: 1.0.0
#
# Changelog:
# 1.0.0 - 11.03.19: First release
#
# Contributors:
# Ralf Stemmer - ralf.stemmer@uni-oldenburg.de
#
source ./scripts/settings.sh
# Check environment
if [ -d "$SDKDIR" ] ; then
echo -e "\e[1;31mSDK-Directory $SDKDIR does already exist."
echo -e "\e[1;30mTo create a new SDK, the old one must be removed manually."
exit 1
fi
if [ -d "$XSDKSDKDIR" ] ; then
echo -e "\e[1;31mXSDK-SDK-Directory $XSDKSDKDIR does already exist."
echo -e "\e[1;30mTo create a new SDK, the old one must be removed manually."
exit 1
fi
# Prepare environment
echo -e -n "\e[1;34mCreating SDK tree in \e[0;36m$SDKDIR\e[1;34m: "
mkdir -p $SDKDIR/lib
if [ $? -ne 0 ] ; then
echo -e "\e[1;31mFAILED!\e[0m"
exit 1
else
echo -e "\e[1;32m✔\e[0m"
fi
# Extract System Definitions from Vivado Project
echo -e -n "\e[1;34mFinding System Definition "
SYSDEF=$(find $OUTPUTDIR/$PROJECTNAME.runs -name "*.sysdef" -print)
cp $SYSDEF $SDKDIR/sysdef.zip
if [ $? -ne 0 ] ; then
echo -e "\e[1;31mFAILED!\e[0m"
exit 1
else
echo -e "\e[1;32m✔\e[0m"
fi
echo -e "\e[1;34mExtracting System Definition \e[0;36m$SYSDEF\e[0m"
unzip $SDKDIR/sysdef.zip -d $SDKDIR/.
if [ $? -ne 0 ] ; then
echo -e "\e[1;31munzip FAILED!\e[0m"
exit 1
fi
# Create Memorymap
echo -e -n "\e[1;34mCreating MemoyMap \e[0;36m$SDK_MEMORYMAP\e[1;34m: "
xsltproc ./scripts/memorymap.xslt $SDKDIR/$HARDWARENAME.hwh > $SDK_MEMORYMAP
if [ $? -ne 0 ] ; then
echo -e "\e[1;31mFAILED!\e[0m"
exit 1
else
echo -e "\e[1;32m✔\e[0m"
fi
# Check if the Synthesis process was successful
echo -e -n "\e[1;34m$HARDWAREDEF: "
if [ ! -f "$HARDWAREDEF" ] ; then
echo -e "\e[1;31m$HARDWAREDEF missing! Did you export the Hardware?"
exit 1
else
echo -e "\e[1;32m✔\e[0m"
fi
# Renaming Memory-Info file
MEMINFOR=$( find $SDKDIR -name "*.mmi" -print)
echo -e -n "\e[1;34m$SDK_MEMORYINFO: "
mv $MEMINFOR $SDK_MEMORYINFO
if [ $? -ne 0 ] ; then
echo -e "\e[1;31mFAILED!\e[0m"
exit 1
else
echo -e "\e[1;32m✔\e[0m"
fi
# Make everything clean
BITSTREAM=$(find $SDKDIR -name "*.bit" -print)
echo -e -n "\e[1;34m$SDK_BITFILE: "
mv $BITSTREAM $SDK_BITFILE
if [ $? -ne 0 ] ; then
echo -e "\e[1;31mFAILED!\e[0m"
exit 1
else
echo -e "\e[1;32m✔\e[0m"
fi
echo -e -n "\e[1;34m$SDK_HARDWAREDEF: "
cp $HARDWAREDEF $SDK_HARDWAREDEF
if [ $? -ne 0 ] ; then
echo -e "\e[1;31mFAILED!\e[0m"
exit 1
else
echo -e "\e[1;32m✔\e[0m"
fi
echo -e -n "\e[1;34mChecking Architecture "
# Get Architecture
# Source: https://stackoverflow.com/questions/25508512/shellscript-read-xml-attribute-value
ARCHITECTURE=$(echo 'cat //Project/SYSTEMINFO/@ARCH' | xmllint --shell "$SDK_SYSTEMDEF" | grep ARCH | grep -v cat | cut -d "\"" -f 2)
if [ "$ARCHITECTURE" == "zynq" ] ; then
ARMCOUNT=2
else
ARMCOUNT=0
fi
# Count microblazes
MICROBLAZECOUNT=$( grep InstPath $SDK_MEMORYINFO | grep -i microblaze | wc -l )
# Print architecture details
echo -e "\e[1;32m✔\e[1;34m ➔ \e[1;35m$ARCHITECTURE\e[0m"
echo -e "\e[1;34mCores:"
echo -e "\e[1;34m\tMicroBlazes: \e[0;36m$MICROBLAZECOUNT"
echo -e "\e[1;34m\tARM Cores: \e[0;36m$ARMCOUNT"
if [ "$ARCHITECTURE" == "zynq" ] ; then
# Create SDK for ARM core 0
LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21:/usr/local/lib $XSDK -batch -source $CREATEARMSDK_SCRIPT -tclargs 0
# Compile SDK for ARM core 0
CWD=$(pwd)
cd $XSDKSDKDIR/board_arm0
echo -e "\e[1;34mBuilding Board-Driver for ARM CortexA9 0\e[0m"
make --silent > /dev/null
if [ $? -ne 0 ] ; then
echo -e "\e[1;31mmake FAILED!\e[0m"
exit 1
else
echo -e "\e[0;32mmake succeeded.\e[0m"
fi
cd $CWD
# Exporting SDK
LIBDIR=$SDKDIR/lib/arm0
INCDIR=$SDKDIR/include/arm0
mkdir -p $LIBDIR
mkdir -p $INCDIR
echo -e "\e[1;34mOrganize SDK directory for ARM CortexA9 0\e[0m"
echo -e -n "\t\e[1;34m$LIBDIR: "
cp -r $XSDKSDKDIR/board_arm0/ps7_cortexa9_0/lib/*.a $LIBDIR/.
if [ $? -ne 0 ] ; then
echo -e "\e[1;31mFAILED!\e[0m"
exit 1
else
echo -e "\e[1;32m✔\e[0m"
fi
echo -e -n "\t\e[1;34m$INCDIR: "
cp -r $XSDKSDKDIR/board_arm0/ps7_cortexa9_0/include/* $INCDIR/.
if [ $? -ne 0 ] ; then
echo -e "\e[1;31mFAILED!\e[0m"
exit 1
else
echo -e "\e[1;32m✔\e[0m"
fi
LDSCRIPT="$XSDKSDKDIR/software_arm0/src/lscript.ld"
echo -e -n "\t\e[1;34m$SDKDIR/ldscript_arm0.ld: "
cp $LDSCRIPT $SDKDIR/ldscript_arm0.ld
if [ $? -ne 0 ] ; then
echo -e "\e[1;31mFAILED!\e[0m"
exit 1
else
echo -e "\e[1;32m✔\e[0m"
fi
# Building PS7_INIT
echo -e "\e[1;34mBuilding ps7_init library\e[0m"
CFLAGS="-O0 -c -Wall -fmessage-length=0 -mcpu=cortex-a9 -mfpu=vfpv3 -mfloat-abi=hard"
GCC=arm-none-eabi-gcc
AR=arm-none-eabi-ar
$GCC $CFLAGS -I$SDKDIR -I$SDKDIR/include/arm0 -o $SDKDIR/ps7_init.o $SDKDIR/ps7_init.c
$GCC $CFLAGS -I$SDKDIR -I$SDKDIR/include/arm0 -o $SDKDIR/ps7_init_gpl.o $SDKDIR/ps7_init_gpl.c
$AR r $SDKDIR/lib/arm0/libps7init.a $SDKDIR/ps7_init_gpl.o $SDKDIR/ps7_init.o
cp $SDKDIR/*.h $SDKDIR/include/arm0/.
fi # if architecture is zynq
# Generate SDK all MicroBlazes
echo -e "\e[1;34mGenerating XSDK SDK for $MICROBLAZECOUNT MicroBlazes in \e[0;36m$XSDKSDKDIR\e[1;34m using following TCL-Script: \e[0;36m$CREATEMBSDK_SCRIPT\e[0m"
for MBNR in $(seq 0 $((MICROBLAZECOUNT - 1)) ) ; do
# Create SDK
LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21:/usr/local/lib $XSDK -batch -source $CREATEMBSDK_SCRIPT -tclargs $MBNR
if [ $? -ne 0 ] ; then
echo -e "\e[1;31mXSDK FAILED!\e[0m"
exit 1
else
echo -e "\e[0;32mXSDK succeeded.\e[0m"
fi
# Check if creation was successful
if [ ! -d "$XSDKSDKDIR/board_mb$MBNR" ] ; then
echo -e "\e[1;31mBoard-Drivers in $XSDKSDKDIR/board_mb$MBNR missing!"
exit 1
fi
done
# Compile SDK
for MBNR in $(seq 0 $((MICROBLAZECOUNT - 1)) ) ; do
CWD=$(pwd)
cd $XSDKSDKDIR/board_mb$MBNR
echo -e "\e[1;34mBuilding Board-Driver for MicroBlaze $MBNR\e[0m"
make --silent > /dev/null
if [ $? -ne 0 ] ; then
echo -e "\e[1;31mmake FAILED!\e[0m"
exit 1
else
echo -e "\e[0;32mmake succeeded.\e[0m"
fi
cd $CWD
done
# export SDK
echo -e "\e[1;34mOrganize SDK directory for all MicroBlazes\e[0m"
for MBNR in $(seq 0 $((MICROBLAZECOUNT - 1)) ) ; do
LIBDIR=$SDKDIR/lib/mb$MBNR
INCDIR=$SDKDIR/include/mb$MBNR
mkdir -p $LIBDIR
mkdir -p $INCDIR
echo -e -n "\t\e[1;34m$LIBDIR: "
cp -r $XSDKSDKDIR/board_mb$MBNR/microblaze_$MBNR/lib/libxil.a $LIBDIR/.
if [ $? -ne 0 ] ; then
echo -e "\e[1;31mFAILED!\e[0m"
exit 1
else
echo -e "\e[1;32m✔\e[0m"
fi
echo -e -n "\t\e[1;34m$INCDIR: "
cp -r $XSDKSDKDIR/board_mb$MBNR/microblaze_$MBNR/include/* $INCDIR/.
if [ $? -ne 0 ] ; then
echo -e "\e[1;31mFAILED!\e[0m"
exit 1
else
echo -e "\e[1;32m✔\e[0m"
fi
LDSCRIPT="$XSDKSDKDIR/software_mb$MBNR/src/lscript.ld"
echo -e -n "\t\e[1;34m$SDKDIR/ldscript_mb$MBNR.ld: "
cp $LDSCRIPT $SDKDIR/ldscript_mb$MBNR.ld
if [ $? -ne 0 ] ; then
echo -e "\e[1;31mFAILED!\e[0m"
exit 1
else
echo -e "\e[1;32m✔\e[0m"
fi
done
echo -e "\e[1;32mSDK created.\e[0m"
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
#!/usr/bin/env python3
#
# Version: 1.0.0
#
# Changelog:
# 1.0.0 - 11.03.19: First release
#
# Contributors:
# Ralf Stemmer - ralf.stemmer@uni-oldenburg.de
#
import numpy as np
import math
import matplotlib.pyplot as pyplot
import csv
import argparse
import array
def column(matrix, i):
return [row[i] for row in matrix]
cli = argparse.ArgumentParser(description='Plot Graph from File')
cli.add_argument("infile", type=str, action="store",
help="Path where the measured data will be read from.")
args = cli.parse_args()
if __name__ == '__main__':
# read vector of data
with open(args.infile) as f:
lines = f.read().splitlines()
data = [int(line) for line in lines]
print("\033[1;34mmin: \033[1;35m %5i"%(min(data)))
print("\033[1;34mmax: \033[1;35m %5i"%(max(data)))
print("\033[1;34mavg: \033[1;35m %5f"%(sum(data)/float(len(data))))
npdata = np.asarray(data)
fig = pyplot.figure()
fig.set_size_inches(18.5, 10.5)
fig.suptitle("time in cycles", fontsize=11)
# time over time
time = fig.add_subplot(1,2,1, label="time")
time.plot(np.arange(len(npdata)), npdata,
color="C0", markersize = 1, marker = ".", linestyle = "")
time.set_xlabel("Measurement", color="C0")
time.set_ylabel("Time", color="C0")
time.tick_params(axis="x", colors="C0")
time.tick_params(axis="y", colors="C0")
pyplot.grid(True)
# histogram
hist = fig.add_subplot(1,2,2, label="hist")
hist.hist(npdata, 100, density=0, color="C1")
hist.set_xlabel("Time", color="C1")
hist.set_ylabel("Occurence", color="C1")
hist.tick_params(axis="x", colors="C1")
hist.tick_params(axis="y", colors="C1")
pyplot.grid(True)
pyplot.show()
#if args.savePlot is not None:
# fig.savefig(args.savePlot, bbox_inches='tight', dpi=100)
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
#
# Version: 1.0.0
#
# Changelog:
# 1.0.0 - 11.03.19: First release
#
# Contributors:
# Ralf Stemmer - ralf.stemmer@uni-oldenburg.de
#
puts "\x1B\[1;36mCreating SDK for ARM CortexA9 [lindex $argv 1] using xsdk\x1B\[0m"
# Define environment
source ./scripts/settings.tcl
set SDKDIR "$OUTPUTDIR/$PROJECTNAME.sdk"
set PROCESSOR "ps7_cortexa9_[lindex $argv 1]"
set HWNAME "hardware_arm[lindex $argv 1]"
set SWNAME "software_arm[lindex $argv 1]"
set BSPNAME "board_arm[lindex $argv 1]"
# Create output directory
file mkdir $SDKDIR
#set_workspace $SDKDIR
setws $SDKDIR
puts "\x1B\[1;34mCreating BSP…\x1B\[0m"
createhw -name $HWNAME -hwspec $HARDWAREDEF
createbsp -name $BSPNAME -hwproject $HWNAME -proc $PROCESSOR -os standalone
puts "\x1B\[1;34mAdding libraries to BSP…\x1B\[0m"
openbsp $BSPNAME
setlib -bsp $BSPNAME -lib xilffs
regenbsp -bsp $BSPNAME
closebsp $BSPNAME
puts "\x1B\[1;34mCreating FSBL…\x1B\[0m"
createapp -name $SWNAME -hwproject $HWNAME -proc $PROCESSOR -os standalone -lang C -app {Zynq FSBL} -bsp $BSPNAME
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
#
# Version: 1.0.0
#
# Changelog:
# 1.0.0 - 11.03.19: First release
#
# Contributors:
# Ralf Stemmer - ralf.stemmer@uni-oldenburg.de
#
puts "\x1B\[1;36mCreating SDK for Microblaze [lindex $argv 1] using xsdk\x1B\[0m"
# Define environment
source ./scripts/settings.tcl
set SDKDIR "$OUTPUTDIR/$PROJECTNAME.sdk"
set PROCESSOR "microblaze_[lindex $argv 1]"
set HWNAME "hardware_mb[lindex $argv 1]"
set SWNAME "software_mb[lindex $argv 1]"
set BSPNAME "board_mb[lindex $argv 1]"
# Create output directory
file mkdir $SDKDIR
set_workspace $SDKDIR
puts "\x1B\[1;34mCreating BSP…\x1B\[0m"
create_hw_project -name $HWNAME -hwspec $HARDWAREDEF
create_bsp_project -name $BSPNAME -hwproject $HWNAME -proc $PROCESSOR -os standalone
create_app_project -name $SWNAME -hwproject $HWNAME -proc $PROCESSOR -os standalone -lang C -app {Hello World} -bsp $BSPNAME
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:for-each select="EDKSYSTEM/MODULES/MODULE/MEMORYMAP/MEMRANGE">
<xsl:value-of select="@INSTANCE" /> <xsl:text>,</xsl:text>
<xsl:value-of select="@BASEVALUE" /> <xsl:text>,</xsl:text>
<xsl:value-of select="@HIGHVALUE" /> <xsl:text>&#x0A;</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
#!/usr/bin/bash
# Configurations necessary to edit by the user
################################################################
# The Project Name is the name of the project as given in the "Create new Project" dialog in Vivado.
# This name is the same name as the directory, all files manages by Vivado are stored at.
# This directory names as the project contains several subdirectorys starting with $PROJECTNAME.*
PROJECTNAME=HWv3.2
# The Hardware Name is the name of the created Block Design
# This name also appears at several positions with some suffixes like $HARDWARENAME_wrapper
# The name gets displayed in the title of the Block Designer.
HARDWARENAME=SoC
# The Software Name is the name of to the source code directory of the whole system.
# Subdirectories are the "shared" directory and a directory for each Microblaze and ARM core
SOFTWARENAME=SWv3.3
# Derived configurations - usually they do not need to be edited
################################################################
OUTPUTDIR=./${PROJECTNAME}
HARDWAREDEF=$OUTPUTDIR/$PROJECTNAME.sdk/${HARDWARENAME}_wrapper.hdf
# SDK Directory. This is the place the SDK generated by the makesdk.sh script gets stored.
SDKDIR=$OUTPUTDIR/sdk
SDK_BITFILE=$SDKDIR/hardware.bit
SDK_MEMORYMAP=$SDKDIR/memorymap.csv
SDK_MEMORYINFO=$SDKDIR/memory.mmi
SDK_HARDWAREDEF=$SDKDIR/hardware.hdf
SDK_SYSTEMDEF=$SDKDIR/sysdef.xml
# SOFTWARE
SW_SRCDIR=./${SOFTWARENAME}
SW_BUILDDIR=$OUTPUTDIR/build
# temporary path used for working XSDK. The data stored at this directory will be processed by makesdk.sh
XSDKSDKDIR=$OUTPUTDIR/temp.sdk
# programm paths
VIVADOVERSION=2016.3
XILINXROOT=/opt/Xilinx
VIVADO=$XILINXROOT/Vivado/${VIVADOVERSION}/bin/vivado
XSDK=$XILINXROOT/SDK/${VIVADOVERSION}/bin/xsdk
# Scripts
CREATEMBSDK_SCRIPT=./scripts/creatembsdk.tcl
CREATEARMSDK_SCRIPT=./scripts/createarmsdk.tcl
TCLSETTINGS=./scripts/settings.tcl
UPLOADSCRIPT=./scripts/upload2.tcl
# Generate a TCL version of the settings that can be used by the TCL scripts
echo "# This file is auto-generated by settings.sh and contains a subset of that script in TCL syntax" > $TCLSETTINGS
echo "set OUTPUTDIR \"$OUTPUTDIR\"" >> $TCLSETTINGS
echo "set PROJECTNAME \"temp\"" >> $TCLSETTINGS
echo "set PROJECTDIR \"$OUTPUTDIR\"" >> $TCLSETTINGS
echo "set HARDWAREDEF \"$SDK_HARDWAREDEF\"" >> $TCLSETTINGS
echo "set BITSTREAM \"$SDK_BITFILE\"" >> $TCLSETTINGS
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
// Xilinx Libraries
#include <xparameters.h>
#include <xil_io.h>
#include <xil_cache.h>
int main()
{
Xil_ICacheEnable();
Xil_DCacheEnable();
while(1);
return 0; // Satisfy compiler
}
// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
/*******************************************************************/
/* */
/* This file IS BASED ON the */
/* automatically generated by linker script generator. */
/* by: */
/* */
/* Copyright (c) 2010-2016 Xilinx, Inc. All rights reserved. */
/* */
/* Description : MicroBlaze Linker Script */
/* */
/*******************************************************************/
_STACK_SIZE = DEFINED(_STACK_SIZE) ? _STACK_SIZE : 0x400;
_HEAP_SIZE = DEFINED(_HEAP_SIZE) ? _HEAP_SIZE : 0x800;
/* Define Memories in the system */
MEMORY
{
mainmemory : ORIGIN = 0x00000000, LENGTH = 64K
}
/* Specify the default entry point to the program */
ENTRY(_start)
/* Define the sections, and where they are mapped in memory */
SECTIONS
{
.vectors.reset 0x0 : {
KEEP (*(.vectors.reset))
}
.vectors.sw_exception 0x8 : {
KEEP (*(.vectors.sw_exception))
}
.vectors.interrupt 0x10 : {
KEEP (*(.vectors.interrupt))
}
.vectors.hw_exception 0x20 : {
KEEP (*(.vectors.hw_exception))
}
.text : {
*(.text)
*(.text.*)
*(.gnu.linkonce.t.*)
} > mainmemory
.init : {
KEEP (*(.init))
} > mainmemory
.fini : {
KEEP (*(.fini))
} > mainmemory
.ctors : {
__CTOR_LIST__ = .;
___CTORS_LIST___ = .;
KEEP (*crtbegin.o(.ctors))
KEEP (*(EXCLUDE_FILE(*crtend.o) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
__CTOR_END__ = .;
___CTORS_END___ = .;
} > mainmemory
.dtors : {
__DTOR_LIST__ = .;
___DTORS_LIST___ = .;
KEEP (*crtbegin.o(.dtors))
KEEP (*(EXCLUDE_FILE(*crtend.o) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
PROVIDE(__DTOR_END__ = .);
PROVIDE(___DTORS_END___ = .);
} > mainmemory
.rodata : {
__rodata_start = .;
*(.rodata)
*(.rodata.*)
*(.gnu.linkonce.r.*)
__rodata_end = .;
} > mainmemory
.sdata2 : {
. = ALIGN(8);
__sdata2_start = .;
*(.sdata2)
*(.sdata2.*)
*(.gnu.linkonce.s2.*)
. = ALIGN(8);
__sdata2_end = .;
} > mainmemory