A Rust library and command-line toolkit for communicating with Rockchip devices over USB.
rkusb is a Rust library and CLI tool for working with Rockchip devices over USB.
It supports common Maskrom and Loader workflows such as downloading a loader, reading and writing storage, switching storage media, parsing Rockchip images, and writing IDBlock data.
- List devices
- Download a bootloader in Maskrom mode
- Reset devices
- Read, write, and erase raw LBAs
- Wait for device enumeration
- Query and switch storage media
- Read GPT partitions and transfer partition contents
- Parse Rockchip image files
- Generate and write IDBlock data from a loader image
Ensure you have Rust installed, then:
cargo install rkusbOn Linux you may also need libusb development headers:
# Debian / Ubuntu
sudo apt install libusb-1.0-0-dev
# Fedora / RHEL
sudo dnf install libusb1-develOn Linux you need either udev rules granting access to Rockchip USB devices, or run rktools as root.
On Windows, you must install the libusb-win32 driver for the Rockchip USB gadget device. The recommended way is to use Zadig: select the Rockchip device from the list and choose the libusb-win32 driver.
Important: Do not select the WinUSB or libusbK drivers — neither supports the
claim_interfaceoperation required byrktools.
Installing libusb-win32 will replace Rockchip's official kernel-space driver. If you later need to use Rockchip's official tools, open Device Manager, right-click the device, choose Update driver, and switch back to the official driver.
rktools [OPTIONS] <COMMAND>
Use rktools --help or rktools <COMMAND> --help to see all available options.
# basic usage
rktools db rk3588_spl_loader_v1.19.113.bin
# wait up to 30 s for the device to appear first
rktools db --wait 30s rk3588_spl_loader_v1.19.113.binrktools rst # normal reboot
rktools rst --subcode 1 # power off| Command | Aliases | Description |
|---|---|---|
list |
ls |
Enumerate connected Rockchip USB devices |
download-boot |
db |
Download a loader image to a device in Maskrom mode |
info |
- | Detect and inspect Rockchip image files |
reset |
rst |
Reset or power off a connected device |
lba |
- | Read, write, or erase raw sectors by LBA |
wait |
- | Wait for a Rockchip device to appear |
storage |
st |
Query storage, switch media, print flash info, and access GPT partitions |
upgrade-loader |
ul |
Generate and write an IDBlock from a Rockchip loader image |
rktools lsThis prints each matching USB device with its bus, address, VID:PID, and detected mode.
# wait forever until a supported device appears
rktools wait
# fail if nothing appears within 20 seconds
rktools wait 20sThis is useful in flashing scripts where the device may re-enumerate between Maskrom and Loader mode.
# inspect a Rockchip loader image
rktools info rk3588_spl_loader_v1.19.113.bin
# inspect a Rockchip firmware bundle
rktools info update.imgThe command prints the file size and a parsed debug view of the detected Rockchip image header.
# read 0x400 sectors starting at sector 0x2000
rktools lba read 0x2000 0x400 boot.img
# write a file to storage starting at sector 0x4000
rktools lba write 0x4000 rootfs.img
# erase 256 sectors starting at sector 0x8000
rktools lba erase 0x8000 256Notes:
begin_sectorandsector_countaccept decimal and0x-prefixed hexadecimal values.lba writeautomatically pads the last partial sector with zeros.--timeoutapplies to the full command, not each individual USB transfer.
The storage command family works on the currently selected storage medium and supports device selection with --bus, --addr, and --wait just like lba and upgrade-loader.
# query current storage selection
rktools storage select
# switch to eMMC
rktools storage select 1
# switch to SPI NOR
rktools storage select 9
# switch to NVMe
rktools storage select 11Known storage codes:
1= eMMC2= SD9= SPI NOR11= NVMe
rktools storage infoThis prints the parsed flash/storage information structure returned by the device.
rktools storage partition tableThe command opens the currently selected storage as a 512-byte logical block device, reads the GPT, and prints the discovered partitions.
# select by GPT partition name
rktools storage partition read --name boot boot.img
# select by partition index
rktools storage partition read --index 4 rootfs.img
# select by partition GUID
rktools storage partition read --guid 01234567-89ab-cdef-0123-456789abcdef misc.img# write by name
rktools storage partition write --name boot boot.img
# write by index
rktools storage partition write --index 4 rootfs.imgPartition write behavior:
- The target partition can be selected by exactly one of
--name,--guid, or--index. - The input file must fit inside the selected partition.
- The final partial sector is zero-padded automatically when needed.
# write the generated IDBlock to the default LBA 64
rktools upgrade-loader rk3588_spl_loader_v1.19.113.bin
# wait for the device and override the destination LBA
rktools upgrade-loader --wait 30s --lba 64 rk3588_spl_loader_v1.19.113.binupgrade-loader parses the Rockchip loader image, extracts FlashBoot and FlashData, and writes a generated IDBlock to storage. If the image also contains FlashHead, the tool will build the newer IDBlock format when the target device reports support for it.