Skip to content

new RKBootstrapDriver, use rk-usb-loader to bootstrap Rockchip SoCs#1898

Open
saschahauer wants to merge 2 commits into
labgrid-project:masterfrom
saschahauer:rkbootstrap
Open

new RKBootstrapDriver, use rk-usb-loader to bootstrap Rockchip SoCs#1898
saschahauer wants to merge 2 commits into
labgrid-project:masterfrom
saschahauer:rkbootstrap

Conversation

@saschahauer

Copy link
Copy Markdown
Contributor

Labgrid currently has a RKUSBDriver which uses rkdeveloptool to write a bootloader image to a SD/MMC card connected to a Rockchip SoC. There currently is no driver to just upload and start a bootloader image without modifying the device storage. This PR adds exactly that. As the obvious name for this driver is already used by the existing driver, the driver is named RKBootstrapDriver.

Some confusion exists in the rk-usb-loader tool. The documentation wrongly states that this should point to equally named rk-usb-loader tool from barebox when it really expects a rkdeveloptool in that key. This is cleaned up in a way that the existing RKUSBDriver now expects a rkdevelop key to find the rkdeveloptool and the new RKBootstrapDriver now expects a barebox rk-usb-loader tool under the rk-usb-loader key (as the documentation already states). For compatibility RKBootstrapDriver still falls back to the rk-usb-loader key, but a warning is printed when it's actually used.

Description

Checklist

  • Documentation for the feature
  • Tests for the feature
  • The arguments and description in doc/configuration.rst have been updated
  • Add a section on how to use the feature to doc/usage.rst
  • Add a section on how to use the feature to doc/development.rst
  • PR has been tested
  • Man pages have been regenerated

Several drivers resolved their host tool paths with an identical,
copy-pasted block guarded by a "FIXME make sure we always have an
environment or config" comment: look up the tool via the environment's
config when present, otherwise fall back to the bare tool name so it can
be found via $PATH.

Add a Target.get_tool() helper that encapsulates this fallback (mirroring
the existing Target.interact()) and convert the drivers to use it,
so that a potential fix of this issue can be done in a single place.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Assisted-by: Claude Opus 4.8
The existing RKUSBDriver uses rkdeveloptool's 'db' and 'wl' commands to
load a first-stage loader into RAM and then write a bootloader to the
target's storage. It does not load and execute a bootloader in RAM.

Add an RKBootstrapDriver which uses barebox's rk-usb-loader tool to
upload a combined barebox image into a Rockchip SoC in MaskROM mode and
execute it from RAM, i.e. a true USB bootstrap. Both drivers bind the
existing RKUSBLoader resource.

As the rk-usb-loader name now correctly refers to the barebox tool used
by the new driver, the rkdeveloptool binary used by RKUSBDriver moves to
a dedicated 'rkdeveloptool' tools key. The previous (misnamed)
'rk-usb-loader' key is still honored for backward compatibility, emitting
a DeprecationWarning.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Assisted-by: Claude Opus 4.8
@Kwiboo

Kwiboo commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

This PR seem to be missing the RKBootstrapDriver driver?

Also please take a look at #1721 that implement Rockchip bootstrap support of IDBlock v2 images (supported by rk-usb-loader), along with IDBlock v1 images, boot_merger loader images, or separate 471/472 images.

@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 34.69388% with 32 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.0%. Comparing base (be8f3a2) to head (d3e566d).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
labgrid/driver/usbloader.py 31.5% 26 Missing ⚠️
labgrid/driver/quartushpsdriver.py 0.0% 2 Missing ⚠️
labgrid/driver/dfudriver.py 0.0% 1 Missing ⚠️
labgrid/driver/fastbootdriver.py 0.0% 1 Missing ⚠️
labgrid/driver/sigrokdriver.py 0.0% 1 Missing ⚠️
labgrid/target.py 75.0% 1 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff           @@
##           master   #1898   +/-   ##
======================================
  Coverage    45.9%   46.0%           
======================================
  Files         180     180           
  Lines       14496   14514   +18     
======================================
+ Hits         6666    6681   +15     
- Misses       7830    7833    +3     
Flag Coverage Δ
3.10 46.0% <34.6%> (+<0.1%) ⬆️
3.11 46.0% <34.6%> (+<0.1%) ⬆️
3.12 46.0% <34.6%> (+<0.1%) ⬆️
3.13 46.0% <34.6%> (+<0.1%) ⬆️
3.14 46.0% <34.6%> (+<0.1%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@saschahauer

Copy link
Copy Markdown
Contributor Author

This PR seem to be missing the RKBootstrapDriver driver?

Ups, yes. Updated now.

Also please take a look at #1721 that implement Rockchip bootstrap support of IDBlock v2 images (supported by rk-usb-loader), along with IDBlock v1 images, boot_merger loader images, or separate 471/472 images.

I wasn't aware of #1721 when I wrote this. I'll happily abandon my PR when #1721 is the way forward. I'd appreciate a word from the labgrid maintainers @jluebbe given that this is brewing for 10 months now

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