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 <marc.herbert@intel.com>
This commit is contained in:
Marc Herbert 2022-02-10 17:52:44 -08:00 committed by Anas Nashif
commit 1b3d590e22

View file

@ -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)