u-boot/board/theobroma-systems/puma_rk3399
Quentin Schulz b1f1b4a5a5 rockchip: puma-rk3399: load environment from same medium as one used to load U-Boot proper
Chances are when one boots U-Boot proper from a given storage medium,
they want the same medium to be used to load and store the environment.

This basically allows to have completely separate U-Boot (TPL/SPL/U-Boot
proper/environment) per storage medium which is convenient when working
with recovery from SD-Card as one would just need to insert a properly
configured SD-Card into the device to have access to their whole debug
setup.

No fallback mechanism is provided as to not dirty other storage medium
environment by mistake. However, since arch_env_get_location() is called
by env_init() which is part of the pre-relocation process, a valid,
non-ENVL_UNKNOWN, value shall be returned otherwise the relocation fails
with the following message:
initcall sequence 00000000002866c0 failed at call 0000000000256b34 (err=-19)

This valid, non-ENVL_UNKNOWN, value is ENVL_NOWHERE which requires to
always select CONFIG_ENV_IS_NOWHERE otherwise this work-around does not
work.

Cc: Quentin Schulz <foss+uboot@0leil.net>
Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
2022-10-19 19:30:49 +08:00
..
Kconfig rockchip: puma-rk3399: remove unused default ENV_OFFSET for SPI flashes 2022-10-19 19:30:49 +08:00
MAINTAINERS rockchip: puma/lion: update MAINTAINERS file 2022-01-07 09:30:44 -05:00
Makefile rockchip: ARM64: split RK3399-Q7 board off the RK3399-EVB board 2017-04-15 10:13:17 -06:00
puma-rk3399.c rockchip: puma-rk3399: load environment from same medium as one used to load U-Boot proper 2022-10-19 19:30:49 +08:00
README doc: rockchip: puma: update build and flash instructions 2021-12-24 14:53:31 +08:00

Introduction
============

The RK3399-Q7 (Puma) is a system-on-module featuring the Rockchip
RK3399 in a Qseven-compatible form-factor.

RK3399-Q7 features:
	* CPU: ARMv8 64bit Big-Little architecture,
		* Big: dual-core Cortex-A72
		* Little: quad-core Cortex-A53
		* IRAM: 200KB
	* DRAM: 4GB-128MB dual-channel
	* eMMC: onboard eMMC
	* SD/MMC
	* GbE (onboard Micrel KSZ9031) Gigabit ethernet PHY
	* USB:
		* USB3.0 dual role port
		* 2x USB3.0 host, 1x USB2.0 host via onboard USB3.0 hub
	* Display: HDMI/eDP/MIPI
	* Camera: 2x CSI (one on the edge connector, one on the Q7 specified CSI ZIF)
	* NOR Flash: onboard SPI NOR
	* Companion Controller: onboard additional Cortex-M0 microcontroller
		* RTC
		* fan controller
		* CAN

Here is the step-by-step to boot to U-Boot on rk3399.

Get the Source and build ATF binary
===================================

  > git clone https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git

Compile the ATF
===============

  > cd trusted-firmware-a
  > make CROSS_COMPILE=aarch64-linux-gnu- PLAT=rk3399 bl31
  > cp build/rk3399/release/bl31/bl31.elf ../u-boot/bl31.elf

Compile the U-Boot
==================

  > cd ../u-boot
  > make CROSS_COMPILE=aarch64-linux-gnu- puma-rk3399_defconfig all

Package the image
=================

The SPL image for SD-Card/eMMC is readily available in idbloader.img at the
root of U-Boot after compilation.

Creating an SPL image for SPI-NOR:
  > tools/mkimage -n rk3399 -T rkspi -d spl/u-boot-spl.bin idbloader-spi.img

Flash the image
===============

Copy the SPL to offset 32k for SD/eMMC, offset 0 for NOR-Flash and the FIT
image to offset 256k.

SD-Card
-------

  > dd if=idbloader.img of=/dev/sdb seek=64
  > dd if=u-boot.itb of=/dev/sdb seek=512

eMMC
----

rkdeveloptool allows to flash the on-board eMMC via the USB OTG interface with
help of the Rockchip loader binary.

  > git clone https://github.com/rockchip-linux/rkdeveloptool
  > cd rkdeveloptool
  > autoreconf -i && ./configure && make
  > git clone https://github.com/rockchip-linux/rkbin.git
  > cd rkbin
  > ./tools/boot_merger RKBOOT/RK3399MINIALL.ini
  > cd ..
  > ./rkdeveloptool db rkbin/rk3399_loader_v1.25.126.bin
  > ./rkdeveloptool wl 64 ../idbloader.img
  > ./rkdeveloptool wl 512 ../u-boot.itb

NOR-Flash
---------

rkdeveloptool allows to flash the on-board SPI via the USB OTG interface with
help of the Rockchip loader binary.

  > git clone https://github.com/rockchip-linux/rkdeveloptool
  > cd rkdeveloptool
  > autoreconf -i && ./configure && make
  > git clone https://github.com/rockchip-linux/rkbin.git
  > cd rkbin
  > ./tools/boot_merger RKBOOT/RK3399MINIALL_SPINOR.ini
  > cd ..
  > ./rkdeveloptool db rkbin/rk3399_loader_spinor_v1.25.114.bin
  > ./rkdeveloptool ef
  > ./rkdeveloptool wl 0 ../idbloader-spi.img
  > ./rkdeveloptool wl 512 ../u-boot.itb