Dev/OPi/OPi3/From Scratch: Difference between revisions

From Embeded Linux (and more) Wiki by Nathael
< Dev‎ | OPi‎ | OPi3
Jump to navigation Jump to search
(Created page with "== ARM trusted firmware == You can generate it following the instructions from the file board/sunxi/README.sunxi64 from u-boot sources (see below) or get it directly [http://d...")
 
 
Line 51: Line 51:
=== Use ===
=== Use ===
* Linux Kernel
* Linux Kernel
Compilation result is in arch/arm/boot/zImage
Compilation result is in arch/arm64/boot/zImage
* Device tree
* Device tree
Use the sun50i-h6-orangepi-3.dtb device-tree (found in arch/arm/boot/dts/)
Use the sun50i-h6-orangepi-3.dtb device-tree (found in arch/arm64/boot/dts/)
* Modules
* Modules
If the compilation has been performed using the above command lines you should have a directory "Build/Mods/lib/modules/***" (*** = name of the kernel you just compiled)<br />
If the compilation has been performed using the above command lines you should have a directory "Build/Mods/lib/modules/***" (*** = name of the kernel you just compiled)<br />

Latest revision as of 07:07, 3 May 2020

ARM trusted firmware

You can generate it following the instructions from the file board/sunxi/README.sunxi64 from u-boot sources (see below) or get it directly from here.

git clone https://github.com/ARM-software/arm-trusted-firmware.git
cd arm-trusted-firmware
make CROSS_COMPILE=aarch64-linux-gnu- PLAT=sun50i_h6 DEBUG=1 bl31

Result is in build/sun50i_h6/debug/bl31.bin

U-boot

Grab the sources

This is the repository from megous (linux-sunxi.org Wiki)

git clone https://megous.com/git/u-boot/
cd u-boot/
git checkout 

Compile

Note: fix the path (or use the right path) to your bl31.bin firmware

make CROSS_COMPILE=aarch64-linux-gnu- orangepi_3_defconfig
export BL31=/path/to/arm-trusted-firmware/bl31.bin
make -j8 CROSS_COMPILE=aarch64-linux-gnu-

Note: you can customize your u-boot configuration by using a make menuconfig, or get my config_uboot_ed3l_*** and save the file as ".config" in u-boot sources directory and then make oldconfig.

Use

Erase the first Mo of the SD card while keeping the partition table:

dd if=/dev/zero of=${card} bs=1k count=1023 seek=1

Copy uboot image (SPL + ATF + second stage) to the SD card:

dd if=u-boot-sunxi-with-spl.bin of=${card} bs=1k seek=8

Linux Kernel

Grab the sources

  • Kernel from kernel.org
git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
get patches from megous (on linux-sunxi.org Wiki) https://xff.cz/kernels/5.3/patches/opi3.patch
  • Kernel from megous (on linux-sunxi.org Wiki)
git clone https://megous.com/git/linux/
  • Kernel 4.9 from xunlong
git clone https://github.com/orangepi-xunlong/OrangePiH6_Linux4_9.git

Compile

mkdir -p Build/linux
cd linux
cp config_5.3.0_2019-09-21-ed3l ../opi3/Build/linux/.config
make ARCH=arm64 -j8 O=../opi3/Build/linux/ oldconfig
make ARCH=arm64 -j8 O=../opi3/Build/linux/ CROSS_COMPILE=aarch64-linux-gnu-
make ARCH=arm64 -j8 O=../opi3/Build/linux/ CROSS_COMPILE=aarch64-linux-gnu- dtbs
make ARCH=arm64 -j8 O=../opi3/Build/linux/ CROSS_COMPILE=aarch64-linux-gnu- modules_install INSTALL_MOD_PATH=../Mods
mkimage -A arm -n "OrangePiH6" -O linux -T kernel -C none -a 0x40080000 -e 0x40080000 \
  -d ../opi3/Build/linux/arch/arm64/boot/Image ../opi3/Build/uImage

Use

  • Linux Kernel

Compilation result is in arch/arm64/boot/zImage

  • Device tree

Use the sun50i-h6-orangepi-3.dtb device-tree (found in arch/arm64/boot/dts/)

  • Modules

If the compilation has been performed using the above command lines you should have a directory "Build/Mods/lib/modules/***" (*** = name of the kernel you just compiled)
You must copy the whole directory (not only the content) on the SD card, in the partition holding the root filesystem (rootfs), in the /lib/modules/ directory without changing the name.

SD Card creation

Original information from linux-sunxi wiki

SD card architecture

start sector size usage
0KB 0 8KB Unused, available for an MBR or (limited) GPT partition table
8KB 16 32KB Initial SPL loader
40KB 80 - U-Boot

Typically partitions start at XXXMB (which is the default setting of most partitioning tools), but there is no hard requirement for this, so U-Boot can grow bigger than 984KB, if needed.

Cleaning

Erase the first Mo of the SD card while keeping the partition table:

dd if=/dev/zero of=${card} bs=1k count=1023 seek=1

(Use count=1024 and remove "seek" option to also erase the partition table)

Bootloader

Copy (dd) uboot images (u-boot-sunxi-with-spl.bin) to the SD card. Refer to "U-boot/Use" section above.

First partition

The first partition must start at +XXXMo, and be a few Mo (50 Mo should be OK) and be formated using ext2/3/4
Place the files "Image-5.3.0-ed3l", "sun50i-h6-orangepi-3.dtb" and "boot.scr" on the first partition.

  • The file "boot.scr" is generated using mkimage from "boot.cmd" with the following command :
mkimage -C none -A arm -T script -d boot.cmd boot.scr

An example "boot.cmd" file can be found in boot_devuan_ceres_***.tar.bz2

A short one can look like this :

setenv kernel_image "Image-5.3.0-ed3l"
setenv fdtfile "sun50i-h6-orangepi-3.dtb"
setenv bootargs "console=ttyS0,115200 root=/dev/mmcblk0p2 rw rootwait usb-storage.quirks=0x2537:0x1066:u,0x2537:0x1068:u quiet"

load ${devtype} ${devnum} ${fdt_addr_r} ${fdtfile}
load ${devtype} ${devnum} ${kernel_addr_r} ${kernel_image}
booti ${kernel_addr_r} - ${fdt_addr_r}

Second partition

The second partition must be formated using ext4 and starts right after the first one. It can take all the remaining size unless you have other specific needs.

This partition holds the root filesystem (rootfs).

Rootfs

This board uses an ARM64 processor, thus the root filesystem should be built using "aarch64-linux-gnu-" cross-toolchain or use the arm64 architecture for Devuan or other Debian based distribution.

Refer to the rootfs creation page for more information. You should find a base Devuan rootfs here : rootfs_devuan_ceres_arm64_***.tar.bz2.