Difference between revisions of "Mainline Linux on Orange Pi 4"

From Dejvino's Knowledge Base
Jump to navigation Jump to search
(Created page with "Mainline Linux used on Orange Pi 4. == Overview == There are several components that need to be compiled and prepared from the ground up: # U-Boot # Linux ker...")
 
Line 17: Line 17:
 
make orangepi-rk3399_defconfig</pre>
 
make orangepi-rk3399_defconfig</pre>
  
{{Todo|Sort out BL31 according to doc/README.rockchip}}
+
<pre>
 +
3. To build RK3399 board:
 +
 
 +
  Option 1: Package the image with Rockchip miniloader:
 +
 
 +
  - Compile U-Boot
 +
 
 +
    => cd /path/to/u-boot
 +
    => make nanopi-neo4-rk3399_defconfig
 +
    => make
 +
 
 +
  - Get the rkbin
 +
 
 +
    => git clone https://github.com/rockchip-linux/rkbin.git
 +
 
 +
  - Create trust.img
 +
 
 +
    => cd /path/to/rkbin
 +
    => ./tools/trust_merger RKTRUST/RK3399TRUST.ini
 +
 
 +
  - Create uboot.img
 +
 
 +
    => cd /path/to/rkbin
 +
    => ./tools/loaderimage --pack --uboot /path/to/u-boot/u-boot-dtb.bin uboot.img
 +
 
 +
    (Get trust.img and uboot.img)
 +
 
 +
  Option 2: Package the image with SPL:
 +
 
 +
  - Export cross compiler path for aarch64
 +
 
 +
  - Compile ATF
 +
 
 +
    For Puma board.
 +
 
 +
=> git clone git://git.theobroma-systems.com/arm-trusted-firmware.git
 +
=> cd arm-trusted-firmware
 +
=> make CROSS_COMPILE=aarch64-linux-gnu- PLAT=rk3399 bl31
 +
 
 +
(export bl31.bin)
 +
=> export BL31=/path/to/arm-trusted-firmware/build/rk3399/release/bl31/bl31.bin
 +
 
 +
    For rest of rk3399 boards.
 +
 
 +
=> git clone https://github.com/ARM-software/arm-trusted-firmware.git
 +
=> cd arm-trusted-firmware
 +
 
 +
(export cross compiler path for Cortex-M0 MCU likely arm-none-eabi-)
 +
=> make realclean
 +
=> make CROSS_COMPILE=aarch64-linux-gnu- PLAT=rk3399
 +
 
 +
(export bl31.elf)
 +
=> export BL31=/path/to/arm-trusted-firmware/build/rk3399/release/bl31/bl31.elf
 +
 
 +
  - Compile PMU M0 firmware
 +
 
 +
    This is optional for most of the rk3399 boards and required only for Puma board.
 +
 
 +
    => git clone git://git.theobroma-systems.com/rk3399-cortex-m0.git
 +
    => cd rk3399-cortex-m0
 +
 
 +
    (export cross compiler path for Cortex-M0 PMU)
 +
    => make CROSS_COMPILE=arm-cortex_m0-eabi-
 +
 
 +
    (export rk3399m0.bin)
 +
    => export PMUM0=/path/to/rk3399-cortex-m0/rk3399m0.bin
 +
 
 +
  - Compile U-Boot
 +
 
 +
    => cd /path/to/u-boot
 +
    => make orangepi-rk3399_defconfig
 +
    => make
 +
 
 +
    (Get spl/u-boot-spl-dtb.bin, u-boot.itb images and some boards would get
 +
      spl/u-boot-spl.bin since it doesn't enable CONFIG_SPL_OF_CONTROL
 +
 
 +
      If TPL enabled on the target, get tpl/u-boot-tpl-dtb.bin or tpl/u-boot-tpl.bin
 +
      if CONFIG_TPL_OF_CONTROL not enabled)
 +
</pre> Source: [https://gitlab.denx.de/u-boot/u-boot/-/blob/master/doc/README.rockchip README.rockchip]
  
 
=== Building ===
 
=== Building ===

Revision as of 12:51, 24 March 2020

Mainline Linux used on Orange Pi 4.

Overview

There are several components that need to be compiled and prepared from the ground up:

  1. U-Boot
  2. Linux kernel
  3. rootfs
  4. Creating a Disk Image
  5. Flashing to SD Card

U-Boot

Mainline repository: [1]

Setup

git clone https://gitlab.denx.de/u-boot/u-boot.git
cd u-boot
make orangepi-rk3399_defconfig
3. To build RK3399 board:

   Option 1: Package the image with Rockchip miniloader:

   - Compile U-Boot

     => cd /path/to/u-boot
     => make nanopi-neo4-rk3399_defconfig
     => make

   - Get the rkbin

     => git clone https://github.com/rockchip-linux/rkbin.git

   - Create trust.img

     => cd /path/to/rkbin
     => ./tools/trust_merger RKTRUST/RK3399TRUST.ini

   - Create uboot.img

     => cd /path/to/rkbin
     => ./tools/loaderimage --pack --uboot /path/to/u-boot/u-boot-dtb.bin uboot.img

     (Get trust.img and uboot.img)

   Option 2: Package the image with SPL:

   - Export cross compiler path for aarch64

   - Compile ATF

     For Puma board.

	=> git clone git://git.theobroma-systems.com/arm-trusted-firmware.git
	=> cd arm-trusted-firmware
	=> make CROSS_COMPILE=aarch64-linux-gnu- PLAT=rk3399 bl31

	(export bl31.bin)
	=> export BL31=/path/to/arm-trusted-firmware/build/rk3399/release/bl31/bl31.bin

     For rest of rk3399 boards.

	=> git clone https://github.com/ARM-software/arm-trusted-firmware.git
	=> cd arm-trusted-firmware

	(export cross compiler path for Cortex-M0 MCU likely arm-none-eabi-)
	=> make realclean
	=> make CROSS_COMPILE=aarch64-linux-gnu- PLAT=rk3399

	(export bl31.elf)
	=> export BL31=/path/to/arm-trusted-firmware/build/rk3399/release/bl31/bl31.elf

   - Compile PMU M0 firmware

     This is optional for most of the rk3399 boards and required only for Puma board.

     => git clone git://git.theobroma-systems.com/rk3399-cortex-m0.git
     => cd rk3399-cortex-m0

     (export cross compiler path for Cortex-M0 PMU)
     => make CROSS_COMPILE=arm-cortex_m0-eabi-

     (export rk3399m0.bin)
     => export PMUM0=/path/to/rk3399-cortex-m0/rk3399m0.bin

   - Compile U-Boot

     => cd /path/to/u-boot
     => make orangepi-rk3399_defconfig
     => make

     (Get spl/u-boot-spl-dtb.bin, u-boot.itb images and some boards would get
      spl/u-boot-spl.bin since it doesn't enable CONFIG_SPL_OF_CONTROL

      If TPL enabled on the target, get tpl/u-boot-tpl-dtb.bin or tpl/u-boot-tpl.bin
      if CONFIG_TPL_OF_CONTROL not enabled)

Source: README.rockchip

Building

make all

Linux Kernel

TODO: THIS

RootFS

TODO: THIS

Creating a Disk Image

TODO: THIS

Flashing an SD Card

See Flashing Linux to SD Card.