-
Notifications
You must be signed in to change notification settings - Fork 3
/
bringup_mmc.sh
executable file
·98 lines (82 loc) · 2.51 KB
/
bringup_mmc.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
#!/bin/sh
# Environment Config:
# Mandatory Environment Variables:
# MMC_PATH=/path/to/marble_mmc
# LTM_SCRIPT=/path/to/LTM4673_reglist.txt
# Optional Environment Variables:
# TTY_MMC=/dev/ttyUSB3
# ============================= NOTE! ==================================
# == This script is currently brittly dependent on the assignment of ==
# == the ttyUSB device names. Please ensure the following before ==
# == executing: ==
# == /dev/ttyUSB0 -> JTAG to FPGA ==
# == /dev/ttyUSB1 -> Reset control ==
# == /dev/ttyUSB2 -> UART to/from FPGA ==
# == /dev/ttyUSB3 -> UART to/from MMC ==
# ======================================================================
# Turn on exit on failure
set -e
if [ $# -lt 0 ]; then
echo "Usage: bringup_mmc.sh"
exit 2
fi
# Mandatory Paths Check.
paths_complete=1
if [ -z "$MMC_PATH" ]; then
echo "Define MMC_PATH environment variable"
paths_complete=0
fi
if [ -z "$LTM_SCRIPT" ]; then
echo "Define register list for LTM4673"
paths_complete=0
fi
if [ "$paths_complete" -eq 0 ]; then
exit 1
fi
# Optional Environment Variables Check.
if [ -z "$TTY_MMC" ]; then
TTY_MMC=/dev/ttyUSB3
fi
# Handy Params
SCRIPTS_PATH=$MMC_PATH/scripts
# Test for exist
if [ ! -e "$MMC_PATH" ]; then
echo "$MMC_PATH does not exist"
exit 1
fi
if [ ! -d "$MMC_PATH" ]; then
echo "$MMC_PATH is not a directory"
exit 1
fi
#### Marble Bringup Steps ####
# 1. Program MMC
echo "Programming MMC...."
cd "$MMC_PATH"
if ! make marble_download; then
echo "Could not program marble_mmc. Is Segger J-Link attached? Is board powered?"
exit 1
else
echo "Successfully programmed MMC!"
fi
echo "##################################"
# Sleep for a few seconds to give the MMC time to boot
echo "napping for 5 seconds.."
sleep 5
# 2. Program LTM4673 power management chip
echo "Programming LTM4673 power management chip...."
if ! python3 "$SCRIPTS_PATH"/ltm4673.py -d "$TTY_MMC" write -f "$LTM_SCRIPT"; then
echo "Could not program LTM4673."
exit 1
else
echo "##################################"
python3 "$SCRIPTS_PATH"/ltm4673.py -d "$TTY_MMC" store
echo "napping for 5 seconds.."
sleep 5
python3 "$SCRIPTS_PATH"/load.py -d "$TTY_MMC" "4b"
echo "napping for 5 seconds.."
sleep 5
python3 "$SCRIPTS_PATH"/load.py -d "$TTY_MMC" "4B"
echo "Successfully programmed LTM4673!"
fi
echo "bringup_mmc DONE"
exit 0