Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script to get all the enjoy-digital repos and set up a conda environment for using them in
#! /bin/bash
# Get environment setup for working with nexys+netv2 SoC
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 -x
set -e
echo "####################################"
echo "# Installing dependencies"
echo "####################################"
echo "Installing apt packages for simulation"
sudo apt-get install build-essential libsdl1.2-dev libftdi-dev atftpd openvpn
echo
ARCHS="or1k lm32"
echo "Installing conda for toolchains"
echo "===================================="
CONDA_DIR=$PWD/conda
export PATH=$CONDA_DIR/bin:$PATH
(
if [ ! -d $CONDA_DIR ]; then
wget -c https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
chmod a+x Miniconda3-latest-Linux-x86_64.sh
./Miniconda3-latest-Linux-x86_64.sh -p $CONDA_DIR -b
conda config --set always_yes yes --set changeps1 no
conda update -q conda
fi
conda config --add channels timvideos
# Downgrade to python3.5 as python3.6 doesn't work yet.
conda install python=3.5
echo "python ==3.5.4" > $CONDA_DIR/conda-meta/pinned
for ARCH in $ARCHS; do
conda install binutils-${ARCH}-elf
conda install gcc-${ARCH}-elf
conda install gdb-${ARCH}-elf
done
conda install verilator
conda install openocd
conda install flterm
)
echo "------------------------------------"
echo
function git-fetch-all {
for i in $(git remote); do git fetch -p $i ; done
}
# Get HDMI2USB-mode-switch so we can do the programming
#echo "Installing mode switch"
#echo "===================================="
#if [ ! -d "HDMI2USB-mode-switch" ]; then
# sudo apt-get install fxload
# git clone https://github.com/timvideos/HDMI2USB-mode-switch.git
#fi
#(
# cd HDMI2USB-mode-switch
# git-fetch-all
# git status
# git merge origin/master
# python setup.py develop
#
# cd udev
# sudo make install
# sudo make reload
#)
#echo "------------------------------------"
#echo
echo "####################################"
echo "# Getting lite repos"
echo "####################################"
LITE_REPOS="
litex
litedram
liteeth
litepcie
litescope
litevideo
"
for REPO in $LITE_REPOS; do
echo "$REPO"
echo "===================================="
if [ ! -d $REPO ]; then
git clone --recursive https://github.com/enjoy-digital/$REPO.git
fi
(
cd $REPO
git-fetch-all
git status
git merge origin/master --ff-only
git submodule update --init --recursive
git submodule -q foreach git fetch origin
python setup.py develop
)
echo "------------------------------------"
echo
done
echo "####################################"
echo "# Getting soc repos"
echo "####################################"
SOC_REPOS="
arty-soc
netv2-soc
nexys-soc
opsis-soc
scarab-soc
transceiver_test
daisho_usb3ipcore_test
Artix-7-HDMI-processing
"
for REPO in $SOC_REPOS; do
echo "$REPO"
echo "===================================="
if [ ! -d $REPO ]; then
git clone https://github.com/enjoy-digital/$REPO.git
fi
(
cd $REPO
git-fetch-all
if [ -z "$(git status --porcelain)" ]; then
git merge origin/master --ff-only
else
echo "$REPO is dirty, not updating..."
git status
fi
)
echo "------------------------------------"
echo
done
echo
echo "####################################"
echo "# Finished setup!"
echo "####################################"
echo
echo "Enter environment:"
echo "export PATH=$PWD/conda/bin:\$PATH"
#! /bin/bash
set -x
set -e
function git_commit {
git commit -a -m"litex import: $1"
}
DIR=$(echo temp.$(date +%Y%m%d-%H%M%S))
mkdir $DIR
cd $DIR
git clone https://github.com/m-labs/migen.git
(
cd migen
mkdir litex
touch litex/__init__.py
git add litex/__init__.py
git mv migen litex/gen
git_commit "Move migen to litex.gen"
# Moving the build dir around
git mv litex/gen/build litex/build
git_commit "Move migen.build to litex.build"
# Moving the platforms around
mkdir litex/boards
touch litex/boards/__init__.py
git add litex/boards/__init__.py
git mv litex/build/platforms litex/boards/platforms
git_commit "Moving migen.build.platforms to litex.boards.platforms."
# License file.
git mv LICENSE litex/gen/MIGEN_LICENSE
git_commit "Moving the Migen License file"
# Remove migen specific files
git rm .gitignore
git rm conda/migen/meta.yaml
git rm README.md
git rm setup.py
git_commit "Removing Migen top level files."
cd ..
)
git clone https://github.com/m-labs/misoc.git
(
cd misoc
mkdir litex
git mv misoc litex/soc
git_commit "Move misoc to litex.soc."
# Move the cores around
(
cd litex/soc/cores
# Move the CPUs into the CPU directory
mkdir cpu
touch cpu/__init__.py
git add cpu/__init__.py
git mv lm32 cpu/lm32
git mv mor1kx cpu/mor1kx
git_commit "Moving misoc CPU cores."
# Remove the cores that are provided by liteeth
git rm -rf liteeth_mini
git_commit "Removing cores provided by liteeth."
# Remove the cores that are provided by litevideo
git rm -rf dvi_sampler
git rm -rf framebuffer
git_commit "Removing cores provided by litevideo."
)
# Removing lasmi
git rm -rf litex/soc/cores/lasmicon
git rm litex/soc/interconnect/dma_lasmi.py
git rm litex/soc/interconnect/wishbone2lasmi.py
git_commit "Removing LASMI."
# Remove the cores that are provided by litedram
git rm litex/soc/cores/sdram_model.py
git rm -rf litex/soc/cores/sdram_phy
git rm litex/soc/cores/sdram_settings.py
git rm litex/soc/cores/sdram_tester.py
git rm -rf litex/soc/cores/minicon
git rm litex/soc/cores/dfii.py
git rm litex/soc/interconnect/dfi.py
git_commit "Removing cores provided by litedram."
# License file.
git mv LICENSE litex/soc/MISOC_LICENSE
git_commit "Moving the MiSoC License file"
# Moving the boards files
mkdir litex/boards
touch litex/boards/__init__.py
git add litex/boards/__init__.py
git mv litex/soc/targets litex/boards/targets
git_commit "Moving misoc.soc.targets to litex.boards.targets."
# Remove migen specific files
git rm .gitignore
git rm conda/misoc/meta.yaml
git rm CONTRIBUTING.rst
git rm README
git rm setup.py
git rm MANIFEST.in
git_commit "Removing top level files."
)
mkdir litex-merge
(
cd litex-merge
git init
git remote add migen ../migen/.git
git fetch migen
git remote add misoc ../misoc/.git
git fetch misoc
# Merge migen + misoc
git merge migen/master
git merge misoc/master --allow-unrelated-histories -m "Merging migen and misoc for litex merge."
# Doing renames
# -e"s/misoc.cores.dvi_sampler/litevideo.???/g" \
# -e"s/misoc.cores.framebuffer/litevideo.???/g" \
sed -i \
-e"s/misoc.cores.liteeth_mini/liteeth/g" \
-e"s/liteeth.mac/liteeth.core.mac/g" \
$(find -name \*.py) \
$(find -name \*.rst) \
git_commit "Doing renames for liteeth."
sed -i \
-e"s/misoc.cores.sdram_settings/litedram.modules/g" \
-e"s/misoc.cores.sdram_phy/litedram.phy/g" \
-e's/ "minicon",//g' \
$(find -name \*.py) \
$(find -name \*.rst) \
git_commit "Doing renames for litedram."
sed -i \
-e's/Migen/LiteX/g' \
-e's/MiSoC/LiteX/g' \
-e's/LiteX gen/LiteX/g' \
-e's/migen"/litex"/g' \
-e"s/migen'/litex'/g" \
-e's/misoc"/litex"/g' \
-e"s/misoc'/litex'/g" \
-e"s/misoc.targets/litex.boards.targets/g" \
-e"s/misoc.cores.lm32/litex.soc.cores.cpu.lm32/g" \
-e"s/misoc.cores.mor1kx/litex.soc.cores.cpu.mor1kx/g" \
-e"s/misoc.cores/litex.soc.cores/g" \
-e"s/migen.build.platforms/litex.boards.platforms/g" \
-e"s/migen.build/litex.build/g" \
-e"s^/migen/^/litex/^g" \
-e"s^migen_^litex_^g" \
-e"s^misoc_^litex_^g" \
-e"s^github.com/m-labs^github.com/enjoy-digital^g" \
-e"s/misoc/litex.soc/g" \
-e"s/migen/litex.gen/g" \
-e"s/dfii_/sdram_dfii_/g" \
-e"s/MISOC_DIRECTORY/SOC_DIRECTORY/g" \
-e"s/CSR_DFII_BASE/CSR_SDRAM_BASE/g" \
-e"s^LiteX/LiteX^Migen/LiteX^g" \
$(find -name \*.py) \
$(find -name \*.rst) \
$(find -name Makefile) \
$(find litex/soc/software -name \*.c) \
git_commit "Doing renames for LiteX."
# -e"s/DFII_/SDRAM_DFII_/g" \
sed -i \
-e's/\(sink\|source\|fifo_in\|fifo_out\).ack/\1.ready/g' \
-e's/\(sink\|source\|fifo_in\|fifo_out\).stb/\1.valid/g' \
-e's/\(sink\|source\|fifo_in\|fifo_out\).eop/\1.last/g' \
$(find -name \*.py) \
$(find -name \*.rst) \
git_commit "Doing renames for stream interface."
sed -i \
-e's/import litex.gen/import litex/g' \
-e"s/'litex.gen.'/'litex.'/g" \
doc/conf.py \
git_commit "Fixing up docs."
git branch to-merge
# Get litex for the merging
git remote add upstream https://github.com/enjoy-digital/litex.git
git fetch upstream
git merge upstream/master || true
#git rm misoc/cores/liteeth_mini/LICENSE
#git rm misoc/cores/uart/core.py
git add $(git status | grep 'added by' | sed -e's/[^:]*: *//')
git rm $(git status | grep 'both deleted' | sed -e's/[^:]*: *//')
git checkout upstream/master .gitignore
git checkout upstream/master LICENSE
git checkout upstream/master MANIFEST.in
git checkout upstream/master README
git checkout upstream/master setup.py
git checkout to-merge doc
git checkout to-merge examples
)
echo $DIR/litex-merge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.