Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) #!/bin/sh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) # build id cache operations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) # SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) # skip if there's no readelf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) if ! [ -x "$(command -v readelf)" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 	echo "failed: no readelf, install binutils"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 	exit 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) # skip if there's no compiler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) if ! [ -x "$(command -v cc)" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 	echo "failed: no compiler, install gcc"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 	exit 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) ex_md5=$(mktemp /tmp/perf.ex.MD5.XXX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) ex_sha1=$(mktemp /tmp/perf.ex.SHA1.XXX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) echo 'int main(void) { return 0; }' | cc -Wl,--build-id=sha1 -o ${ex_sha1} -x c -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) echo 'int main(void) { return 0; }' | cc -Wl,--build-id=md5 -o ${ex_md5} -x c -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) echo "test binaries: ${ex_sha1} ${ex_md5}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) check()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	id=`readelf -n ${1} 2>/dev/null | grep 'Build ID' | awk '{print $3}'`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	echo "build id: ${id}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	link=${build_id_dir}/.build-id/${id:0:2}/${id:2}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	echo "link: ${link}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	if [ ! -h $link ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 		echo "failed: link ${link} does not exist"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 		exit 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	file=${build_id_dir}/.build-id/${id:0:2}/`readlink ${link}`/elf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	echo "file: ${file}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	if [ ! -x $file ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 		echo "failed: file ${file} does not exist"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 		exit 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	diff ${file} ${1}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	if [ $? -ne 0 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 		echo "failed: ${file} do not match"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 		exit 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	echo "OK for ${1}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) test_add()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	build_id_dir=$(mktemp -d /tmp/perf.debug.XXX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	perf="perf --buildid-dir ${build_id_dir}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	${perf} buildid-cache -v -a ${1}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	if [ $? -ne 0 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 		echo "failed: add ${1} to build id cache"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 		exit 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	check ${1}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	rm -rf ${build_id_dir}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) test_record()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	data=$(mktemp /tmp/perf.data.XXX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	build_id_dir=$(mktemp -d /tmp/perf.debug.XXX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	perf="perf --buildid-dir ${build_id_dir}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	${perf} record --buildid-all -o ${data} ${1}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	if [ $? -ne 0 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		echo "failed: record ${1}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 		exit 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	check ${1}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	rm -rf ${build_id_dir}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	rm -rf ${data}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) # add binaries manual via perf buildid-cache -a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) test_add ${ex_sha1}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) test_add ${ex_md5}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) # add binaries via perf record post processing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) test_record ${ex_sha1}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) test_record ${ex_md5}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) # cleanup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) rm ${ex_sha1} ${ex_md5}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) exit ${err}