summaryrefslogtreecommitdiffstats
path: root/meta-xilinx-bsp/recipes-bsp/dfx-mgr/files/zcu106-xlnx-firmware-detect
diff options
context:
space:
mode:
Diffstat (limited to 'meta-xilinx-bsp/recipes-bsp/dfx-mgr/files/zcu106-xlnx-firmware-detect')
-rw-r--r--meta-xilinx-bsp/recipes-bsp/dfx-mgr/files/zcu106-xlnx-firmware-detect71
1 files changed, 71 insertions, 0 deletions
diff --git a/meta-xilinx-bsp/recipes-bsp/dfx-mgr/files/zcu106-xlnx-firmware-detect b/meta-xilinx-bsp/recipes-bsp/dfx-mgr/files/zcu106-xlnx-firmware-detect
new file mode 100644
index 00000000..ef5654cc
--- /dev/null
+++ b/meta-xilinx-bsp/recipes-bsp/dfx-mgr/files/zcu106-xlnx-firmware-detect
@@ -0,0 +1,71 @@
1#! /bin/sh
2
3# Copyright (C) 2022 Xilinx, Inc. All rights reserved.
4# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
5#
6# SPDX-License-Identifier: MIT
7
8# read values from dfx-mgr conf file
9conffile="/etc/dfx-mgrd/daemon.conf"
10if [ ! -f "${conffile}" ]; then
11 echo "dfx-mgrd configuration file not found: ${conffile}"
12 exit 1
13fi
14
15fwbasedir=$(grep "firmware_location" ${conffile} | sed 's/.*:.*\[\"\(.*\)\"\],\?/\1/')
16if [ -z "${fwbasedir}" ]; then
17 echo "Property 'firmware_location' not found in ${conffile}"
18 exit 1
19fi
20
21fwfile=$(grep "default_accel" ${conffile} | sed 's/.*:.*\"\(.*\)\",\?/\1/')
22if [ -z "${fwfile}" ]; then
23 echo "Property 'default_accel' not found in ${conffile}"
24 exit 1
25fi
26
27# check if default firmware is already set and present
28if [ -f "${fwfile}" ]; then
29 fwname=$(cat ${fwfile})
30 fwdir="${fwbasedir}/${fwname}"
31 if [ -n "${fwname}" ] && [ -d "${fwdir}" ]; then
32 echo "Default firmware detected: ${fwname}"
33 exit 0
34 fi
35fi
36
37# search for firmware based on EEPROM board id
38echo "Trying to detect default firmware based on EEPROM..."
39
40#check if board is a zcu106 eval board product
41eeprom=$(ls /sys/bus/i2c/devices/*54/eeprom 2> /dev/null)
42if [ -n "${eeprom}" ]; then
43 boardid=`dd if=$eeprom bs=1 count=6 skip=208 2>/dev/null | tr '[:upper:]' '[:lower:]'`
44 revision=`dd if=$eeprom bs=1 count=3 skip=224 2>/dev/null | tr '[:upper:]' '[:lower:]'`
45
46 fwname="${boardid}-${revision}"
47 fwdir="${fwbasedir}/${fwname}"
48
49 fixed_rev=2.0
50 var=$(awk 'BEGIN{ print "'$fixed_rev'"<"'$revision'" }')
51
52 if [ "${boardid}" == "zcu106" ] && [ "${var}" -eq 1 ] ;then
53 revision=2.0
54 echo "later than 2.0 board revisions are supported in 2.0 bit and dtbo files"
55 fwname="${boardid}-${revision}"
56 fwdir="${fwbasedir}/${fwname}"
57 echo "${fwname}" > "${fwfile}"
58 exit 1
59 elif [ ! -d "${fwdir}" ] ; then
60 echo "No default firmware named ${fwname} found in ${fwbasedir} , Loading rev1.0 bitstream and dtbo as default "
61 revision=1.0
62 fwname=$(ls ${fwbasedir} | grep ${revision})
63 fwdir="${fwbasedir}/${fwname}"
64 echo "${fwname}" > "${fwfile}"
65 exit 1
66 fi
67
68 echo "Default firmware detected: ${fwname}"
69 echo "${fwname}" > "${fwfile}"
70 exit 0
71fi