How to get the unit into recovery mode (with photos): recovery-mode.md.
How to write a whole OS image to the board's eMMC from a host computer over the micro-USB port labelled COM, with no SD card. Developed and tested on one G295 (RK3566/RK3568, 58 GiB Samsung eMMC, U-Boot from the community Armbian image).
Status: worked on one unit (flashed the eMMC image over USB, it booted and installed itself; settings seeding on top of
that has not been run yet). The steps below were run by hand; the build script
(tools/usb-flash/build-flashmode.sh) reproduces the pieces but the whole procedure is not yet automated or run on
other units.
Use bobcat-g295-emmc.img.xz (a release asset from v0.2.5): the Armbian OS the eMMC flasher installs, with this
project's installer and first-boot service already in it. It uses the generic Armbian boot script, which picks the
boot device and the root filesystem by itself, so it boots from the eMMC.
Do not write the standalone SD image (bobcat-g295-reticulum.img.xz) to the eMMC. Its boot script is hard-wired
to the SD card: it loads the kernel with load mmc 1:1 (the SD slot) and sets root=/dev/mmcblk0p2, but on this board
the eMMC is mmcblk1. Written to the eMMC it was verified byte for byte and still never booted (solid blue LED; the
root filesystem was untouched, with no first boot). The same method with the eMMC image booted and ran the installer.
The board's download mode (hold Recovery, press Reset; the host sees 2207:350a "USB download gadget" and
rkdeveloptool ld says Loader) reads and writes only the first 32 MiB of the eMMC (sectors 0-65,535). Past
that it answers every command with success and returns a repeated 0xCC. Tested with rkdeveloptool and with a
separate minimal rockusb client (tools/usb-flash/rockusb_probe.py), at every read/write sub-code, and after
CHANGE_STORAGE: identical, so the limit is in the board's U-Boot, not the host tool. A full-image write in this mode
looks successful and leaves a unit that cannot boot (the read-back is the only way to see it).
The same U-Boot has a ums command (ums 0 mmc 0) that exports the whole eMMC as a USB disk, with no limit. Download
mode can write the small area where U-Boot looks for a boot script. So:
tools/usb-flash/build-flashmode.sh makes boot.scr (a compiled script that runs
ums 0 mmc 0), an 8 MiB FAT12 fat.img holding it, and a gpt.bin whose only partition is that FAT at sectorgpt.bin at sector 0 and fat.img at sector 32768 (rkdeveloptool wl 0 gpt.bin,
rkdeveloptool wl 32768 fat.img) and read them back to check. Note rkdeveloptool rl takes its length in
bytes, not sectors.rkdeveloptool rd, or the Reset button). U-Boot runs boot.scr and the board shows up as
2207:0010 "USB download gadget" and a new disk, model "UMS disk 0", 122,142,720 sectors on the unit tested.dd (bs=4M conv=fsync) and verify with cmp -n <image size> <image> <disk>.
Check the model and sector count first: the host disk node (often /dev/sda) is the Bobcat's eMMC now.Measured: 2.84 GB written in 144 s (19.8 MB/s); the byte-for-byte verification of the whole image matched.
U-Boot's ums makes the board a mass-storage disk, which browsers cannot open (WebUSB blocks that class). The same
U-Boot also has fastboot usb 0, which WebUSB can use. Verified on one unit:
fastboot usb 0 (tools/usb-flash/build-flashmode.sh --mode fastboot) written through download
mode makes the board appear as 18d1:4d00, interface class ff/42/03 (standard fastboot).getvar all: max-download-size 0x04000000 (64 MiB), partitions listed by GPT name with type and size,
unlocked: no, secure: yes. Flashing is not blocked by the lock state: fastboot flash returned OKAY while it
reported unlocked: no; flashing unlock is not implemented.fastboot flash gpt returns OKAY but did not change the partitions the board lists in the same session; the table is
set through download mode (rockusb) instead, which works.fat.img holding boot.scr (runs
fastboot usb 0) at sector 32768, where the image's bootfs starts. Reset the device.flash rootfs, then flash bootfs last (it overwrites the temporary boot partition with the real one,
including any settings file), then reboot. No partition table change is needed afterwards.Not yet done: this whole sequence on a real image, and the browser version (WebUSB) of either step.
A unit that still runs the factory firmware has Rockchip's own U-Boot (2017.09, Jan 2022), not the community one. Differences found on a G290 (59,325 MB eMMC, 121,497,728 sectors):
2207:350a, bcdDevice 0100, no product name), not in U-Boot's download
mode. A loader has to be sent first. The standard RK3566 loader from rkbin (RK3566MINIALL.ini, built with
boot_merger, sent with rkdeveloptool db) worked: the board re-enumerates as USB-MSC and answers
rockusb. Reads and writes are still limited to the first 32 MiB.bootfs starts, 16 MiB, containing the idbloader and U-Boot)
fixed it: after a reset the board appeared as fastboot (18d1:4d00) within two seconds.rootfs ends past the end of the disk is judged
invalid and rewritten by the factory U-Boot with its own Android layout. The page takes the size from the board.uboot. A valid table without one made the board fall back
to Maskrom. This stops mattering once the community bootloader is in place.The web page's first phase therefore writes the partition table, the boot area and the image's bootloader
region, then verifies all three. The page also does the Maskrom stage itself (site/flash/maskrom.mjs): when the device it is given is in Maskrom
(bcdDevice 0100, no product name) it downloads the two loader files from a pinned commit of Rockchip's public rkbin
repository (then the fork nmadd57/rkbin, then nmadd57/rockchip-loader-mirror, which holds just these two files, if the first is unavailable), checks their SHA-256, and sends them with the boot ROM's vendor requests (0x471 DRAM init, then 0x472 USB
plug; 4096-byte pieces, CRC-CCITT at the end), exactly as rkdeveloptool db does. Verified on a G290: the module,
run through Node's WebUSB implementation, took a board from Maskrom to the USB-MSC loader state. A U-Boot unit can be
put back into Maskrom with rkdeveloptool rd 3 from its download mode.
Before overwriting a factory unit, save its first 32 MiB (rkdeveloptool rl 0 33554432 backup.bin).
The page does the two phases above from Chrome or Edge over WebUSB: download mode writes the image's partition
table (with rootfs extended to the end of the disk) and a temporary 8 MiB boot partition holding a
fastboot usb 0 script, then resets; fastboot then flashes rootfs, and bootfs last (with
bobcat-install.conf added to it), and reboots. The image (bobcat-g295-emmc.img.xz or the unpacked .img) is
chosen from disk because GitHub release downloads send no CORS headers. The .xz is decompressed in the browser.
Tested: every module against emulated boards and real filesystem tools (test/test-flash-*.mjs), the sparse
encoder against simg2img, and the fastboot write path by hand on a real unit. Not yet tested: the page
itself on a real unit. Linux needs a udev rule for the USB ids; Windows needs the WinUSB driver.
For the standalone image, put bobcat-install.conf on its FAT boot partition before writing (inside the image file,
for example mcopy -i image.img@@$((32768*512)) bobcat-install.conf ::bobcat-install.conf). The first boot reads it.
ums, or number its MMC devices differently
(ums 0 mmc 0 is the eMMC here).