Skip to content

Commit 5e046e5

Browse files
authored
PR #14288 from remibettan: Cherry Pick PR #14276, PR # 14279 by Kontra2B - support for JP7.0 and fixed version comparison issues
2 parents a1de24c + 115afac commit 5e046e5

File tree

4 files changed

+412
-59
lines changed

4 files changed

+412
-59
lines changed

scripts/Tegra/source_sync_7.0.sh

Lines changed: 344 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,344 @@
1+
#!/bin/bash
2+
3+
# SPDX-FileCopyrightText: Copyright (c) 2012-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
#
6+
# Redistribution and use in source and binary forms, with or without
7+
# modification, are permitted provided that the following conditions are met:
8+
#
9+
# 1. Redistributions of source code must retain the above copyright notice, this
10+
# list of conditions and the following disclaimer.
11+
#
12+
# 2. Redistributions in binary form must reproduce the above copyright notice,
13+
# this list of conditions and the following disclaimer in the documentation
14+
# and/or other materials provided with the distribution.
15+
#
16+
# 3. Neither the name of the copyright holder nor the names of its
17+
# contributors may be used to endorse or promote products derived from
18+
# this software without specific prior written permission.
19+
#
20+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
31+
32+
#
33+
# This script sync's NVIDIA's version of
34+
# 1. the kernel source
35+
# from nv-tegra, NVIDIA's public git repository.
36+
# The script also provides opportunities to the sync to a specific tag
37+
# so that the binaries shipped with a release can be replicated.
38+
#
39+
# Usage:
40+
# By default it will download all the listed sources
41+
# ./source_sync.sh
42+
# Use the -t <TAG> option to provide the TAG to be used to sync all the sources.
43+
# Use the -k <TAG> option to download only the kernel and device tree repos and optionally sync to TAG
44+
# For detailed usage information run with -h option.
45+
#
46+
47+
48+
# verify that git is installed
49+
if ! which git > /dev/null ; then
50+
echo "ERROR: git is not installed. If your linux distro is 10.04 or later,"
51+
echo "git can be installed by 'sudo apt-get install git-core'."
52+
exit 1
53+
fi
54+
55+
# source dir
56+
LDK_DIR=$(cd `dirname $0` && pwd)
57+
# script name
58+
SCRIPT_NAME=`basename $0`
59+
# info about sources.
60+
# NOTE: *Add only kernel repos here. Add new repos separately below. Keep related repos together*
61+
# NOTE: nvethrnetrm.git should be listed after "linux-nv-oot.git" due to nesting of sync path
62+
SOURCE_INFO="
63+
k:kernel/kernel-noble-src:nv-tegra.nvidia.com/3rdparty/canonical/linux-noble.git:
64+
k:nvgpu:nv-tegra.nvidia.com/tegra/kernel-src/linux-nvgpu.git:
65+
k:nvidia-oot:nv-tegra.nvidia.com/linux-nv-oot.git:
66+
k:hwpm:nv-tegra.nvidia.com/linux-hwpm.git:
67+
k:nvethernetrm:nv-tegra.nvidia.com/kernel/nvethernetrm.git:
68+
k:hardware/nvidia/t23x/nv-public:nv-tegra.nvidia.com/device/hardware/nvidia/t23x-public-dts.git:
69+
k:hardware/nvidia/tegra/nv-public:nv-tegra.nvidia.com/device/hardware/nvidia/tegra-public-dts.git:
70+
k:nvdisplay:nv-tegra.nvidia.com/tegra/kernel-src/nv-kernel-display-driver.git:
71+
k:dtc-src/1.4.5:nv-tegra.nvidia.com/3rdparty/dtc-src/1.4.5.git:
72+
o:tegra/argus-cam-libav/argus_cam_libavencoder:nv-tegra.nvidia.com/tegra/argus-cam-libav/argus_cam_libavencoder.git:
73+
o:tegra/cuda-src/nvsample_cudaprocess:nv-tegra.nvidia.com/tegra/cuda-src/nvsample_cudaprocess.git:
74+
o:tegra/gfx-src/nv-xconfig:nv-tegra.nvidia.com/tegra/gfx-src/nv-xconfig.git:
75+
o:tegra/gst-src/gst-egl:nv-tegra.nvidia.com/tegra/gst-src/gst-egl.git:
76+
o:tegra/gst-src/gst-jpeg:nv-tegra.nvidia.com/tegra/gst-src/gst-jpeg.git:
77+
o:tegra/gst-src/gst-nvarguscamera:nv-tegra.nvidia.com/tegra/gst-src/gst-nvarguscamera.git:
78+
o:tegra/gst-src/gst-nvcompositor:nv-tegra.nvidia.com/tegra/gst-src/gst-nvcompositor.git:
79+
o:tegra/gst-src/gst-nvtee:nv-tegra.nvidia.com/tegra/gst-src/gst-nvtee.git:
80+
o:tegra/gst-src/gst-nvv4l2camera:nv-tegra.nvidia.com/tegra/gst-src/gst-nvv4l2camera.git:
81+
o:tegra/gst-src/gst-nvvidconv:nv-tegra.nvidia.com/tegra/gst-src/gst-nvvidconv.git:
82+
o:tegra/gst-src/gst-nvvideo4linux2:nv-tegra.nvidia.com/tegra/gst-src/gst-nvvideo4linux2.git:
83+
o:tegra/gst-src/nvgstapps:nv-tegra.nvidia.com/tegra/gst-src/nvgstapps.git:
84+
o:tegra/gst-src/libgstnvcustomhelper:nv-tegra.nvidia.com/tegra/gst-src/libgstnvcustomhelper.git:
85+
o:tegra/gst-src/libgstnvdrmvideosink:nv-tegra.nvidia.com/tegra/gst-src/libgstnvdrmvideosink.git:
86+
o:tegra/gst-src/libgstnvvideosinks:nv-tegra.nvidia.com/tegra/gst-src/libgstnvvideosinks.git:
87+
o:tegra/v4l2-src/libv4l2_nvargus:nv-tegra.nvidia.com/tegra/v4l2-src/libv4l2_nvargus.git:
88+
o:tegra/nv-sci-src/nvsci_headers:nv-tegra.nvidia.com/tegra/nv-sci-src/nvsci_headers.git:
89+
o:tegra/optee-src/atf:nv-tegra.nvidia.com/tegra/optee-src/atf.git:
90+
o:tegra/optee-src/nv-optee:nv-tegra.nvidia.com/tegra/optee-src/nv-optee.git:
91+
o:tegra/v4l2-src/v4l2_libs:nv-tegra.nvidia.com/tegra/v4l2-src/v4l2_libs.git:
92+
"
93+
94+
# exit on error on sync
95+
EOE=0
96+
# after processing SOURCE_INFO
97+
NSOURCES=0
98+
declare -a SOURCE_INFO_PROCESSED
99+
# download all?
100+
DALL=1
101+
102+
function Usages {
103+
local ScriptName=$1
104+
local LINE
105+
local OP
106+
local DESC
107+
local PROCESSED=()
108+
local i
109+
110+
echo "Use: $1 [options]"
111+
echo "Available general options are,"
112+
echo " -h : help"
113+
echo " -e : exit on sync error"
114+
echo " -d [DIR] : root of source is DIR"
115+
echo " -t [TAG] : Git tag that will be used to sync all the sources"
116+
echo ""
117+
echo "By default, all sources are downloaded."
118+
echo "Only specified sources are downloaded, if one or more of the following options are mentioned."
119+
echo ""
120+
echo "$SOURCE_INFO" | while read LINE; do
121+
if [ ! -z "$LINE" ]; then
122+
OP=$(echo "$LINE" | cut -f 1 -d ':')
123+
DESC=$(echo "$LINE" | cut -f 2 -d ':')
124+
if [[ ! " ${PROCESSED[@]} " =~ " ${OP} " ]]; then
125+
echo " -${OP} [TAG]: Download $DESC source and optionally sync to TAG"
126+
PROCESSED+=("${OP}")
127+
else
128+
echo " and download $DESC source and sync to the same TAG"
129+
fi
130+
fi
131+
done
132+
echo ""
133+
}
134+
135+
function ProcessSwitch {
136+
local SWITCH="$1"
137+
local TAG="$2"
138+
local i
139+
local found=0
140+
141+
for ((i=0; i < NSOURCES; i++)); do
142+
local OP=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 1 -d ':')
143+
if [ "-${OP}" == "$SWITCH" ]; then
144+
SOURCE_INFO_PROCESSED[i]="${SOURCE_INFO_PROCESSED[i]}${TAG}:y"
145+
DALL=0
146+
found=1
147+
fi
148+
done
149+
150+
if [ "$found" == 1 ]; then
151+
return 0
152+
fi
153+
154+
echo "Terminating... wrong switch: ${SWITCH}" >&2
155+
Usages "$SCRIPT_NAME"
156+
exit 1
157+
}
158+
159+
function UpdateTags {
160+
local SWITCH="$1"
161+
local TAG="$2"
162+
local i
163+
164+
for ((i=0; i < NSOURCES; i++)); do
165+
local OP=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 1 -d ':')
166+
if [ "${OP}" == "$SWITCH" ]; then
167+
SOURCE_INFO_PROCESSED[i]=$(echo "${SOURCE_INFO_PROCESSED[i]}" \
168+
| awk -F: -v OFS=: -v var="${TAG}" '{$4=var; print}')
169+
fi
170+
done
171+
}
172+
173+
function DownloadAndSync {
174+
local WHAT_SOURCE="$1"
175+
local LDK_SOURCE_DIR="$2"
176+
local REPO_URL="$3"
177+
local TAG="$4"
178+
local OPT="$5"
179+
local RET=0
180+
181+
if [ -d "${LDK_SOURCE_DIR}" ]; then
182+
echo "Directory for $WHAT, ${LDK_SOURCE_DIR}, already exists!"
183+
pushd "${LDK_SOURCE_DIR}" > /dev/null
184+
git status 2>&1 >/dev/null
185+
if [ $? -ne 0 ]; then
186+
echo "But the directory is not a git repository -- clean it up first"
187+
echo ""
188+
echo ""
189+
popd > /dev/null
190+
return 1
191+
fi
192+
git fetch --all 2>&1 >/dev/null
193+
popd > /dev/null
194+
else
195+
echo "Downloading default $WHAT source..."
196+
197+
git clone "$REPO_URL" -n ${LDK_SOURCE_DIR} 2>&1 >/dev/null
198+
if [ $? -ne 0 ]; then
199+
echo "$2 source sync failed!"
200+
echo ""
201+
echo ""
202+
return 1
203+
fi
204+
205+
echo "The default $WHAT source is downloaded in: ${LDK_SOURCE_DIR}"
206+
fi
207+
208+
if [ -z "$TAG" ]; then
209+
echo "Please enter a tag to sync $2 source to"
210+
echo -n "(enter nothing to skip): "
211+
read TAG
212+
TAG=$(echo $TAG)
213+
UpdateTags $OPT $TAG
214+
fi
215+
216+
if [ ! -z "$TAG" ]; then
217+
pushd ${LDK_SOURCE_DIR} > /dev/null
218+
git tag -l 2>/dev/null | grep -q -P "^$TAG\$"
219+
if [ $? -eq 0 ]; then
220+
echo "Syncing up with tag $TAG..."
221+
git checkout -b mybranch_$(date +%Y-%m-%d-%s) $TAG
222+
echo "$2 source sync'ed to tag $TAG successfully!"
223+
else
224+
echo "Couldn't find tag $TAG"
225+
echo "$2 source sync to tag $TAG failed!"
226+
RET=1
227+
fi
228+
popd > /dev/null
229+
fi
230+
echo ""
231+
echo ""
232+
233+
return "$RET"
234+
}
235+
236+
# prepare processing ....
237+
GETOPT=":ehd:t:"
238+
239+
OIFS="$IFS"
240+
IFS=$(echo -en "\n\b")
241+
SOURCE_INFO_PROCESSED=($(echo "$SOURCE_INFO"))
242+
IFS="$OIFS"
243+
NSOURCES=${#SOURCE_INFO_PROCESSED[*]}
244+
245+
for ((i=0; i < NSOURCES; i++)); do
246+
OP=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 1 -d ':')
247+
GETOPT="${GETOPT}${OP}:"
248+
done
249+
250+
# parse the command line first
251+
while getopts "$GETOPT" opt; do
252+
case $opt in
253+
d)
254+
case $OPTARG in
255+
-[A-Za-z]*)
256+
Usages "$SCRIPT_NAME"
257+
exit 1
258+
;;
259+
*)
260+
LDK_DIR="$OPTARG"
261+
;;
262+
esac
263+
;;
264+
e)
265+
EOE=1
266+
;;
267+
h)
268+
Usages "$SCRIPT_NAME"
269+
exit 1
270+
;;
271+
t)
272+
TAG="$OPTARG"
273+
PROCESSED=()
274+
for ((i=0; i < NSOURCES; i++)); do
275+
OP=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 1 -d ':')
276+
if [[ ! " ${PROCESSED[@]} " =~ " ${OP} " ]]; then
277+
UpdateTags $OP $TAG
278+
PROCESSED+=("${OP}")
279+
fi
280+
done
281+
;;
282+
[A-Za-z])
283+
case $OPTARG in
284+
-[A-Za-z]*)
285+
eval arg=\$$((OPTIND-1))
286+
case $arg in
287+
-[A-Za-Z]-*)
288+
Usages "$SCRIPT_NAME"
289+
exit 1
290+
;;
291+
*)
292+
ProcessSwitch "-$opt" ""
293+
OPTIND=$((OPTIND-1))
294+
;;
295+
esac
296+
;;
297+
*)
298+
ProcessSwitch "-$opt" "$OPTARG"
299+
;;
300+
esac
301+
;;
302+
:)
303+
case $OPTARG in
304+
#required arguments
305+
d)
306+
Usages "$SCRIPT_NAME"
307+
exit 1
308+
;;
309+
#optional arguments
310+
[A-Za-z])
311+
ProcessSwitch "-$OPTARG" ""
312+
;;
313+
esac
314+
;;
315+
\?)
316+
echo "Terminating... wrong switch: $@" >&2
317+
Usages "$SCRIPT_NAME"
318+
exit 1
319+
;;
320+
esac
321+
done
322+
shift $((OPTIND-1))
323+
324+
GRET=0
325+
for ((i=0; i < NSOURCES; i++)); do
326+
OPT=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 1 -d ':')
327+
WHAT=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 2 -d ':')
328+
REPO=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 3 -d ':')
329+
TAG=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 4 -d ':')
330+
DNLOAD=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 5 -d ':')
331+
332+
if [ $DALL -eq 1 -o "x${DNLOAD}" == "xy" ]; then
333+
DownloadAndSync "$WHAT" "${LDK_DIR}/${WHAT}" "https://${REPO}" "${TAG}" "${OPT}"
334+
tRET=$?
335+
let GRET=GRET+tRET
336+
if [ $tRET -ne 0 -a $EOE -eq 1 ]; then
337+
exit $tRET
338+
fi
339+
fi
340+
done
341+
342+
ln -sf ../../../../../../nvethernetrm ${LDK_DIR}/nvidia-oot/drivers/net/ethernet/nvidia/nvethernet/nvethernetrm
343+
344+
exit $GRET

0 commit comments

Comments
 (0)