-
Notifications
You must be signed in to change notification settings - Fork 16
/
sonic_202106_mvl_patch.sh
240 lines (194 loc) · 8.21 KB
/
sonic_202106_mvl_patch.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
#!/bin/bash
# Copyright (c) Marvell, Inc. All rights reservered. Confidential.
# Description: Applying open PRs needed for ARM arch compilation
#
# patch script for ARM64 Falcon board
#
#
# CONFIGURATIONS:-
#
SONIC_COMMIT="206f7b66b59600e46761ab287ae780b0248a3e84"
declare -a PATCHES=(P1)
url="https://github.com/Azure"
declare -A P1=( [NAME]=sonic-buildimage [DIR]=. [PR]="50" [URL]="https://github.com/Marvell-OpenNOS/" [PREREQ]="" [POSTREQ]="")
#
# END of CONFIGURATIONS
#
# PREDEFINED VALUES
CUR_DIR=$(basename `pwd`)
LOG_FILE=patches_result.log
FULL_PATH=`pwd`
log()
{
echo $@
echo $@ >> ${FULL_PATH}/${LOG_FILE}
}
pre_patch_help()
{
log "STEPS TO BUILD:"
log "git clone https://github.com/Azure/sonic-buildimage.git"
log "cd sonic-buildimage"
log "git checkout $SONIC_COMMIT"
log "make init"
log "<<Apply patches using patch script>>"
log "bash $0"
log "<<FOR ARM64>> make configure PLATFORM=marvell-arm64 PLATFORM_ARCH=arm64"
log "<<FOR INTEL>> make configure PLATFORM=marvell"
log "make all"
}
enable_sdk_shell()
{
#PR 5519
wget -c https://raw.githubusercontent.com/Marvell-switching/sonic-scripts/master/files/master-buster/shell_buildimage.patch
patch -p1 < shell_buildimage.patch
#PR 1454
pushd src/sonic-swss
wget -c https://raw.githubusercontent.com/Marvell-switching/sonic-scripts/master/files/master-buster/shell_swss.patch
patch -p1 < shell_swss.patch
popd
#PR 1146
pushd src/sonic-utilities
wget -c https://raw.githubusercontent.com/Marvell-switching/sonic-scripts/master/files/master-buster/shell_utilities.patch
patch -p1 < shell_utilities.patch
popd
}
apply_patches()
{
CWD=`pwd`
#URL_CMD="wget $url/$module/pull/$pr.diff"
for f in ${PATCHES[*]}
do
P_NAME=${f}[NAME]
log "INFO: ${!P_NAME} ... "
P_DIR=${f}[DIR]
log "CMD: cd ${!P_DIR}"
cd ${!P_DIR}
P_PRS=${f}[PR]
P_URL=${f}[URL]
P_PREREQ=${f}[PREREQ]
P_POSTREQ=${f}[POSTREQ]
if [ -n "${!P_PREREQ}" ]
then
log "INFO calling prereq ${!P_PREREQ}"
eval ${!P_PREREQ}
fi
for p in ${!P_PRS}
do
log "INFO: URL ${!P_URL}/${!P_NAME}/pull/${p}.diff"
rm -f ${p}.diff || true
wget "${!P_URL}/${!P_NAME}/pull/${p}.diff"
if [ -f ${p}.diff ]
then
log "INFO: patch -p1 < ${p}.diff"
patch -p1 -f --dry-run < ${p}.diff
if [ $? -eq 0 ]; then
log "INFO: Applying patch"
patch -p1 < ${p}.diff
else
log "ERROR: Patch ${!P_NAME} ${p} has failures, try manually"
fi
rm -f ${p}.diff
else
log "ERROR: Could not download patch ${!P_NAME} ${p}.diff"
fi
done
if [ -n "${!P_POSTREQ}" ]
then
log "INFO calling post script ${!P_POSTREQ}"
eval ${!P_POSTREQ}
fi
cd ${CWD}
done
}
create_temp_rclocal_patch()
{
cat <<EOF > /tmp/rclocal_fix
echo "Marvell: Executing Workarounds !!!!"
echo "Switch Mac Address Update"
MAC_ADDR=\`ip link show eth0 | grep ether | awk '{print \$2}'\`
find /usr/share/sonic/device/*db98cx* -name profile.ini | xargs sed -i "s/switchMacAddress=.*/switchMacAddress=\$MAC_ADDR/g"
EOF
}
bug_fixes()
{
pushd src/sonic-linux-kernel
wget -c https://raw.githubusercontent.com/Marvell-switching/sonic-scripts/master/files/master-buster/linux-ARM64-and-ARMHF-build-changes.patch
patch -p1 --dry-run < ./linux-ARM64-and-ARMHF-build-changes.patch
patch -p1 < ./linux-ARM64-and-ARMHF-build-changes.patch
popd
wget -c https://raw.githubusercontent.com/Marvell-switching/sonic-scripts/master/files/master-buster/build_fix.patch
patch -p1 --dry-run < ./build_fix.patch
patch -p1 < ./build_fix.patch
#redis workaround to increase lua-time-limit to 20000ms
wget -c https://raw.githubusercontent.com/Marvell-switching/sonic-scripts/master/files/redis_wa.patch
patch -p1 < redis_wa.patch
# Mac address fix
sed -i "s/'cat'/'cat '/g" src/sonic-py-common/sonic_py_common/device_info.py
# snmp subagent
#echo 'sudo sed -i "s/python3.6/python3/g" $FILESYSTEM_ROOT/etc/monit/conf.d/monit_snmp' >> files/build_templates/sonic_debian_extension.j2
#1 Disable Mgmt Framework and Telemetry
sed -i 's/INCLUDE_MGMT_FRAMEWORK = y/INCLUDE_MGMT_FRAMEWORK = n/g' rules/config
#2 update mac in profile.ini
create_temp_rclocal_patch
sed '16r /tmp/rclocal_fix' < files/image_config/platform/rc.local > files/image_config/platform/rc.local_new
mv files/image_config/platform/rc.local files/image_config/platform/rc.local_orig
mv files/image_config/platform/rc.local_new files/image_config/platform/rc.local
chmod a+rwx files/image_config/platform/rc.local
#3 Watchdog/select Timeout workaround
sed -i 's/#define SELECT_TIMEOUT 1000/#define SELECT_TIMEOUT 1999999/g' src/sonic-swss/orchagent/orchdaemon.cpp
sed -i 's/(60\*1000)/(1999999)/g' src/sonic-sairedis/lib/inc/sairedis.h
#4 copp configuration for jumbo
sed -i 's/"cir":"600",/"cir":"6000",/g' files/image_config/copp/copp_cfg.j2
sed -i 's/"cbs":"600",/"cbs":"6000",/g' files/image_config/copp/copp_cfg.j2
#5 Download hwsku
wget -c https://raw.githubusercontent.com/Marvell-switching/sonic-scripts/master-buster/files/mrvl_sonic_hwsku.tgz
rm -fr device/marvell/x86_64-marvell_db98cx8580_32cd-r0 || true
rm -fr device/marvell/arm64-marvell_db98cx8580_32cd-r0 || true
rm -fr device/marvell/x86_64-marvell_db98cx8540_16cd-r0 || true
rm -fr device/marvell/arm64-marvell_db98cx8540_16cd-r0 || true
rm -fr device/marvell/arm64-marvell_rd98DX7312_32G16HVG6HLG-r0 || true
tar -C device/marvell/ -xzf mrvl_sonic_hwsku.tgz
cp -dr device/marvell/arm64-marvell_db98cx8580_32cd-r0 device/marvell/x86_64-marvell_db98cx8580_32cd-r0
cp -dr device/marvell/arm64-marvell_db98cx8540_16cd-r0 device/marvell/x86_64-marvell_db98cx8540_16cd-r0
cp -dr device/marvell/arm64-marvell_db98cx8514_10cc-r0 device/marvell/x86_64-marvell_db98cx8514_10cc-r0
rm device/marvell/arm64-marvell_db98cx8580_32cd-r0/plugins/x86_64_sfputil.py
rm device/marvell/arm64-marvell_db98cx8540_16cd-r0/plugins/x86_64_sfputil.py
rm device/marvell/arm64-marvell_db98cx8514_10cc-r0/plugins/x86_64_sfputil.py
mv device/marvell/x86_64-marvell_db98cx8580_32cd-r0/plugins/x86_64_sfputil.py device/marvell/x86_64-marvell_db98cx8580_32cd-r0/plugins/sfputil.py
mv device/marvell/x86_64-marvell_db98cx8540_16cd-r0/plugins/x86_64_sfputil.py device/marvell/x86_64-marvell_db98cx8540_16cd-r0/plugins/sfputil.py
mv device/marvell/x86_64-marvell_db98cx8514_10cc-r0/plugins/x86_64_sfputil.py device/marvell/x86_64-marvell_db98cx8514_10cc-r0/plugins/sfputil.py
#6 Add Falcon module
wget -c https://raw.githubusercontent.com/Marvell-switching/sonic-scripts/master/files/master-buster/falcon_modules.patch
patch -p1 < falcon_modules.patch
#7 TODO: Intel USB access
wget -c https://raw.githubusercontent.com/Marvell-switching/sonic-scripts/master/files/sonic_usb_install_slow.patch
patch -p1 < sonic_usb_install_slow.patch
#8 use buster for syncd. Present in upstream for 202012.
wget -c https://raw.githubusercontent.com/Marvell-switching/sonic-scripts/master/files/202106/sync_buster.patch
patch -p1 --dry-run < ./sync_buster.patch
patch -p1 < ./sync_buster.patch
#9 arm64 platform patch
wget -c https://raw.githubusercontent.com/Marvell-switching/sonic-scripts/master/files/master-buster/arm64-platform.patch
patch -p1 --dry-run < ./arm64-platform.patch
patch -p1 < ./arm64-platform.patch
}
main()
{
sonic_buildimage_commit=`git rev-parse HEAD`
if [ "$CUR_DIR" != "sonic-buildimage" ]; then
log "ERROR: Need to be at sonic-builimage git clone path"
pre_patch_help
exit
fi
if [ "${sonic_buildimage_commit}" != "$SONIC_COMMIT" ]; then
log "Checkout Dec14 sonic-buildimage commit to proceed"
log "git checkout ${SONIC_COMMIT}"
pre_patch_help
exit
fi
date > ${FULL_PATH}/${LOG_FILE}
apply_patches
enable_sdk_shell
bug_fixes
}
main $@