forked from timvideos/HDMI2USB-litex-firmware
-
Notifications
You must be signed in to change notification settings - Fork 8
/
build-renode.sh
executable file
·102 lines (82 loc) · 2.32 KB
/
build-renode.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
#!/bin/bash
SCRIPT_SRC=$(realpath ${BASH_SOURCE[0]})
SCRIPT_DIR=$(dirname $SCRIPT_SRC)
TOP_DIR=$(realpath $SCRIPT_DIR/..)
if [[ "${BASH_SOURCE[0]}" != "${0}" ]]; then
echo "You must run this script, rather then try to source it."
echo "$SCRIPT_SRC"
exit 1
fi
source $SCRIPT_DIR/build-common.sh
init
RENODE_BIN=${RENODE_BIN:-renode}
RENODE_FOUND=false
if [ -x "$RENODE_BIN" ]; then
RENODE_FOUND=true
fi
if command -v "$RENODE_BIN" 2>&1 1>/dev/null; then
RENODE_FOUND=true
fi
if ! $RENODE_FOUND; then
# Download prebuilt renode Release if none is currently installed
RENODE_PACKAGE=renode-latest.linux-portable.tar.gz
RENODE_URL=https://antmicro.com/projects/renode/builds/$RENODE_PACKAGE
RENODE_LOCATION="$BUILD_DIR/renode"
mkdir -p $RENODE_LOCATION
RENODE_BIN=`find $RENODE_LOCATION -executable -type f -name renode`
if [ ! -x "$RENODE_BIN" ]; then
(
cd $RENODE_LOCATION
wget $RENODE_URL
tar -xf $RENODE_PACKAGE
)
RENODE_BIN=`find $RENODE_LOCATION -executable -type f -name renode`
chmod u+x $RENODE_BIN
echo "Renode downloaded and installed locally: $RENODE_BIN"
fi
fi
case $CPU in
vexriscv | picorv32)
;;
*)
echo "CPU $CPU_TYPE isn't supported at the moment."
exit 1
;;
esac
LITEX_CONFIG_FILE="$TARGET_BUILD_DIR/test/csr.csv"
if [ ! -f "$LITEX_CONFIG_FILE" ]; then
make firmware
fi
# Ethernet
ETH_BASE_ADDRESS=$(parse_generated_header "csr.h" CSR_ETHMAC_BASE)
if [ ! -z "$ETH_BASE_ADDRESS" ]; then
RENODE_NETWORK=${RENODE_NETWORK:-tap}
case $RENODE_NETWORK in
tap)
echo "Using tun device for Renode networking, (may need sudo)..."
configure_tap
start_tftp
# Build/copy the image into the TFTP directory.
make tftp
TAP_INTERFACE=tap0
;;
none)
echo "Renode networking disabled..."
;;
*)
echo "Unknown RENODE_NETWORK mode '$RENODE_NETWORK'"
return 1
;;
esac
fi
RENODE_SCRIPTS_DIR="$TARGET_BUILD_DIR/renode"
RENODE_RESC="$RENODE_SCRIPTS_DIR/litex_buildenv.resc"
RENODE_REPL="$RENODE_SCRIPTS_DIR/litex_buildenv.repl"
mkdir -p $RENODE_SCRIPTS_DIR
python $TOP_DIR/third_party/litex-renode/generate-renode-scripts.py $LITEX_CONFIG_FILE \
--repl "$RENODE_REPL" \
--resc "$RENODE_RESC" \
--bios-binary "$TARGET_BUILD_DIR/software/bios/bios.bin" \
--firmware-binary "$TARGET_BUILD_DIR/software/$FIRMWARE/firmware.bin" \
--configure-network ${TAP_INTERFACE:-""}
$RENODE_BIN "$RENODE_RESC"