Skip to content

Build script for building firmware (ARM systemready) for the RockPro64 board.

License

Notifications You must be signed in to change notification settings

MontaVista-OpenSourceTechnology/rockpro64-firmware

Repository files navigation

RockPro64 ARM SystemReady Firmware

This repository builds firmware for a RockPro 64 that can be used for SystemReady OSes.

Building

To build it, you will need to install an aarch64 and arm compiler, probably in packages named "gcc-aarch64-linux-gnu" and "gcc-arm-none-eabi". You will also need "python3-setuptools". Then check out this repository and "cd" do it. Then do:

git submodule init
git submodule update
make -j `nproc`

The binary files will be in the "bin" directory. There will be three files:

  • idbloader.img - The first-stage and second loader for an SD card or eMMC card.
  • u-boot.itb - u-boot for the card for an SD card.
  • u-boot-spi.img - A complete image for writing to SPI.

The makefile will spit out instruction on how to burn it at the end of the run.

Baud Rate

The standard baud rate for these boards is 1500000 baud, for some strange reason. The default baud rate for an ARM systemready image is 115200. So there are patches here to adjust the baud rate to 115200. If you are following the instructions elsewhere, be sure to account for this.

Installing

The rk3399 boots from SPI first, followed by eMMC, followed by the SD card. So if you have valid firmware in the SPI, it will not boot anything else. Else if you have firmware in eMMC, it will not boot from SD.

To install on an SD card or eMMC on a host system, do:

  sudo dd if=bin/idbloader.img of=/dev/mmcblkX seek=64
  sudo dd if=bin/u-boot.itb of=/dev/mmcblkX seek=16384
  sync

to an SD device, replacing X with your specific card. Note that if you use an adapter the device may appear as /dev/sdX on your host system. Also, this is the same when running Linux on the RockPine64. On Linux on the RockPine64, /dev/mmcblk0 is the eMMC device and /dev/mmcblk1 is the SD card.

You can also do this on the RockPin64 running u-boot. The eMMC is mmc dev 0, the SD card is mmc dev 1. To write the firmware to the one of these, do:

  mmc dev <n>
  mmc info  (verify that Rd Block Len is 512)
  dhcp
  tftp 0x2000000 idbloader.img
  (Calculate the length in 512 byte blocks from the 'Bytes transferred'.
   Convert that to hexidecimal and use that in the next command.  If it's
   not an even number of 512 bytes, you have to round up the length.  For
   instance, for 172032 (decimal) bytes, 172032 / 512 = 1845.  172032 % 512
   is not zero, so round up to 1846, which is 0x7e6 blocks for length.)
  mmc write 0x2000000 0x40 <length>
  tftp 0x2000000 u-boot.itb
  (Calculate the length again as above.)
  mmc write 0x2000000 0x4000 <length>

For spi, you will need to boot u-boot on the card somehow then load u-boot-spi.img into memory somehow and write it to SPI. Something like:

  dhcp
  tftp 0x2000000 u-boot-spi.img
  sf probe
  sf update 0x2000000 0 <size>

where is the size (in hex) reported by the download. You can also "dd" it to /dev/mtdblock0 on Linux. Don't forget to sync before rebooting.

Upgrading

If you upgrade from an older version of this, in u-boot you may need to run:

  env default -a
  env save

and the reset. The older environment will not work.

Bypassing SPI boot

If your SPI gets messed up or the boot process fails for some reason, do not despair! Power off the board, then get a jumper and short pins 23 and 25 on the Pi compatible header. This will disable the SPI. Then power the board on. Then it will boot from the next device in the sequence. Note that as soon as you see output from the board you should remove the jumper or your SPI device may not be available.

If you want to remove the firmware from the SPI, you can erase the first part of it by doing the following in u-boot:

sf erase 0 4000

or in Linux you can use "dd" to copy /dev/zero into /dev/mtd0.

Useful Resources

I pulled information from all over the place, including:

https://stikonas.eu/wordpress/2019/09/15/blobless-boot-with-rockpro64/

https://gitlab.arm.com/systemready/firmware-build/rk3399-manifest

https://opensource.rock-chips.com/wiki_RK3399

https://opensource.rock-chips.com/images/e/ee/Rockchip_RK3399TRM_V1.4_Part1-20170408.pdf

https://opensource.rock-chips.com/wiki_Boot_option

https://blog.3mdeb.com/2021/2021-12-03-rockchip-secure-boot/

About

Build script for building firmware (ARM systemready) for the RockPro64 board.

Resources

License

Stars

Watchers

Forks

Packages

No packages published