-
Notifications
You must be signed in to change notification settings - Fork 176
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
driver/usbloader: rename RKUSBDriver to reflect rkdeveloptool usage #1542
base: master
Are you sure you want to change the base?
Conversation
The support was originally added in #437. Pinging @otavio and @chtavares for their input. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1542 +/- ##
======================================
Coverage 56.5% 56.5%
======================================
Files 168 168
Lines 13111 13111
======================================
Hits 7417 7417
Misses 5694 5694
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
25fc0f3
to
d278c0b
Compare
The match list doesn't yet support the RK3399pro (2207:330c). Add it along with the rest of the VID/PIDs listed in rkdeveloptool's udev rule[1] as well as the VID/PID pairs for the newer RK3566 and RK3588[2]. [1]: https://github.com/rockchip-linux/rkdeveloptool/blob/master/99-rk-rockusb.rules [2]: labgrid-project#1542 (comment) Signed-off-by: Ahmad Fatoum <[email protected]>
d278c0b
to
4aba887
Compare
To interact with a Rockchip SoC in BootROM mode over USB, Rockchip offers the rkdeveloptool, which is among others already packaged in Debian. We currently support this via the RKUSBDriver, which binds to the RKUSBLoader resource, which currently lists a single VID/PID pair. Actually making use of this is where things get confusing: Labgrid will look up the rk-usb-loader key to find rkdeveloptool and then fall back to a binary named `rk-usb-loader`. To my knowledge, no one names their rkdeveloptool that way and `rk-usb-loader` has since become the name of the Rockchip USB loader distributed by barebox. On systems, like the LXA TAC, this is doubly confusing: There's a rk-usb-loader binary, which Labgrid would use by default, but it's not compatible with rkdeveloptool, supports only the RK35xx SoCs barebox supports and is currently not supported by Labgrid at all. Given that RKUSBLoader only supports a single SoC, our documentation is wrong (it references the unrelated barebox' rk-usb-loader) and that our usage of rkdeveloptool goes beyond the BootROM's USB protocol and additionally flashes persistent media by talking to a first stage usb_loader that's uploaded first, I think the best course of action is to rename both the driver and the tool key to reflect that rkdeveloptool is actually used. Signed-off-by: Ahmad Fatoum <[email protected]>
The match list doesn't yet support the RK3399pro (2207:330c). Add it along with the rest of the VID/PIDs listed in rkdeveloptool's udev rule[1] as well as the VID/PID pairs for the newer RK3566 and RK3588[2]. [1]: https://github.com/rockchip-linux/rkdeveloptool/blob/master/99-rk-rockusb.rules [2]: labgrid-project#1542 (comment) Signed-off-by: Ahmad Fatoum <[email protected]>
4aba887
to
203206a
Compare
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.
Thanks for working on this and your changes are very good. I believe that this makes much clear for the user about the intended goal and the tool that is required for make it to work.
I also think that adding extra device support is very good.
@@ -87,7 +87,7 @@ def load(self, filename=None): | |||
|
|||
@target_factory.reg_driver | |||
@attr.s(eq=False) | |||
class RKUSBDriver(Driver, BootstrapProtocol): |
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.
We usually let the old RKUSBDriver
raise a DeprecationWarning
and instead use the new driver, i.e. see NetworkUSBStorageDriver
.
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.
This won't work transparently, because I am changing the name of the tool key as well, but I can do this, so users are nudged into the right direction.
Sorry for chiming in with something that is not entirely related to those changes. So we sell Rockchip-based SoMs and boards for the last 6-7 years and I've taken interest in labgrid but I've hit a few "weirdnesses" (to me) in that process, that may very well be because I misunderstood how labgrid works. So, my setup is the following:
RKUSBLoader is only matching devices with vendor id 0x2207 and model id 0x110a. I've no clue what that represents as the RK3399, PX30 and RK3588 I work with aren't matching that model id. For now I've just added mines in there but I was wondering if it would make more sense to have parameters for that Resource, à-la AndroidUSBFastboot for example. Otherwise we can simply add more to the matching list over time, not sure it's interesting to bind labgrid updates with Rockchip SoC support? The tool to use to interact with the USB loader on Rockchip needs to run on the executor, but this needs to be specified on the Driver configuration side, which is part of the labgrid-device-config yaml file, which is on PC-B while it's going to run on PC-A. My issue is... there are currently three known tools for USB loading on Rockchip devices, rkdeveloptool, rockusb and this rk-usb-loader. I assume we could have some executors with one binary, and some others with another one. Why would the target conf file need to know on which executor something is going to run? Shouldn't this be related to a Place or the Resource itself? |
I am not sure either, maybe RV11?
I think it's useful anyhow to have the well-known VID/PIDs known to Labgrid. If it's possible to override them, it makes sense to have parameters for it, but the default should be that users add the VIDs/PIDs to Labgrid for shared benefit.
I don't find it unreasonable to update Labgrid when you are interfacing with a new SoC.
I haven't used rockusb so far, but both rkdeveloptool and rk-usb-loader have an incompatile commnad-line interface. For i.MX, there are multiple tools as well and Labgrid handles this by separating the resource ( Best case, both rk-usb-loader and rkdeveloptool are installed into What the client needs to know about though is which driver should handle the resource. This isn't something that we can just leave to the exporter, because the tools tend to have their idiosyncrasies, which leak through the abstraction. Once the driver is configured in your environment YAML though (e.g. with the name of the USB loader binary to use), the rest of Labgrid can interface with it generically via the Boostrap protocol, e.g. in the client it's just |
RV1108 apparently :)
I think it's unnecessary churn for the project and waiting time for people to be able to use labgrid with their yet-unsupported SoC. But that's a perfectly understandable policy, there's such policy for Yocto bbclasses for example, which is implemented in such a way it is very difficult to extend transparently.
rockusb[1] implements a third one :)
[1] https://github.com/collabora/rockchiprs/blob/main/rockusb/examples/rockusb.rs though there is an issue by one of the contributors to add short parameters like rkdeveloptool[2]
I'm a bit worried by the rename because if we add support back for rk-usb-loader in the future, we'll have releases with "rk-usb-loader support but actually not really, the only way to use it is to point rk-usb-loader to rkdeveloptool with the tools: from the client config", other releases with "no rk-usb-loader support at all, rkdeveloptool is now through rkdeveloptoolusbdriver" and other releases with "actually now rk-usb-loader works, with the same driver as the releases that didn't work before". Which means we are breaking backward compatibility for the config file format (I don't know what's the stance of the project on that though). [...]
OK, so this means I need to have a huge myconfig.yaml, with all targets, that I maintain in a versioned repo that I could share with other devs I guess. It's a bit difficult for me to wrap my head around the potential sync issues between a place that is handled by the coordinator (and not versioned) and a client config file which could be defining a resource for a target via a place, those necessarily need to be in sync but by being different files, stored and used on different machines. Anyway, nothing related to this MR :) Thanks for the explanation. |
if match not in [("2207", "110a"), ("2207", "301a"), | ||
("2207", "310c"), ("2207", "320b"), | ||
("2207", "320a"), ("2207", "320c"), | ||
("2207", "330a"), ("2207", "330c"), | ||
("2207", "350a"), ("2207", "350b") | ||
]: |
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.
suggestion (non-blocking): please comment on the SoC model those represents
This would make it easier to spot what's supported and what's not.
330c is RK3399
350b is RK3588
I also have:
330d for PX30 (but I can add myself, not an issue)
c.f. https://github.com/rockchip-linux/rkdeveloptool/blob/master/99-rk-rockusb.rules for some model ID
https://elixir.bootlin.com/u-boot/v2024.10/source/drivers/usb/gadget/Kconfig#L69 probably could help too :)
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.
I agree with this.
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.
I didn't do that before, because I didn't know what the original VID/PID was for, but I can annotate them now. Thanks!
Thanks for finding this out.
I'll have to defer to the maintainers what they think should be the policy.
Heh, even more reason to rename the driver to reflect what is supports.
Yes, this is confusing and this PR is rectifying the situation. I hope the impact will be limited as the driver seems not yet widely used evidenced by the single VID/PID match and the wrong documentation. I will add a deprecation warning and fallback as suggested by @Emantor.
Even in a future, where we have drivers for all three host utilities, the name
will cease to work, but we got to make a tradeoff between complicating things for everyone or breaking it for existing users. The authors of the change, which are the only users I knew of, are fine with it. I hope such breaking changes will be rare in future.
For test suites, you'll want to check in the environment yaml into the repository alongside the tests anyway. You can customize values with For interactive labgrid-client usage, the client already instantiates drivers by default to match against resources. You still need a config though for the USB loader. Thinking about it, maybe we should change this in the same go: Other bootstrap drivers don't do persistent flashing of the bootstrapped image, maybe we should change the Rockchip USB driver to load only into RAM by default. That way |
[...]
RKUSBLoaderDriver was an awfully good name for a driver for rk-usb-loader though ;)
I think we could simply add support for rkdeveloptool in another driver and keep RKUSBLoaderDriver (and maybe even fix its support?). While we won't support an rkdeveloptool in tools:rk-usb-loader anymore, it should be rather easy to warn users of that via doc update and parsing the config and warn/fail if rk-usb-loader containers rkdeveloptool and say "please use RKDevelopToolDriver instead" or something like that. Also, I quickly went trhough the rk-usb-loader script and I think it is the equivalent of Currently RKUSBLoaderDriver allows to flash an image after a special binary has been USB loaded through special commands (for rkdeveloptool, that is Also, I just remembered that I'm therefore wondering if we shouldn't have clear separation of
We could very well use rk-usb-loader for the former and rockusb with the latter, or rkdeveloptool + df-util, etc...
kas is dealing with that with versioning the config format and warning/failing if you're using outdated config format with newer kas. Maybe something to investigate? In any case, if the breaking of backward compatibility is documented somewhere, that's fine to me :)
Thanks, I'll need to finalize some kind of setup, make mistake and learn from them. A bit still too fresh in my head for now.
AFAICT (haven't worked on it), on Rockchip we USB load TPL+SPL but then you have something very limited (proper + TF-A + OP-TEE + ... missing). You have the option of doing rkusb (or rockusb (the protocol) whatever its actual name) via rkdeveloptool to do stuff (write somewhere for example) or using DFU (or probably also fastboot). So, "USB loading" via |
And this name wasn't used before.
That's what I am doing basically
I don't think adding support anew for rk-usb-loader can be considered a fix. But eventually, we may have a driver for it. Note that the current name is
I will look into extending the deprecation warning, so there are messages for both using the old driver name and the old tools key.
I know. That's what the driver in Labgrid currently implements.
The current driver implements the Fastboot and DFU go beyond that and they don't implement
Yes, I am starting to think a rename alone is insufficient. The proper abstraction would be a fastboot/DFU-esque driver that makes available the flashing, erasing, system reset functionality of the USB loader and BootstrapProtocol::load would just do the equivalent of
barebox only emulates SoC-specific USB gadget protocols if it's needed for the prebootloader to chainload barebox proper. The idea is that the tools in barebox
It's documented in the changelog and there will be deprecation warnings along with a fallback for a transitory period. As a counterpoint to kas, docker has made their docker-compose.yml version field obsolete. I don't feel strongly either way, but there are tradeoffs involved and this would need more careful consideration.
rk-usb-loader only supports what barebox supports upstream, which at this time is RK3568 and RK3588. On both of these, it takes only the barebox image and the system boots to shell. I don't know if this is easily doable for older SoCs or this is just a side-effect of the new boot flow on the RK35xx and the RKNS format. (The RK3399 I mention in the PR is not supported in barebox. Getting Labgrid to handle the RK3399 properly is part of my Yak shave to eventually upstream out-of-tree barebox RK3399/PX30 support).
Personally, I'd always go with Fastboot or DFU, so I am not too motivated to implement a driver for the rockusb protocol in full..
That's how we use it. Then a script checks that "$bootsource" = "serial" and then barebox starts a composite gadget with fastboot/DFU and ACM in the background and then flashing is done via that.
Yes, IMXUSBLoader boots to shell. |
Well, if only I had taken the time to double check what I was saying... So I guess that's a +1 for the rename then since we'd probably have a driver named RKUSBLoaderDriver for rk-usb-loader (if anyone wants to implement that :) )?
Agreed.
Thanks for the info. My point being that it depends what one means with 'bootstrapping'. If I'm not mistaken, U-Boot images that are USB loaded only contain TPL+SPL and then is waiting for proper via rockusb/rkusb protocol, fastboot or dfu, no CLI access. I believe it should be possible for fastboot and dfu to upload a file to DRAM and execute it, not sure for rockusb/rkusb though. I seem to recall Collabora is doing that very thing https://gitlab.collabora.com/hardware-enablement/rockchip-3588/notes-for-rockchip-3588/-/blob/main/upstream_uboot.md#how-to-create-a-blob-containing-ddr-init-and-spl-for-rockusb So the issue here is that depending on the bootloader (I believe, haven't checked myself), we'd reach or not CLI with a simple
FWIW, I would need to use rkdeveloptool with rockusb support for my board(s) for flashing/erasing/reset since USB gadget isn't working in upstream U-Boot (at the very least on PX30 Ringneck, RK3399 Puma and RK3588 Tiger may be fine), only with the blob, who only supports rockusb commands.
OK. I am not sure this is possible in U-Boot SPL though. And if it is, I doubt it is common on Rockchip boards. I haven't had the need for USB loading upstream U-Boot so far, so have no experience with that.
Thanks for the info!
Is there some documentation available somewhere for this new boot flow for USB aside from the code in Barebox? I was considering making U-Boot generate a USB bootable (TPL+SPL) image but the source code stopped being released a few years ago and no support for RK35xx in it.
I have never built nor used Barebox so all I was and am saying is with respect to U-Boot.
We have some support in upstream U-Boot (though if it is actually properly tested... who knows). FWIW, U-Boot currently doesn't generate a USB bootable image so I doubt many people are generating them by hand using Rockchip host blobs :) (
IIRC, in U-Boot we check if the boot source is USB and then start USB gadget with different functions (DFU/fastboot/rockusb)? But no CLI at that point, everything done in C code at build time. |
Meh. I guess, we can just kick the can down the road by making
I see. Would you like to submit a follow-up PR bringing rockup support in Labgrid to parity with Fastboot? ;)
I don't know of anything besides the code, sorry. I assume either BootROM or DDR blob has logic to continue USB boot into DRAM once RAM is setup.
What does USB-bootable mean? The same barebox image placed on eMMC/SD/SPI can also be loaded via
Never too late to start: https://barebox.org/demo ;)
I see.
For me that's the point of bootstrap. Get a full bootloader running, so I can decide what to do next.
I am grateful, I can use a single binary for everything. |
That would force us to use rkdeveloptool with the rockusb protocol, which for example doesn't implement erasing
What exactly are you suggesting here, I do not understand.
I can explain how that works in U-Boot though :) The BootROM finds magic value which starts the expected header. It loads the DRAM init code in SRAM. The DRAM init stage (either through upstream U-Boot TPL with open-source DRAM init or via the blob provided by Rockchip) init the DRAM and then exits back to BootROM which continues reading from the medium according to info in the header and loads the next stage. In U-Boot, that's SPL. Then SPL loads from the same medium (or a fallback one) a fitImage which contains TF-A, OP-TEE and U-Boot proper. Loads TF-A, executes it. TF-A does its thing, changing the EL before executing into U-Boot proper. You'll notice that we don't do a back-to-bootrom step between SPL and TF-A.
I need to look into Barebox source but I can already tell you that's not the case for U-Boot. We have one image for eMMC/SD and another for SPI. This is required for RK3399 (and older SoCs) because some SoCs have a broken BootROM implementation for the SPI controller which reads only the first half of every sector (what I have been told). I believe this is fine for SoCs with the headerv2 support in BootROM? Also, we allow different location on storage medium depending on whether it's eMMC/SD or SPI (we use that on RK3399 Puma for example, which has a "small" SPI-NOR). Considering Rockchip builds that USB loader (the one passed to
Got it. So, to come clean. I'm currently investigating labgrid for automating U-Boot testing as this is quickly growing out of proportions with everything I need to test. One of the things I need to test is a fallback mechanism for U-Boot itself. Basically, U-Boot TPL+SPL written to medium A, U-Boot proper written to medium B, U-Boot environment loaded from medium B. I have three storage media (not counting USB booting a whole U-Boot though that would be neat for manufacturing stage), so that makes a decent matrix of tests to run :) I'm not asking you to support this use-case, just asking you to try to think about not making it impossible (I am not saying you're suggesting something that is making it impossible!) I've derailed a bit the conversation from the original topic I believe though. Is there something I can help with/needs to be discussed wrt this PR? |
To interact with a Rockchip SoC in BootROM mode over USB, Rockchip
offers the rkdeveloptool, which is among others already packaged in
Debian.
We currently support this via the RKUSBDriver, which binds to the
RKUSBLoader resource, which currently lists a single VID/PID pair.
Actually making use of this is where things get confusing:
Labgrid will look up the rk-usb-loader key to find rkdeveloptool and then
fall back to a binary named
rk-usb-loader
. To my knowledge, no one namestheir rkdeveloptool that way and
rk-usb-loader
has since become thename of the Rockchip USB loader distributed by barebox.
On systems, like the LXA TAC, this is doubly confusing: There's a
rk-usb-loader binary, which Labgrid would use by default, but it's not
compatible with rkdeveloptool, supports only the RK35xx SoCs barebox
supports and is currently not supported by Labgrid at all.
Given that RKUSBLoader only supports a single SoC, our documentation is
wrong (it references the unrelated barebox' rk-usb-loader) and that
our usage of rkdeveloptool goes beyond the BootROM's USB protocol and
additionally flashes persistent media by talking to a first stage
usb_loader that's uploaded first, I think the best course of action
is to rename both the driver and the tool key to reflect that
rkdeveloptool is actually used.
I have yet to test the first (rename) commit, but posting it anyway to get some feedback if the rename is ok.