Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MT6765 issue: [ERROR] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: PCCIF ring no too large (value: 16, is only: 8) #38

Open
docfate111 opened this issue Jan 7, 2024 · 4 comments

Comments

@docfate111
Copy link

docfate111 commented Jan 7, 2024

AT: 0xdeadbeef  -> 0xdeadbeef   -> 0x00000000
V0: 0x0 -> 0x00000000
V1: 0x0 -> 0x00000000
A0: 0x63df642c  -> 0x63df642c   -> 0x00000000
A1: 0x2986174   -> 0x02986174   -> 0x00000001   -> 0x183c0601   -> 0x00000000
A2: 0x0 -> 0x00000000
A3: 0x69100990  -> 0x69100990   -> 0x00000000
T0: 0x0 -> 0x00000000
T1: 0xb2e8      -> 0x0000b2e8   -> 0x2b0eeb8e   -> 0x00000000
T2: 0x0 -> 0x00000000
T3: 0xda79      -> 0x0000da79   -> 0x409a44f0   -> 0x00000000
T4: 0x90bac5e7  -> 0x90bac5e7   -> 0x786a00ea   -> 0x00000000
T5: 0x90db23d4  -> 0x90db23d4   -> 0x00000034   -> 0x00000000
T6: 0x0 -> 0x00000000
T7: 0x3c386ae   -> 0x03c386ae   -> 0x00000000
S0: 0x0 -> 0x00000000
S1: 0x0 -> 0x00000000
S2: 0x2986174   -> 0x02986174   -> 0x00000001   -> 0x183c0601   -> 0x00000000
S3: 0x1 -> 0x00000001   -> 0x183c0601   -> 0x00000000
S4: 0xd0        -> 0x000000d0   -> 0x00000000
S5: 0x0 -> 0x00000000
S6: 0x2 -> 0x00000002   -> 0x0a183c06   -> 0x00000000
S7: 0x0 -> 0x00000000
T8: 0x8 -> 0x00000008   -> 0x00c00008   -> 0xa076f020   -> 0x00000000
T9: 0x691010a0  -> 0x691010a0   -> 0x00000000
K0: 0xdeadbeef  -> 0xdeadbeef   -> 0x00000000
K1: 0xdeadbeef  -> 0xdeadbeef   -> 0x00000000
GP: 0x9f108000  -> 0x9f108000   -> 0xdededede   -> 0x00000000
SP: 0x63df642c  -> 0x63df642c   -> 0x00000000
FP: 0xc8        -> 0x000000c8   -> 0x00000000
RA: 0x90db2598  -> 0x90db2598   -> 0x64faf030   -> 0x00000000
Stack:
[SP+0x00 == 0x63df642c]: 0xdeadbeef00000000     -> 0xdeadbeef00000000   -> 0x3c060157   -> 0x00000000
[SP+0x08 == 0x63df6434]: 0x00000000     -> 0x00000000
[SP+0x10 == 0x63df643c]: 0x298617402986184      -> 0x298617402986184    -> 0x00000000
[SP+0x18 == 0x63df6444]: 0x6910099000000000     -> 0x6910099000000000   -> 0x3c060157   -> 0x00000000
[SP+0x20 == 0x63df644c]: 0xb2e800000000 -> 0xb2e800000000       -> 0x3c060157   -> 0x00000000
[SP+0x28 == 0x63df6454]: 0xda7900000000 -> 0xda7900000000       -> 0x3c060157   -> 0x00000000
[SP+0x30 == 0x63df645c]: 0x90db23d490bac5e7     -> 0x90db23d490bac5e7   -> 0x786a00ea   -> 0x00000000
[SP+0x38 == 0x63df6464]: 0x3c386ae00000000      -> 0x3c386ae00000000    -> 0x3c060157   -> 0x00000000
[ERROR] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: PCCIF ring no too large (value: 16, is only: 8)
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.8/dist-packages/avatar2/avatar2.py", line 522, in run
    handler(message)
  File "/usr/local/lib/python3.8/dist-packages/avatar2/watchmen.py", line 78, in watchtrigger
    ret = func(self, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/avatar2/avatar2.py", line 491, in _handle_remote_memory_write_message
    success = mem_range.forwarded_to.write_memory(
  File "/usr/local/lib/python3.8/dist-packages/avatar2/peripherals/avatar_peripheral.py", line 66, in write_memory
    return intervals.pop().data(offset, size, value, **kwargs)
  File "/firmwire/firmwire/vendor/mtk/hw/PCCIFPeripheral.py", line 492, in hw_write
    assert False
AssertionError

May be a dumb question but can I just change the ring size in the peripheral?

Somewhat similar to this #12

@mariusmue
Copy link
Contributor

Hi,

The ring size is SoC specific; I'm not sure if the SoC you are using has been tested by us.
Either way, for adjusting, I would suggest to change the according SoC definition, located in https://github.com/FirmWire/FirmWire/blob/main/firmwire/vendor/mtk/soc/__init__.py

The variables to adjust should be SHM_QUEUE_NUM and SHM_LAYOUT; Our definition for the MT6765 seems to follow that layout.

If you have a new SoC and it works after adding a definition, we'd happily look forward to a pull request :)

@docfate111
Copy link
Author

docfate111 commented Jan 7, 2024

@mariusmue
How do I determine what goes in SHM_LAYOUT?
I was able to get rid of the error by appending zeroes and increasing SHM_QUEUE_NUM to 17 since the value that is used to index the ringbuffer is 16 but now readPacket() returns None which causes an error.

Here is the firmware: https://drive.google.com/file/d/1sxwNvbu79noHNy4NtQSprBglU8EajYjP/view?usp=sharing

I tried enabling debug for the peripheral but I don't know what to do?
Attached gdb did not work either when I use "-s" then started gdb and then "target remote :1234"

[SP+0x38 == 0x63df6464]: 0x32a836fa00000000     -> 0x32a836fa00000000   -> 0x3c060157   -> 0x00000000
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.8/dist-packages/avatar2/avatar2.py", line 522, in run
    handler(message)
  File "/usr/local/lib/python3.8/dist-packages/avatar2/watchmen.py", line 78, in watchtrigger
    ret = func(self, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/avatar2/avatar2.py", line 491, in _handle_remote_memory_write_message
    success = mem_range.forwarded_to.write_memory(
  File "/usr/local/lib/python3.8/dist-packages/avatar2/peripherals/avatar_peripheral.py", line 66, in write_memory
    return intervals.pop().data(offset, size, value, **kwargs)
  File "/firmwire/firmwire/vendor/mtk/hw/PCCIFPeripheral.py", line 495, in hw_write
    packet = bytes(ring.readPacket())
TypeError: cannot convert 'NoneType' object to bytes
==> BOOT                                                                                                                                                                                                 [321/1749]
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: boot status: POLLING_BUS_READY                                                                                                                               
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: boot status: PREINIT_PDAMON                                                                                                                                  
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: boot status: PREINIT_BUSMON                                                                                                                                  
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: boot status: PREINIT_FRC                                                                                                                                     
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: boot status: START_P1                                                                                                                                        
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: boot status: RESTART_WDT                                                                                                                                     
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: boot status: SAVE_RASP                                                                                                                                       
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: boot status: SET_C0_COFIG5_K                                                                                                                                 
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: boot status: CLR_C0_STATUS_BEV_ERL                                                                                                                           
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: boot status: INTERRUPT_PREINIT                                                                                                                               
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: boot status: CM_L2_INIT                                                                                                                                      
==> WAIT SHUTDOWN                                                                                                                                                                                                  
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: boot status: CM_INIT                                                                                                                                         
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: boot status: PLL_INIT                                                                                                                                        
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: boot status: L1_CACHE_INIT                                                                                                                                   
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: boot status: L2_CACHE_INIT                                                                                                                                   
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: boot status: SET_CM_WT                                                                                                                                       
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: boot status: INIT_OTHER_CORES                                                                                                                                
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: boot status: SET_BOOTSLAVE                                                                                                                                   
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: boot status: JOIN_CH_DOMAIN                                                                                                                                  
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: boot status: ABN_RST_CHECK                                                                                                                                   
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: boot status: MPU_INIT                                                                                                                                        
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: boot status: START_P2                                                                                                                                        
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: boot status: REGION_INIT                                                                                                                                     
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: boot status: REGION_INIT_DONE                                                                                                                                
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: boot status: INIT_GPR                                                                                                                                        
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: boot status: SET_C0_EBASE                                                                                                                                    
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: boot status: DISPATCH_SP                                                                                                                                     
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: boot status: STACK_INIT                                                                                                                                      
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: boot status: INIT_VPE1                                                                                                                                       
XXX halted in vpe_sleep helper                                                                                                                                                                                     
XXX halted in vpe_sleep helper                                                                                                                                                                                     
XXX halted in vpe_sleep helper                                                                                                                                                                                     
[INFO] firmwire.vendor.mtk.machine: Quirk: Setting VPE count                                                                                                                                                       
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: boot status: CLIB_BASE_INIT                                                                                                                                  
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: boot status: CCCI_HW_INIT                                                                                                                                    
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: boot status: TRACK_HWINIT_START                                                                                                                              
[WARN] firmwire.hw.peripheral.PCCIF_Periph.PCCIF1_MD: ACKed channels which aren't ready!                                                                                                                           
[0.44122][NO_TASK] 0x9028c705 [CCCI_ERR] =========>ccci_inst_initr  [CCCI_ISNT_INIT]                                                                                                                               
[0.44193][NO_TASK] 0x9015891f ===> ccci_it_init                                                                                                                                                                    
                                                                                                                                                                                                                   
[0.44278][NO_TASK] 0x9015891f ===> ccci_it_init initialize ccci_duser_it_port[0]                                                                                                                                   
                                                                                                                                                                                                                   
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: boot status: TRACK_HWINIT_END                                                                                                                                
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: boot status: CCCI_HS1                                                                                                                                        
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: boot status: TRACK_HS1_START                                                                                                                                 
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: boot status: TRACK_HS1_START_TX                                                                                                                              
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: FSM: starting boot                                                                                                                                           
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: boot status: TRACK_HS1_START_RX                                                                                                                              
[INFO] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: boot status: TRACK_HS1_TX_END                                                                                                                                
Exception no: 18                                                                                                                                                                                                   
Registers:                                                                                                                                                                                                         
32                                                                                                                                                                                                                 
ZERO: 0x0       -> 0x00000000                                                                                                                                                                                      
AT: 0xdeadbeef  -> 0xdeadbeef   -> 0x00000000                                                                                                                                                                      
V0: 0x0 -> 0x00000000   

@noopwafel
Copy link

You need to check the corresponding Linux kernel source.

For the MT6765, you can look at https://github.com/xiaomi-mt6765/android_kernel_xiaomi_mt6765/blob/lineage-17.1/drivers/misc/mediatek/eccci/hif/ccci_hif_ccif.c - but the only other values there seem to be equivalent to our MT6768 config. Did you try just copying that one directly? (Or do you have kernel source matching your firmware?)

@docfate111
Copy link
Author

docfate111 commented Feb 25, 2024

thanks for your response.
the kernel version is

MT6765 
4.9.190+
QKQ1
Oct 1, 2020 patch level

When I try this the error is ERROR] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: PCCIF ring no too large (value: 16, is only: 8) so I had changed it the one with 16 instead but then I get
ERROR] firmwire.hw.peripheral.PCCIF_Periph.PCCIF0_MD: PCCIF ring no too large (value: 16, is only: 16)

I tried appending a 0 to each and changing SHM_QUEUE_NUM from 16 to 17 but then ring.readPacket() receives None irmwire/vendor/mtk/hw/PCCIFPeripheral.py line 495.

Also in the binary amms_pccif_read_from_buffer goes to secpccif_read_sram - is the ring buffer the emulator using in the sram?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants