From 1b3d590e22c5d44384f7f81e53812241a9b60360 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Thu, 10 Feb 2022 17:52:44 -0800 Subject: [PATCH] soc/intel_adsp: cavstool: poll FW_STATUS even when --log-only Failures to boot are not exclusive to the cavstool.py, they can happen with the kernel driver and --log-only too. For such a situation this commit adds a useful delay and these two log lines (before the mmap crashes eventually): INFO:cavs-fw:Waiting for firmware handoff, FW_STATUS = 0x81000012 WARNING:cavs-fw:Load failed? FW_STATUS = 0x1006701 Signed-off-by: Marc Herbert --- soc/xtensa/intel_adsp/tools/cavstool.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/soc/xtensa/intel_adsp/tools/cavstool.py b/soc/xtensa/intel_adsp/tools/cavstool.py index 795176c0ad7..b809088a875 100755 --- a/soc/xtensa/intel_adsp/tools/cavstool.py +++ b/soc/xtensa/intel_adsp/tools/cavstool.py @@ -252,13 +252,7 @@ def load_firmware(fw_file): log.info(f"Starting DMA, FW_STATUS = 0x{dsp.SRAM_FW_STATUS:x}") sd.CTL |= 2 # START flag - log.info(f"Waiting for firmware handoff, FW_STATUS = 0x{dsp.SRAM_FW_STATUS:x}") - for _ in range(200): - alive = dsp.SRAM_FW_STATUS & ((1 << 28) - 1) == 5 # "FW_ENTERED" - if alive: break - time.sleep(0.01) - if not alive: - log.warning(f"Load failed? FW_STATUS = 0x{dsp.SRAM_FW_STATUS:x}") + wait_fw_entered() # Turn DMA off and reset the stream. Clearing START first is a # noop per the spec, but absolutely required for stability. @@ -272,6 +266,18 @@ def load_firmware(fw_file): sd.CTL |= 1 log.info(f"cAVS firmware load complete") + +def wait_fw_entered(): + log.info("Waiting for firmware handoff, FW_STATUS = 0x%x", dsp.SRAM_FW_STATUS) + for _ in range(200): + alive = dsp.SRAM_FW_STATUS & ((1 << 28) - 1) == 5 # "FW_ENTERED" + if alive: + break + time.sleep(0.01) + if not alive: + log.warning("Load failed? FW_STATUS = 0x%x", dsp.SRAM_FW_STATUS) + + # This SHOULD be just "mem[start:start+length]", but slicing an mmap # array seems to be unreliable on one of my machines (python 3.6.9 on # Ubuntu 18.04). Read out bytes individually. @@ -320,7 +326,9 @@ async def main(): log.info(f"Detected cAVS {'1.5' if cavs15 else '1.8+'} hardware") - if not args.log_only: + if args.log_only: + wait_fw_entered() + else: if not args.fw_file: log.error("Firmware file argument missing") sys.exit(1)