From 5a5c4fc84dbed92ad1cdefefc394e8d86607cc27 Mon Sep 17 00:00:00 2001 From: Eileen Yoon Date: Tue, 16 Jan 2024 00:11:02 +0900 Subject: [PATCH] aop: Bring up AOP via standard ASC API Works up to "Finished boot" on J293AP 13.5 ``` < 27:0x85000000000000 [audio] 02:0x5000000000000d (TYPE=0x5, INDEX=0xd) Finished boot ``` Signed-off-by: Eileen Yoon --- proxyclient/experiments/aop.py | 143 +++++++++++++------------------- proxyclient/m1n1/fw/afk/rbep.py | 9 +- 2 files changed, 62 insertions(+), 90 deletions(-) diff --git a/proxyclient/experiments/aop.py b/proxyclient/experiments/aop.py index 0dba36fb0..c1041cf32 100755 --- a/proxyclient/experiments/aop.py +++ b/proxyclient/experiments/aop.py @@ -9,7 +9,7 @@ from m1n1.setup import * from m1n1.shell import run_shell -from m1n1.hw.dart import DART, DARTRegs +from m1n1.hw.dart import DART from m1n1.fw.asc import StandardASC, ASCDummyEndpoint from m1n1.fw.asc.base import * from m1n1.fw.aop import * @@ -17,13 +17,15 @@ from m1n1.fw.afk.rbep import * from m1n1.fw.afk.epic import * +# aop nodes have no clocks described in adt for j293. it does it itself +# p.pmgr_adt_clocks_enable("/arm-io/aop") +# p.pmgr_adt_clocks_enable("/arm-io/dart-aop") + # Set up a secondary proxy channel so that we can stream # the microphone samples p.usb_iodev_vuart_setup(p.iodev_whoami()) p.iodev_set_usage(IODEV.USB_VUART, USAGE.UARTPROXY) -p.pmgr_adt_clocks_enable("/arm-io/dart-aop") - adt_dc = u.adt["/arm-io/aop/iop-aop-nub/aop-audio/dc-2400000"] pdm_config = Container( @@ -72,6 +74,7 @@ class AFKEP_Hello_Ack(AFKEPMessage): class EPICEndpoint(AFKRingBufEndpoint): BUFSIZE = 0x1000 + VERBOSE = True def __init__(self, *args, **kwargs): self.seq = 0x0 @@ -81,10 +84,11 @@ def __init__(self, *args, **kwargs): @msg_handler(0x80, AFKEP_Hello) def Hello(self, msg): + self.log("hello!") self.rxbuf, self.rxbuf_dva = self.asc.ioalloc(self.BUFSIZE) self.txbuf, self.txbuf_dva = self.asc.ioalloc(self.BUFSIZE) - self.send(AFKEP_Hello_Ack()) + return True def handle_hello(self, hdr, sub, fd): if sub.type != 0xc0: @@ -115,11 +119,11 @@ def handle_ipc(self, data): if sub.category == EPICCategory.REPLY: handled = self.handle_reply(hdr, sub, fd) - if not handled and getattr(self, 'VERBOSE', False): - self.log(f"< 0x{hdr.channel:x} Type {hdr.type} Ver {hdr.version} Tag {hdr.seq}") - self.log(f" Len {sub.length} Ver {sub.version} Cat {sub.category} Type {sub.type:#x} Ts {sub.timestamp:#x}") - self.log(f" Unk1 {sub.unk1:#x} Unk2 {sub.unk2:#x}") - chexdump(fd.read()) + self.log(f"< 0x{hdr.channel:x} Type {hdr.type} Ver {hdr.version} Tag {hdr.seq}") + self.log(f" Len {sub.length} Ver {sub.version} Cat {sub.category} Type {sub.type:#x} Ts {sub.timestamp:#x}") + self.log(f" Unk1 {sub.unk1:#x} Unk2 {sub.unk2:#x}") + chexdump(fd.read()) + return handled def indirect(self, call, chan=0x1000000d, timeout=0.1): tx = call.ARGS.build(call.args) @@ -168,99 +172,67 @@ def roundtrip(self, call, chan=0x1000000d, timeout=0.3, return call -class SPUAppEndpoint(EPICEndpoint): - SHORT = "SPUAppep" +class SPUEndpoint(EPICEndpoint): # SPUApp.t / i2c.pp.t + SHORT = "spu" class AccelEndpoint(EPICEndpoint): - SHORT = "accelep" + SHORT = "accel" class GyroEndpoint(EPICEndpoint): - SHORT = "gyroep" + SHORT = "gyro" -class UNK23Endpoint(EPICEndpoint): - SHORT = "unk23ep" + def start_queues(self): + pass # don't init gyro ep (we don't have one) -class LASEndpoint(EPICEndpoint): - SHORT = "lasep" - #VERBOSE = True # <--- uncomment to see lid angle measurements +class ALSEndpoint(EPICEndpoint): # als.hint + SHORT = "als" -class WakehintEndpoint(EPICEndpoint): - SHORT = "wakehintep" +class WakehintEndpoint(EPICEndpoint): # wakehint + SHORT = "wakehint" class UNK26Endpoint(EPICEndpoint): - SHORT = "unk26ep" - -class AudioEndpoint(EPICEndpoint): - SHORT = "audioep" - + SHORT = "unk26" -class OSLogMessage(Register64): - TYPE = 63, 56 +class AudioEndpoint(EPICEndpoint): # aop-audio.rigger + SHORT = "audio" -class OSLog_Init(OSLogMessage): - TYPE = 63, 56, Constant(1) - UNK = 51, 0 - DVA = 7, 0 - -class AOPOSLogEndpoint(ASCBaseEndpoint): - BASE_MESSAGE = OSLogMessage - SHORT = "oslog" - - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - self.started = False - - @msg_handler(1, OSLog_Init) - def Init(self, msg): - self.iobuffer, self.iobuffer_dva = self.asc.ioalloc(0x1_0000) - self.send(OSLog_Init(DVA=self.iobuffer_dva//0x1000)) - self.started = True - return True +class VoiceTriggerEndpoint(EPICEndpoint): # aop-voicetrigger + SHORT = "voicetrigger" class AOPClient(StandardASC, AOPBase): ENDPOINTS = { - 8: AOPOSLogEndpoint, - - 0x20: SPUAppEndpoint, + 0x20: SPUEndpoint, 0x21: AccelEndpoint, 0x22: GyroEndpoint, - 0x23: UNK23Endpoint, - 0x24: LASEndpoint, + 0x24: ALSEndpoint, 0x25: WakehintEndpoint, 0x26: UNK26Endpoint, 0x27: AudioEndpoint, - 0x28: EPICEndpoint, - 0x29: EPICEndpoint, - 0x2a: EPICEndpoint, - 0x2b: EPICEndpoint + 0x28: VoiceTriggerEndpoint, } def __init__(self, u, adtpath, dart=None): node = u.adt[adtpath] self.base = node.get_reg(0)[0] - AOPBase.__init__(self, u, node) super().__init__(u, self.base, dart) -p.dapf_init_all() - -dart = DART.from_adt(u, "/arm-io/dart-aop", iova_range=(0x2c000, 0x10_000_000)) +dart = DART.from_adt(u, "/arm-io/dart-aop", iova_range=(0x34000, 0x10_000_000)) dart.initialize() -dart.regs.TCR[0].set(BYPASS_DAPF=0, BYPASS_DART=0, TRANSLATE_ENABLE=1) -dart.regs.TCR[7].set(BYPASS_DAPF=0, BYPASS_DART=0, TRANSLATE_ENABLE=1) -dart.regs.TCR[15].val = 0x20100 aop = AOPClient(u, "/arm-io/aop", dart) - aop.update_bootargs({ 'p0CE': 0x20000, -# 'laCn': 0x0, -# 'tPOA': 0x1, + 'laCn': 0x0, + 'tPOA': 0x1, + "gila": 0x80, }) - aop.verbose = 4 +p.dapf_init_all() +aop.asc.OUTBOX_CTRL.val = 0x20001 # (FIFOCNT=0x0, OVERFLOW=0, EMPTY=1, FULL=0, RPTR=0x0, WPTR=0x0, ENABLE=1) + def set_aop_audio_pstate(devid, pstate): audep.roundtrip(SetDeviceProp( devid=devid, @@ -274,34 +246,31 @@ def set_aop_audio_pstate(devid, pstate): )).check_retcode() try: - aop.boot() - for epno in range(0x20, 0x2c): - aop.start_ep(epno) + aop.start() - timeout = 10 - while (not aop.audioep.ready) and timeout: + timeout = 5 + while (not aop.audio.ready) and timeout: aop.work_for(0.1) timeout -= 1 - if not timeout: raise Exception("Timed out waiting on audio endpoint") print("Finished boot") - - audep = aop.audioep - - audep.roundtrip(AttachDevice(devid='pdm0')).check_retcode() - audep.indirect(SetDeviceProp( - devid='pdm0', modifier=200, data=pdm_config) - ).check_retcode() - audep.indirect(SetDeviceProp( - devid='pdm0', modifier=210, data=decimator_config) - ).check_retcode() - audep.roundtrip(AttachDevice(devid='hpai')).check_retcode() - audep.roundtrip(AttachDevice(devid='lpai')).check_retcode() - audep.roundtrip(SetDeviceProp( - devid='lpai', modifier=301, data=Container(unk1=7, unk2=7, unk3=1, unk4=7)) - ).check_retcode() + audep = aop.audio + + if 1: + audep.roundtrip(AttachDevice(devid='pdm0')).check_retcode() + audep.indirect(SetDeviceProp( + devid='pdm0', modifier=200, data=pdm_config) + ).check_retcode() + audep.indirect(SetDeviceProp( + devid='pdm0', modifier=210, data=decimator_config) + ).check_retcode() + audep.roundtrip(AttachDevice(devid='hpai')).check_retcode() + audep.roundtrip(AttachDevice(devid='lpai')).check_retcode() + audep.roundtrip(SetDeviceProp( + devid='lpai', modifier=301, data=Container(unk1=7, unk2=7, unk3=1, unk4=7)) + ).check_retcode() except KeyboardInterrupt: pass except Exception: diff --git a/proxyclient/m1n1/fw/afk/rbep.py b/proxyclient/m1n1/fw/afk/rbep.py index 4fe6a8901..fde32e2ad 100644 --- a/proxyclient/m1n1/fw/afk/rbep.py +++ b/proxyclient/m1n1/fw/afk/rbep.py @@ -154,7 +154,7 @@ def __init__(self, *args, **kwargs): self.alive = False self.started = False self.iobuffer = None - self.verbose = 2 + self.verbose = 3 self.msgid = 0 def start(self): @@ -204,14 +204,17 @@ def InitRX(self, msg): self.start_queues() return True + @msg_handler(0x8c, AFKEP_InitRB) + def InitUnk(self, msg): + return True + def init_rb(self, msg): off = msg.OFFSET * AFKRingBuf.BLOCK_SIZE size = msg.SIZE * AFKRingBuf.BLOCK_SIZE - return AFKRingBuf(self, self.iobuffer + off, size) def start_queues(self): - self.send(AFKEP_Start()) + self.send(AFKEP_Start()) @msg_handler(0x86, AFKEP_Start_Ack) def Start_Ack(self, msg):