### Compile and Install rkdeveloptool Source: https://github.com/rockchip-linux/rkdeveloptool/blob/master/Readme.txt Steps to compile and install the rkdeveloptool from source after installing dependencies. ```bash ./autogen.sh ./configure make ``` -------------------------------- ### Install Dependencies and Build rkdeveloptool Source: https://context7.com/rockchip-linux/rkdeveloptool/llms.txt Installs necessary development libraries and builds the rkdeveloptool from source on Debian/Ubuntu systems. Includes steps for installing the udev rule for non-root access. ```bash sudo apt-get install libudev-dev libusb-1.0-0-dev dh-autoreconf ./autogen.sh ./configure make sudo cp 99-rk-rockusb.rules /etc/udev/rules.d/ sudo udevadm control --reload-rules ``` -------------------------------- ### Install Dependencies for rkdeveloptool Source: https://github.com/rockchip-linux/rkdeveloptool/blob/master/Readme.txt Install necessary development libraries for compiling rkdeveloptool on Debian/Ubuntu-based systems. ```bash sudo apt-get install libudev-dev libusb-1.0-0-dev dh-autoreconf ``` -------------------------------- ### Install pkg-config and libusb-1.0 for Compilation Source: https://github.com/rockchip-linux/rkdeveloptool/blob/master/Readme.txt Install required packages to resolve compilation errors related to PKG_CHECK_MODULES and libusb-1.0. ```bash sudo apt-get install pkg-config libusb-1.0 ``` -------------------------------- ### Write GUID Partition Table Source: https://context7.com/rockchip-linux/rkdeveloptool/llms.txt Writes a GUID Partition Table (GPT) to the device. Accepts either a pre-built GPT image file or a Rockchip parameter file to generate the GPT. Adjusts disk size fields to match flash capacity. ```bash sudo rkdeveloptool gpt parameter_gpt.txt ``` ```bash sudo rkdeveloptool gpt gpt.img ``` -------------------------------- ### Download Kernel Image to Rockchip Device Source: https://github.com/rockchip-linux/rkdeveloptool/blob/master/Readme.txt Example of downloading a kernel image to a Rockchip device using rkdeveloptool. This involves downloading a loader, writing the kernel image to a specific partition, and then resetting the device. ```bash sudo ./rkdeveloptool db RKXXLoader.bin ``` ```bash sudo ./rkdeveloptool wl 0x8000 kernel.img ``` ```bash sudo ./rkdeveloptool rd ``` -------------------------------- ### Show rkdeveloptool Help and Version Source: https://context7.com/rockchip-linux/rkdeveloptool/llms.txt Displays the built-in help menu or the current version of the rkdeveloptool. Requires a connected RockUSB device. ```bash sudo rkdeveloptool -h ``` ```bash sudo rkdeveloptool -v ``` -------------------------------- ### Print Partition Table with rkdeveloptool ppt Source: https://context7.com/rockchip-linux/rkdeveloptool/llms.txt Reads and prints the partition table from the device, attempting GPT first and falling back to Rockchip parameter-based format. ```bash sudo rkdeveloptool ppt # Output (GPT example): # **********Partition Info(GPT)********** # NO LBA Name # 00 00000040 loader1 # 01 00002000 reserved1 # 02 00004000 loader2 # 03 00008000 boot # 04 00040000 rootfs ``` -------------------------------- ### Test Device Communication with rkdeveloptool td Source: https://context7.com/rockchip-linux/rkdeveloptool/llms.txt Sends a TEST_UNIT_READY command to verify that USB communication with the device is functioning correctly. ```bash sudo rkdeveloptool td # Output: Test Device OK. ``` -------------------------------- ### rkdeveloptool Commands Source: https://context7.com/rockchip-linux/rkdeveloptool/llms.txt Common commands for flashing firmware and managing partitions on Rockchip devices. ```APIDOC ## rkdeveloptool Commands This section outlines the primary commands available in the `rkdeveloptool` for interacting with Rockchip devices. ### Download USB plug / DDR init to device SDRAM ```bash sudo rkdeveloptool db ``` ### Write the full loader to flash (IDB block at LBA 64) ```bash sudo rkdeveloptool ul ``` ### Write the GPT partition table ```bash sudo rkdeveloptool gpt ``` ### Flash individual partition images by name ```bash sudo rkdeveloptool wlx ``` ### Verify partition table was written correctly ```bash sudo rkdeveloptool ppt ``` ### Reset the device to boot into the new firmware ```bash sudo rkdeveloptool rd ``` ### Erase flash (requires Loader mode) ```bash sudo rkdeveloptool ef ``` ``` -------------------------------- ### Pack Boot Loader with rkdeveloptool pack Source: https://context7.com/rockchip-linux/rkdeveloptool/llms.txt Merges DDR init, USB plug, and U-Boot loader binaries into a single signed RockBoot .bin file, using settings from config.ini. The output file includes a CRC32 checksum trailer. ```bash # config.ini must be present in the working directory sudo rkdeveloptool pack # Output: # Starting to parse... # chip: RK320A # Writing header... # Writing loader... # Writing crc... # Done. ``` -------------------------------- ### rkdeveloptool Commands for Firmware Flashing Source: https://context7.com/rockchip-linux/rkdeveloptool/llms.txt Sequence of rkdeveloptool commands for flashing firmware onto a device, from downloading the loader to resetting the device. ```bash sudo rkdeveloptool db RK3399MiniLoaderAll_V1.30.bin ``` ```bash sudo rkdeveloptool ul RK3399MiniLoaderAll_V1.30.bin ``` ```bash sudo rkdeveloptool gpt parameter_gpt.txt ``` ```bash sudo rkdeveloptool wlx boot boot.img ``` ```bash sudo rkdeveloptool wlx rootfs rootfs.ext4.img ``` ```bash sudo rkdeveloptool ppt ``` ```bash sudo rkdeveloptool rd ``` -------------------------------- ### Tag U-Boot SPL with rkdeveloptool tagspl Source: https://context7.com/rockchip-linux/rkdeveloptool/llms.txt Prepends a binary tag string to a U-Boot SPL file and writes the result to a new file with a .tag extension. This is used to embed platform-identification markers. ```bash sudo rkdeveloptool tagspl RK3399 u-boot-spl.bin # Writes: u-boot-spl.bin.tag (with "RK3399" prepended) # Output: done ``` -------------------------------- ### Download Bootloader Stub Source: https://context7.com/rockchip-linux/rkdeveloptool/llms.txt Downloads a bootloader stub (USB plug) into the device's SDRAM via Maskrom USB. This is a prerequisite for most flashing operations. ```bash sudo rkdeveloptool db RK3399MiniLoaderAll_V1.30.bin ``` -------------------------------- ### Write Image to Partition by Name Source: https://context7.com/rockchip-linux/rkdeveloptool/llms.txt Writes a binary image to a partition identified by its name. The tool automatically finds the partition's LBA from the GPT or parameter table. Supports sparse and UBIFS images. ```bash sudo rkdeveloptool wlx boot kernel.img ``` ```bash sudo rkdeveloptool wlx rootfs rootfs.ext4.img ``` -------------------------------- ### Upgrade On-Flash Bootloader Source: https://context7.com/rockchip-linux/rkdeveloptool/llms.txt Writes a new bootloader (IDB block) to the device's flash memory at LBA sector 64. Supports legacy and newer bootloader formats and handles RC4 encryption. ```bash sudo rkdeveloptool ul RK3399MiniLoaderAll_V1.30.bin ``` -------------------------------- ### Change Storage with rkdeveloptool cs Source: https://context7.com/rockchip-linux/rkdeveloptool/llms.txt Switches the active storage medium on devices that support multiple storage targets, using specific codes for eMMC, SD card, or SPI NOR flash. ```bash # Switch to eMMC (storage code 1) sudo rkdeveloptool cs 1 # Switch to SD card (storage code 2) sudo rkdeveloptool cs 2 # Switch to SPI NOR flash (storage code 9) sudo rkdeveloptool cs 9 # Output: Change Storage OK. ``` -------------------------------- ### Reset Device with rkdeveloptool rd Source: https://context7.com/rockchip-linux/rkdeveloptool/llms.txt Sends a device-reset command. Accepts an optional subcode to select the reset type, such as normal reset, power off, or reset to Maskrom mode. ```bash # Normal reset (re-enumerates as Loader/MSC) sudo rkdeveloptool rd # Reset to Maskrom mode (subcode 3) sudo rkdeveloptool rd 3 # Power off the device (subcode 2) sudo rkdeveloptool rd 2 ``` -------------------------------- ### Write Parameter with rkdeveloptool prm Source: https://context7.com/rockchip-linux/rkdeveloptool/llms.txt Writes a Rockchip parameter file to the legacy parameter area. The file must be prefixed with a specific magic header and CRC32 trailer. ```bash sudo rkdeveloptool prm parameter.txt # Output: # Writing parameter... # Writing parameter succeeded. ``` -------------------------------- ### List Connected Rockchip USB Devices Source: https://context7.com/rockchip-linux/rkdeveloptool/llms.txt Lists all connected Rockchip USB devices recognized by the rkdeveloptool, showing their device number, vendor/product IDs, and mode (Maskrom or Loader). ```bash sudo rkdeveloptool ld ``` -------------------------------- ### Unpack Boot Loader with rkdeveloptool unpack Source: https://context7.com/rockchip-linux/rkdeveloptool/llms.txt Extracts embedded entries (DDR init, USB plug, loader binaries) from a RockBoot .bin file. Each entry is decrypted with RC4 before being written to the current directory. ```bash sudo rkdeveloptool unpack RK3399MiniLoaderAll_V1.30.bin # Output: # 471 num:1, 472 num:1, loader num:2 # entry num: 4 # unpacking entry (rk3399_ddr_400MHz) # unpacking entry (rk3399_usbplug) # unpacking entry (FlashData) # unpacking entry (FlashBoot) # done ``` -------------------------------- ### CRKUsbComm: Low-Level USB Communication Class Source: https://context7.com/rockchip-linux/rkdeveloptool/llms.txt C++ class for raw libusb operations, using bulk-transfer endpoints with CBW/CSW framing. Instantiate with a device handle and log object. ```cpp CRKUsbComm *pComm = new CRKUsbComm(dev, g_pLogObject, bRet); if (!bRet) { fprintf(stderr, "Failed to open USB device\n"); return false; } // Read 34 sectors (GPT area) starting at LBA 0 u8 buf[34 * 512]; int ret = pComm->RKU_ReadLBA(0, 34, buf); if (ret != ERR_SUCCESS) { fprintf(stderr, "RKU_ReadLBA failed: %d\n", ret); } // Write 128 sectors from a buffer to LBA 0x8000 u8 writeBuf[128 * 512] = { /* image data */ }; ret = pComm->RKU_WriteLBA(0x8000, 128, writeBuf); // Read 5-byte flash chip ID u8 flashId[5]; pComm->RKU_ReadFlashID(flashId); printf("Flash ID: %02X %02X %02X %02X %02X\n", flashId[0], flashId[1], flashId[2], flashId[3], flashId[4]); // Reset the device to Maskrom mode pComm->RKU_ResetDevice(RST_RESETMASKROM_SUBCODE); delete pComm; ``` -------------------------------- ### Detect Device in Maskrom Mode with rkdeveloptool ld Source: https://context7.com/rockchip-linux/rkdeveloptool/llms.txt Verifies if the device is detected in Maskrom mode, typically after holding the RECOVERY/MASKROM button and connecting USB. ```bash # 1. Hold RECOVERY/MASKROM button and connect USB # Verify device is detected in Maskrom mode sudo rkdeveloptool ld ``` -------------------------------- ### CRKScan: Rockchip Device Discovery Source: https://context7.com/rockchip-linux/rkdeveloptool/llms.txt C++ class to enumerate connected Rockchip USB devices and classify them as Maskrom or Loader type. Use SetVidPid() to load default VID/PID. ```cpp CRKScan *pScan = new CRKScan(); pScan->SetVidPid(); // load default VID/PID table // Search for Maskrom and Loader devices int cnt = pScan->Search(RKUSB_MASKROM | RKUSB_LOADER); printf("Found %d device(s)\n", cnt); STRUCT_RKDEVICE_DESC dev; if (pScan->GetDevice(dev, 0)) { printf("VID=0x%04X PID=0x%04X Type=%s\n", dev.usVid, dev.usPid, dev.emUsbType == RKUSB_MASKROM ? "Maskrom" : "Loader"); } // Wait up to 20 seconds for a device to re-enumerate as Maskrom pScan->Wait(dev, RKUSB_MASKROM, dev.usVid, dev.usPid); delete pScan; ``` -------------------------------- ### Read Detailed Flash Info with rkdeveloptool rfi Source: https://context7.com/rockchip-linux/rkdeveloptool/llms.txt Reads detailed information about the flash chip, including manufacturer, size, sector count, block size, page size, and ECC bits. ```bash # Read detailed flash info sudo rkdeveloptool rfi # Output: # Flash Info: # Manufacturer: Samsung, value=EC # Flash Size: 7452 MB # Flash Size: 15253504 Sectors # Block Size: 512 KB # Page Size: 2 KB # ECC Bits: 24 ``` -------------------------------- ### Read Chip Info Buffer with rkdeveloptool rci Source: https://context7.com/rockchip-linux/rkdeveloptool/llms.txt Reads the 16-byte chip info buffer from the device. ```bash # Read the 16-byte chip info buffer sudo rkdeveloptool rci # Output: Chip Info: 33 39 39 38 ... ``` -------------------------------- ### Read Capability Flags with rkdeveloptool rcb Source: https://context7.com/rockchip-linux/rkdeveloptool/llms.txt Reads capability flags, indicating features like Direct LBA, Vendor Storage, and New IDB support. ```bash # Read capability flags (Direct LBA, Vendor Storage, New IDB, etc.) sudo rkdeveloptool rcb # Output: # Capability: 0F 03 00 00 00 00 00 00 # Direct LBA: enabled # Vendor Storage: enabled # New IDB: enabled ``` -------------------------------- ### Read LBA Sectors from Flash Source: https://context7.com/rockchip-linux/rkdeveloptool/llms.txt Reads a specified number of LBA sectors from the device's flash memory and saves them to a local file. Progress is shown as a percentage. ```bash sudo rkdeveloptool rl 0x8000 0x2000 backup.img ``` ```bash sudo rkdeveloptool rl 0 34 gpt_dump.bin ``` -------------------------------- ### Write Raw Image to LBA Sector Source: https://context7.com/rockchip-linux/rkdeveloptool/llms.txt Writes a binary image to a specified LBA sector in the device's flash. Handles sparse Android images and pre-erases UBIFS images. ```bash sudo rkdeveloptool wl 0x8000 boot.img ``` ```bash sudo rkdeveloptool wl 0x40000 system.img ``` -------------------------------- ### CRKScan Class Source: https://context7.com/rockchip-linux/rkdeveloptool/llms.txt Device discovery class for enumerating and classifying connected Rockchip USB devices. ```APIDOC ## CRKScan `CRKScan` enumerates connected Rockchip USB devices using libusb and classifies them as Maskrom or Loader type. ### Methods - **SetVidPid()**: Loads the default VID/PID table. - **Search(device_types)**: Searches for connected devices of specified types. - `device_types` (int): Bitmask of device types to search for (e.g., `RKUSB_MASKROM | RKUSB_LOADER`). - Returns the number of devices found. - **GetDevice(dev_desc, index)**: Retrieves the description of a device at a given index. - `dev_desc` (STRUCT_RKDEVICE_DESC&): Reference to a structure to populate with device details. - `index` (int): The index of the device to retrieve. - Returns `true` if successful, `false` otherwise. - **Wait(dev_desc, device_type, vid, pid, timeout)**: Waits for a device to re-enumerate as a specific type. - `dev_desc` (STRUCT_RKDEVICE_DESC&): Reference to a structure to populate with device details. - `device_type` (int): The target device type (e.g., `RKUSB_MASKROM`). - `vid` (int): Vendor ID. - `pid` (int): Product ID. - `timeout` (int, optional): Maximum time to wait in seconds. ### Device Types - `RKUSB_MASKROM` - `RKUSB_LOADER` ``` -------------------------------- ### CRKUsbComm Class Source: https://context7.com/rockchip-linux/rkdeveloptool/llms.txt Low-level USB communication class wrapping libusb operations for Rockchip devices. ```APIDOC ## CRKUsbComm `CRKUsbComm` is the C++ class that wraps all raw libusb operations. It implements the `CRKComm` interface and is instantiated internally by every high-level command. It uses bulk-transfer endpoints with CBW/CSW framing. ### Methods - **RKU_ReadLBA(start_lba, num_sectors, buffer)**: Reads data from the device's storage. - `start_lba` (int): The starting Logical Block Address. - `num_sectors` (int): The number of sectors to read. - `buffer` (u8*): Pointer to the buffer where data will be stored. - Returns `ERR_SUCCESS` on success, or an error code on failure. - **RKU_WriteLBA(start_lba, num_sectors, buffer)**: Writes data to the device's storage. - `start_lba` (int): The starting Logical Block Address. - `num_sectors` (int): The number of sectors to write. - `buffer` (u8*): Pointer to the buffer containing data to write. - Returns `ERR_SUCCESS` on success, or an error code on failure. - **RKU_ReadFlashID(buffer)**: Reads the flash chip ID. - `buffer` (u8*): Pointer to a buffer to store the 5-byte flash ID. - **RKU_ResetDevice(subcode)**: Resets the device. - `subcode` (int): Specifies the reset type, e.g., `RST_RESETMASKROM_SUBCODE`. ### Error Codes | Code | Meaning | |------|---------| | `0` (`ERR_SUCCESS`) | Operation succeeded | | `-1` | Device open failed | | `-3` | USB write failed | | `-4` | USB read failed | | `-6` | Device not ready | | `-7` | Bad block found | | `-10` | Device does not support operation | ``` -------------------------------- ### Erase Flash with rkdeveloptool ef Source: https://context7.com/rockchip-linux/rkdeveloptool/llms.txt Erases all blocks on the connected flash device. This command iterates block-by-block or uses specific eMMC erase commands and waits for the device to re-enumerate in Maskrom mode. ```bash sudo rkdeveloptool ef # Output: # Starting to erase flash... # Erase Flash total 65536, current 65536 # Erasing flash complete. ``` -------------------------------- ### Read Flash Chip ID with rkdeveloptool rid Source: https://context7.com/rockchip-linux/rkdeveloptool/llms.txt Reads the NAND/eMMC flash chip ID, which is typically 5 bytes long. ```bash # Read the NAND/eMMC flash chip ID (5 bytes) sudo rkdeveloptool rid # Output: Flash ID: EC D3 84 72 57 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.