- 通过USB下载固件
1。进入rockusb 模式
2。使用 rkdeveloptool工具下载
- rockusb模式
在rockusb模式下,可通过rkdeveloptool:
– 对eMMC/sdcard/SPI nor flash做读写操作
– 可获取存储设备信息
– 获取分区表信息
– 获取芯片信息
– 重启
进入rockusb模式的方法:
1。 通过maskrom模式进入:
– 通过rkdeveloptool 加载bootloader (rk3399_loader_v1.12.112.bin) 进入rockusb模式
$ ../rkbin/tools/rkdeveloptool db rk3399_loader_v1.12.112.bin
2。通过u-boot中的rockusb命令进入
- 固件下载
对于只使用sdcard作为启动设备的情况,目前看来只能通过先将idbloader.img, uboot.img及trust.img通过读卡器写入到sdcard:
如:
#! /bin/bash dd if=/dev/zero of=/dev/sdc bs=$((1024*1024)) count=16 conv=notrunc dd if=idbloader.img of=/dev/sdc bs=512 seek=$((0x40)) conv=notrunc dd if=uboot.img of=/dev/sdc bs=512 seek=$((0x4000)) conv=notrunc dd if=trust.img of=/dev/sdc bs=512 seek=$((0x6000)) conv=notrunc
写入完之后,第一次开机如果找不到gpt分区表,会重新创建分区表:
DDR Version 1.22 20190506 In channel 0 CS = 0 MR0=0x98 MR4=0x3 MR5=0xFF MR8=0x8 MR12=0x72 MR14=0x72 MR18=0x0 MR19=0x0 MR24=0x8 MR25=0x0 channel 1 CS = 0 MR0=0x98 MR4=0x3 MR5=0xFF MR8=0x8 MR12=0x72 MR14=0x72 MR18=0x0 MR19=0x0 MR24=0x8 MR25=0x0 channel 0 training pass! channel 1 training pass! change freq to 416MHz 0,1 Channel 0: LPDDR4,416MHz Bus Width=32 Col=10 Bank=8 Row=15 CS=1 Die Bus-Width=16 Size=1024MB Channel 1: LPDDR4,416MHz Bus Width=32 Col=10 Bank=8 Row=15 CS=1 Die Bus-Width=16 Size=1024MB 256B stride channel 0 CS = 0 MR0=0x98 MR4=0x3 MR5=0xFF MR8=0x8 MR12=0x72 MR14=0x72 MR18=0x0 MR19=0x0 MR24=0x8 MR25=0x0 channel 1 CS = 0 MR0=0x98 MR4=0x81 MR5=0xFF MR8=0x8 MR12=0x72 MR14=0x72 MR18=0x0 MR19=0x0 MR24=0x8 MR25=0x0 channel 0 training pass! channel 1 training pass! channel 0, cs 0, advanced training done channel 1, cs 0, advanced training done change freq to 856MHz 1,0 ch 0 ddrconfig = 0x101, ddrsize = 0x20 ch 1 ddrconfig = 0x101, ddrsize = 0x20 pmugrf_os_reg[2] = 0x3281F281, stride = 0x9 OUT Boot1: 2019-03-14, version: 1.19 CPUId = 0x0 ChipType = 0x10, 254 mmc: ERROR: SDHCI ERR:cmd:0x102,stat:0x18000 mmc: ERROR: Card did not respond to voltage select! emmc reinit mmc: ERROR: SDHCI ERR:cmd:0x102,stat:0x18000 mmc: ERROR: Card did not respond to voltage select! emmc reinit mmc: ERROR: SDHCI ERR:cmd:0x102,stat:0x18000 mmc: ERROR: Card did not respond to voltage select! SdmmcInit=2 1 mmc0:cmd5,20 SdmmcInit=0 0 BootCapSize=0 UserCapSize=30436MB FwPartOffset=2000 , 0 StorageInit ok = 56385 SecureMode = 0 SecureInit read PBA: 0x4 SecureInit read PBA: 0x404 SecureInit read PBA: 0x804 SecureInit read PBA: 0xc04 SecureInit read PBA: 0x1004 SecureInit read PBA: 0x1404 SecureInit read PBA: 0x1804 SecureInit read PBA: 0x1c04 SecureInit ret = 0, SecureMode = 0 atags_set_bootdev: ret:(0) GPT 0x3380ec0 signature is wrong recovery gpt... GPT part: 0, name: loader1, start:0x40, size:0x1f40 GPT part: 1, name: loader2, start:0x4000, size:0x2000 GPT part: 2, name: trust, start:0x6000, size:0x2000 GPT part: 3, name: boot, start:0x8000, size:0x38000 GPT part: 4, name: rootfs, start:0x40000, size:0x3b323df recovery gpt success! no find partition:uboot. LoadTrust Addr:0x4000 No find bl30.bin No find bl32.bin Load uboot, ReadLba = 2000 hdr 0000000003380880 + 0x0:0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, Load OK, addr=0x200000, size=0xc98f4 RunBL31 0x10000 NOTICE: BL31: v1.3(debug):0e7a845 NOTICE: BL31: Built : 16:13:46, Apr 17 2019 NOTICE: BL31: Rockchip release version: v1.1 INFO: GICv3 with legacy support detected. ARM GICV3 driver initialized in EL3 INFO: Using opteed sec cpu_context! INFO: boot cpu mask: 0 INFO: plat_rockchip_pmu_init(1181): pd status 3e INFO: BL31: Initializing runtime services WARNING: No OPTEE provided by BL2 boot loader, Booting device without OPTEE initialization. SMC`K ERROR: Error initializing runtime service opteed_fast INFO: BL31: Preparing for EL3 exit to normal world INFO: Entry point address = 0x200000 INFO: SPSR = 0x3c9 U-Boot 2017.09-00011-g0568348 (Jul 22 2019 - 01:28:51 +0800) Model: ROCK PI 4 Board DRAM: 2 GiB Relocation Offset is: 7dc05000 PMIC: RK808 pwm-regulator(vdd-center): init 950000 uV vdd_center 950000 uV regulator(vdd-center) init 950000 uV MMC: dwmmc@fe320000: 1, sdhci@fe330000: 0 Using default environment Warn: can't find connect driver Failed to found available display route Warn: can't find connect driver Failed to found available display route In: serial Out: serial Err: serial Model: ROCK PI 4 Board Enable PCIE Power for ROCKPI4 board rk3399_force_pcie_power_on: trying to force pcie power on RKPARM: Invalid parameter part table switch to partitions #0, OK mmc1 is current device do_rkimg_test found IDB in SDcard Boot from SDcard RKPARM: Invalid parameter part table get part misc fail -1 Net: eth0: ethernet@fe300000 Hit any key to stop autoboot: 0 switch to partitions #0, OK mmc1 is current device RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table RKPARM: Invalid parameter part table ** No partition table - mmc 1 ** Card did not respond to voltage select! mmc_init: -95, time 26 starting USB... USB0: USB EHCI 1.00 USB1: USB OHCI 1.0 USB2: USB EHCI 1.00 USB3: USB OHCI 1.0 USB4: Can't get the usbphy register address probe failed, error -6 USB5: Can't get the usbphy register address probe failed, error -6 scanning bus 0 for devices... 1 USB Device(s) found scanning bus 1 for devices... 1 USB Device(s) found scanning bus 2 for devices... 1 USB Device(s) found scanning bus 3 for devices... 1 USB Device(s) found scanning usb for storage devices... 0 Storage Device(s) found Device 0: unknown device DMA reset timeout missing environment variable: pxeuuid missing environment variable: bootfile Retrieving file: pxelinux.cfg/01-26-1f-c5-4c-71-80 DMA reset timeout missing environment variable: bootfile Retrieving file: pxelinux.cfg/00000000 DMA reset timeout missing environment variable: bootfile Retrieving file: pxelinux.cfg/0000000 DMA reset timeout missing environment variable: bootfile Retrieving file: pxelinux.cfg/000000 DMA reset timeout missing environment variable: bootfile Retrieving file: pxelinux.cfg/00000 DMA reset timeout missing environment variable: bootfile Retrieving file: pxelinux.cfg/0000 DMA reset timeout missing environment variable: bootfile Retrieving file: pxelinux.cfg/000 DMA reset timeout missing environment variable: bootfile Retrieving file: pxelinux.cfg/00 DMA reset timeout missing environment variable: bootfile Retrieving file: pxelinux.cfg/0 DMA reset timeout missing environment variable: bootfile Retrieving file: pxelinux.cfg/default-arm-rockchip DMA reset timeout missing environment variable: bootfile Retrieving file: pxelinux.cfg/default-arm DMA reset timeout missing environment variable: bootfile Retrieving file: pxelinux.cfg/default DMA reset timeout Config file not found DMA reset timeout DMA reset timeout Card did not respond to voltage select! mmc_init: -95, time 19 Could not get mmc 0 Card did not respond to voltage select! mmc_init: -95, time 18 do_boot_rockchip: dev_desc is NULL! => <INTERRUPT>
可以看到,之后可以进入到u-boot命令行交互模式。
注:
1。 从目前来看,从maskrom模式进入rockusb模式时,可能只能读写eMMC设备,并且也没有找到相关的命令使rkdeveloptool写入到特定的设备。
2。通地rkdeveloptool加载rk3399_loader_spinor_v1.15.114.bin 应该是对SPI flash进行读写操作(我手头上这块板子虽然是v1.4的版本,但没有SPI flash,无法验证。
3。在这种模式下,看起来CPU与DDR在全速运行,需要注意散热。
- u-boot相关命令
1。 printenv
=> printenv arch=arm baudrate=1500000 board=evb_rk3399 board_name=evb_rk3399 boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefix}${script}; source ${scriptaddr} boot_efi_binary=load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} efi/boot/bootaa64.efi; if fdt addr ${fdt_addr_r}; then bootefi $i boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}extlinux/extlinux.conf boot_net_usb_start=usb start boot_prefixes=/ /boot/ boot_script_dhcp=boot.scr.uimg boot_scripts=boot.scr.uimg boot.scr boot_targets=mmc1 mmc0 usb0 pxe dhcp bootargs=sdfwupdate storagemedia=sd androidboot.mode=sd bootcmd=run distro_bootcmd;boot_android ${devtype} ${devnum};bootrkp; bootcmd_dhcp=run boot_net_usb_start; if dhcp ${scriptaddr} ${boot_script_dhcp}; then source ${scriptaddr}; fi;setenv efi_fdtfile ${fdtfile}; s; bootcmd_mmc0=setenv devnum 0; run mmc_boot bootcmd_mmc1=setenv devnum 1; run mmc_boot bootcmd_pxe=run boot_net_usb_start; dhcp; if pxe get; then pxe boot; fi bootcmd_usb0=setenv devnum 0; run usb_boot bootdelay=1 cpu=armv8 cpuid#=544e4d3237372e3030000000000d0085 devnum=0 devplist=1 devtype=mmc distro_bootcmd=for target in ${boot_targets}; do run bootcmd_${target}; done efi_dtb_prefixes=/ /dtb/ /dtb/current/ ethact=ethernet@fe300000 ethaddr=26:1f:c5:4c:71:80 fdt_addr_r=0x01f00000 fdt_overlay_addr_r=0x01e00000 fdtcontroladdr=7bdefe18 fdtfile=rockchip/rockpi-4b-linux.dtb hw_conf_addr_r=0x00700000 kernel_addr_r=0x02080000 load_efi_dtb=load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${prefix}${efi_fdtfile} mmc_boot=if mmc dev ${devnum}; then setenv devtype mmc; run scan_dev_for_boot_part; fi partitions=uuid_disk=${uuid_gpt_disk};name=loader1,start=32K,size=4000K,uuid=${uuid_gpt_loader1};name=loader2,start=8MB,size=4MB,uuid=${uuid_g; pxefile_addr_r=0x00600000 ramdisk_addr_r=0x0a200000 rkimg_bootdev=if mmc dev 1 && rkimgtest mmc 1; then setenv devtype mmc; setenv devnum 1; echo Boot from SDcard;elif mmc dev 0; then setenv dev scan_dev_for_boot=echo Scanning ${devtype} ${devnum}:${distro_bootpart}...; for prefix in ${boot_prefixes}; do run scan_dev_for_extlinux; run ; scan_dev_for_boot_part=part list ${devtype} ${devnum} -bootable devplist; env exists devplist || setenv devplist 1; for distro_bootpart in ${de scan_dev_for_efi=setenv efi_fdtfile ${fdtfile}; for prefix in ${efi_dtb_prefixes}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${pree scan_dev_for_extlinux=if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}extlinux/extlinux.conf; then echo Found ${prefix}extlinux/exi scan_dev_for_scripts=for script in ${boot_scripts}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${script}; then echo Found e scriptaddr=0x00500000 serial#=19966aae93c9e2d5 soc=rockchip stderr=serial,vidconsole stdout=serial,vidconsole usb_boot=usb start; if usb dev ${devnum}; then setenv devtype usb; run scan_dev_for_boot_part; fi vendor=rockchip Environment size: 4570/32764 bytes
2。mmcinfo 当前mmc设备信息(我使用是sankdisk 32G TF卡):
=> mmcinfo Device: dwmmc@fe320000 Manufacturer ID: 3 OEM: 5344 Name: SC32G Timing Interface: Legacy Tran Speed: 50000000 Rd Block Len: 512 SD version 3.0 High Capacity: Yes Capacity: 29.7 GiB Bus Width: 4-bit Erase Group Size: 512 Bytes
3。mmc list
=> mmc list dwmmc@fe320000: 1 (SD) sdhci@fe330000: 0
4。rockusb (进入rockusb 模式)
=> rockusb 0 mmc 1 RKUSB: LUN 0, dev 1, hwpart 0, sector 0x0, count 0x3b72400
这时,我们就可以通过rkdeveloptool对sdcard进行读写操作了,如:
$ time ../rkbin/tools/rkdeveloptool rl 0 0x80000 sdcard_256MiB.bin Read LBA to file (100%) real 0m20.799s user 0m0.254s sys 0m0.982s
读写速度差不多在12MiB左右。
- 相关的参考文档
http://opensource.rock-chips.com/wiki_Rockusb