From 1316fef08477c37c5e12604cdeab767d0bf2abb7 Mon Sep 17 00:00:00 2001 From: Chao Song Date: Thu, 20 Oct 2022 15:26:06 +0800 Subject: [PATCH] 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 --- case-lib/lib.sh | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/case-lib/lib.sh b/case-lib/lib.sh index 7c0a65e9..efe35a9c 100644 --- a/case-lib/lib.sh +++ b/case-lib/lib.sh @@ -680,28 +680,21 @@ is_zephyr() test "$znum" -gt 10 } +get_firmware_path() +{ + journalctl_cmd -k | + awk '/sof.*request_firmware/ { sub(/^.*request_firmware/,""); last_loaded_file=$1 } END { print last_loaded_file }' +} + is_firmware_file_zephyr() { - local firmware_name firmware_path znum platform - # get the FW name and path - # TODO: optimize this part after driver can expose the FW path to userspace via debugfs - if is_ipc4; then - firmware_name=dsp_basefw.bin - fw_mod_para=/sys/module/snd_sof_pci/parameters/fw_path - if [ -s "$fw_mod_para" ]; then - firmware_path=$(cat $fw_mod_para) - else - # # FIXME: the kernel driver should give us the FW path - # https://github.com/thesofproject/linux/issues/3867 - die "Failed to get the IPC4 FW path." - fi - else # for IPC3 - platform=$(sof-dump-status.py -p) - firmware_name=sof-$platform.ri - firmware_path=$(sof-dump-status.py -P) - fi + local firmware_path znum + + firmware_path=$(get_firmware_path) + [ -n "$firmware_path" ] || + die 'firmware path not found from journalctl, no firmware loaded or debug option disabled?' - znum=$(strings "/lib/firmware/$firmware_path/$firmware_name" | grep -c -i zephyr) + znum=$(strings "/lib/firmware/$firmware_path" | grep -c -i zephyr) test "$znum" -gt 10 }