-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_L2_cache.sh
executable file
·112 lines (99 loc) · 4.22 KB
/
setup_L2_cache.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
# This script will equip your system with the rocket-chip implementation dated March 2nd, 2018
# Please make sure:
# 1. you've created a Virtual Machine as advised over at Learning Journey pages
# 2. you've run setup_general.sh before running this script.
# For details, kindly take a look at README.md
#
export PROJ_NAME=F
# If $PROJ_NAME is NOT defined in .bashrc, you may define it as "export PROJ_NAME=F"
#if [ ! -d "$LJRC" ]; then
# Let the user to enter the needed branch name. It can be master if wanted.
#read -p "Enter the name of branch: " branchName
#fi
##########################################################
# Define the tool chain location.
##########################################################
if [ -z ${LJRC} ]; then
export LJRC=${HOME}/learning-journey
fi
##########################################################
# Clone the project.
##########################################################
if [ ! -d "$LJRC/learning_journey_rocket_chip" ]; then
##########################################################
# Prepare the .gitconfig file - important for qemu and jimtcl
##########################################################
git config --global url.https://github.com/qemu.insteadof git://git.qemu-project.org
git config --global url.git://cgit.freedesktop.org/pixman.insteadof https://anongit.freedesktop.org/pixman
git config --global --add url.git://cgit.freedesktop.org/pixman.insteadof git://anongit.freedesktop.org/pixman
git config --global url.https://github.com/msteveb/jimtcl.git.insteadof http://repo.or.cz/r/jimtcl.git
##########################################################
# Clone and get the repository.
##########################################################
mkdir $LJRC
cd $LJRC
git config --global credential.helper "cache --timeout=36000"
git clone https://github.com/Intensivate/learning_journey_rocket_chip.git
cd learning_journey_rocket_chip
git submodule update --init
##########################################################
# Update .bashrc to include RISCV
##########################################################
sed -i '/RISCV/d' ~/.bashrc
sed -i '/ROCKETCHIP/d' ~/.bashrc
sed -i '/LJRC/d' ~/.bashrc
sed -i '/TOP/d' ~/.bashrc
perl -i -p0e 's/\# AUTOGENERATED_CORE START.*?\# AUTOGENERATED_CORE END//s' ~/.bashrc
echo >> ~/.bashrc
echo \# AUTOGENERATED_CORE START >> ~/.bashrc
echo export PROJ_NAME=F >> ~/.bashrc
echo \ >> ~/.bashrc
echo export LJRC=${LJRC} >> ~/.bashrc
echo >> ~/.bashrc
echo if [ \"\$PROJ_NAME\" == \"F\" ]\; then >> ~/.bashrc
echo \ \ cd ${LJRC}/learning_journey_rocket_chip >> ~/.bashrc
echo \ \ source set_env.sh >> ~/.bashrc
echo fi >> ~/.bashrc
echo \# AUTOGENERATED_CORE END >> ~/.bashrc
echo >> ~/.bashrc
##########################################################
# Build the needed tools.
##########################################################
# Building the RISC-V cross-compilation tools
cd $LJRC/learning_journey_rocket_chip
source $LJRC/learning_journey_rocket_chip/set_env.sh
cd riscv-tools
git submodule update --init --recursive
./build.sh
rm -rf riscv-gnu-toolchain/build
##########################################################
# Set up Verilator.
##########################################################
cd $LJRC/learning_journey_rocket_chip
source $LJRC/learning_journey_rocket_chip/set_env.sh
cd $LJRC/learning_journey_rocket_chip/emulator
make
mkdir -p $VERILATOR_ROOT/include
ln -s $VERILATOR_ROOT/share/verilator/include $VERILATOR_ROOT/include
ln -s $VERILATOR_ROOT/share/verilator/include/* $VERILATOR_ROOT/include
ln -s $VERILATOR_ROOT/share/verilator/bin/verilator_includer $VERILATOR_ROOT/bin/verilator_includer
##########################################################
# Return back to the working area.
##########################################################
# Back to normal configuration.
. ~/.bashrc
cd ${LJRC}
else
echo "Re-running the script"
cd $LJRC/learning_journey_rocket_chip
git pull
git pull --recurse-submodules
git pull
cd riscv-tools
git submodule update --init --recursive
./build.sh
rm -rf riscv-gnu-toolchain/build
cd $LJRC/learning_journey_rocket_chip
echo "Script re-run finished"
fi