snagrecover: imx: add support for the i.MX95#93
Conversation
Signed-off-by: AKKOUCHE Yanis <y.akkouche@i2s.fr>
Signed-off-by: AKKOUCHE Yanis <y.akkouche@i2s.fr>
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.
|
|
||
| else: | ||
| if kernel_driver_active: | ||
| self.usb_dev.detach_kernel_driver(self.main_intf.bInterfaceNumber) |
There was a problem hiding this comment.
Will this require root/admin privileges? Or just access rights to the USB device? Also, does it work properly on Windows?
| 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
| 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
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.