-
Notifications
You must be signed in to change notification settings - Fork 63
snagrecover: imx: add support for the i.MX95 #93
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -95,7 +95,10 @@ def _is_cmd_supported(self, cmd: str) -> bool: | |
| try: | ||
| self.cmd(cmd) | ||
| except FastbootError as e: | ||
| if e.data and FASTBOOT_UNRECOGNIZED_CMD_RESPONSE in e.data: | ||
| if e.data and ( | ||
| FASTBOOT_UNSUPPORTED_CMD_RESPONSE in e.data | ||
| or FASTBOOT_UNRECOGNIZED_CMD_RESPONSE in e.data | ||
| ): | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I disagree with this change, U-Boot returns "unrecognized" when the U-Boot command is unsupported, and "unsupported" when the Fastboot command is unsupported[1]. This check is meant to determine if the Fastboot "oem_run" command is supported or not, so we don't want to return False if the Fastboot command is supported but the U-Boot command isn't. [1] https://elixir.bootlin.com/u-boot/v2026.04/source/drivers/fastboot/fb_command.c#L164 |
||
| return False | ||
| return True | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -111,7 +111,7 @@ def get_hidraw_device(self): | |
|
|
||
| return hidraw_path | ||
|
|
||
| def __init__(self, usb_dev: usb.core.Device): | ||
| def __init__(self, usb_dev: usb.core.Device, prefer_libusb: bool = False): | ||
| pretty_addr = prettify_usb_addr((usb_dev.bus, usb_dev.port_numbers)) | ||
| if not is_hid(usb_dev): | ||
| raise IOError(f"Device {pretty_addr}, is USB but not HID!") | ||
|
|
@@ -135,9 +135,11 @@ def __init__(self, usb_dev: usb.core.Device): | |
| ) | ||
| self.usb_dev.set_configuration(self.main_cfg.bConfigurationValue) | ||
|
|
||
| if platform.system() == "Linux" and self.usb_dev.is_kernel_driver_active( | ||
| self.main_intf.bInterfaceNumber | ||
| ): | ||
| kernel_driver_active = platform.system() == "Linux" and ( | ||
| self.usb_dev.is_kernel_driver_active(self.main_intf.bInterfaceNumber) | ||
| ) | ||
|
|
||
| if kernel_driver_active and not prefer_libusb: | ||
| # The kernel driver in question should be usbhid | ||
| hidraw_path = self.get_hidraw_device() | ||
| if hidraw_path is None: | ||
|
|
@@ -151,6 +153,9 @@ def __init__(self, usb_dev: usb.core.Device): | |
| logger.info(f"HID device {pretty_addr} has hidraw dev {hidraw_path}") | ||
|
|
||
| else: | ||
| if kernel_driver_active: | ||
| self.usb_dev.detach_kernel_driver(self.main_intf.bInterfaceNumber) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this require root/admin privileges? Or just access rights to the USB device? Also, does it work properly on Windows? |
||
|
|
||
| # This case is for systems which don't | ||
| # have usbhid loaded for some reason. | ||
| # It is also suitable for Windows. if | ||
|
|
@@ -230,7 +235,13 @@ def close(self): | |
| if self.hidraw: | ||
| self.hidraw.close() | ||
| else: | ||
| usb.util.release_interface(self.usb_dev, self.main_intf.bInterfaceNumber) | ||
| try: | ||
| usb.util.release_interface( | ||
| self.usb_dev, self.main_intf.bInterfaceNumber | ||
| ) | ||
| except usb.USBError: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please refine this catch with a check of the backend error code, so that we don't ignore errors related to access rights, target stalls etc. Something like this: |
||
| # the device may already be gone (re-enumerated after jumping to firmware) | ||
| pass | ||
|
|
||
| def hidraw_read(self, length: int, timeout: int): | ||
| r, w, e = select.select([self.hidraw], [], [], timeout) | ||
|
|
@@ -244,7 +255,7 @@ def hidraw_read(self, length: int, timeout: int): | |
| def libusb_write(self, data: bytes): | ||
| # Use Interrupt OUT endpoint if available | ||
| if self.intr_out: | ||
| return self.usb_dev.write(self.intr_out, data) | ||
| return self.usb_dev.write(self.intr_out, data, timeout=5000) | ||
|
|
||
| report_id = data[0] | ||
| self.set_report(report_id, data) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,6 +58,8 @@ tested: | |
| family: imx | ||
| imx93: | ||
| family: imx | ||
| imx95: | ||
| family: imx | ||
| keembay: | ||
| family: keembay | ||
| r8: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| flash-bin: | ||
| path: imx-boot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please either define constants for the magic number offsets or assign them to explicitely named variables, so that it's clear what we're reading from the blob here.