boards: up_squared_adsp: Add IPM terminal tool
Add tool which can access ADSP console over IPM using Python device library and polling Doorbell registers. Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This commit is contained in:
parent
0b699e931a
commit
23a4040f77
1 changed files with 66 additions and 0 deletions
66
boards/xtensa/up_squared_adsp/tools/mbterm.py
Executable file
66
boards/xtensa/up_squared_adsp/tools/mbterm.py
Executable file
|
@ -0,0 +1,66 @@
|
|||
#!/usr/bin/env python3
|
||||
#
|
||||
# Copyright (c) 2020 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
from time import sleep
|
||||
from mmap import mmap, ACCESS_COPY
|
||||
from ctypes import c_uint8
|
||||
|
||||
from lib.device import Device
|
||||
import lib.registers as regs
|
||||
|
||||
MBOX = 0x91281000
|
||||
LENGTH = 0x1000
|
||||
|
||||
with open("/dev/mem", "rb") as f:
|
||||
mem_map = mmap(f.fileno(), LENGTH, access=ACCESS_COPY, offset=MBOX)
|
||||
mem = (c_uint8 * LENGTH).from_buffer(mem_map)
|
||||
|
||||
def mailbox_poll_mem(dev):
|
||||
while True:
|
||||
if dev.dsp_hipct.value & regs.ADSP_IPC_HIPCT_BUSY:
|
||||
|
||||
# Use only id for passing character
|
||||
line_len = dev.dsp_hipct.value & regs.ADSP_IPC_HIPCT_MSG
|
||||
|
||||
# Mask out internal bits
|
||||
line_len &= 0x10FFFF
|
||||
|
||||
if line_len:
|
||||
print(bytes(mem[:line_len]).decode())
|
||||
|
||||
# Clear interrupt
|
||||
dev.dsp_hipct.value |= regs.ADSP_IPC_HIPCT_BUSY
|
||||
else:
|
||||
sleep(0.005)
|
||||
|
||||
# Character passed in mailbox ID field
|
||||
def mailbox_poll_char(dev):
|
||||
while True:
|
||||
if dev.dsp_hipct.value & regs.ADSP_IPC_HIPCT_BUSY:
|
||||
|
||||
# Use only id for passing character
|
||||
character = dev.dsp_hipct.value & regs.ADSP_IPC_HIPCT_MSG
|
||||
|
||||
# Get readable character
|
||||
character &= 0x10FFFF
|
||||
|
||||
print('{}'.format(chr(character)), end='')
|
||||
|
||||
# Clear interrupt
|
||||
dev.dsp_hipct.value |= regs.ADSP_IPC_HIPCT_BUSY
|
||||
else:
|
||||
sleep(0.005)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Clear Done if needed
|
||||
#dev.dsp_hipct.value |= regs.ADSP_IPC_HIPCT_BUSY
|
||||
|
||||
# Use Device library for controlling registers
|
||||
device = Device()
|
||||
device.open_device()
|
||||
|
||||
mailbox_poll_mem(device)
|
Loading…
Add table
Add a link
Reference in a new issue