981213 / mtk_uartboot

GNU Affero General Public License v3.0
95 stars 23 forks source link

Error: called `Result::unwrap()` on an `Err` value: Custom { kind: TimedOut, error: "Operation timed out" } #2

Closed Fail-Safe closed 4 months ago

Fail-Safe commented 4 months ago
❯ ./mtk_uartboot
mtk_uartboot - 0.1.0

Running on MacOS Sonoma. Using an FT232 UART device.

❯ RUST_BACKTRACE=full ./mtk_uartboot -p bl2-mt7622-1ddr-ram.bin -a -f openwrt-mediatek-mt7622-linksys_e8450-ubi-bl31-uboot.fip -s /dev/cu.usbserial-A50285BI
mtk_uartboot - 0.1.0
Using serial port: /dev/cu.usbserial-A50285BI
Handshake...
hw code: 0x7622
hw sub code: 0x8a00
hw ver: 0xcb00
sw ver: 0x100
Baud rate set to 460800
sending payload to 0x201000...
Checksum: 0xfcf1
Setting baudrate back to 115200
Jumping to 0x201000 in aarch64...
Waiting for BL2. Message below:
==================================
NOTICE:  BL2: v2.10.0   (release):v2.10.0-mtk
NOTICE:  BL2: Built : 13:17:01, Mar  1 2024
NOTICE:  WDT: Cold boot
NOTICE:  CPU: MT7622
NOTICE:  WDT: disabled
NOTICE:  Starting UART download handshake ...
==================================
BL2 UART DL version: 0x10
Baudrate set to: 921600
thread 'main' panicked at src/bl2.rs:59:53:
called `Result::unwrap()` on an `Err` value: Custom { kind: TimedOut, error: "Operation timed out" }
stack backtrace:
   0:        0x1041eead4 - __mh_execute_header
   1:        0x104203f30 - __mh_execute_header
   2:        0x1041ed118 - __mh_execute_header
   3:        0x1041ee908 - __mh_execute_header
   4:        0x1041efc0c - __mh_execute_header
   5:        0x1041ef954 - __mh_execute_header
   6:        0x1041f0054 - __mh_execute_header
   7:        0x1041eff48 - __mh_execute_header
   8:        0x1041eef58 - __mh_execute_header
   9:        0x1041efcd0 - __mh_execute_header
  10:        0x10420b620 - __mh_execute_header
  11:        0x10420b91c - __mh_execute_header
  12:        0x104190594 - __mh_execute_header
  13:        0x1041906a0 - __mh_execute_header
  14:        0x10418cfbc - __mh_execute_header
[1]    85508 abort      RUST_BACKTRACE=full ./mtk_uartboot -p bl2-mt7622-1ddr-ram.bin -a -f  -s
981213 commented 4 months ago

A50285BI is a well-known serial number for fake FT232 chips. Could you try limiting the baudrate to 460800 or 115200, or increasing it to 1500000 with --bl2-load-baudrate option and see if that works?

Fail-Safe commented 4 months ago

A50285BI is a well-known serial number for fake FT232 chips.

Noted--I have seen that as well and plan to get a new FT232 device. Definitely won't be purchasing from Amazon again.

Could you try limiting the baudrate to 460800 or 115200, or increasing it to 1500000 with --bl2-load-baudrate option and see if that works?

I did try these suggestions, but to no avail. At 1500000, it took longer to fail, but failed in the end in the same way as with the other baud rates.

FWIW, I also have a CP210X UART device and it fails the same way on MacOS. However, I dug out an old Linux laptop and used both CP210X and FT232 devices there to confirm mtk_uartboot works with those devices just fine.

Armed with the knowledge that the UART adapters were functional in Linux, I retried them on MacOS, but this time as sudo. No luck. Same error.

Oh, almost forgot to mention. On MacOS, most serial adapters are connected in two ways. I don't remember all the ins-and-outs of why, but the same cu.usbserial-* device will also be available in /dev as tty.usbserial-*. I tried the tty.usbserial-* device in the mtk_uartboot commands to no avail.

981213 commented 4 months ago

Could you try if https://github.com/981213/mtk_uartboot/commit/09ecc3fb87d2accd86f5f78d8cd1ce4f211eb56f fixes the problem on Mac? A build should be available as artifacts on this page when it finished: https://github.com/981213/mtk_uartboot/actions/runs/8123550884

Fail-Safe commented 4 months ago

Oh yeah! Right on!

That's working on my Mac now! Works with both my [knock-off] FT232 and CP210X devices. Many thanks! 😊🙏🏻

981213 commented 4 months ago

Great!