From 40b38d5e48e916f2b8ea52a93e11481e2b8a8afc Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Tue, 25 Jan 2022 22:52:50 -0800 Subject: [PATCH] soc/intel_adsp: cavstool: minor error handling fixes Don't "crash" when passing no argument at all. Log exceptions, adding for instance the second line: ERROR:cavs-fw:Could not map device in sysfs; run as root? ERROR:cavs-fw:[Errno 13] Permission denied: \ '/sys/bus/pci/devices/0000:00:0e.0/power/control' Signed-off-by: Marc Herbert --- soc/xtensa/intel_adsp/tools/cavstool.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/soc/xtensa/intel_adsp/tools/cavstool.py b/soc/xtensa/intel_adsp/tools/cavstool.py index 9ea637b0888..329fb49c4ce 100755 --- a/soc/xtensa/intel_adsp/tools/cavstool.py +++ b/soc/xtensa/intel_adsp/tools/cavstool.py @@ -173,8 +173,9 @@ def runx(cmd): def load_firmware(fw_file): try: fw_bytes = open(fw_file, "rb").read() - except Exception: + except Exception as e: log.error(f"Could not read firmware file: `{fw_file}'") + log.error(e) sys.exit(1) (magic, sz) = struct.unpack("4sI", fw_bytes[0:8]) @@ -302,13 +303,18 @@ async def main(): global hda, sd, dsp, hda_ostream_id try: (hda, sd, dsp, hda_ostream_id) = map_regs() - except Exception: - log.error("Could not map device in sysfs; run as root.") + except Exception as e: + log.error("Could not map device in sysfs; run as root?") + log.error(e) sys.exit(1) log.info(f"Detected cAVS {'1.5' if cavs15 else '1.8+'} hardware") if not args.log_only: + if not args.fw_file: + log.error("Firmware file argument missing") + sys.exit(1) + load_firmware(args.fw_file) time.sleep(0.1) if not args.quiet: