User:Brendlefly62/Rockchip RK3399 Asus Tinker Board 2 S/Build-Install-U-Boot

From Gentoo Wiki
Jump to:navigation Jump to:search

As of 5/8/2024, there is no upstream support for the Tinkerboard 2 or 2 S in u-boot sources. So, the from-scratch u-boot part of this project is still a work in progress. This is also true for the older Tinkerboard -- the general approach is described in this article User:Brendlefly62/Rockchip_RK3288_Asus_Tinker_Board_S/Build-Install-U-Boot.

Meanwhile, there is official support for the Tinkerboard and community support for the Tinkerboard 2/2 S in Armbian. It may be possible to employ defconfig and device tree compilation sources available there, to build u-boot from upstream sources. Alternatively, just use the u-boot produced by Armbian's build script "compile.sh" This tool can be used to build just u-boot and is fully configurable as described below. If you need to rebuild u-boot in order to (for example) change the console baud rate, you can do that and more. First configure u-boot using its "menuconfig" --

user $ ./compile.sh uboot-config SHARE_LOG='yes' ARTIFACT_IGNORE_CACHE='yes' BOARD=tinkerboard-2 BRANCH=current BUILD_DESKTOP=no BUILD_MINIMAL=yes RELEASE=jammy
[๐ŸŒฟ] Applying cmdline param [ 'BUILD_MINIMAL': '(unset)' --> 'yes' early ]

[๐ŸŒฟ] Applying cmdline param [ 'ARTIFACT_IGNORE_CACHE': '(unset)' --> 'yes' early ]
[๐ŸŒฟ] Applying cmdline param [ 'BUILD_DESKTOP': '(unset)' --> 'no' early ]
[๐ŸŒฟ] Applying cmdline param [ 'BRANCH': '(unset)' --> 'current' early ]
[๐ŸŒฟ] Applying cmdline param [ 'BOARD': '(unset)' --> 'tinkerboard-2' early ]
[๐ŸŒฟ] Applying cmdline param [ 'RELEASE': '(unset)' --> 'jammy' early ]
[๐ŸŒฟ] Applying cmdline param [ 'SHARE_LOG': '(unset)' --> 'yes' early ]
[๐ŸŒฑ] artifact [ uboot :: uboot() ]
[๐Ÿšธ] This script requires root privileges; Docker is unavailable [ trying to use sudo ]

[sudo] password for joe: 
[๐ŸŒฟ] Applying cmdline param [ 'PREFER_DOCKER': '(unset)' --> 'no' early ]
[๐ŸŒฟ] Applying cmdline param [ 'BUILD_MINIMAL': '(unset)' --> 'yes' early ]
[๐ŸŒฟ] Applying cmdline param [ 'ARTIFACT_IGNORE_CACHE': '(unset)' --> 'yes' early ]
[๐ŸŒฟ] Applying cmdline param [ 'BUILD_DESKTOP': '(unset)' --> 'no' early ]
[๐ŸŒฑ] Skip     cmdline param [ 'ARMBIAN_RELAUNCHED': already set to 'yes' early ]
[๐ŸŒฟ] Applying cmdline param [ 'BRANCH': '(unset)' --> 'current' early ]
[๐ŸŒฟ] Applying cmdline param [ 'BOARD': '(unset)' --> 'tinkerboard-2' early ]
[๐ŸŒฟ] Applying cmdline param [ 'SET_OWNER_TO_UID': '(unset)' --> '1000' early ]
[๐ŸŒฟ] Applying cmdline param [ 'RELEASE': '(unset)' --> 'jammy' early ]
[๐ŸŒฟ] Applying cmdline param [ 'SHARE_LOG': '(unset)' --> 'yes' early ]
[๐ŸŒฑ] artifact [ uboot :: uboot() ]
[๐ŸŒฑ] Starting single build process [ tinkerboard-2 ]
[๐ŸŒฑ] Checking [ basic host setup ]
[๐ŸŒฑ] Build host OS release [ jammy ]
[๐ŸŒฑ] Build host architecture [ amd64 ]
[๐ŸŒฑ] Sourcing board configuration [ /home/joe/armbian/build/config/boards/tinkerboard-2.csc ]
[โœ…] change-tracking: after sourcing board file config/boards/tinkerboard-2.csc [ BOARDFAMILY='rockchip64' ]
[โœ…] change-tracking: after sourcing board file config/boards/tinkerboard-2.csc [ BOOTBRANCH='tag:v2021.07' ]
[โœ…] change-tracking: after sourcing board file config/boards/tinkerboard-2.csc [ BOOTPATCHDIR='legacy/u-boot-tinkerboard2' ]
[โœ…] change-tracking: after sourcing board file config/boards/tinkerboard-2.csc [ BOOTCONFIG='tinker-2-rk3399_defconfig' ]
[โœ…] change-tracking: after defaulting LINUXFAMILY to BOARDFAMILY [ LINUXFAMILY='rockchip64' ]
[๐ŸŒฑ] Starting main configuration
[๐ŸŒฑ] Using REVISION from [ main VERSION file: '24.5.0-trunk' ]
[๐ŸŒฑ] Sourcing family configuration [ /home/joe/armbian/build/config/sources/families/rockchip64.conf ]
[๐ŸŒฟ] Enabling extension [ rkbin-tools ]
[๐ŸŒฑ] Determined BOOT_SOC from BOOTCONFIG [ BOOT_SOC: 'rk3399'; BOOTCONFIG: 'tinker-2-rk3399_defconfig' ]
[โœ…] change-tracking: after sourcing family config [ KERNEL_MAJOR_MINOR='6.6' ]
[โœ…] change-tracking: after sourcing family config [ LINUXCONFIG='linux-rockchip64-current' ]
[๐ŸŒฑ] Sourcing arch configuration [ arm64.conf ]
[๐ŸŒฑ] Extension manager [ processed 7 Extension Methods calls and 11 Extension Method implementations ]
[๐ŸŒฑ] rockchip64_common: defaulting SERIALCON [ SERIALCON already set to 'ttyS2', keeping it. ]
[๐ŸŒฑ] KERNELPATCHDIR is unset; using 'archive/rockchip64-6.6' [ common_defaults_for_mainline ]
[๐ŸŒฑ] mainline-kernel: default to branch / rolling stable version [ Using KERNELBRANCH='branch:linux-6.6.y' for KERNEL_MAJOR_MINOR='6.6' ]
[โœ…] change-tracking: after late_family_config hooks [ KERNELSOURCE='https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git' ]
[โœ…] change-tracking: after late_family_config hooks [ KERNELBRANCH='branch:linux-6.6.y' ]
[โœ…] change-tracking: after late_family_config hooks [ KERNELPATCHDIR='archive/rockchip64-6.6' ]
[โœ…] change-tracking: after late_family_config hooks [ KERNEL_PATCH_ARCHIVE_BASE='rockchip64' ]
[โœ…] change-tracking: after late_family_config hooks [ BOOTSOURCE='https://github.com/u-boot/u-boot' ]
[โœ…] change-tracking: after late_family_config hooks [ BOOTDIR='u-boot' ]
[โœ…] change-tracking: before handling KERNEL_MAJOR_MINOR in config_post_main [ BOOTSOURCEDIR='u-boot-worktree/u-boot/v2021.07' ]
[โœ…] change-tracking: before calling extension_finish_config [ LINUXSOURCEDIR='linux-kernel-worktree/6.6__rockchip64__arm64' ]
[๐ŸŒฑ] Minimal configuration prepared for build [ prep_conf_main_minimal_ni ]
[๐ŸŒฑ] Running artifact build in interactive mode [ log file will be incomplete ]
[โœจ] Repeat Build Options (early) [ ./compile.sh uboot-config ARTIFACT_IGNORE_CACHE=yes BOARD=tinkerboard-2 BRANCH=current BUILD_DESKTOP=no BUILD_MINIMAL=yes RELEASE=jammy SHARE_LOG=yes ]
[๐ŸŒฑ] Checked directory OK for mount options [ /home/joe/armbian/build/.tmp ('main temporary dir') ]
[๐ŸŒฑ] Preparing [ host ]
[๐ŸŒฑ] Syncing clock [ host ]
[๐Ÿ”จ]   12 May 22:31:23 ntpdate[383445]: step time server 209.51.161.238 offset -9.200191 sec
[๐ŸŒฑ] Ignoring toolchains [ SKIP_EXTERNAL_TOOLCHAINS: yes ]
[๐ŸŒฑ] Producing new & caching [ GIT_INFO_UBOOT ]
[๐ŸŒฑ] Fetching SHA1 of 'tag' 'refs/heads/v2021.07^{}' [ https://github.com/u-boot/u-boot ]
[๐ŸŒฑ] SHA1 of tag refs/heads/v2021.07^{} [ '' ]
[๐ŸŒฑ] Failed to fetch SHA1 of 'tag' 'refs/heads/v2021.07^{}' [ https://github.com/u-boot/u-boot ]
[๐ŸŒฑ] Fetching SHA1 of 'tag' 'refs/heads/v2021.07' [ https://github.com/u-boot/u-boot ]
[๐ŸŒฑ] SHA1 of tag refs/heads/v2021.07 [ '' ]
[๐ŸŒฑ] Failed to fetch SHA1 of 'tag' 'refs/heads/v2021.07' [ https://github.com/u-boot/u-boot ]
[๐ŸŒฑ] Fetching SHA1 of 'tag' 'v2021.07^{}' [ https://github.com/u-boot/u-boot ]
[๐ŸŒฑ] SHA1 of tag v2021.07^{} [ '840658b093976390e9537724f802281c9c8439f5' ]
[๐ŸŒฑ] Getting sources from Git [ rkbin-tools master ]
[๐ŸŒฟ] Initializing empty git local copy [ git init: rkbin-tools master ]
[๐ŸŒฟ] Fetching updates from remote repository [ rkbin-tools master ]
[๐Ÿ”จ]   From https://github.com/armbian/rkbin
[๐Ÿ”จ]    * branch            master     -> FETCH_HEAD
[๐ŸŒฑ] git: Fetch from remote completed, rev-parsing... [ 'rkbin-tools' 'master' 'FETCH_HEAD' ]
[๐ŸŒฑ] Installing [ rkbin-tools ]
[๐ŸŒฑ] Cloning u-boot from mainline into bare tree [ this might take a somewhat-long time ]
Cloning into '/home/joe/armbian/build/cache/git-bare/u-boot'...
POST git-upload-pack (175 bytes)
POST git-upload-pack (gzip 24452 to 12317 bytes)
remote: Enumerating objects: 996643, done.
remote: Counting objects: 100% (6275/6275), done.
remote: Compressing objects: 100% (4097/4097), done.
remote: Total 996643 (delta 2126), reused 6140 (delta 2099), pack-reused 990368
Receiving objects: 100% (996643/996643), 291.91 MiB | 34.61 MiB/s, done.
Resolving deltas: 100% (789380/789380), done.
[๐ŸŒฑ] Getting sources from Git [ u-boot v2021.07 ]
Preparing worktree (checking out 'master')
[๐ŸŒฟ] Fetching updates from remote repository [ u-boot v2021.07 ]
POST git-upload-pack (333 bytes)
From https://github.com/u-boot/u-boot
 * tag                     v2021.07   -> FETCH_HEAD
[๐ŸŒฑ] git: Fetch from remote completed, rev-parsing... [ 'u-boot' 'v2021.07' 'FETCH_HEAD' ]
[๐ŸŒฟ] Using u-boot revision SHA1 [ bf89b7a93992cf313b929cb240f424addc976962 ]
[๐ŸŒฑ] Running uboot build in interactive mode [ log file will be incomplete ]
[๐ŸŒฑ] Compiling u-boot [ 2021.07 /home/joe/armbian/build/cache/sources/u-boot-worktree/u-boot/v2021.07 ]
[๐ŸŒฑ] Compiler version [ aarch64-linux-gnu-gcc '11.4.0' ]
[๐ŸŒฟ] {u-boot:1}  Checking out to clean sources SHA1 bf89b7a93992cf313b929cb240f424addc976962 [ {u-boot-worktree/u-boot/v2021.07} for BL31=/home/joe/armbian/build/cache/sources/rkbin-tools/rk33/rk3399_bl31_v1.35.elf spl/u-boot-spl.bin u-boot.dtb u-boot.itb ]
[๐ŸŒฑ] Python3 version [ 3.10.12 - 'Python 3.10.12' ]
[๐ŸŒฑ] pip3 version [ 22.0.2: 'pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10)' ]
[๐ŸŒฑ] Using cached pip packages for Python tools [ f34c3f616841e80aed6efe6a93e040ed3439314113e5f028c99e76c254e166ba ]
[๐ŸŒฑ] Calling Python patching script [ for u-boot target ]
Applying 3 patches from 3 files of which 3 patches in regular, sorted files...
-> 1/3: add-board-tinker-board-2(:1) (+763/-0)[5M, 7A] {rk3399-tinker-2.dts, tinker-2-rk3399_defconfig, rk3399-tinker-2-u-boot.dtsi, tinker-2-rk3399.c, tinker-2_rk3399.h, Kconfig, Makefile, fan53555.c, fan53555.h}
-> 2/3: add-trust-ini(:1) (+15/-0)[1A] {trust.ini}
-> 3/3: enable-DT-overlays-support(:1) (+2/-0)[1M] {Kconfig}
Summary: u-boot patching: 3 total patches; 3 applied; 0 with problems

                                           Summary of u-boot patches                                           

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Patch / Status             โ”‚ Diffstat / files                    โ”‚ Author / Subject                         โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ add-board-tinker-board-2   โ”‚ (+763/-0)[5M, 7A]                   โ”‚ tonymac32: Add board Tinkerboard-2 uboot โ”‚
โ”‚                            โ”‚ rk3399-tinker-2.dts,                โ”‚ with regulator                           โ”‚
โ”‚                            โ”‚ tinker-2-rk3399_defconfig,          โ”‚                                          โ”‚
โ”‚                            โ”‚ rk3399-tinker-2-u-boot.dtsi,        โ”‚                                          โ”‚
โ”‚                            โ”‚ tinker-2-rk3399.c,                  โ”‚                                          โ”‚
โ”‚                            โ”‚ tinker-2_rk3399.h, Kconfig,         โ”‚                                          โ”‚
โ”‚                            โ”‚ Makefile, fan53555.c, fan53555.h    โ”‚                                          โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ add-trust-ini              โ”‚ (+15/-0)[1A] trust.ini              โ”‚ zador-blood-stained: Add trust.ini       โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ enable-DT-overlays-support โ”‚ (+2/-0)[1M] Kconfig                 โ”‚ zador-blood-stained: Enable DT overlay   โ”‚
โ”‚                            โ”‚                                     โ”‚ support in u-boot                        โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

[๐ŸŒฑ] {u-boot:1} Preparing u-boot config 'tinker-2-rk3399_defconfig' [ 2021.07 BL31=/home/joe/armbian/build/cache/sources/rkbin-tools/rk33/rk3399_bl31_v1.35.elf spl/u-boot-spl.bin u-boot.dtb u-boot.itb ]
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/conf.o
  YACC    scripts/kconfig/zconf.tab.c
  LEX     scripts/kconfig/zconf.lex.c
  HOSTCC  scripts/kconfig/zconf.tab.o
  HOSTLD  scripts/kconfig/conf
#
# configuration written to .config
#

[๐ŸŒฑ] {u-boot:1} Updating u-boot config with olddefconfig [ 2021.07 BL31=/home/joe/armbian/build/cache/sources/rkbin-tools/rk33/rk3399_bl31_v1.35.elf spl/u-boot-spl.bin u-boot.dtb u-boot.itb ]
scripts/kconfig/conf  --olddefconfig Kconfig
.config:1952:warning: override: reassigning to symbol BOOTDELAY
#
# configuration written to .config
#
[๐Ÿšธ] Configuring u-boot [ UBOOT_CONFIGURE=yes; experimental ]
  UPD     scripts/kconfig/.mconf-cfg
  HOSTCC  scripts/kconfig/mconf.o

  ...
...

Then run this command to build u-boot --

user $ ./compile.sh uboot SHARE_LOG='yes' ARTIFACT_IGNORE_CACHE='yes' BOARD=tinkerboard-2 BRANCH=current BUILD_DESKTOP=no BUILD_MINIMAL=yes RELEASE=jammy
...
[โœจ] Repeat Build Options [ ./compile.sh uboot ARTIFACT_IGNORE_CACHE=yes BOARD=tinkerboard-2 BRANCH=current BUILD_DESKTOP=no BUILD_MINIMAL=yes RELEASE=jammy SHARE_LOG=yes ]
[๐ŸŒฑ] Cleaning up [ please wait for cleanups to finish ]
[๐ŸŒฟ] ANSI log file built; inspect it by running: [ less -RS output/logs/log-uboot-6449d7f7-7556-4099-b562-7bd379b9b1b5.log.ans ]
[๐ŸŒฑ] SHARE_LOG=yes, uploading log [ uploading logs ]
[๐ŸŒฟ] Log uploaded, share URL: [ https://paste.armbian.com/ebitazilav ]

Then examine new output in armbian/build/output. Note in particular the "debs" folder, which contains archived .deb packages. Locate the one that looks like "linux-u-boot-tinkerboard-2-current_2021.07-S8406-P5654-H8c72-Vbfac-Bf5f6-R448a_arm64.deb" and copy it to your development workstation. There, you can examine and/or extract the contents with dpkg-deb -c or dpkg-deb -x, respectively --

user $ dpkg-deb -c debs/linux-u-boot-tinkerboard-2-current_24.5.0-trunk_arm64__2021.07-S8406-P5654-H8c72-Vbfac-Bf5f6-R448a.deb ## examine contents
drwx------ root/root         0 2024-03-13 20:32 ./
drwxrwxr-x root/root         0 2024-03-13 20:33 ./usr/
drwxrwxr-x root/root         0 2024-03-13 20:32 ./usr/lib/
drwxrwxr-x root/root         0 2024-03-13 20:33 ./usr/lib/linux-u-boot-current-tinkerboard-2/
-rw-rw-r-- root/root    239616 2024-03-13 20:33 ./usr/lib/linux-u-boot-current-tinkerboard-2/idbloader.img
-rw-rw-r-- root/root   1028980 2024-03-13 20:33 ./usr/lib/linux-u-boot-current-tinkerboard-2/u-boot.itb
drwxrwxr-x root/root         0 2024-03-13 20:33 ./usr/lib/u-boot/
-rw-rw-r-- root/root      7179 2024-03-13 20:33 ./usr/lib/u-boot/LICENSE
-rw-rw-r-- root/root      1697 2024-03-13 20:33 ./usr/lib/u-boot/platform_install.sh
-rw-rw-r-- root/root     50062 2024-03-13 20:33 ./usr/lib/u-boot/tinker-2-rk3399_defconfig
drwxrwxr-x root/root         0 2024-03-13 20:33 ./usr/share/
drwxrwxr-x root/root         0 2024-03-13 20:33 ./usr/share/doc/
drwxrwxr-x root/root         0 2024-03-13 20:33 ./usr/share/doc/linux-u-boot-tinkerboard-2-current/
-rw-rw-r-- root/root       221 2024-03-13 20:33 ./usr/share/doc/linux-u-boot-tinkerboard-2-current/changelog.gz
Tip
Note that the script provided at ./usr/lib/u-boot/platform_install.sh essentially provides instructions on how to burn the u-boot files ./usr/lib/linux-u-boot-current-tinkerboard-2/u-boot.itb and ./usr/lib/linux-u-boot-current-tinkerboard-2/u-boot.itb to the boot media.
Warning
If the device at /mnt/thumb is a vfat fs, it won't support symlinks, so save the information with which to reconstruct them, if they are needed

Creating boot.scr

Also, it may make debugging easier to modify the boot.cmd boot script to be more informative and use the makeimage tool to compile this to a custom boot.scr

One of the several u-boot boot scenarios is to load boot.scr, which will contain commands for U-Boot to execute. This will be in the /boot partition along with the kernel and device tree binary. To generate a custom version of this file, first create or modify the file boot.cmd. The example below includes a lot of extra stuff to facilitate exploration and debugging, but it can be significantly simplified (e.g. the u-boot command env print -a will give you all the information that all these echo commands produce, and more, but the echo commands produce more readable, formatted output --

CODE boot.cmd
# DO NOT EDIT THIS FILE
#
# Please edit /boot/joetooEnv.txt to set supported parameters

setenv load_addr "0x9000000"
setenv overlay_error "false"
# default values
setenv rootdev "/dev/mmcblk0p1"
setenv verbosity "1"
setenv console "both"
setenv bootlogo "false"
setenv rootfstype "ext4"
#setenv docker_optimizations "on"     ### armbian uses this, but I don't want it
setenv earlycon "off"

test -n "${distro_bootpart}" || distro_bootpart=1

echo "Loaded and running boot.scr!"
echo "Boot script loaded from ${devtype} ${devnum}:${distro_bootpart}"

# defaults
if test -z "$bootargs"; then
    setenv bootargs root=${rootdev} rootdelay=5
fi

# print some debugging info
echo "-----[ Initial State ]-----------------------------------"
#echo "userEnv..........: "${userEnv}
echo "load_addr........: "${load_addr}
echo "filesize.........: "${filesize}
echo "rootdev..........: "${rootdev}
echo "devtype..........: "${devtype}
echo "devnum...........: "${devnum}
echo "prefix...........: "${prefix}
echo "distro_bootpart..: "${distro_bootpart}
echo "verbosity........: "${verbosity}
echo "console..........: "${console}
echo "consoleargs......: "${consoleargs}
echo "consolebaud......: "${consolebaud}
echo "logo.............: "${logo}
echo "bootlogo.........: "${bootlogo}
echo "rootfstype.......: "${rootfstype}
echo "arch.............: "${arch}
echo "earlycon.........: "${earlycon}
echo "overlays.........: "${overlays}
echo "overlay_dir......: "${overlay_dir}
echo "overlay_prefix...: "${overlay_prefix}
echo "dtb_prefix.......: "${dtb_prefix}
echo "user_overlays....: "${user_overlays}
echo "fdtfile..........: "${fdtfile}
echo "fdt_addr_r.......: "${fdt_addr_r}
echo "imagefile........: "${imagefile}
echo "kernel_addr_r....: "${kernel_addr_r}
echo "initrdfile.......: "${initrdfile}
echo "ramdisk_addr_r...: "${ramdisk_addr_r}
echo "partuuid.........: "${partuuid}
echo "usbstoragequirks.: "${usbstoragequirks}
echo "extraargs........: "${extraargs}
echo "extraboardargs...: "${extraboardargs}
echo "bootargs.........: "${bootargs}
echo "--------------------------------------------------------"

# Override/overwrite defaults per user's environment selections
echo "Ok - I am about to try reading joetooEnv.txt..."
if test -e ${devtype} ${devnum} ${prefix}joetooEnv.txt; then
        load ${devtype} ${devnum} ${load_addr} ${prefix}joetooEnv.txt
        env import -t ${load_addr} ${filesize}
else
        echo "Did not find or load joetooEnv.txt"
fi

# Manage console settings
setenv consoleargs ""
if test "${logo}" = "disabled"; then setenv logo "logo.nologo"; fi
if test "${console}" = "display" || test "${console}" = "both"; then setenv consoleargs "console=tty1"; fi
#if test "${console}" = "serial" || test "${console}" = "both"; then setenv consoleargs "console=ttyS2,${consolebaud}n8 ${consoleargs}"; fi
if test "${console}" = "serial" || test "${console}" = "both"; then setenv consoleargs "${consoleargs} console=ttyS2,${consolebaud}n8"; fi
if test "${earlycon}" = "on"; then setenv consoleargs "earlycon ${consoleargs}"; fi
if test "${bootlogo}" = "true"; then
        setenv consoleargs "splash plymouth.ignore-serial-consoles ${consoleargs}"
else
        setenv consoleargs "splash=verbose ${consoleargs}"
fi

# get PARTUUID of first partition on SD/eMMC the boot script was loaded from
if test "${devtype}" = "mmc"; then part uuid mmc ${devnum}:1 partuuid; fi

# update bootargs
#setenv bootargs "root=${rootdev} rootwait rootfstype=${rootfstype} ${consoleargs} consoleblank=0 loglevel=${verbosity} ubootpart=${partuuid} usb-storage.quirks=${usbstoragequirks} ${extraargs} ${extraboardargs}"
#setenv bootargs "root=${rootdev} rootwait rootfstype=${rootfstype} ${consoleargs} consoleblank=0 loglevel=${verbosity} usb-storage.quirks=${usbstoragequirks} ${extraargs} ${extraboardargs}"
#setenv bootargs "root=${rootdev} rootdelay=5 rootwait rootfstype=${rootfstype} ${consoleargs} consoleblank=0 loglevel=${verbosity} ubootpart=${partuuid} usb-storage.quirks=${usbstoragequirks} ${extraargs} ${extraboardargs}"
setenv bootargs "root=${rootdev} rootdelay=5 rootwait rootfstype=${rootfstype} ${consoleargs} consoleblank=0 loglevel=${verbosity} usb-storage.quirks=${usbstoragequirks} ${extraargs} ${extraboardargs}"

echo "-----[ Potentially Updated State ]-----------------------"
#echo "userEnv..........: "${userEnv}
echo "load_addr........: "${load_addr}
echo "filesize.........: "${filesize}
echo "rootdev..........: "${rootdev}
echo "devtype..........: "${devtype}
echo "devnum...........: "${devnum}
echo "prefix...........: "${prefix}
echo "distro_bootpart..: "${distro_bootpart}
echo "verbosity........: "${verbosity}
echo "console..........: "${console}
echo "consoleargs......: "${consoleargs}
echo "consolebaud......: "${consolebaud}
echo "logo.............: "${logo}
echo "bootlogo.........: "${bootlogo}
echo "rootfstype.......: "${rootfstype}
echo "arch.............: "${arch}
echo "earlycon.........: "${earlycon}
echo "overlays.........: "${overlays}
echo "overlay_dir......: "${overlay_dir}
echo "overlay_prefix...: "${overlay_prefix}
echo "dtb_prefix.......: "${dtb_prefix}
echo "user_overlays....: "${user_overlays}
echo "fdtfile..........: "${fdtfile}
echo "fdt_addr_r.......: "${fdt_addr_r}
echo "imagefile........: "${imagefile}
echo "kernel_addr_r....: "${kernel_addr_r}
echo "initrdfile.......: "${initrdfile}
echo "ramdisk_addr_r...: "${ramdisk_addr_r}
echo "partuuid.........: "${partuuid}
echo "usbstoragequirks.: "${usbstoragequirks}
echo "extraargs........: "${extraargs}
echo "extraboardargs...: "${extraboardargs}
echo "bootargs.........: "${bootargs}
echo "-----[ now env print -a ]---------------------------------"
env print -a

# Load device tree file and kernel (to do: initramfs option)

# device tree - note that it finds the file in the "dtb" directory
echo "Loading device tree from ${devtype} ${devnum}:${distro_bootpart}..."
load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${prefix}dtb/${dtb_prefix}/${fdtfile}

if test ${initrdfile} = ""; then
        echo "Null initrd [${initrdfile}]; not loading one..."
        setenv ramdisk_addr_r "-"
        echo "ramdisk_addr_r...: "${ramdisk_addr_r}
else
        echo "Loading initrd from ${devtype} ${devnum}:${distro_bootpart}..."
        load ${devtype} ${devnum}:${distro_bootpart} ${ramdisk_addr_r} ${prefix}${initrdfile}
fi

echo "Loading kernel from ${devtype} ${devnum}:${distro_bootpart}..."
load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} ${prefix}${imagefile}

# Load overlays
fdt addr ${fdt_addr_r}
fdt resize 65536
for overlay_file in ${overlays}; do
        if load ${devtype} ${devnum} ${load_addr} ${prefix}dtb/${overlay_dir}/${overlay_prefix}-${overlay_file}.dtbo; then
                echo "Applying kernel provided DT overlay ${overlay_prefix}-${overlay_file}.dtbo"
                fdt apply ${load_addr} || setenv overlay_error "true"
        fi
done
for overlay_file in ${user_overlays}; do
        if load ${devtype} ${devnum} ${load_addr} ${prefix}overlay-user/${overlay_file}.dtbo; then
                echo "Applying user provided DT overlay ${overlay_file}.dtbo"
                fdt apply ${load_addr} || setenv overlay_error "true"
        fi
done
if test "${overlay_error}" = "true"; then
        echo "Error applying DT overlays, restoring original DT"
        load ${devtype} ${devnum} ${fdt_addr_r} ${prefix}dtb/${fdtfile}
else
        echo "No overlay_error. Now trying to load fixup scripts..."
        if test -e ${devtype} ${devnum} ${prefix}dtb/${overlay_dir}/${overlay_prefix}-fixup.scr; then
                load ${devtype} ${devnum} ${load_addr} ${prefix}dtb/${overlay_dir}/${overlay_prefix}-fixup.scr
                echo "Applying kernel provided DT fixup script (${overlay_prefix}-fixup.scr)"
                source ${load_addr}
        else
                echo "could not find to load fixup script ${prefix}dtb/${overlay_dir}/${overlay_prefix}-fixup.scr. Skipping..."
        fi
        if test -e ${devtype} ${devnum} ${prefix}fixup.scr; then
                load ${devtype} ${devnum} ${load_addr} ${prefix}fixup.scr
                echo "Applying user provided fixup script (fixup.scr)"
                source ${load_addr}
        else
                echo "could not find to load fixup script ${prefix}fixup.scr. Skipping..."
        fi
fi

# Boot!
echo "Booting with arguments: ${bootargs}"
echo
echo "imagefile: ${imagefile}"
echo


if test ${imagefile} = "Image"; then
        echo "booting uncompressed kernel image [${imagefile}] ..."
        booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}
else
        if test ${imagefile} = "zImage"; then
                echo "booting compressed kernel image [${imagefile}] ..."
                bootz ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}
        else
                echo "invalid kernel imagefile name specified [${imagefile}]. Unable to boot..."
        fi
fi


# Recompile instruction
#
# Cross-compiling:
# cd to u-boot directory holding boot.cmd and run
# (yes) mkimage -C none -A arm64 -T script -d boot.cmd boot.scr
# (no) mkimage -C none -A arm -T script -d boot.cmd boot.scr
# then copy boot.scr, boot.cmd, and joetooEnv.txt to the /boot partition
# of your target system eMMC or microSD card
#
# If modifying and existing system (from said system)
# (yes) mkimage -C none -A arm64 -T script -d /boot/boot.cmd /boot/boot.scr
# (no) mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr
CODE joetooEnv.txt
verbosity=6
arch=arm64
#console=both
#console=display
console=serial
earlycon=on
consolebaud=1500000
bootlogo=true
overlay_dir=overlays
overlay_prefix=rockchip
dtb_prefix=rockchip
overlays=
fdtfile=rk3399-tinker-2.dtb
imagefile=Image
initrdfile=uInitrd
#initrdfile=
rootdev=/dev/mmcblk1p1
#rootdev=UUID=604e047f-f018-4b90-84b0-72f1be501a8a
#rootdev=PARTUUID=8adf86e2-01
rootfstype=ext4
#extraargs=coherent_pool=2M init=/sbin/init selinux=0 rw debug
#extraargs=coherent_pool=2M selinux=0 rw debug
extraargs=coherent_pool=2M init=/usr/bin/init selinux=0 net.ifnames=0 debug
usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u
Important
Be sure to change rootdev= to point to your actual root partition! This can by done by PARTUUID= as in this example, more portably than by path to block device, like "/dev/mmcblk0p1" or by LABEL=-- but either way is valid. Note however, that boot.cmd, compiled to boot.scr must pass the associated parameter on the kernel command line, so that it can be referenced in userspace. For the author, trial and error

Then, compile it to boot.scr:

root #mkimage -C none -A arm64 -T script -d boot.cmd boot.scr
Tip
* mkimage can be used from either the bin directory in your U-Boot build directory or from dev-embedded/u-boot-tools
  • Create a Makefile or a shell script so you don't have to look up the command above next time you need to edit

If the /boot partition is on microSD, it should work without additional steps.