DavidBuchanan314 / rabbit_r1_boot_notes

Documenting the boot process of the Rabbit R1 (MediaTek mt6765, k65v1_64_bsp, Android 13)
MIT License
40 stars 4 forks source link

DOMException when calling requestPort #2

Closed buley closed 1 month ago

buley commented 4 months ago

When connecting to WebUSB on the bootkit site, running remotely or locally, I see this error being thrown:

"Failed to execute 'requestPort' on 'Serial': Must be handling a user gesture to show a permission request."

The log in console comes out as something like:

Chooser dialog is not displaying a port blocked by the Serial blocklist: bluetoothServiceClassId=0000110a-0000-1000-8000-XXXX, name='XXX iPhone'
main.js:233 DOMException: Failed to execute 'requestPort' on 'Serial': No port selected by the user.
main.js:11 [-] FATAL: JavaScript exception :(

There are further errors as this repeats itself a few times.

The call is in the main go() routine https://github.com/DavidBuchanan314/rabbit_r1_boot_notes/blob/main/scripts/webusb/main.js#L70

buley commented 4 months ago

the attachment of the event handler via the on attribute in the HTML should work, but I'm able to workaround this by doing a simple connectButton.addEventHandler


☠️  ∴ git diff     

-let logdiv = document.getElementById("logpre");
+let logdiv = document.getElementById("logpre"),
+    connectButton = document.getElementById("connect");

...

+if (connectButton) {
+
+       connectButton.addEventListener('click', go);
+}
+
DavidBuchanan314 commented 4 months ago

Interesting, what browser are you using here?

buley commented 4 months ago

Chrome version 126.0.6478.183 (Official Build) (arm64) and I was able to replicate in Arc browser.

After this issue, my issue getting going seems related to the WebUSB API and not on the implementation.

I can't get any USB devices to yet show up in the selection panel, even though I see them using lsusb and can see them show in the Device log at chrome://device-log

If I clear the filters argument to the requestPort() method I can see one device, a Bluetooth connection to my iPhone, but nothing else yet. Currently working through it on my side, trying first with updating Chrome.

DavidBuchanan314 commented 4 months ago

Curious, I've also tested on Chromium 126 aarch64 (but will also test Chrome proper soon)

Have you installed the udev rules documented here? https://github.com/DavidBuchanan314/rabbit_r1_boot_notes/tree/main/scripts/webusb#linux-prerequisites

DavidBuchanan314 commented 4 months ago

By the way, your device needs to have a cdc_acm driver. It should be present on ~all desktop systems and ~most(?) android devices, but I don't know about things like chromebooks.

buley commented 4 months ago

I'm on Mac Sonoma 14.5. Installed lsusb through homebrew but don't have access to udevadm on this environment unfortunately. Interesting because I see the device! This seemingly has nothing to do with your great work. I'll keep trying.

☠️  ∴ lsusb | grep r1
Bus 000 Device 001: ID 0e8d:20ff MediaTek Inc. r1  Serial: XXXX

Screenshot 2024-07-17 at 2 55 06 PM

buley commented 4 months ago

For anyone curious, I'm looking into the SerialAllowAllPortsForUrls preference and policy: https://chromeenterprise.google/policies/?policy=SerialAllowAllPortsForUrls

DavidBuchanan314 commented 4 months ago

I upgraded my (x86) mac mini to Sonoma 14.5, using Chrome latest official, and everything worked as-is.

Fwiw I do my regular testing on an apple silicon macbook running Asahi, but I haven't tried the full aarch64/sonoma/chrome combo together yet. I think there's something weird going on with your setup!