summarylogtreecommitdiffstats
path: root/xrt_plugin-amdxdna.install
blob: cddabe89a159443935a2bfaaf34aa58bee2a29fc (plain)
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
post_install() {

	# SPDX-License-Identifier: Apache-2.0
	# Copyright (C) 2023-2024 AMD, Inc. All rights reserved.

	RED="\e[31m"
	ENDCOLOR="\e[0m"

	build_type=Release
	if [ "$build_type" = "Debug" ]; then
		set -x
	fi

	installdir=/opt/xilinx/xrt
	udev_rules_d=/etc/udev/rules.d
	amdxdna_rules_file=99-amdxdna.rules
	export XILINX_XRT=$installdir

	echo "Installing new amdxdna Linux kernel module in dkms"
	if [ "$build_type" = "Debug" ]; then
		DKMS_DRIVER_VERBOSE=true $installdir/amdxdna/dkms_driver.sh --install
	else
		$installdir/amdxdna/dkms_driver.sh --install
	fi

    echo "amdxdna" > /etc/modules-load.d/amdxdna.conf

	echo "Loading new amdxdna Linux kernel module"
	if [ ! -f ${udev_rules_d}/${amdxdna_rules_file} ]; then
		touch ${udev_rules_d}/${amdxdna_rules_file}
	fi
	echo "KERNEL==\"accel*\",DRIVERS==\"amdxdna\",MODE=\"0666\"" > ${udev_rules_d}/${amdxdna_rules_file}
    if lsmod | grep -q "amdxdna "; then
        rmmod amdxdna
    fi
	if [ "$build_type" = "Debug" ]; then
	modprobe amdxdna dyndbg=+pf
	else
	modprobe amdxdna
	fi

	unset XILINX_XRT
	if [ "$build_type" = "Debug" ]; then
		set +x
	fi
}

post_upgrade() {
	post_install
}

pre_remove() {

	# SPDX-License-Identifier: Apache-2.0
	# Copyright (C) 2023-2024 AMD, Inc. All rights reserved.

	RED="\e[31m"
	ENDCOLOR="\e[0m"

	build_type=Release
	if [ "$build_type" = "Debug" ]; then
		echo "========= Pretrm Debug ========="
		set -x
	fi

	installdir=/opt/xilinx/xrt
	udev_rules_d=/etc/udev/rules.d
	amdxdna_rules_file=99-amdxdna.rules

	if lsmod | grep -q "amdxdna "; then
		rmmod amdxdna
	fi

    rm -f /etc/modules-load.d/amdxdna.conf

	if [ -f ${udev_rules_d}/${amdxdna_rules_file} ]; then
		rm -rf ${udev_rules_d}/${amdxdna_rules_file}
	fi

	export XILINX_XRT=$installdir
	if [ "$build_type" = "Debug" ]; then
		DKMS_DRIVER_VERBOSE=true $installdir/amdxdna/dkms_driver.sh --remove
	else
		$installdir/amdxdna/dkms_driver.sh --remove
	fi
	unset XILINX_XRT

	if [ "$build_type" = "Debug" ]; then
		set +x
	fi
}