Skip to content

snagrecover: imx: add support for the i.MX95#93

Open
YanAkkI2S wants to merge 3 commits into
bootlin:mainfrom
YanAkkI2S:imx95
Open

snagrecover: imx: add support for the i.MX95#93
YanAkkI2S wants to merge 3 commits into
bootlin:mainfrom
YanAkkI2S:imx95

Conversation

@YanAkkI2S

Copy link
Copy Markdown

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:

  1. Its boot ROM expects the SDPS stream on a dedicated interrupt OUT endpoint, which the hidraw backend can't target, so HIDDevice gets a prefer_libusb flag (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).
  2. The boot image uses "v2" containers (larger alignment + a V2X tag), so get_container_size() now handles those as well.
  3. Like the i.MX8QM it's a two-stage flow (SDPS to the ROM, then SDPV to the SPL), and the ROM re-enumerates once it has consumed the first container.

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.

Signed-off-by: AKKOUCHE Yanis <y.akkouche@i2s.fr>
Signed-off-by: AKKOUCHE Yanis <y.akkouche@i2s.fr>

@rgantois rgantois left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Copy link
Copy Markdown
Collaborator

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.


else:
if kernel_driver_active:
self.usb_dev.detach_kernel_driver(self.main_intf.bInterfaceNumber)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The 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?

usb.util.release_interface(
self.usb_dev, self.main_intf.bInterfaceNumber
)
except usb.USBError:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The 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:

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
):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants