Skip to content

Commit 1316fef

Browse files
author
Chao Song
committed
lib.sh: get firmware path from log with journalctl
This patch simplifies the acquisition of firmware path with journalctl, so that we can test if the firmware loaded is using zephyr rtos by checking the occurrence of 'zephyr' in the firmware binary. Signed-off-by: Chao Song <chao.song@linux.intel.com>
1 parent d388738 commit 1316fef

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

case-lib/lib.sh

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -680,28 +680,21 @@ is_zephyr()
680680
test "$znum" -gt 10
681681
}
682682

683+
get_firmware_path()
684+
{
685+
journalctl_cmd -k |
686+
awk '/sof.*request_firmware/ { sub(/^.*request_firmware/,""); last_loaded_file=$1 } END { print last_loaded_file }'
687+
}
688+
683689
is_firmware_file_zephyr()
684690
{
685-
local firmware_name firmware_path znum platform
686-
# get the FW name and path
687-
# TODO: optimize this part after driver can expose the FW path to userspace via debugfs
688-
if is_ipc4; then
689-
firmware_name=dsp_basefw.bin
690-
fw_mod_para=/sys/module/snd_sof_pci/parameters/fw_path
691-
if [ -s "$fw_mod_para" ]; then
692-
firmware_path=$(cat $fw_mod_para)
693-
else
694-
# # FIXME: the kernel driver should give us the FW path
695-
# https://github.com/thesofproject/linux/issues/3867
696-
die "Failed to get the IPC4 FW path."
697-
fi
698-
else # for IPC3
699-
platform=$(sof-dump-status.py -p)
700-
firmware_name=sof-$platform.ri
701-
firmware_path=$(sof-dump-status.py -P)
702-
fi
691+
local firmware_path znum
692+
693+
firmware_path=$(get_firmware_path)
694+
[ -n "$firmware_path" ] ||
695+
die 'firmware path not found from journalctl, no firmware loaded or debug option disabled?'
703696

704-
znum=$(strings "/lib/firmware/$firmware_path/$firmware_name" | grep -c -i zephyr)
697+
znum=$(strings "/lib/firmware/$firmware_path" | grep -c -i zephyr)
705698
test "$znum" -gt 10
706699
}
707700

0 commit comments

Comments
 (0)