superna9999 / pyamlboot

Amlogic USB Boot Protocol Library
https://pypi.org/project/pyamlboot/
Apache License 2.0
71 stars 27 forks source link

Retry when DDR init doesn't work #19

Open superna9999 opened 1 year ago

superna9999 commented 1 year ago

For an unknown reason, on AMD platforms the first DDR init load fails, but a rety works, this retries until DDR init works.

Fixes #18

superna9999 commented 1 year ago

CC @dsx724

dsx724 commented 1 year ago
Using GX Family boot parameters
Traceback (most recent call last):
  File "/home/dxue/git/pyamlboot/./boot.py", line 132, in <module>
    usb.load_uboot()
  File "/home/dxue/git/pyamlboot/./boot.py", line 86, in load_uboot
    self.init_ddr()
  File "/home/dxue/git/pyamlboot/./boot.py", line 74, in init_ddr
    self.soc_id()
  File "/home/dxue/git/pyamlboot/./boot.py", line 54, in soc_id
    s = self.dev.identify()
  File "/home/dxue/git/pyamlboot/pyamlboot/pyamlboot.py", line 306, in identify
    ret = self.dev.ctrl_transfer(bmRequestType = 0xc0,
  File "/usr/lib/python3/dist-packages/usb/core.py", line 1082, in ctrl_transfer
    ret = self._ctx.backend.ctrl_transfer(
  File "/usr/lib/python3/dist-packages/usb/backend/libusb1.py", line 893, in ctrl_transfer
    ret = _check(self.lib.libusb_control_transfer(
  File "/usr/lib/python3/dist-packages/usb/backend/libusb1.py", line 602, in _check
    raise USBTimeoutError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBTimeoutError: [Errno 110] Operation timed out

I think something is fundamentally broken in AMD/asmedia's USB linux hardware/driver.

superna9999 commented 1 year ago

@dsx724 can you try https://github.com/superna9999/aml-usb-load-uboot/commit/dace10064ad8a9c74df6ae0580c12f54da49d890 ?

dsx724 commented 1 year ago
+ ./update cwr u-boot.bin.usb.bl2 0xd9000000
................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Transfer Complete! total size is 49152 Bytes
+ ./update write usbbl2runpara_ddrinit.bin 0xd900c000
..
Transfer Complete! total size is 32 Bytes
+ ./update run 0xd9000000
[update]Run at Addr d9000000
AmlUsbRunBinCode:ram_addr=d9000000
+ sleep 1
++ ./update identify 7
++ awk -F- '{print $4}'
+ proto='
0'
+ echo proto 0
proto 0
+ '[' '
0' -eq 8 ']'
+ sleep 1
+ ./update write u-boot.bin.usb.bl2 0xd9000000
..
Transfer Complete! total size is 49152 Bytes
+ ./update write usbbl2runpara_runfipimg.bin 0xd900c000
..
Transfer Complete! total size is 48 Bytes
+ ./update write u-boot.bin.usb.tpl 0x200c000
usbWriteFile len=4096,ret=-19 error_msg=error submitting URB: No such device
ERR: write data to device failed

The moment you try to send a big payload, it's gone. I know on Windows, AMD is notorious for USB problems.