snagrecover: imx: add support for the i.MX95#93
Conversation
rgantois
left a comment
There was a problem hiding this comment.
Hi, thanks a lot for the contribution! I've requested a few changes and asked some questions in the review. In addition to these, please remove the first commit which merges main into your feature branch. What you should do instead is rebase your feature branch onto main (without the merge commit) and then force push.
| cont_index = 2 | ||
| rom_container_tag = boot_blob[2 * CONTAINER_HDR_ALIGNMENT + 3] | ||
| if rom_container_tag != CONTAINER_TAG: | ||
| if boot_blob[3] == CONTAINER_TAG and boot_blob[0] >= 2: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Done, i used named constants for the offsets as you asked
| usb.util.release_interface( | ||
| self.usb_dev, self.main_intf.bInterfaceNumber | ||
| ) | ||
| except usb.USBError: |
There was a problem hiding this comment.
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:
except usb.core.USBError as e:
if e.errno != errno.ENODEV:
raise e
There was a problem hiding this comment.
Done, only ignoring NO_DEVICE now
| if e.data and ( | ||
| FASTBOOT_UNSUPPORTED_CMD_RESPONSE in e.data | ||
| or FASTBOOT_UNRECOGNIZED_CMD_RESPONSE in e.data | ||
| ): |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
You're right, i dropped this change, the branch doesn't change fastboot.py anymore since there is a commit in main from you that covers it now
Signed-off-by: AKKOUCHE Yanis <y.akkouche@i2s.fr>
rgantois
left a comment
There was a problem hiding this comment.
Thanks! Almost good, just one last point to address.
| from snagrecover.utils import prettify_usb_addr | ||
| import glob | ||
| import usb | ||
| from usb.backend.libusb1 import LIBUSB_ERROR_NO_DEVICE |
There was a problem hiding this comment.
We shouldn't assume that libusb1 is being used.
| except usb.USBError as err: | ||
| # the device may already be gone (re-enumerated after jumping to firmware) | ||
| # and don't silently ignore any other errors | ||
| if err.backend_error_code != LIBUSB_ERROR_NO_DEVICE: |
There was a problem hiding this comment.
Why not use e.errno instead? That way you don't have to assume a particular USB backend.
|
I'd like to try this out. This is what I got so far: Any suggestions? Update, nevermind, seems to be a permission issue. |
This adds i.MX95 recovery support, tested on a Variscite DART-MX95 (full ROM → SPL → U-Boot).
It was first modelled on the i.MX91/93 but the i.MX95 needs a bit more:
prefer_libusbflag (only set for the i.MX95, so nothing else changes path, but any future SoC that needs the same can simply opt in the same way).I don't have other i.MX9 / i.MX8Q boards on hand, but the HID backend change is gated on the SoC, so existing devices keep their exact current behaviour.