Rockchip · AI & Linux Hub

Linux と起動

RockchipUボットNextdev開発者ガイド:ブート、ドライバー、FITおよびプラットフォーム構成

完全なV2.37.0 UボットNextdevプラットフォーム参照:ブートフロー、デバイスモデル、ドライバ、FIT、安全なブート、SPL、ツール、付録。

ArmSoMプラットフォームは、英語と中国語のRockchipUボットNextdev V2.37.0開発者ガイド(329および314 PDFページ)に基づいて参照します。 ソースプラットフォームをサポートするテーブルは、以下に保持されます。ArmSoMのすべてのボードのブランケットサポートステートメントではありません。 実際の SoC、ボード DTS、SDK/BSP、U-Boot ブランチ、DDR と、これらの例を適応させる前にファームウェアやカーネルを信頼します。 ArmSoM ハードウェア検証や性能測定は行いません。 ソーステストとログはソース例のままです。 英語版とロシア語/ドイツ語の翻訳で英語の数字が使われています。

ソースの調整: PDF は V2.37.0 と同じ 393 番号付き見出しを運ぶ。 このエディションは、そのソースの順序で完全な英語の技術的なテキストと例を保持します。 中国語は、ロシア/ドイツの専門家のための基礎です。 ページの壊れた断片は、必ずしも機能しないとは異なる。 §1.11と5.3.4の2つの偽りなく検出された英語表は、両方のソースに対してコードとして復元されるコードです。 §14.1(RK3566/RK3568行のファームウェア名は、rk3588ファイルの名前を命じる)と§14.4(RK3588ネーミングrk3568-dfu.config)は、別のチップのファームウェアをフラッシュする推奨事項ではなく、ソースの不確実性を保持しています。 オリジナルTODOマーカーは、未完成のソースコンテンツのままです。 実際のSDK/TRMに対して検証します。 フラッシュ消去、OTP/eFuse 書き込み、キーの書き込み、パーティションの変更と署名/ブート例は、ハードウェアやデータに反して影響する可能性があります。準備中に実行されたものはありません。

さらなる共有ソースの不確実性: §4.8.2のCONFIG_ENV_IS_NOWHERE_XXXは、書面として保持されます。 規制初期化では、ソースがregulator-min-microvoltを2回繰り返す;別のプロパティを持つ無声置換は行われません。 ソースコードの例には、全幅の句読点または文字字形引用符が含まれています。 実際の SDK の定義と構文を、任意の例を適用する前にチェックします。

ArmSoM のドキュメント・RockchipUボットソース

チップセット ミニローダー+ RKIMG u-boot SPL + FIT u-boot の
RV1108 Y  
RK3036 Y  
RK3126C Y  
RK3128 Y  
RK3229 Y  
RK3288 Y  
RK3308 Y  
RK3326/PX30 Y  
RK3328 Y  
RK3368/PX5 Y  
RK3399 Y  
RK1808 Y  
RV1126/RV1109   Y
RK3566/RK3568   Y
RK3588   Y
RV1106/RV1103   Y
RK3528   Y
RK3562   Y
RK3576   Y
RV1106B/RV1103B   Y
RK3506   Y
RV1126B   Y

1. . 第1章 基本紹介 {#1-chapter-1-basic-introduction}

1.1 特徴 {#11-feature}

v2017(next-dev)は、U-Bootの公式v2017.09版からRKによって開発されたバージョンで、RKが販売する主流チップをすべてサポートしています。 主な機能がサポートされています:RK Androidファームウェアの起動をサポート。 Android AOSPファームウェアの起動をサポートします。 Linuxディストロファームウェアの起動をサポートしています。 RockchipミニローダーとSPL / TPLプリローダーのブートの両方をサポート。 LVDS、EPD、MIPI、HDMI、CVBS、RGBなどのディスプレイデバイスをサポートします。 eMMC、Nand Flash、SPI Nandフラッシュ、SPI NORフラッシュ、SDカード、USBフラッシュディスク、およびその他のストレージデバイスをサポート。 FAT、EXT2、およびEXT4ファイルシステムをサポートしています。 GPT、RKパラメータパーティションテーブルをサポートします。 パワーオンロゴをサポートし、低電力管理、電力管理。 I2C、PMIC、CHARGE、FUEL GUAGE、 USB、GPIO、PWM、GMAC、eMMC、NAND、Interrupt、等; ベンダーの貯蔵はユーザー データおよび構成を救います。 RockUSB および Google Fastboot USB ガジェットをサポートし、eMMC を書く。量産ストレージ、イーサネット、HID などの USB デバイスをサポートし、ハードウェアの状態でカーネル DTB の動的選択をサポートします。

1.2 バージョン {#12-version}

RKのU-Bootには、それぞれv2014とv2017を含む2つのバージョンがあります。 ユーザが現在のU-Bootがv2017であるか確認するために2つのメソッドが利用できます。 方法1: Makefileバージョン番号が2017年かどうかを確認します。

#
## Chapter-1 SPDX-License-Identifier:      GPL-2.0+
#

VERSION = 2017
PATCHLEVEL = 09
SUBLEVEL =
EXTRAVERSION =
NAME =
......

方法2:ブートプリントの最初の公式ラインがU-Boot 2017.09であるかどうかを確認します。

U-Boot 2017.09-01818-g11818ff-dirty (Nov 14 2019 - 11:11:47 +0800)
......

オープンソース: v2017 はオープンソースで、定期的に Github に更新されています。 https://github.com/r ockchip-linux/u-boot カーネルバージョン: v2017 では RK カーネルバージョン >= 4.4 が必要です。

DM(DM) {#13-dm}

DM(Driver Model)は、カーネルのデバイスドライバモデルと非常に似ているU-Bootの標準的なデバイスドライバ開発モデルです。 v2017はDMフレームワークに従ってさまざまな機能モジュールを開発しています。 そのため、DM アーキテクチャの原則と実装を最初に読み込むことを推奨します。 フィードバック:

./doc/driver-model/README.txt
Terminology
-----------

Uclass - a group of devices which operate in the same way. A uclass provides
         a way of accessing individual devices within the group, but always
         using the same interface. For example a GPIO uclass provides
         operations for get/set value. An I2C uclass may have 10 I2C ports,
         4 with one driver, and 6 with another.

Driver - some code which talks to a peripheral and presents a higher-level
         interface to it.

Device - an instance of a driver, tied to a particular port or peripheral.

概要:uclass: デバイスドライバモデルドライバーデバイスコアコード:

./drivers/core/

1.4 セキュリティ {#14-security}

U-Bootは、ARM TrustZoneセキュリティシステムに非セキュアな世界に属し、安全なリソース(例えば、安全なメモリ、安全なOTP、ヒューズ)に直接アクセスできず、それらにアクセスするために信頼を使用する必要があります。 U-Bootは、RKプラットフォーム上で以下のモードで動作します。

32-bit platform: Non-Secure PL1
64-bit platform:  EL2(Always be Non-Secure)

1.5 ブートオーダー {#15-boot-order}

RKプラットフォームは、フロントレベルのLoaderコードがオープンソースであるか否かに応じて、2つのスタートアップメソッドを持っています。

//  Front loader closed source
BOOTROM => ddr bin => Miniloader => TRUST => U-BOOT => KERNEL
// Front loader open source
BOOTROM => TPL => SPL => TRUST => U-BOOT => KERNEL

TPLはddrビンと同等です。SPLはミニローダーと同等です。TPL+SPLの組合せはRKクローズドソースddr.bin+miniloaderと同じ機能を実現し、それぞれに交換することができます。

1.6 ドライバープローブ {#16-driver-probe}

U-Bootはデバイスドライバ開発モデルを導入していますが、初期化フェーズではカーネルが実行されるため、登録されたデバイスドライバのプローブが自動的に起動しません。 ドライバーのプローブは、ユーザーのアクティブコールで起動する必要があります。 インターフェイスは次の通りです:

int uclass_get_device(enum uclass_id id, int index, struct udevice **devp);
int uclass_get_device_by_name(enum uclass_id id, const char *name,
                              struct udevice **devp);
int uclass_get_device_by_seq(enum uclass_id id, int seq, struct udevice **devp);
int uclass_get_device_by_of_offset(enum uclass_id id, int node, struct udevice **devp);
int uclass_get_device_by_ofnode(enum uclass_id id, ofnode node, struct udevice **devp);
int uclass_get_device_by_phandle_id(enum uclass_id id,
                                    int phandle_id, struct udevice **devp);
int uclass_get_device_by_phandle(enum uclass_id id,
                                 struct udevice *parent, struct udevice **devp);
int uclass_get_device_by_driver(enum uclass_id id,
                                const struct driver *drv, struct udevice **devp);
int uclass_get_device_tail(struct udevice *dev, int ret, struct udevice **devp);
......

上記のインターフェイスへのコア呼び出し:

int device_probe(struct udevice *dev);  // Users are recommended to understand the internal
implementation!

1.7 シェル {#17-shell}

U-Bootのシェルは、CLI(Command Line Interface)と呼ばれ、ユーザーは、ニーズに応じてCMDをカスタマイズできます。 シェルだけでなく、CMDはrun_command()とrun_command_list()を経由してコードとして呼び出すことができます。

int run_command(const char *cmd, int flag)
int run_command_list(const char *cmd, int len, int flag)

1.8 ブートコマンド {#18-boot-command}

U-Bootは、最終的にCONFIG_BOOTCOMMANDで定義されたブートコマンドでカーネルを起動します。 CONFIG_PREBOOT の事前ブートコマンドは、通常、空の定義である CONFIG_BOOTCMD の実行前に実行されます。

1.9 TPL/SPL/U ブートのプロペラ {#19-tplsplu-boot-proper}

異なるコンパイル条件を使用することで、U-Bootは、同じコードのセットで、3つの異なる機能ローダー、TPL / SPL / U-Boot-properを入手できます。 TPL(Tiny Program Loader)とSPL(Secondary Program Loader)は、U-Bootよりも以前の段階で積込み機です。 TPL: sramで実行し、ddrの初期化を補完する責任があります。 SPL: ddrで実行し、システムの低レベル初期化を完了し、後でファームウェアをロードする責任があります(trust.imgとuboot.img)。 U-Boot は適切な: ddr で実行すると、通常はカーネルの起動に責任を負う「U-Boot」と呼びます。注記: U-Boot の用語は、SPL から区別するために使われます。 大会の酒については、U-Bootの全ての参考文献をU-Bootに省略します。 ブートのプロセス:

BOOTROM => TPL(ddr bin) => SPL(miniloader) => TRUST => U-BOOT => KERNEL

詳細は、doc/README.TPL と doc/README.SPL を参照してください。

1.10 ビルドアウトプット {#110-build-output}

U-Boot は、U-Boot(TPL/SPL 生成されたファイルのみ TPL/SPL コンパイルがサポートされているときにのみ、ルートディレクトリに重要なファイルを生成します。

// U-Boot phase
./u-boot.map            // MAP table file
./u-boot.sym            // SYMBOL table file
./u-boot                // ELF files, kernel-like vmlinux (important!)
./u-boot.dtb            //  u-boot's own dtb file
./u-boot.bin            // Executable binary file that will be packaged as uboot.img for
                       programming

// SPL phase
./spl/u-boot-spl.map    // MAP table file
./spl/u-boot-spl.sym    // SYMBOL table file
./spl/u-boot-spl        // ELF files, kernel-like vmlinux (important!)
./spl/u-boot-spl.dtb    // spl's own dtb file
./spl/u-boot-spl.bin    // Executable binary file that will be packaged into a loader for
                         programming

// TPL phase
./tpl/u-boot-tpl.map    // MAP table file
./tpl/u-boot-tpl.sym    // SYMBOL table file
./tpl/u-boot-tpl        // ELF files, kernel-like vmlinux (important!)
./tpl/u-boot-tpl.dtb    // tpl's own dtb file
./tpl/u-boot-tpl.bin    // Executable binary file that will be packaged into a loader for
                         programming

1.11 環境変数 {#111-environment-variables}

ENV(環境変数)は、U-Bootがサポートするグローバルデータ管理と配信方法であり、HASHマッピングテーブルの構築、ユーザーデータを「キーデータ」テーブルのエントリとして管理することです。 EVN は、通常、ファームウェアのロードアドレス、ネットワーク設定(ipaddr、serverip)、bootcmd、bootargs などのプラットフォーム構成パラメーターを定義するために使用されます。これは、コマンドラインで printenv コマンドを使用してユーザーが出力できるものです。

ユーザーは、ENVデータをローカルストレージに保存するかどうかを選択できます。ENVデータはU-Bootのみに制限され、カーネルに直接渡したり、カーネルによって解析されることはできません。 ユーザレイヤーは、U-Bootが提供するfw_printenvツールを介してENVデータにアクセスすることができます。 RKプラットフォーム上のENVデータの保存アドレスとサイズは、次のように定義されます(単位:バイト):

if ARCH_ROCKCHIP
config ENV_OFFSET
        hex
        depends on !ENV_IS_IN_UBI
        depends on !ENV_IS_NOWHERE
        default 0x3f8000
        help
          Offset from the start of the device (or partition)

config ENV_SIZE
        hex
        default 0x8000
        help
          Size of the environment storage area
endif

1.12 UボットDTS {#112-u-boot-dts}

U-Boot は独自の DTS ファイルを持ち、コンパイル時に対応する DTB ファイルが自動的に生成され、u-boot.bin の最後に追加されます。 ファイルディレクトリ:

arch/arm/dts/

各プラットフォームで使用する DTS ファイルが defconfig の CONFIG_DEFAULT_DEVICE_TREE で指定されるか

1.13 移転 {#113-relocation}

通常、起動フェーズでは、U-Bootは以前のブートローダで低DRAMアドレスにロードされ、board_f.cプロセスが完了すると、U-Bootはメモリの最後に予約されたアドレスにそれ自体を再配置します(リロケーションと呼ばれ、U-Bootのメモリレイアウトに依存します)。 再配置完了後、board_r.cプロセスは継続します。 これは、ブートメッセージによって認識することができます。

U-Boot 2017.09-gabfd1c5e3d-210202-dirty #cjh (Mar 08 2021 - 16:57:31 +0800)

Model: Rockchip RK3568 Evaluation Board
PreSerial: 2, raw, 0xfe660000
DRAM:  2 GiB
Sysmem: init
// relocate to ddr where first address offset 0x7d304000. If the offset is 0, no relocation
is executed.

Relocation Offset: 7d304000, fdt: 7b9f8ed8
Using default environment
......

2. . 第2章 RKアーキテクチャ {#2-chapter-2-rk-architecture}

この章では、RKプラットフォーム上で重要な基本や機能などについて紹介しています。

2.1 プレファス {#21-preface}

テキスト全体でConFIG_設定項目を有効に/無効にするすべての参照は、メニュー設定のmake によって有効または無効化するを参照してください。 .h ファイル内で直接定義される特別な CONFIG_ 設定項目を除きます。 設定の依存関係がKconfigで定義されているため、.configが効果を取らないことを避けるために、CONFIG_設定項目を直接有効/無効にしないでください。 defconfig を更新する際に、savedefconfig を ご使用ください。

2.2 プラットフォームのドキュメント {#22-platform-documentation}

プラットホームのカタログ:

./arch/arm/include/asm/arch-rockchip/
./arch/arm/mach-rockchip/
./board/rockchip/
./include/configs/

defconfigカタログ:

./configs/

パブリックボードレベルのドキュメントをコア!

./arch/arm/mach-rockchip/board.c

2.3 プラットフォーム構成 {#23-platform-configuration}

設定ファイル 構成項目、各プラットフォームのパラメーターは、通常次の場所にある:

//Public documents for each platform (developers usually don't need to modify them)
./arch/arm/mach-rockchip/Kconfig
./include/configs/rockchip-common.h

// Unique to each platform, here taking RK3399 as an example
./include/configs/rk3399_common.h
./include/configs/evb_rk3399.h
./configs/rk3399_defconfig

構成ノート: 以下は、rockchip-common.h、rkxxx_common.h、evb_rkxxx.hで定義された重要な構成を記述します。 RKIMG_DET_BOOTDEV: ストレージ型検出コマンドは、スキャン・バイ・スキャン・ファッションの現在のストレージ・デバイスタイプを検出します。 RKIMG_BOOTCOMMAND: カーネル・ブート・コマンド; ENV_MEM_LAYOUT_SETTINGS: ファームウェア・ロード・アドレス, ラムディスク/fdt/kernelを含みます; PARTS_DEFAULT: 有効な GPT パーティション・テーブルがストアに見つからない場合、いくつかのケースで使用されます ROCKCHIP_DEVICE_SETTINGS: 周辺関連コマンド, 主にstdio(通常、ディスプレイモジュールのブーストコマンドを含む)を指定する。 BOOTENV: ブートデバイス検出コマンド 起動時に linux in モード CONFIG_SYS_MALLOC_LEN: モールコットメモリープールのサイズ; CONFIG_SYS_TEXT_BASE: U ブート操作のアドレスを開始; CONFIG_BOOTCOMMAND: ブートコマンドは、通常 RKIMG_BOOTCOMMAND と定義されます。 CONFIG_PREBOOT: プレブートコマンド、CONFIG_BOOTCOMMAND 前に実行されます。 CONFIG_SYS_MMC_ENV_DEV: MMCがENVストレージ媒体として使用されるとき、dev numは通常0です。 以下はRK3399の例です: ./include/configs/rockchip-common.h:

......
#define RKIMG_DET_BOOTDEV \                           // Dynamically detects the current
storage type
    "rkimg_bootdev=" \
    "if mmc dev 1 && rkimgtest mmc 1; then " \
        "setenv devtype mmc; setenv devnum 1; echo Boot from SDcard;" \
    "elif mmc dev 0; then " \
        "setenv devtype mmc; setenv devnum 0;" \
    "elif rknand dev 0; then " \
        "setenv devtype rknand; setenv devnum 0;" \
        "elif rksfc dev 0; then " \
                "setenv devtype rksfc; setenv devnum 0;" \
    "fi; \0"

#define RKIMG_BOOTCOMMAND \
    "boot_android ${devtype} ${devnum};" \           // Booting android format firmware
    "bootrkp;" \                                     // Booting RK format firmware
    "run distro_bootcmd;"                            // Booting the linux firmware
......

./include/configs/rk3399_common.h:

......
#ifndef CONFIG_SPL_BUILD
#define ENV_MEM_LAYOUT_SETTINGS \        // Firmware loading address
    "scriptaddr=0x00500000\0" \
    "pxefile_addr_r=0x00600000\0" \
    "fdt_addr_r=0x01f00000\0" \
    "kernel_addr_r=0x02080000\0" \
    "ramdisk_addr_r=0x0a200000\0"

#include <config_distro_bootcmd.h>
#define CONFIG_EXTRA_ENV_SETTINGS \
    ENV_MEM_LAYOUT_SETTINGS \
    "partitions=" PARTS_DEFAULT \        // Default GPT partition table
    ROCKCHIP_DEVICE_SETTINGS \
    RKIMG_DET_BOOTDEV \
    BOOTENV                              // Booting device detection command when booting
                                          linux
#endif

#define CONFIG_PREBOOT                   // Pre-boot commands that are executed before
                                        CONFIG_BOOTCOMMAND
......

./include/configs/evb_rk3399.h:

......
#ifndef CONFIG_SPL_BUILD
#undef CONFIG_BOOTCOMMAND
#define CONFIG_BOOTCOMMAND RKIMG_BOOTCOMMAND // Define boot command (set to
                                              RKIMG_BOOTCOMMAND)
#endif
......
#define ROCKCHIP_DEVICE_SETTINGS \           // Enable display module
        "stdout=serial,vidconsole\0" \
        "stderr=serial,vidconsole\0"
......

2.4 ブート プロセス {#24-boot-process}

RKプラットフォームのU-Bootブートプロセスは、次の通りです。重要な手順の一部のみがリストされています。

start.s
    // assembly environment
    => IRQ/FIQ/lowlevel/vbar/errata/cp15/gic   // ARM architecture related lowlevel
                                                initialization
    => _main
        => stack                               // Prepare the stack needed for the C
                                              environment
        // [Phase 1] Initialization of the C environment, initiating a series of function
calls
        => board_init_f: init_sequence_f[]
            initf_malloc
            arch_cpu_init                      // [Lowlevel initialization of SoCs]
            serial_init                        // Serial port initialization
            dram_init                          // [Getting ddr capacity information]
            reserve_mmu                        // Reserve memory from the end of ddr to a
                                                lower address.
            reserve_video
            reserve_uboot
            reserve_malloc
            reserve_global_data
            reserve_fdt
            reserve_stacks
            dram_init_banksize
            sysmem_init
            setup_reloc                        //Determine the address of the U-Boot
                                             itself to be relocated
        // Compilation environment
        => relocate_code                       // Compilation of U-Boot code to implement
relocation
        // [Phase 2] C environment initialization, initiating a series of function calls
        => board_init_r: init_sequence_r[]
            initr_caches                       // Enable MMU and I/Dcache
            initr_malloc
            bidram_initr
            sysmem_initr
            initr_of_live                      // Initialize of_live
            initr_dm                           // Initializing the dm framework
            board_init                         // [Platform initialization, the core part]
                board_debug_uart_init          // Serial port iomux, clk configuration
                init_kernel_dtb                // [Switch to kernel dtb]!
                clks_probe                     // Initialize system frequency
                regulators_enable_boot_on      // Initialize system power
                io_domain_init                 // io-domain initialization
                set_armclk_rate                // __weak, ARM boost (implemented on demand
by the platform)
                dvfs_init                      // wide-temperature chip frequency modulation
and voltage control
                rk_board_init                  // __weak, implemented by each specific
platform
            console_init_r
            board_late_init                    // [Platform late initialization]
                rockchip_set_ethaddr           // Setting the mac address
                rockchip_set_serialno          // Setting serialno
                setup_boot_mode                // Parsing the “reboot xxx” command
                                               // Recognizes key and loader modes, recovery
                charge_display                 // U-Boot charge
                rockchip_show_logo             // Display boot logo
                soc_clk_dump                   // print clk tree
                rk_board_late_init             // __weak, implemented by each specific
platform
            run_main_loop                      // [Enter command line mode, or execute the
boot command]

2.5 記憶レイアウト {#25-memory-layout}

U-Bootは、CONFIG_SYS_TEXT_BASEアドレスに先代の loader がロードされ、現在のシステム全体のメモリ容量をプロービングすることで初期化されます。これは、32ビットプラットフォームで利用可能な 4GB の最大値であると仮定しています(ただし、カーネルの容量の認識に影響を与えません)、すべてのメモリは 64ビットプラットフォームで利用可能であると仮定します。 それから、reserve_xxx() インターフェイスのシリーズを通して、それは記憶の端から必要とする記憶を先に予約し、そして最終的にある予約されたスペースにそれ自身を再配置します。 メモリ使用レイアウトは、ARM64 を例に使用して次のようにします。(正規の場合):

名前 スタートアダプラーオフセット サイズ 利用条件 セキュア
ATF 0x00000000 1M ARMはファームウェアを信頼しました はい
SHM 0x00100000 1M SHM, ストア いいえ
OP-TEE 0x08400000 2M~30M TEE開発マニュアルを参照 はい
FDT fdt_addr_r - カーネルdtb いいえ
KERNEL kernel_addr_r - カーネルイメージ いいえ
RAMDISK ramdisk_addr_r - ラムディスクイメージ いいえ
…… - - - -
FASTBOOT - - Fastboot バッファ いいえ
…… - - -  
SP - - スタック いいえ
FDT - のりば(dtb) U ボット dtb いいえ
GD - サイズの(gd) - いいえ
ボード - sizeof(bd_t) の仕様 - いいえ
MALLOC - CONFIG_SYS_MALLOC_LEN システムヒープスペース いいえ
Uブート - 寸法(月) u-boot イメージ いいえ
ビデオFB - fbサイズ 32M いいえ
TLBテーブル RAM_TOP-64K 32K MMUページテーブル いいえ

上記表の[スタートアダプター]オフセットカラムは、DDRベースに基づくアドレスオフセットを表しています。Fastbootアドレスとサイズは、設定で決定されます。CONFIG_FASTBOOT_BUF_ADDR、CONFIG_FASTBOOT_BUF_SIZE。 ビデオFB/U-Boot/Malloc/Board/Gd/Fdt/Spは実際の要件サイズに基づいてトップからボトムまで割り当てられます。 64ビットプラットフォーム: ATFはARMv8、OP-TEEのオプションが必要です。 32ビットプラットフォーム: OP-TEE利用可能なカーネルfdt/kernel/ramdiskのみが、 U-Bootがロードする必要があるファームウェアのアドレスです。 ENV_MEM_LAYOUT_SETTINGS で定義されている; Fastboot 機能に必要なバッファのアドレスとサイズは defconfig で定義されます。 OP-TEE が占有するスペースは、実際の需要に基づいている必要があります。最大は 30M です。 RK1808/RK3308 の OP-TEE が 0x8400000 ではなく、低アドレスに配置されます。

2.6 ストレージレイアウト {#26-storage-layout}

RK linuxプログラムのストレージレイアウトは、次のとおりであり、Androidプログラムは基本的にはブート/rootfsの定義がLinuxプラットフォームのものと異なることを除いて同じです。

出典図、英語PDF p28

映像の参照: http://opensource.rock-chips.com/wiki_Partitions

2.7 アリアーゼ {#27-aliases}

カーネルDTSで定義されているものと異なるU-Bootには、いくつかの特別なエイリアスがあります。 eMMC/SDは、U-Bootのmmcデバイスとして集約され、数値0と1を差分に使用します。SDはeMMCよりも高い起動優先度を持っています。

mmc1: indicates sd
mmc0: indicates emmc

2.8 アンプ {#28-amp}

RKプラットフォーム用のU-Bootは、AMP(Asymmetric Multi-Processing)ファームウェアの起動をサポートしています。 詳しくは、ドライバモジュールのセクションをご確認ください。

2.9 タグ {#29-atags}

RKプラットフォームの起動プロセス:

BOOTROM => ddr-bin => Miniloader => TRUST => U-BOOT => KERNEL

ATAGS メカニズムを介して RK プラットフォーム上のさまざまなレベルのファームウェア間で、いくつかの構成情報を渡すことができます。 アプリケーションの範囲: カーネルの渡されたコンテンツを除くddr-bin、miniloader、trust、U-Boot:シリアルポート構成、ストレージタイプ、ATFおよびOP-TEE、ddr容量などで占有されるメモリ コードの実装:

./arch/arm/include/asm/arch-rockchip/rk_atags.h
./arch/arm/mach-rockchip/rk_atags.c

2.10 ビットラム/シズム {#210-bidramsysmem}

U-Bootは、システムのすべてのメモリを使用できるため、メモリを保存した後、システムが高アドレスから低アドレスに必要とするメモリを予約できます。通常、大きなメモリスペースが残っています。 U- Boot は、このスペースを管理するためのメカニズムを持たないため、RK プラットフォームでは、このメモリのブロックを管理するために、bidram、sysmem メモリブロックの仕組みを導入しています。 そのため、U-Bootの既存のモールロック管理機構と併せて、RKプラットフォームは、sysmem + bidram + mallocを通じてシステムメモリを管理し、メモリの競合などの問題を防ぎます。

low-addr                                                                    high-addr
|-----------------------------------------------------------|-----------------|
|             no management                                 | system used     |
|-----------------------------------------------------------|-----------------|
0x0                                                                          N GB

bidram: u-boot とカーネルのステージで利用できなくなったメモリブロックを管理し、削除する必要があります。例えば ATF と OP-TEE によって占有されるスペース。

sysmem: メモリのブロックを可視化し、カーネルに利用できるように管理します。 例えば、fdt, ramdisk, カーネル, と fastboot によって占有された空間。 関連コード:

./lib/sysmem.c
./lib/bidram.c
./include/memblk.h
./arch/arm/mach-rockchip/memblk.c

ブロックが初期化または異常に割り当てられたときにダンプされた、bidram および sysmem のメモリ管理情報を示します。 以下は簡単な説明です。 bidramメモリ情報テーブル:

bidram_dump_all:
    --------------------------------------------------------------------
    // <1> Here shows the total capacity information of the ddr that U-Boot got from the
previous loader, which is 2GB in total
    memory.rgn[0].addr     = 0x00000000 - 0x80000000 (size: 0x80000000)

    memory.total           = 0x80000000 (2048 MiB. 0 KiB)
    --------------------------------------------------------------------
    // <2> This shows information about the memory that has been set aside for each
firmware, which is unvisible to the kernel.
    reserved.rgn[0].name   = "ATF"
                   .addr   = 0x00000000 - 0x00100000 (size: 0x00100000)
    reserved.rgn[1].name   = "SHM"
                   .addr   = 0x00100000 - 0x00200000 (size: 0x00100000)
    reserved.rgn[2].name   = "OP-TEE"
                   .addr   = 0x08400000 - 0x0a200000 (size: 0x01e00000)

    reserved.total         = 0x02000000 (32 MiB. 0 KiB)
    --------------------------------------------------------------------
    // <3> Here is how the core algorithm organizes the reserved information for <2> above,
e.g., it will merge adjacent blocks
    LMB.reserved[0].addr   = 0x00000000 - 0x00200000 (size: 0x00200000)
    LMB.reserved[1].addr   = 0x08400000 - 0x0a200000 (size: 0x01e00000)

    reserved.core.total    = 0x02000000 (32 MiB. 0 KiB)
    --------------------------------------------------------------------

sysmem の記憶情報テーブル:

sysmem_dump_all:
    --------------------------------------------------------------------
    // <1> Here is the total amount of memory that sysmem can manage, i.e., the amount of
available ddr, excluding bidram <3>, visible to the kernel.
    memory.rgn[0].addr     = 0x00200000 - 0x08400000 (size: 0x08200000)
    memory.rgn[1].addr     = 0x0a200000 - 0x80000000 (size: 0x75e00000)

    memory.total           = 0x7e000000 (2016 MiB. 0 KiB)
    --------------------------------------------------------------------
    // <2> This shows information about the memory blocks allocated away by each firmware
    allocated.rgn[0].name  = "U-Boot"
                    .addr  = 0x71dd6140 - 0x80000000 (size: 0x0e229ec0)
    allocated.rgn[1].name  = "STACK"      <Overflow!> // Indicates stack overflow
                    .addr  = 0x71bd6140 - 0x71dd6140 (size: 0x00200000)
    allocated.rgn[2].name  = "FDT"
                    .addr  = 0x08300000 - 0x08316204 (size: 0x00016204)
    allocated.rgn[3].name  = "KERNEL"     <Overflow!> // Indicates a memory block overflow
                    .addr  = 0x00280000 - 0x014ce204 (size: 0x0124e204)
    allocated.rgn[4].name  = "RAMDISK"
                    .addr  = 0x0a200000 - 0x0a3e6804 (size: 0x001e6804)
    // <3>  size of malloc_r/f
    malloc_r: 192 MiB, malloc_f: 16 KiB

    allocated.total        = 0x0f874acc (248 MiB. 466 KiB)
    --------------------------------------------------------------------
    // <4> Here's the information that the core algorithm organizes for the above <2>,
showing information about occupied memory blocks
    LMB.reserved[0].addr   = 0x00280000 - 0x014ce204 (size: 0x0124e204)
    LMB.reserved[1].addr   = 0x08300000 - 0x08316204 (size: 0x00016204)
    LMB.reserved[2].addr   = 0x0a200000 - 0x0a3e6804 (size: 0x001e6804)
    LMB.reserved[3].addr   = 0x71bd6140 - 0x80000000 (size: 0x0e429ec0)

    reserved.core.total    = 0x0f874acc (248 MiB. 466 KiB)
    --------------------------------------------------------------------

以下は、一般的なエラー出力です。 これらの例外が発生したときは、上記に示す bidram と sysmem のダンプメモリ情報と組み合わせて解析します。

//The memory expected to be requested is already occupied by other firmware and there is
memory overlap. This indicates that the current system's memory block usage is not planned
properly
Sysmem Error: "KERNEL" (0x00200000 - 0x02200000) alloc is overlap with existence "RAMDISK"
(0x00100000 - 0x01200000)

// Memory expected to be requested could not be requested for some specific reason (analyze
sysmem and bidram messages)
Sysmem Error: Failed to alloc "KERNEL" expect at 0x00200000 - 0x02200000 but at 0x00400000 -
0x0420000

// sysmem manages space starting at 0x200000, so it simply can't claim space starting at
0x100000
Sysmem Error: Failed to alloc "KERNEL" at 0x00100000 - 0x02200000

// Duplicate request for “RAMDISK” memory block.
Sysmem Error: Failed to double alloc for existence "RAMDISK"

2.11 ヒューズ/OTP {#211-fuseotp}

RKプラットフォームは、セキュアブートモード(Fuse/otpをダウンロードする必要はありません)をセキュアブートの容易なデバッグのためにファームウェアに署名することで、セキュアブートモードを有効にします。 Miniloaderは、現在のefuse/otpがダウンロードされているか否かを示すために、U-Boot経由でカーネルにcmdlineを付加します。 “fuse.programmed=1” : Secure-bootが有効になっています。 efuse/otpは既にダウンロードされています。 “fuse.programmed=0” : Secure-bootはエンバルされ、efuse/otpはダウンロードされていません。 cmdline で fuse.programmed なし: セキュア・ブートが有効ではありません (Miniloader がパスしません)。 またはMiniloader は渡るサポートに 古いです。 U-Boot は、以下のコミットを含む必要があります。

83c9bd4 board: rockchip: pass fuse programmed state to kernel

2.12 のホットキー {#212-hotkey}

RKプラットフォームは、デバッグとダウンロードのためのいくつかのイベントをトリガーするためにシリアルポートキーの組み合わせを提供します(トリガーできない場合は、再度試してみてください。安全なブートが有効になっている場合無効)。 起動時に、長いプレス:ctrl + c:U-Bootコマンドラインモードを入力します。 ctrl +d:ローダーモードを入力してください。 ctrl + b:マスクROMモード ctrl + f: fastbootモードを入力します。 ctrl+m: プリントビブラム/システム情報 ctrl+i: カーネルのinitcall_debug ctrl+pを有効化: プリントcmdline情報 ctrl+s: “カーネルの開始…” その後、U-Bootコマンドラインを入力します。

2.13 イメージの解凍 {#213-image-decompress}

64ビットマシンは、通常、U-Bootがターゲットの実行アドレスにロードされる画像をダウンロードします。 RKプラットフォーム用のU-ブートは、64ビットLZ4圧縮カーネルの減圧にも対応できます。 しかし、その達成のために、ユーザーは次の機能を有効にする必要があります。

CONFIG_LZ4=y

64ビットLZ4圧縮カーネルのプレおよびポストの解凍アドレスは、各プラットフォームのrkxxx_common.hファイルで定義する必要があります。

#define ENV_MEM_LAYOUT_SETTINGS \
    "scriptaddr=0x00500000\0" \
    "pxefile_addr_r=0x00600000\0" \
    "fdt_addr_r=0x01f00000\0" \
    "kernel_addr_no_bl32_r=0x00280000\0" \
    "kernel_addr_r=0x00680000\0" \        // Address of the LZ4 decompression kernel
    "kernel_addr_c=0x02480000\0" \        // Address of the LZ4 compression kernel
    "ramdisk_addr_r=0x04000000\0"

32ビットマシンは通常ダウンロード zImage U-Boot がロードされる kernel_addr_r カーネルが自身でアドレスをとり、自動で分解します。 U-Boot for RKプラットフォームは、U-Bootがターゲットランタイムアドレスにロードされるイメージフォーマットもサポートできます。 現在は rkxxx_common.h 各プラットフォームのファイルのみを定義します kernel_addr_r ではなく、 kernel_addr_c アドレス

ユーザーは、設定を変更する必要はありません。U-Bootは、現在zImageまたはイメージであるかどうかを決定し、これらの2アドレスを動的に処理します。 しかし、ユーザーは無効にする必要があります。

CONFIG_SKIP_RELOCATE_UBOOT

32ビットカーネルの読み込みアドレス定義。

#define ENV_MEM_LAYOUT_SETTINGS \
    "scriptaddr=0x60000000\0" \
    "pxefile_addr_r=0x60100000\0" \
    "fdt_addr_r=0x68300000\0" \
    "kernel_addr_r=0x62008000\0" \       // zImage compressed kernel address
    "ramdisk_addr_r=0x6a200000\0"

2.14 イメージカーネル {#214-image-kernel}

RKプラットフォーム用のU-Bootは、カーネルファームウェアのブートの3つのフォーマットをサポートしています:RK形式の画像ファイルのマジックは「KRNL」です。

00000000   4B 52 4E 4C  42 97 0F 00  1F 8B 08 00  00 00 00 00  KRNL..y.........
00000010   00 03 A4 BC  0B 78 53 55  D6 37 BE 4F  4E D2 A4 69  .....xSU.7.ON..i

kernel.img = カーネル; resource.img = dtb +ロゴ.bmp + logo_kernel.bmp; boot.img = ramdisk; recovery.img = ramdisk(回復用); Androidのフォーマット 画像ファイルの魔法は「ANDROID!」です:

00000000   41 4E 44 52  4F 49 44 21  24 10 74 00  00 80 40 60  ANDROID!$.t...@`
00000010   F9 31 CD 00  00 00 00 62  00 00 00 00  00 00 F0 60  .1.....b.......`

boot.img = カーネル + ramdisk+ リソース + < dtbの >; recovery.img = カーネル + ramdisk(回復のために) + リソース + <recovery_dtbo> + < dtbの > ; ノート: recovery_dtbo : Android-9.0 以降に画像が追加されました。dtb: Android-10.0 以降だけ画像が追加されました。Distro 形式 1 一般的なファームウェアのパッケージングフォーマットは、オープンソース Linux の ramdisk、dtb、カーネルをイメージにパッケージすることです。 この画像は、通常、ext2、ext4、fat などのsertainファイルシステムフォーマットに存在します。 U- Boot はファイルシステムからコンテンツにアクセスする必要があります。 詳しくは、下記をご覧ください。

./doc/README.distro
./include/config_distro_defaults.h
./include/config_distro_bootcmd.h

ブートの優先順位: android > rk > の変位, 各ファームウェアは、対応するブートコマンドを持っています, そして、 3 つのコマンドは、ファームウェアが起動するまで優先順位の順に 1 つずつ実行されます. すべてのコマンドが失敗した場合は、U-Bootコマンドラインモードにとどまります。 ブート優先順位の定義:

#define RKIMG_BOOTCOMMAND \
    "boot_android ${devtype} ${devnum};" \
    "bootrkp;" \
    "run distro_bootcmd;"

2.15 イメージUブート {#215-image-u-boot}

U-Boot と RK プラットフォームの信頼のための 2 つのファームウェア形式があります。RK および FIT フォーマットは、それぞれ Miniloader と SPL によって起動されます。 Rockchipがリリースした現在のSDKは、RV1126をセパレートポイントとして取り、RV1126の後にプラットフォームはFIT形式、RV1126前のプラットフォームはRK形式を使用します。 RK フォーマット Rockchip のカスタマイズされたファームウェアフォーマット、U ボットおよび信頼はそれぞれ uboot.img および trust.img として包まれます。 次のようにします。 uboot.img および 32 ビット trust.img のイメージに魔法「LOADER」があります。

00000000  4c 4f 41 44 45 52 20 20  00 00 00 00 00 00 00 00  |LOADER  ........|
00000010  00 00 20 00 78 d0 0f 00  06 99 c2 a8 20 00 00 00  |.. .x....... ...|
00000020  09 8a b0 e1 89 7a c2 89  0d e8 da ef 86 3e f2 24  |.....z.......>.$|

64ビットtrust.imgイメージファイルにはマジック「BL3X」が搭載されています。

00000000  42 4c 33 58 00 01 00 00  23 00 00 00 f8 00 04 00  |BL3X....#.......|
00000010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

U-Bootのメインラインは、U-Boot、信頼、およびmcuファームウェアがuboot.imgとしてパッケージ化した非常に柔軟なファームウェアフォーマットをサポートしています。 uboot.imgのイメージファイルには、ファームウェアのヘッダーを表示できるコマンドfdtdump uboot.imgでマジック「d0 0d fe ed」があります。

00000000  d0 0d fe ed 00 00 06 00  00 00 00 58 00 00 04 c4  |...........X....|
00000010  00 00 00 28 00 00 00 11  00 00 00 10 00 00 00 00  |...(............|

詳しくはFITセクションをご覧ください。 通常、uboot.imgおよびtrust.imgはOTAのアップグレードプロセスの電源異常によるファームウェアの破損の可能性に等に対処するために複数のバックアップと包まれます。

ファームウェア コピーごとのサイズ コピー数
NK uboot.imgの特長 1MB 4
RK 32ビット trust.img 1MB 4
RK 64ビット trust.img 2MB 2
フィッツ uboot.img 2MB 2

上記の表から見ることができるように、uboot.imgとtrust.imgはデフォルトでサイズが4MBです。 コピーとコピー数のコピーごとにサイズを変更するためのメソッド RK 形式: コンパイルコマンドにパラメーターを追加します。 例えば: -sz-uboot 2048 1 と - sz-trust 4096 1 は、uboot.img のシングルコピーサイズが 2M で、1 コピーパッケージ。 trust.img シングルコピーサイズは 4M、1 コピーパッケージ付き。 FIT フォーマット: 設定パラメータを変更します。: CONFIG_SPL_FIT_IMAGE_KB と CONFIG_SPL_FIT_IMAGE_MULTIPLE 、それぞれ単一のコピーサイズ(KB)とパッケージされたコピーの数を示します。

注:SPLは、CONFIG_SPL_FIT_IMAGE_KBまたはCONFIG_SPL_FIT_IMAGE_MULTIPLEに従ってuboot.imgのバックアップ項目の場所と数を決定します。 開発者がこれらの2つのオプションを変更した場合、生成されたローダーがリアルタイムのコンパイルによって生成されたu-boo-spl.binを格納するように、パラメータ–spl-newをmake.shに追加する必要があります。 それ以外の場合は、 rkbinで提出されたu- boo-spl.binはデフォルトで梱包されています(デフォルトでは、2MB*2のuboot.imgでバックアップ項目を見つける)。

2.16 中断 {#216-interrupt}

U-Bootのネイティブコードは、割込みにフルサポートされていないため、RKプラットフォームはGIC-V2とGIC-V3をサポートする機能を改善します。 ドライバーモジュールのセクションを参照してください。

2.17 カーネルDTB {#217-kernel-dtb}

ネイティブU-Bootは、U-Boot独自のDTBを使用するだけをサポートし、RKプラットフォームは、カーネルDTBメカニズムのサポートを追加します。つまり、カーネルDTBを使用して周辺機器を初期化します。 主目的は、パワー、クロック、ディスプレイなど、周辺ボードレベルの違いと互換性があります。 二つの役割: U ボット DTB: ストレージやシリアルポートを印刷するためのデバイスなどの初期化デバイスの責任; カーネル DTB: ストレージとシリアルポートを印刷するためのデバイス以外のデバイスを初期化するための責任; U ボットが初期化するとき、それは最初にストレージを完了し、シリアルポートの初期化を印刷するために U ボット DTB を使用します。 カーネルの DTB をストレージから読み込んで、この DTB に切り替えて、末尾の残りの部分を初期化します。Kerne DTB のコードは、init_kernel_dtb() で実装されています。 開発者は、一般的にU-Boot DTB(印刷シリアルポートが置換されていない限り)を変更する必要はありません。各プラットフォームでリリースされたSDKで使用されるデフコンフィグは、カーネルDTBメカニズムが有効になっています。 つまり、通常、周辺DTS変更では、カーネルDTBを変更する必要があります。 U-Boot DTB:DTSディレクトリ:

./arch/arm/dts/

カーネル DTB のメカニズムを有効にした後:コンパイルフェーズは、u-boot、dm- プレリロックと u-boot、dm-spl 属性を U-Boot DTS からフィルタアウトし、その上部に、 defconfig から CONFIG_OF_SPL_REMOVE_PROPS によって指定されたプロパティーを除外します。 u-boot.dtbファイルを生成して、u-boot.binの最後に追加します。

U-Boot コンパイル後、fdtdump コマンドで DTB コンテンツを確認できます。

fdtdump ./u-boot.dtb | less

詳しくは、上級原則セクションをご覧ください。

2.18 MMUキャッシュ {#218-mmu-cache}

RKプラットフォームは、デフォルトでMMU、Dcache、Icacheを有効化し、1:1リニアマッピングを採用し、Dcacheは書き込みバックポリシーを採用しています。 関連インターフェイス:

// Icache interface:
void icache_enable (void);
void icache_disable (void);
void invalidate_icache_all(void);

// Dcache interface:
void dcache_disable (void);
void dcache_enable(void);
void flush_dcache_range(unsigned long start, unsigned long stop);
void flush_cache(unsigned long start, unsigned long size);
void flush_dcache_all(void);
void invalidate_dcache_range(unsigned long start, unsigned long stop);
void invalidate_dcache_all(void);
// Remap the Dcache attributes of a block of memory intervals
void mmu_set_region_dcache_behaviour(phys_addr_t start, size_t size,
                                     enum dcache_option option)

2.19 Make.sh {#219-makesh}

make.shはコンパイルスクリプトとパッケージとデバッグツールの両方で、ファームウェアを分解しパッケージ化するために使用できます。

// help command
./make.sh --help

// Functions of packaging firmware
./make.sh trust              // packaging trust
./make.sh loader             // packaging loader
./make.sh trust <ini-file>   // Specify ini file when packaging trust
./make.sh loader <ini-file>  // Specify ini file when packaging loader
./make.sh spl                // Replace ddr and miniloader with tpl+spl, and packaged as
loader
./make.sh spl-s              // Replace miniloader with spl, packaged as loader
./make.sh itb                // Packaging u-boot.itb (64-bit platforms only support
packaging ATF and U-Boot, OP-TEE does not)
./make.sh env                // Generate fw_printenv tool

// Disassembly Functions
./make.sh elf-[x] [type]     // Disassembly: Use the -[x] parameter, [type] to select
whether to disassemble SPL or TPL.
./make.sh elf                // Disassemble the u-boot file, using the -D parameter by
default.
./make.sh elf-S              // Disassemble the u-boot file, using the -S parameter
./make.sh elf-d              // Disassemble the u-boot file, using the -d parameter
./make.sh elf spl            // Disassemble the tpl/u-boot-tpl file, using the -D parameter
by default.
./make.sh elf tpl            // Disassemble the spl/u-boot-tpl file, use the -D parameter by
default
./make.sh <addr>             // Requires the function name and code location corresponding
to addr
./make.sh map                // open u-boot.map
./make.sh sym                // open u-boot.sym

2.20 HW-ID DTBの特長 {#220-hw-id-dtb}

RKプラットフォームのUボットは、GPIOやADCsのハードウェア状態に基づいてロードされるために複数のDTBファイルからハードウェアの状態に一致するDTBをフィルタリングすることができます。 詳しくは、システムモジュールのセクションをご確認ください。

2.21 仕切りテーブル {#221-partition-table}

RKプラットフォーム用のU-Bootは、2種類のパーティションテーブルをサポートしています:RKパラメータフォーマット(旧)と標準GPTフォーマット(新)、マシンに2種類のパーティションテーブルがある場合、GPTパーティションテーブルが優先されます。 GPT 形式や RK パラメータの整形板で、ダウンロード時に使われるパーティションテーブルファイルが parameter.txt と呼ばれ、GPT か「TYPE: GPT」属性を通さないか確認できます。

FIRMWARE_VER:8.1
MACHINE_MODEL:RK3399
MACHINE_ID:007
MANUFACTURER: RK3399
MAGIC: 0x5041524B
ATAG: 0x00200800
MACHINE: 3399
CHECK_MASK: 0x80
PWR_HLD: 0,0,A,0,1
TYPE: GPT               // Partition table in GPT format is under using, otherwise it is RK
paramter format
CMDLINE:mtdparts=rk29xxnand:0x00002000@0x00004000(uboot),0x00002000@0x00006000(trust),0
x00002000@0x00008000(misc),0x00008000@0x0000a000(resource),0x00010000@0x00012000(kernel
),0x00010000@0x00022000(boot),0x00020000@0x00032000(recovery),0x00038000@0x00052000(bac
kup),0x00002000@0x0008a000(security),0x00100000@0x0008c000(cache),0x00500000@0x0018c000
(system),0x00008000@0x0068c000(metadata),0x00100000@0x00694000(vendor),0x00100000@0x007
96000(oem),0x00000400@0x00896000(frp),-@0x00896400(userdata:grow)

2.22 移転 {#222-relocation}

U-Bootは、U-Bootメモリレイアウトに応じて、board_f.cプロセスを完了した後、メモリの最後にアドレスに自身を再配置します。 RKのUボットデフォルト:32ビットプラットフォーム:CONFIG_SKIP_RELOCATE_UBOOT=yはリロケーションがない場合、そうしない。

64ビットプラットフォームの移転

2.23 リセット {#223-reset}

カーネルのように、U-Bootリセットは、最終的に信頼で行われる必要があります。 U-Boot コマンドラインモードは、カーネルと同じリブートxxxコマンドをサポートできます(カーネルのdtsの定義に依存します)。

2.24 sd/Udisk {#224-sdudisk}

RKプラットフォーム用のU-Bootは、SD / Uディスクから起動またはアップグレードするファームウェアをサポートしています。 それらの中で:SDの起動/アップグレードは、USBフラッシュドライブ起動/アップグレードの起動からサポートされます。 U-Bootレベル以降は、参照のためにサポートされています。 システムモジュールセクションを確認してください。

2.25 スタットレース {#225-stacktrace}

ネイティブU-Bootはコールスタックトレースバック機構をサポートしていませんが、RKプラットフォームは機能を追加しました。 現在、コールスタック印刷をトリガーする3つの方法の合計があります。システムがクラッシュしたときに自動的にトリガーされます。 dump_stack() へのユーザー認証呼び出し。 CONFIG_ROCKCHIP_DEBUGGERを有効にします。 例えば、システムが中止します。

"Synchronous Abort" handler, esr 0x96000010

// abort reason, pc, lr, sp
* Reason:        Exception from a Data abort, from current exception level
* PC         =   000000000028f430
* LR         =   00000000002608d0
* SP         =   00000000f3dceb30

...

// Highlighting PC and LR
Call trace:
  PC:   [< 0028f430 >]
  LR:   [< 002608d0 >]

// Function call relationships
Stack:
        [< 0028f430 >]
        [< 0028da24 >]
        [< 00211600 >]
        [< 002117b0 >]
        [< 00202910 >]
        [< 00202aa8 >]
        [< 0027698c >]
        [< 002151ec >]
        [< 00201b2c >]

// Instructs the user to convert the above call stack information
Copy info from "Call trace..." to a file(eg. dump.txt), and run
command in your U-Boot project: ./scripts/stacktrace.sh dump.txt

上記の手順に従って、ユーザーはコールスタック情報を任意の txt ファイル(dump.txt など)にコピーし、次のコマンドを実行します。

cjh@Ubuntu:~/u-boot$ ./scripts/stacktrace.sh dump.txt

// Symbol Table Sources
SYMBOL File: ./u-boot.sym

// Highlight the code locations corresponding to PC and LR
Call trace:
 PC:   [< 0028f430 >]  strncpy+0xc/0x20      ./lib/string.c:98
 LR:   [< 002608d0 >]  on_serialno+0x10/0x1c ./drivers/usb/gadget/g_dnl.c:217

// Converted to get the real function name
Stack:
       [< 0028f430 >]  strncpy+0xc/0x20
       [< 0028da24 >]  hdelete_r+0xcc/0xf0
       [< 00211600 >]  _do_env_set.isra.0+0x70/0x1b8
       [< 002117b0 >]  env_set+0x3c/0x58
       [< 00202910 >]  rockchip_set_serialno+0x54/0x140
       [< 00202aa8 >]  board_late_init+0x5c/0xa0
       [< 0027698c >]  initcall_run_list+0x58/0x94
       [< 002151ec >]  board_init_r+0x20/0x24
       [< 00201b2c >]  relocation_return+0x4/0x0

注意: 変換コマンドの3種類があります。コールスタックのプリントアウト後に指示に従って、どの種類の変換コマンドを使用するかを判断してください。

./scripts/stacktrace.sh ./dump.txt        // Parsing Call Stack Information from U-
Boot
./scripts/stacktrace.sh ./dump.txt tpl    // Parsing call stack information from tpl
./scripts/stacktrace.sh ./dump.txt spl    // Parsing call stack information from spl

このコマンドを実行すると、現在のマシン上のファームウェアは、現在のコード環境に有意である必要があります!それ以外の場合は、誤った変換を取得します。

2.26 タイムコスト {#226-timecost}

U-Boot 初期化の終了は、デフォルトでこのフェーズの合計経過時間を表示します。

### Booting Android Image at 0x02007800 ...
Kernel load addr 0x02008000 size 8062 KiB
### Flattened Device Tree blob at 08300000
   Booting using the fdt blob at 0x8300000
   XIP Kernel Image ... OK
  'reserved-memory' dma-unusable@fe000000: addr=fe000000 size=1000000
  'reserved-memory' ramoops@00000000: addr=8000000 size=f0000
   Using Device Tree in place at 08300000, end 08316ed1
Adding bank: 0x00000000 - 0x08400000 (size: 0x08400000)
Adding bank: 0x09200000 - 0x80000000 (size: 0x76e00000)
Total: 812.613 ms    //Total elapsed time for the U-Boot phase

Starting kernel ...

ユーザーは、次の処理タイミングを得るために、lib/initcall.c で debug() と DEBUG を開くことができます。 機能アドレスは、 . /make.sh の分解の助けを借りて取得できます。

U-Boot 2017.09-00019-g9b55ed0-dirty (Dec 26 2019 - 14:45:33 +0800)

                                         #    5212 us # 137.868 ms
initcall: 0020de1f
                                         #       1 us # 142.636 ms
initcall: 0020e015
Model: Evb-RK3288
                                         #    1646 us # 149. 48 ms
initcall: 0020dd61
PreSerial: 2
                                         #    1213 us # 155. 28 ms
initcall: 0020ddcd
DRAM:                                    #     606 us # 160.401 ms
initcall: 00203719
              // The following 187 us is the time consumed by initcall: 00203719 call
              // The following 165.355 ms is the U-Boot boot time until initcall: 00203719
                                         #     187 us # 165.355 ms
initcall: 0020de81
                                         #       2 us # 169.938 ms
initcall: 0020dc29
                                         #       1 us # 174.703 ms
initcall: 0020dc3d
                                         #       1 us # 179.469 ms
initcall: 0020ddad
                                         #       2 us # 184.237 ms
initcall: 0020de27
                                         #       1 us # 189.  2 ms
......

2.27 タイムスタンプ {#227-timestamp}

Kernelのprintメッセージはデフォルトでタイムスタンプを持っています。これは、ユーザーがtime.U-Bootのprintメッセージに注目を払うのに便利です。デフォルトではタイムスタンプはありません。必要に応じて、ユーザーは設定CONFIG_BOOTSTAGE_PRINTF_TIMESTAMPを有効にできます。

[    0.324987] U-Boot 2017.09-00019-g9b55ed0-dirty (Dec 26 2019 - 14:31:44 +0800)

[    0.327215] Model: Evb-RK3288
[    0.330039] PreSerial: 2
[    0.332526] DRAM:  2 GiB
[    0.336454] Relocation Offset: 00000000, fdt: 7be22c38
[    0.346981] Using default environment

[    0.351075] dwmmc@ff0c0000: 1, dwmmc@ff0f0000: 0
[    0.394136] Bootdev(atags): mmc 0
[    0.394272] MMC0: High Speed, 52Mhz
[    0.395276] PartType: EFI
[    0.400347] Android 9.0, Build 2019.6
[    0.402070] boot mode: None
[    0.405213] Found DTB in boot part
[    0.407833] DTB: rk-kernel.dtb
[    0.418211] ANDROID: fdt overlay OK
[    0.432128] I2c0 speed: 400000Hz
[    0.435916] PMIC:  RK808
[    0.439113] vdd_arm 1100000 uV
[    0.444148] vdd_gpu 1100000 uV
......

[    1.005018] ## Booting Android Image at 0x02007800 ...
[    1.009917] Kernel load addr 0x02008000 size 8062 KiB
[    1.014981] ## Flattened Device Tree blob at 08300000
[    1.019970]    Booting using the fdt blob at 0x8300000
[    1.025185]    XIP Kernel Image ... OK
[    1.035469]   'reserved-memory' dma-unusable@fe000000: addr=fe000000 size=1000000
[    1.037448]   'reserved-memory' ramoops@00000000: addr=8000000 size=f0000
[    1.044412]    Using Device Tree in place at 08300000, end 08316ed1
[    1.064363] Adding bank: 0x00000000 - 0x08400000 (size: 0x08400000)
[    1.064976] Adding bank: 0x09200000 - 0x80000000 (size: 0x76e00000)
[    1.075259] Total: 812.613 ms

[    1.075279] Starting kernel ...
......:

注意:タイムスタンプは相対時間、絶対時間を印刷しません。

2.28 ベンダーの貯蔵 {#228-vendor-storage}

RKプラットフォームのUボットは、SN、MACなどの情報を保存するために、ユーザーがベンダーストレージ領域を提供します。 ストレージオフセットは、次の通りです(詳細はvendor.cを参照してください)。

#define EMMC_VENDOR_PART_OFFSET     (1024 * 7)
/* --- Spi Nand/SLC/MLC large capacity case define --- */
#define NAND_VENDOR_PART_OFFSET     0
/* --- Spi/Spi Nand/SLC/MLC small capacity case define --- */
#define FLASH_VENDOR_PART_OFFSET    8
......

ユーザーは、一般的に、読み取りインターフェースと書き込みインターフェイスのみ、ストレージオフセットに関心を持ち、変更する必要はありません。

int vendor_storage_read(u16 id, void *pbuf, u16 size)
int vendor_storage_write(u16 id, void *pbuf, u16 size)

3. . Chapter-3 コンパイルとダウンロード {#3-chapter-3-compile-and-download}

3.1 準備 {#31-preparations}

rkbin Rkbinをダウンロードし、RKの非オープンソースのビン、スクリプト、およびパッケージツール用のツールキットリポジトリです。 U-Bootは、このリポジトリからコンパイルし、関連するファイルをインデックス化して、ローダー、信頼、およびubootファームウェアをパッケージ化します。 Rkbin と U-Boot プロジェクトは同じディレクトリーレベルで保存する必要があります。 rkbin のダウンロード: Appendix を参照してください。 GCCのGCCコンパイラは、gcc-linaro-6.3.1を使用し、ビルド前のディレクトリに設置されています。 プレビルドとU-ブートは、兄弟ディレクトリ関係を維持します。

// 32-bit:
prebuilts/gcc/linux-x86/arm/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf
// 64-bit:
prebuilts/gcc/linux-x86/aarch64/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/

GCCのダウンロード: のAppendixセクションは、defconfigを選択します: プラットフォーム定義セクションを参照してください。 設定フラグメント導入 単一のプラットフォーム上の製品の異なるニーズのため、デフコンはもはや満たすことはできません。 そのため、RV1126 以降では、config フラグメントをサポートし、 defconfig をオーバーレイします。 例えば、. /CONFIG_BASE_DEFCONFIG=「rv1126_defconfig」が rv1126-emmc-tb.config で指定された場合、. /make.sh rv1126-emmc-tb コマンドが実行されると、まず rv1126_defconfig で .config を生成します。 .config を rv1126-emmc-tb.config で設定して上書きします。 このコマンドは、次のコマンドと同じです。

make rv1126_defconfig rv1126-emmc-tb.config && make

設定フラグメントファイルへの更新を行うには、単に. /scripts/sync-fragment.shに頼る。

例:

./scripts/sync-fragment.sh configs/rv1126-emmc-tb.config

コマンド効果: .config と rv1126_defconfig の構成の違いを rv1126-emmc-tb.config ファイルに diff します。

3.2 ファームウェアコンパイル {#32-firmware-compiling}

コマンドのコンパイル:

./make.sh [board]               // [board]: configs/[board]_defconfig file.

初回コンパイル: 32ビットまたは64ビットのプラットフォームに関係なく、 defconfig を指定するか、 defconfig を再指定したいときは、コンパイルコマンドは [board] を指定する必要があります。

例:

./make.sh rk3399                // build for rk3399_defconfig
./make.sh evb-rk3399            // build for evb-rk3399_defconfig
./make.sh firefly-rk3288        // build for firefly-rk3288_defconfig

二次コンパイル: 32ビットまたは64ビットのプラットフォームに関係なく、現在の「.config」に基づいてコンパイルしたい場合、コンパイルコマンドで[board]を指定する必要はありません。

./make.sh

注意:コンパイル中に奇妙な問題が失敗した場合は、distcleanとrecompileを作ろう。 ファームウェア生成:コンパイルが完了すると、U-ブートルートディレクトリに次の情報が生成されます。信頼、uboot、ローダー。:

// compile...
....

// uboot packaging process
load addr is 0x60000000!
pack input u-boot.bin
pack file size: 478737
crc = 0x840f163c
uboot version: v2017.12 Dec 11 2017
pack uboot.img success!
pack uboot okay! Input: u-boot.bin

// loader packaging process and the referenced ini file
out:rk3126_loader_v2.09.247.bin
fix opt:rk3126_loader_v2.09.247.bin
merge success(rk3126_loader_v2.09.247.bin)
pack loader okay! Input: /home/cjh/rkbin/RKBOOT/RK3126MINIALL.ini

// trust packaging process and the referenced ini file
 load addr is 0x68400000!
pack file size: 602104
crc = 0x9c178803
trustos version: Trust os
pack ./trust.img success!
trust.img with ta is ready
pack trust okay! Input: /home/cjh/rkbin/RKTRUST/RK3126TOS.ini
// Prompts for a successful compilation. Note: This is prompted even if the above trust and
loader packaging fails, indicating that at least uboot.img was generated
Platform RK3126 is build OK, with new .config(make rk3126_defconfig)

最終的には、ダウンロード可能なファームウェアはrootディレクトリに生成されます。

./uboot.img
./trust.img    // Note: If the firmware is in fit format, there is no trust.img. the trust
binary is packed in uboot.img.
./rk3126_loader_v2.09.247.bin

ファームウェアのパッケージングツール:ツールセクションを参照してください。

3.3 ファームウェアのダウンロード {#33-firmware-downloading}

ダウンロードツール: Windows/Linux用のファームウェアのダウンロードツールは、SDKまたは最新バージョンでリリースされたツールバージョンを使用することをお勧めします。 ダウンロードモード: RKプラットフォームには、マスロムモードとローダーモード(Uボット)の2つのダウンロードモードが2つあります。

  1. ロードモードに入る方法: 電源を入れるとき、長い出版物のボリューム+ボタン 電源を入れるとき、ホストコンピューターは同時にU-Bootコマンドライン入力でctrl+dを押します: ダウンロードまたはrockusb 0 $devtype $devnum

  2. マスロムモードに入る方法:電源を入れるとき、ホストコンピュータは同時にctrl + bを押します。 U-Bootコマンドライン入力:rbrom Note: 現在、U-BootはRKパラメータ(old)とGPT(new)の2種類のパーティションテーブルをサポートしています。 別のパーティションテーブルタイプで現在のパーティションテーブルを交換したい場合、Nandマシンは、ファームウェア全体に書き換え/再ダウンロードする必要があります。 eMMCマシンは、パーティションテーブルを個別に置き換えるサポートすることができます。 マシンに仕切りテーブルが2つあると、GPTパーティションテーブルが最初に認識されます。 起動メッセージで確認できます。

...
PartType: EFI // Currently it is the GPT partitioned table, otherwise print “PartType:
RKPARM”.
...

3.4 ファームウェアのサイズ {#34-firmware-size}

セクションを参照してください。 RKアーキテクチャ = > Uボットイメージ.

3.5 特別な包装 {#35-special-packaging}

コードのコンパイルに加えて、. /make.shは、ファームウェアパッケージ機能を統合し、開発者が使用する追加のスタンドアローンパッケージコマンドを提供しています。 しかし、その前提条件は、U-Bootが既にコンパイル済みです。 非FITフォーマット:

./make.sh trust              // package trust
./make.sh loader             // package loader
./make.sh trust <ini-file>   // Specify the ini file when packaging trust, otherwise use the
default ini file
./make.sh loader <ini-file>  // Specify the ini file when packing the loader. Otherwise, use
the default ini file

FIT のフォーマット:

// old script:
./make.sh spl                // Replace ddr and miniloader with tpl+spl and package them
into loader
./make.sh spl-s              // Replace the miniloader with spl and package it into loader

// new script:
./make.sh --spl              // Replace the miniloader with spl and package it into loader
./make.sh --tpl              // Replace ddr with tpl and package it into loader
./make.sh --tpl --spl        // Replace ddr and miniloader with tpl and spl and package them
into loader
./make.sh --spl-new          // ./make.sh--spl command do packages but not compile. This
command recompiles and repackages.

古いスクリプトと新しいスクリプトを識別する方法 新しいコマンドが有効になっている場合、make.shは新しいスクリプトです。

4. . 章4システムモジュール {#4-chapter-4-system-module}

4.1 AArch32 {#41-aarch32}

ARMv8の64ビットチップは、AArch64からAArch32モード(ARMv7)への劣化をサポートし、32ビットでコードをコンパイルする必要があります。

ユーザーは、このマクロを使用して、現在のモードがARMv8のAArch32であるかを確認することができます。

CONFIG_ARM64_BOOT_AARCH32=y

4.2 アンドロイドAB {#42-android-ab}

いわゆる A/B システムでは、それぞれ、システムファームウェアを 2 つの部分に分割し、それぞれスロット a と slot-b と呼ばれる。 任意のスロットから起動することができ、一つのスロットが失敗したときに、他のスロットから起動することもできます。 また、アップグレード時にシステムアップグレードモードを入力せずに他のスロットに直接コピーできます。 具体的な原則・手順については、上級原則セクションを参照してください。 現在のRKプラットフォームのプリローダーとUボットは、A/Bシステムをサポートできます。

4.2.1 構成項目 {#421-configuration-item}

A/Bシステムは、LIBAVBの以下の通りです。

// A/B dependent libraries
CONFIG_AVB_LIBAVB=y
CONFIG_AVB_LIBAVB_AB=y
CONFIG_AVB_LIBAVB_ATX=y
CONFIG_AVB_LIBAVB_USER=y
CONFIG_RK_AVB_LIBAVB_USER=y
// Enable A/B function
CONFIG_ANDROID_AB=y

4.2.2 仕切りテーブル {#422-partition-table}

A/B システムには、パーティションテーブルの要件があります。A/B をサポートする必要があるパーティションは、suffixes _a と _b を追加する必要があります。 Parameter.txtは以下を参照します。

FIRMWARE_VER:8.1
MACHINE_MODEL:RK3326
MACHINE_ID:007
MANUFACTURER: RK3326
MAGIC: 0x5041524B
ATAG: 0x00200800
MACHINE: 3326
CHECK_MASK: 0x80
PWR_HLD: 0,0,A,0,1
TYPE: GPT
CMDLINE:
mtdparts=rk29xxnand:0x00002000@0x00004000(uboot_a),0x00002000@0x00006000(uboot_b),0x00002000
@0x00008000(trust_a),0x00002000@0x0000a000(trust_b),0x00001000@0x0000c000(misc),0x00001000@0
x0000d000(vbmeta_a),0x00001000@0x0000e000(vbmeta_b),0x00020000@0x0000e000(boot_a),0x00020000
@0x0002e000(boot_b),0x00100000@0x0004e000(system_a),0x00300000@0x0032e000(system_b),0x001000
00@0x0062e000(vendor_a),0x00100000@0x0072e000(vendor_b),0x00002000@0x0082e000(oem_a),0x00002
000@0x00830000(oem_b),0x0010000@0x00832000(factory),0x00008000@0x842000(factory_bootloader),
0x00080000@0x008ca000(oem),-@0x0094a000(userdata)

4.2.3 ノート {#423-notes}

古いU-BootがA/Bシステムを有効にしました。ユーザーがa/bでパーティションにアクセスする場合、part_get_info_by_name()に渡されるパーティション名は、スロットサフィックス(例えば、「boot_a」または「boot_b」を持っている必要があります。 これは冗長コードの多くを追加します。: ユーザーはまず現在のシステムスロットを取得してから、パーティション名を取得するためにスプライシングを文字列します。 この問題が最適化される新しいコード。 下のコミットポイントが終わると、ユーザのコードのバージョンがコミットポイントの後にある場合、パーティションa/bはスロットサフィックスの有無にかかわらずアクセスでき、フレームワークレイヤーはシステムによって現在使用されているスロットを自動的に検出します。例えば、上記の場合には、直接「ブート」を使用することができます。

commit c6666740ee3b51c3e102bfbaf1ab95b78df29246
Author: Joseph Chen <chenjh@rock-chips.com>
Date:   Thu Oct 24 15:48:46 2019 +0800

    common: android/rkimg: remove/clean android a/b (slot) code

    - the partition disk layer takes over the responsibility of slot suffix
      appending, we remove relative code to make file clean;
    - put android a/b code together and name them to be eary understood,
      this makes file esay to read.

    Change-Id: Id8c838da682ce6098bd7192d7d7c64269f4e86ba
    Signed-off-by: Joseph Chen <chenjh@rock-chips.com>

4.3 アンドロイド BCB {#43-android-bcb}

BCB(ボトローダーコントロールブロック)は、Android用に設計された機構で、ブートプロセスを制御し、ブートローダと相互作用する仕組みです。 誤ったパーティションオフセット16KBまたは0位置でデータ構造を定義します。 データ構造:

struct android_bootloader_message {
    char command[32];
    char status[32];
    char recovery[768];

    /* The 'recovery' field used to be 1024 bytes.  It has only ever
     * been used to store the recovery command line, so 768 bytes
     * should be plenty.  We carve off the last 256 bytes to store the
     * stage string (for multistage packages) and possible future
     * expansion. */
    char stage[32];

    /* The 'reserved' field used to be 224 bytes when it was initially
     * carved off from the 1024-byte recovery field. Bump it up to
     * 1184-byte so that the entire bootloader_message struct rounds up
     * to 2048-byte. */
    char reserved[1184];
};

command: boot コマンドは、現在次の 3 つをサポートしています。

パラメータ 機能性
bootonce-bootloader(ブートオンス) ブート U ブートの fastboot エントリに
ブート回復 ブート エントリー回復
ブートファストブー ブート エントリー回復fastboot (fastbootd)

回復: 回復モードに入るためのインシデントコマンドは、 “recovery\n” で始まり、 “-“ から始まる複数のパラメーターを続けて “\n” で終わることができます。例えば、 “recovery\n-wipe_ab\n—- wipe_package_size=345\n-reason=wipePackage\n” で始まる:

パラメータ 機能性
update_package OTAアップグレード
retry_count アップグレード時に、この値に基づいて、再入力された回復アップグレードにしたがって、アップグレード中に誤った電力などの回復アップグレードに入る回数。
wipe_data ユーザデータ(およびキャッシュ)を消去し、再起動します。
wipe_cache キャッシュを消去(ただし、ユーザデータではない)、再起動
show_text いくつかのブートローダで使用した回復テキストメニューが表示されます
サイドロード  
sideload_auto_reboot ユーザデバッグビルドでのみ利用可能なオプションで、待機せずにデバイスを再起動します。
just_exit 何もしない、出口および再起動
ローカル キャッシュに locale を保存し、回復すると、reboot がキャッシュから locale をロードします。
shutdown_after リターン操業停止
wipe_all ユーザデータパーティション全体を消去する
wipe_ab 現在の A/B デバイスを拭き取り、RECOVERY_WIPE のすべてのパーティションの安全なワイプ
wipe_package_size パッケージのサイズを拭いて下さい
prompt_and_wipe_data データの破損をユーザにプロンプトで、同意消去ユーザーデータ(およびキャッシュ)で、データを破棄し、再起動します。
fw_update SDカードファームウェアのアップグレード
factory_mode PCBAのテストのようなある装置テストを、主にするのに使用される工場モード、
pcba_test PCBAのテストへのアクセス
resize_partition パーティションのリサイズ、アンドロイドQでの動的パーテーションサポート
rk_fwupdate U-Bootに限られるアークSD/USBのファームウェアのアップグレード、適当な規模を指定する

一般的に、U-Bootフェーズでは、上記のパラメータの使用と注意を必要としません。

4.4 AVBセキュアブート {#44-avb-secure-boot}

Android Verified Boot(AVB)は、主にブートシステムやその他のファームウェアを検証するために使用されるGoogleによって設計されたファームウェア検証プロセスのセットです。 Rockchipセキュアブートは、認証方法と通信中のAVBを参照して、セキュアブート検証プログラムの完全なセットを達成します。

4.4.1 特長 {#441-feature}

安全点検完全性は反ロールバックの保護永続的な仕切りサポート チェーンを付けられた仕切りサポートを、ブートと一致して、システム署名の秘密鍵かoemはそれ自体によって私用キーを救うことができますがPRKによって署名されなければなりません点検します。

4.4.2 構成 {#442-configuration}

AVB のエンブラリングは、信頼のサポートが必要です。

CONFIG_OPTEE_CLIENT=y
CONFIG_OPTEE_V1=y
CONFIG_OPTEE_ALWAYS_USE_SECURITY_PARTITION=y  //Security data is stored in the security
partition

CONFIG_OPTEE_V1:312x、322x、3288、3228H、3368、3399のプラットホームのために適した。 CONFIG_OPTEE_V2 : 3326,3308 のプラットフォームに適しています。 CONFIG_OPTEE_ALWAYS_USE_SECURITY_PARTITION : このマクロは、eMMCのrpmbが動作していない場合にのみ有効です。デフォルトでは有効ではありません。 AVB 関連の構成を有効にします。

CONFIG_AVB_LIBAVB=y
CONFIG_AVB_LIBAVB_AB=y
CONFIG_AVB_LIBAVB_ATX=y
CONFIG_AVB_LIBAVB_USER=y
CONFIG_RK_AVB_LIBAVB_USER=y
// The above options are mandatory, the following options support AVB and A/B features, the
two features can be used separately.
CONFIG_ANDROID_AB=y //This supports A/B
CONFIG_ANDROID_AVB=y //This supports A/B
// The following macros are for efuse-only platforms
CONFIG_ROCKCHIP_PRELOADER_PUB_KEY=y
// The following macros need to be turned on for strict unlock checksums
CONFIG_RK_AVB_LIBAVB_ENABLE_ATH_UNLOCK=y
// Enable Security check
CONFIG_AVB_VBMETA_PUBLIC_KEY_VALIDATE=y
// If you need the cpuid as a challenge number, enable the following macro
CONFIG_MISC=y
CONFIG_ROCKCHIP_EFUSE=y
CONFIG_ROCKCHIP_OTP=y

4.4.3 参照 {#443-reference}

AVBは、より多くのコンテンツを含むため、原則と構成の残りの部分については、上級原則部門を参照してください。

4.5 シンドリン {#45-cmdline}

cmdline は、起動ストレージやデバイスの状態など、カーネルにパラメータを渡すために U-Boot にとって重要な手段です。 現在、U-Bootがスプライスし、カーネルに渡される前に重複をフィルタリングするcmdlinesのいくつかのソースがあります。 U-Bootフェーズのcmdlinesはbootargs環境変数に保存されます。 U-Bootは、修正されたカーネルDTBで/chosen/bootargsを経由して、最終的にcmdlineを継承する。

4.5.1 データソース {#451-data-sources}

parameter.txt パーティションテーブルがRK形式である場合は、parameter.txtのcmdline情報を格納することができます。

  CMDLINE: console=ttyFIQ0 androidboot.baseband=N/A androidboot.selinux=permissive
androidboot.hardware=rk30board androidboot.console=ttyFIQ0 init=/init
mtdparts=rk29xxnand:0x00002000@0x00002000(uboot),0x00002000@0x00004000(trust),

パーティションテーブルが GPT 形式での場合、parameter.txt の cmdline 情報を保存するには有効ではありません。 /chosen/bootargs のカーネル dts など。

chosen {
    bootargs = "earlyprintk=uart8250,mmio32,0xff30000 swiotlb=1 console=ttyFIQ0
                androidboot.baseband=N/A androidboot.veritymode=enforcing
                androidboot.hardware=rk30board androidboot.console=ttyFIQ0
                init=/init kpti=0";
};

U-Boot: 現在の実行状態に応じて、U-Bootはcmdlineに何かを動的に追加します。例えば:

storagemedia=emmc androidboot.mode=emmc ......

boot/recovery.imgファームウェアのヘッダーにあるものは、通常、cmdlineフィールド情報も含まれています。

4.5.2 データ意味 {#452-data-meaning}

以下は、RKプラットフォームで一般的に使用されているcmdlineパラメータのリストです。 詳細は、カーネルのドキュメント: Documentation/admin-guide/kernel-parameters.txt を参照してください。 sdfwupdate: sd アップグレードカードロゴ、リカバリプログラムで要求される; root=PARTUID: ルートの UUID を指定します (システム) パーティション, GPT テーブル skip_initramfs のみでサポートされている: カーネルは rootfs(システム) の ramdisk を使用しますが、 uboot によってロードされた ramdisk ではなく、 storagemedia: ストレージブートタイプ; コンソール: カーネルのプリントポート設定情報 初期設定: シリアルポートと、シリアルノードが作成される前にその構成を指定します。max_part: max_part は、各ループのデバイスでサポートされているパーティションの数を設定するために使用されます。 rootwait: ファイルシステムがすぐに利用できなくなった場合、例えば、emmc の初期化が完了していない場合は、この時に root_wait を設定しない場合は、 rootfs をマウントしても失敗しましたが、このパラメータを追加すれば、ドライバーがロードを完了し、その後、rootfs をストレージデバイスからコピーして再びマウントすると、Failed ro/rw: Load rootfs 属性、読み取り専用/読み取り書き込み firmware_calss.path: ドライバの場所を指定する、例えば wifi、bt、gpu、等。 dm=”lroot none 0、 0 4096 線形 98:3 0, 4096 4096 リニア 98:32” root=/dev/dm-0: 8192 セクターの rw dm- リニアターゲットに起動します。 2 つのブロックデバイスをメジャーで識別しました。マイナー番号。ブート後、 udev は、このターゲットを /dev/mapper/lroot に変更します (ルールによって異なります)。uuid は割り当てられませんでした。https://android.googlesource.com/kernel/common/+/android-3.18/D ocumentation/device-mapper/boot.txt> アンドロイドブート.slot_suffix を参照して下さい: AB システム中に起動するカーネルのスロットを指定します。androidboot.serialno: カーネルと上位層のシリアル番号を提供して下さい。 例えば、adbのシリアル番号など androidboot.verifiedbootstate: uboot の検証ファームウェアの状態を上層に提供する Android 要件は、次の 3 つの状態を持っています。

  1. 緑: LOCKED状態と認証に使用されるキーがエンドユーザによって設定されていない場合

  2. 黄色: LOCKED状態と認証に使用されるキーがエンドユーザによって設定されている場合

  3. オレンジ: UNLOCKED 状態 androidboot.hardware で: デバイスを起動します。例えば、 rk30board androidboot.verifymode: 検証パーティションの真モード/状態を指定します (つまり、ファームウェアの完全性を検証します) androidboot.selinux: SELinux はドメイン型モデルに基づく必須アクセス制御(MAC) セキュリティシステムです。3つのモデルがあります。

  4. 強化: モードの強制, SELinux が実行されていることを意味し、ドメイン/型を正しく制限し始めています.

  5. 許容: 許容モード: これはSELinuxが実行されていることを意味しますが、警告メッセージのみが実行されます

実際にドメイン/型へのアクセスを制限することなく表示します。 SELinux のデバッグに使用できるモードです。

  1. 無効: シュットダウン、SELinux は実際に動作しません! androidboot.mode: Android ブート方法: 通常と充電器。

  2. ノーマル: ノーマル ブート

  3. 充電器:電源オフとオンの後、androidboot.modeは、電源充電を検出した後、ubootによってブートラグ環境変数に設定されている充電器に設定されます。 androidboot.wificountrycode: wifiの国コードを設定します。 米国、CN androidboot.baseband: ベースバンドの設定、RKにはN/A androidboot.consoleに設定されていない機能はありません。アンドロイドメッセージ出力ポート構成とroidboot.vbmeta.device=PARTUID:ストレージandroidboot.vbmeta.hash_algにvbmetaの場所を指定します: vbmetaハッシュアルゴリズムを設定し、 e.g. sha512 androidboot.vbmeta.size: カーネルに vbmeta の消化をアップロードする vbmeta の値を、カーネルは vbmeta をロードし、消化を計算し、この消化器に比較します。androidboot.vbmeta.device_state: avb2.0 システムロックとロックのロックを解除

4.6 DFUの更新のファームウェア {#46-dfu-update-firmware}

DFUは装置ファームウェアを更新するのに使用される装置ファームウェアの更新です。 DFUをサポートするプラットフォームについては、プラットフォーム定義セクションを参照してください。 DFU 機能を有効にするには、有効化する必要があるマクロは次のとおりです。

CONFIG_CMD_DFU=y
CONFIG_USB_FUNCTION_DFU=y

使用するストレージメディアによっては、次のスイッチをオンにすることができます。

CONFIG_DFU_MMC
CONFIG_DFU_MTD
CONFIG_DFU_NAND
CONFIG_DFU_RAM
CONFIG_DFU_SF

DFU をサポートするプラットフォームは通常、次のコンパイルコマンドを実行することで、RV1126 ファームウェアを DFU サポートとコンパイルするなど、別のコンフィグファイルを提供します。

./make.sh rv1126-dfu

ファームウェアを開発ボードにダウンロードし、OTGコネクタをPCに接続し、U-Bootコマンドラインで以下を実行します。

dfu 0 $devtype $devnum

devtype が mmc または mtd である場合、この時点で PC に USB ダウンロード ガジェットデバイスを見つけ、Zadadig を使用して、デバイス ドライバーを交換し、交換後のスクリーンショットは次のようにします。

出典図、英語PDF p56

ホストコンピューターソフトウェアを使用して、Windowsコマンドラインから次のを実行します

./dfu-util.exe -l

この時点で、デバイスはinclude/configs/evb_rv1126.hで定義されているパーティションテーブルをアップロードします。

F:\Prj\20210901-Hisense-AB\dfu-util-0.9-win64>dfu-util.exe -l
dfu-util 0.9

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2016 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

Found DFU: [2207:0107] ver=0223, devnum=16, cfg=1, intf=0, path="1-12", alt=5,
name="userdata", serial="UNKNOWN"
Found DFU: [2207:0107] ver=0223, devnum=16, cfg=1, intf=0, path="1-12", alt=4,
name="rootfs", serial="UNKNOWN"
Found DFU: [2207:0107] ver=0223, devnum=16, cfg=1, intf=0, path="1-12", alt=3, name="boot",
serial="UNKNOWN"
Found DFU: [2207:0107] ver=0223, devnum=16, cfg=1, intf=0, path="1-12", alt=2, name="uboot",
serial="UNKNOWN"
Found DFU: [2207:0107] ver=0223, devnum=16, cfg=1, intf=0, path="1-12", alt=1,
name="loader", serial="UNKNOWN"
Found DFU: [2207:0107] ver=0223, devnum=16, cfg=1, intf=0, path="1-12", alt=0, name="gpt",
serial="UNKNOWN"

Windows コマンドラインは、コマンド・ライン・フォーマットの dfu-util.exe VID:PID -a (部分名) -D (ファイル名) -R (再起動オプション) で、ファイルを開発ボードに転送するために、次のコマンドを実行します。

F:\Prj\20210901-Hisense-AB\dfu-util-0.9-win64>dfu-util.exe -d 2207:0107 -a system_b -D
rootfs.img -R

ダウンロードの成功ログは以下の通りです。

dfu-util 0.9

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2016 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

Invalid DFU suffix signature
A valid DFU suffix will be required in a future dfu-util release!!!
Opening DFU capable USB device...
ID 2207:0107
Run-time device DFU version 0110
Claiming USB DFU Interface...
Setting Alternate Setting #8 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 0110
Device returned transfer size 4096
Copying data from PC to DFU device
Download        [=========================] 100%     49938432 bytes
Download done.
state(7) = dfuMANIFEST, status(0) = No error condition is present
state(2) = dfuIDLE, status(0) = No error condition is present
Done!
can't detach
Resetting USB to switch back to runtime mode

他のパーティションをダウンロードする必要がある場合は、ダウンロードコマンドの -a オプションと -Dオプションの後のファイル名の後にパーティション名を置き換えるだけです。 -R パラメータはダウンロードコマンドに追加され、ダウンロードが完了した後にボードが再起動されることを示します。

4.7 DTBO/DTOの {#47-dtbodto}

このページでは、この章の内容についてユーザーの理解を深めるために、まず、まず、付録セクションを読んで、用語の認識を促すことをおすすめします。 DTB、DTBO、DTC、DTO、DTS、FDT。 それらとの関係は、DTS が FDT を記述するために使用されるファイルです。 DTS は DTC によってコンパイルされ、DTB/DTBO を生成できます。 DTB と DTBO は DTO の操作で新しい DTB に結合することができます。 通常、多くのユーザーは、「DTO」という単語の動作の意味を「DTBO」に置き換えるために使用されます。 以下では、この混合コンセプトを回避するために、DTOが動作する動詞概念であることを明確にしています。DTBOは正午の概念でありながら、これは集計を示すdtbの数を参照します。 この章のさらなる知識は、次の点で見つけることができます: https://source.android.google.cn/devices/architecture/dto.

4.7.1 原則の紹介 {#471-principle-introduction}

DTO(Devcie Tree Overlay)は、既存のプライマリデバイスツリーBlobの上にオーバーレイされる二次デバイスツリーBlob(DTBO)を可能にするAndroid Pで導入された必須機能です。 DTOは、システムオンチップのSoCデバイスツリーを維持し、デバイス固有のデバイスツリーを動的にオーバーレイし、ノードをツリーに追加し、既存のツリー内のプロパティに変更を加える。 プライマリデバイスツリーブロブ(.dtb)は通常、ベンダーによって提供され、セカンダリーデバイスツリーブロブ(.dtbo)はODM / OEMなどで提供でき、最終的にカーネルに渡る前にブートローダによって結合される。 下の図のように:

出典図、英語PDF p58

のイメージ: https://source.android.google.cn/devices/architecture/dto Note: DTB と DTO の DTBO のコンパイルは通常の DTB コンパイルとは異なるため、特別な構文の違いがあります。 .dts を dtc とコンパイルするときは、symbols ノードを .dtbo に追加するためにオプション -@ を追加する必要があります。 symbols ノードには、DTO ライブラリが参照としてリストを使用できるラベル付きのすべてのノードのリストが含まれています。 以下は例です。

  1. メイン .dts をコンパイルするためのコマンドのサンプル:
dtc -@ -O dtb -o my_main_dt.dtb my_main_dt.dts
  1. オーバーレイDT .dts のコンパイルのためのサンプルコマンド:
dtc -@ -O dtb -o my_overlay_dt.dtbo my_overlay_dt.dts

4.7.2 DTO を有効にする {#472-enable-dto}

  1. 構成 有効:
CONFIG_CMD_DTIMG=y
CONFIG_OF_LIBFDT_OVERLAY=y
  1. board_select_fdt_index() 関数の実装 ユーザが再導入できる __weak 関数です。 関数は、複数のDTBO(リターンインデックスインデックス、最小値は0から始まります)の間でDTO操作を実行するために使用されるDTBOを取得することです。デフォルトの弱関数はインデックスを返します

0.

/*
* Default return index 0.
*/
__weak int board_select_fdt_index(ulong dt_table_hdr)
{
    /*
     * User can use "dt_for_each_entry(entry, hdr, idx)" to iterate
     * over all dt entry of DT image and pick up which they want.
     *
     * Example:
     *  struct dt_table_entry *entry;
     *  int index;
     *
     *  dt_for_each_entry(entry, dt_table_hdr, index) {
     *
     *      .... (use entry)
     *  }
     *
     *  return index;
     */
    return 0;
}

4.7.3 DTO結果 {#473-dto-result}

  1. DTO の実行が完了すると、U-Boot のブートメッセージで結果を見ることができます。
// The printout when it succeed
ANDROID: fdt overlay OK

// The printout when it failed
ANDROID: fdt overlay failed, ret=-19

多くの場合、障害の原因は、主に/秒単位のデバイスブックの空白の内容と互換性のため一般的にあります。そのため、ユーザーは、生成の構文と互換性について明確にする必要があります。

  1. 次のメッセージは、成功したDTO実行後にカーネルのcmdlineに付加されます。

DTO 操作に DTBO が使用されることを示す:

androidboot.dtbo_idx=1  // The idx starts from 0. Here it means that the DTBO with idx=1 is
selected for DTO operation.
  1. DTOが正常に実行された後、U-Bootコマンドラインでfdtコマンドを使用して、変更が有効になっていることを確認するためにDTBの内容を表示できます。

4.8 の env {#48-env}

4.8.1フレームワークサポート {#481-framework-support}

マッピング管理のためのハッシュテーブルで「キー値」と「データ」を構成するU-Bootフレームワークの非常に重要なデータ管理手法であり、「追加/削除/変更/チェック」操作をサポートします。 通常、環境変数として管理するキーとデータを呼び出します。U-Bootは、さまざまなストレージメディアでENVデータを保存するサポートをサポートしています: NOWHERE / eMMC / FLASH / EEPROM / NAND / SPI_FLASH / UBI …構成:

// Default configuration: ENV saved in memory
CONFIG_ENV_IS_NOWHERE

// ENV saved on various storage media
CONFIG_ENV_IS_IN_MMC
CONFIG_ENV_IS_IN_NAND
CONFIG_ENV_IS_IN_EEPROM
CONFIG_ENV_IS_IN_FAT
CONFIG_ENV_IS_IN_FLASH
CONFIG_ENV_IS_IN_NVRAM
CONFIG_ENV_IS_IN_ONENAND
CONFIG_ENV_IS_IN_REMOTE
CONFIG_ENV_IS_IN_SPI_FLASH
CONFIG_ENV_IS_IN_UBI

// Any storage media (except mmc) that has been accessed to the BLK framework layer is
recommended by the RK platform !
CONFIG_ENV_IS_IN_BLK_DEV

フレームワークコード:

./env/nowhere.c
./env/env_blk.c
./env/mmc.c
./env/nand.c
./env/eeprom.c
./env/embedded.c
./env/ext4.c
./env/fat.c
./env/flash.c
......

4.8.2 関連するインターフェイス {#482-relevant-interface}

// Getting Environment Variables
char *env_get(const char *varname);
ulong env_get_ulong(const char *name, int base, ulong default_val);
ulong env_get_hex(const char *varname, ulong default_val);

// Modify or create environment variables, value NULL is equivalent to deletion.
int env_set(const char *varname, const char *value);
int env_set_ulong(const char *varname, ulong value);
int env_set_hex(const char *varname, ulong value);

// Load all the ENV information saved on the storage media
int env_load(void);

// Save all current ENV information to a storage medium
int env_save(void);

env_load(): ユーザーは、それを呼び出しする必要はありません。 U-Bootフレームワークは、適切なブートプロセスでそれを呼び出します。 env_save(): 必要な瞬間にユーザが初期化した呼び出しは、CONFIG_ENV_IS_NOWHERE_XXXによって指定されたストレージ媒体にすべてのENV情報を保存します。

4.8.3 高度インターフェイス {#483-advanced-interface}

RK は、ENV の処理を生成、追加、および機能の交換を統一する 2 つの高レベル インターフェイスを提供します。 これは主にbootargs環境変数を扱うためですが、他の環境変数操作に等しく適用されます。

/**
 * env_update() - update sub value of an environment variable
 *
 * This add/append/replace the sub value of an environment variable.
 *
 * @varname: Variable to adjust
 * @valude: Value to add/append/replace
 * @return 0 if OK, 1 on error
 */
int env_update(const char *varname, const char *varvalue);

/**
 * env_update_filter() - update sub value of an environment variable but
 * ignore some key word
 *
 * This add/append/replace/igore the sub value of an environment variable.
 *
 * @varname: Variable to adjust
 * @valude: Value to add/append/replace
 * @ignore: Value to be ignored that in varvalue
 * @return 0 if OK, 1 on error
 */
int env_update_filter(const char *varname, const char *varvalue, const char *ignore);

1 varname が存在しない場合は、変数名と値が生成されるように、env_update(): Create: varname と varvalue を生成します。 varname が既に存在して varvalue が存在しない場合は、 varvalue を追加してください。 置換: varname が既に存在する場合、varvalue が既に存在している場合は、現在の varvalue に元の値を置き換えます。 例えば、元の「storagemedia=emmc」は、現在の入力変数が「storagemedia=rknand」で、最終更新は「storagemedia=rknand」になります。 rknand。 2 env_update_filter()は、env_update(): varvalueからキーワードを除去し、envを更新する; 3 特別なノート: env_update() と env_update_filter() 両方使用スペースと「=」を分離するセパレータとして、操作の単位は: 単一の単語、 “key=value” 組み合わせワード: 単一単語: sdwupdate, …… “key=value” 接種語: storagemedia=emmc, init=/init, androidboot.console=ttyFIQ0, …… 上記2つのインターフェースは、長い文字列単位を扱うことができません。 例えば、ユニット全体として「console=ttyFIQ0 androidboot.baseband=N/A androidboot.selinux=permissive」を動作させることはできません。

4.8.4 貯蔵の場所 {#484-storage-location}

env_save()は、ENVをストレージ媒体に保存します。 RKプラットフォームのENVの保存場所とサイズは、以下に定義されます。

if ARCH_ROCKCHIP
config ENV_OFFSET
    hex
    depends on !ENV_IS_IN_UBI
    depends on !ENV_IS_NOWHERE
    default 0x3f8000
    help
      Offset from the start of the device (or partition)
config ENV_SIZE
    hex
    default 0x8000
    help
      Size of the environment storage area
endif

通常、ENV_OFFSET や ENV_SIZE は変更をお勧めしません。

4.8.5 一般的なオプション {#485-general-options}

現在、一般的に使用されるストレージメディアは以下のとおりです。 eMMC /sdmmc/Nandflash/Norflash、等。 しかし、U-BootのネイティブNandとNor ENVドライバーはMTDフレームワークを全てフォローしていますが、RKのサポートされているストレージメディアはすべてBLKフレームワークに従います。そのため、これらのENVドライバは使用できません。 したがって、RKは CONFIG_ENV_IS_IN_BLK_DEV BLKフレームワークにアクセスするストレージの構成オプション eMMC /sdmmc ケース, 選択 CONFIG_ENV_IS_IN_MMC ; ナンドのために、Norの箱は、選ぶ CONFIG_ENV_IS_IN_BLK_DEV ; ユーザーは最初に定義を読んで下さい CONFIG_ENV_IS_IN_BLK_DEV Kconfigの

// It is already specified by default and does not need to be changed.
CONFIG_ENV_OFFSET
CONFIG_ENV_SIZE

// It won't be used usually.
CONFIG_ENV_OFFSET_REDUND (optional)
CONFIG_ENV_SIZE_REDUND (optional)
CONFIG_SYS_MMC_ENV_PART (optional)

Note: どの CONFIG_ENV_IS_IN_XXX 設定を選択するか、サブコンフィグ記述を含む Kconfig の定義記述を最初に読みます。

4.8.6 Fw_printenv ツール {#486-fw_printenv-tool}

fw_printenvは、U-BootがLinux用に提供しているエンブツールです。 このツールでは、ユーザーはlinux の env の内容にアクセスして変更することができます。 このツールを使用するには、エンブ領域がカーネルの可視パーティション(分離パーティションが推奨)にあることが必要です。これは、カーネルsysのストレージノードを介して、エンブ領域に本質的にアクセスします。 工具獲得方法:

./make.sh env

コマンドを実行した後、次のようになります。

./tools/env/fw_printenv      // env read/write tool
./tools/env/fw_env.config    // env configuration file
./tools/env/README           // env read/write tool documentation

ご利用にあたっては、README のドキュメントをご覧ください。

4.8.7 封筒 {#487-envf}

現在、env.img(主にIPC型製品)に存在するSDKファームウェアのみに適用されます。 存在しない場合は、このセクションを無視してください。 U-Boot のネイティブ ENV 関数は、環境変数を指定したストレージ領域に保存することです。これにより、外部に変更できます。 システム関連の変数が正しく変更された場合、システムは通常起動しないか、悪意のある攻撃を受けません。 例えば、bootコマンド bootcmd は、悪意のあるブートプロセスを消去または指すこともできます。 そのため、外部のユーザ環境変数からU-Bootシステム環境変数を分離するためにENV Fragment関数を追加しました。

ユーザーは、カスタマイズされた環境変数を保存し、U-Bootでホワイトリストを設定するためのエンブフラグメントを定義する必要があります。 U-Bootは、エンブフラグメントからホワイトリストされた環境変数をインポート/エクスポート/変更することができます。 ENVFプロセス: ユーザーは、要求に応じて env.txt を作成し、コンテンツを指定すると、mkenvimage を使用して env.img を生成し、保存 0 アドレスにダウンロードします。 ローダーとUボットロードとenv.imgのコンテンツをブート時にパースし、CONFIG_ENVF_LISTホワイトリストによると、法的環境変数をインポートします。 どこ: 異なるストレージタイプの場合、env.imgの異なるサイズは作るべきです。 構成:

CONFIG_ENVF
CONFIG_SPL_ENVF
CONFIG_ENVF_LIST="blkdevparts mtdparts sys_bootargs app reserved"

// eMMC:
// Specifies the storage address of Primary env.img. Unit: bytes.
CONFIG_ENV_OFFSET=0x0
// Specifies the storage address of Backup env.img, which is the same as CONFIG_ENV_OFFSET
when there is no backup. Unit: bytes.
CONFIG_ENV_OFFSET_REDUND=0x0
// Size of Primary and Backup env.img. Unit: bytes.
CONFIG_ENV_SIZE=0x8000

// spi-nor: the same usage as above.
CONFIG_ENV_NOR_OFFSET=0x0
CONFIG_ENV_NOR_OFFSET_REDUND=0x0
CONFIG_ENV_NOR_SIZE=0x10000

// spi-nand/slc-nand: the same usage as above.
CONFIG_ENV_NAND_OFFSET=0x0
CONFIG_ENV_NAND_OFFSET_REDUND=0x0
CONFIG_ENV_NAND_SIZE=0x40000

コード:

./env/envf.c

ツール:

// By default, it participates in U-Boot compilation and generates tools/mkenvimage, which
is used to package env.img.
./tools/mkenvimage.c

PC開発プロセス(例)

  1. クリートenv.txt:
// The system partition table must be defined or it will not boot properly. Example:
blkdevparts=mmcblk0:4M@8M(uboot),4M(trust),32M(boot),32M(recovery),32M(backup),-(rootfs)
sys_bootargs=rootwait earlycon=uart8250,mmio32,0xff570000 console=ttyFIQ0
......

フォーマット要件: (1) キー値のペアの「キー=値」キー値のペアを使用します。 (2)キー値のペアで「=」: スペースが左または右にない場合、シングル/ダブルクォートなし (3) キー値のペアの最後に示すために、新しい行を使用する sys_bootargs: この効果は、カーネルのdtsでbootargsと等しいです。 このフィールドが指定されている場合、U-Bootは、カーネルdtsでbootargsをオーバーレイするためにsys_bootargsを使用します。 同じエントリがある場合、sys_bootargs は優先度が高い。 パーティションテーブル: カーネル標準のmtdpartsとblkdevpartsパーティションテーブルフォーマットをサポートし、ニーズに応じて選択してください(いずれかを選択)。 異なるストレージのパーティション形式は以下のとおりです。

// eMMC:
blkdevparts=mmcblk0:32K(env),512K@32K(idblock),256K(uboot),32M(boot),2G(rootfs),1G(oem),2G(u
serdata),-(media)

// spi-nor:
mtdparts=sfc_nor:64K(env),128K@64K(idblock),128K(uboot),2M(boot),4M(rootfs),6M(oem),-
(userdata)

// spi-nand/slc-nand:
mtdparts=rk-
nand:256K(env),256K@256K(idblock),256K(uboot),8M(boot),64M(rootfs),32M(userdata),-(media)
  1. env.img を発生させます:
## Chapter-4 eMMC:
./tools/mkenvimage -s 0x8000 -p 0x0 -o env.img env.txt

## Chapter-4 spi-nor:
./tools/mkenvimage -s 0x10000 -p 0x0 -o env.img env.txt

#spi-nand/slc-nand:
./tools/mkenvimage -s 0x40000 -p 0x0 -o env.img env.txt
  1. env.imgはメモリ0アドレスにダウンロードされます。 U-Boot-sideの開発プロセス(例):

  2. 要求に応じてenv.imgを有効にして構成

// enable ENVF
CONFIG_ENVF=y
CONFIG_SPL_ENVF=y
CONFIG_ENVF_LIST="blkdevparts mtdparts sys_bootargs app reserved"

// eMMC:
CONFIG_ENV_SIZE=0x8000
CONFIG_ENV_OFFSET=0x0
CONFIG_ENV_OFFSET_REDUND=0x0

// spi nor:
CONFIG_ENV_NOR_OFFSET=0x0
CONFIG_ENV_NOR_OFFSET_REDUND=0x0
CONFIG_ENV_NOR_SIZE=0x10000

// spi nand/slc nand:
CONFIG_ENV_NAND_OFFSET=0x0
CONFIG_ENV_NAND_OFFSET_REDUND=0x0
CONFIG_ENV_NAND_SIZE=0x40000
  1. uboot.imgのコンパイルとダウンロード.

  2. パワーオンメッセージ表示

......
dwmmc@ffc50000: 0, dwmmc@ffc60000: 1
Bootdev(atags): mmc 0
MMC0: HS200, 200Mhz
// printout as follows:
ENVF: Primary 0x00000000 - 0x00008000
ENVF: OK
PartType: ENV
DM: v1
boot mode: normal
FIT: no signed, no conf required
DTB: rk-kernel.dtb
......
  1. ユーザは、U-Bootコマンドラインから次のコマンドでenvを保存したり、コードenv_save()を使うことができます。
=> env save
Saving Environment to env...  // Exporting and saving whitelisted environment variables

4.9 Fastbootの特長 {#49-fastboot}

Fastbootは、一般的にデバイス情報を取得するために使用されるUSB経由でUブートと相互作用するAndroidによって提供されている方法です。, ファームウェアをダウンロード, など.

4.9.1 構成オプション {#491-configuration-options}

// Enabled Configuration
CONFIG_FASTBOOT
CONFIG_FASTBOOT_FLASH
CONFIG_USB_FUNCTION_FASTBOO

// Parameter Configuration
CONFIG_FASTBOOT_BUF_ADDR
CONFIG_FASTBOOT_BUF_SIZE
CONFIG_FASTBOOT_FLASH_MMC_DEV
CONFIG_FASTBOOT_USB_DEV

4.9.2 トリガー方法 {#492-trigger-method}

Fastboot は、デフォルトで Google の Adb の VID/PID を使用します。このトリガーメソッドは、カーネルのコマンドライン実行をトリガーします。U-Boot の fastboot コマンドライン実行を再起動します。fastboot usb 0 電源オンと長押しの組み合わせキー : ctrl+f

4.9.3 コマンドサポート {#493-command-support}

fastboot flash < partition > [ < filename > ]
fastboot erase < partition >
fastboot getvar < variable > | all
fastboot set_active < slot >
fastboot reboot
fastboot reboot-bootloader
fastboot flashing unlock
fastboot flashing lock
fastboot stage [ < filename > ]
fastboot get_staged [ < filename > ]
fastboot oem fuse at-perm-attr-data
fastboot oem fuse at-perm-attr
fastboot oem at-get-ca-request
fastboot oem at-set-ca-response
fastboot oem at-lock-vboot
fastboot oem at-unlock-vboot
fastboot oem at-disable-unlock-vboot
fastboot oem fuse at-bootloader-vboot-key
fastboot oem format
fastboot oem at-get-vboot-unlock-challenge
fastboot oem at-reset-rollback-index

4.9.4 コマンドの詳細 {#494-command-details}

速いブートのフラッシュ < パーティション > [ < ファイル名 > ] 機能: パーティションのダウンロード例: fastboot フラッシュ ブート boot.img 速いブートの消去 < パーティション > 関数: 消去の隔離の例: fastboot はブートのfastboot getvarを消去します < 変数 > 関数: デバイス情報の取得例: fastboot getvar version-bootloader < 変数 > パラメーター:

version                               /* fastboot version */
version-bootloader                    /* uboot version */
version-baseband
product                               /* Product Information */
serialno                              /* sertial number */
secure                                /* security checking enabled or not*/
max-download-size                     /* the maximum number of bytes supported by
fastboot in a single transfer */
logical-block-size                    /* Number of logical blocks */
erase-block-size                      /* Number of erased blocks */
partition-type : < partition >        /* Partition type*/
partition-size : < partition >        /* Partition size */
unlocked                              /* Device lock status */
off-mode-charge
battery-voltage
variant
battery-soc-ok
slot-count                            /* Number of slots*/
has-slot: < partition >               /* Check if the partition name is in the slot
*/
current-slot                          /* Currently booted slots*/
slot-suffixes                         /* The current slot of the device, print its
name. */
slot-successful: < _a | _b >          /* See if the partition is properly verified and
booted*/
slot-unbootable: < _a | _b >          /* Check if the partition is set to unbootable
*/
slot-retry-count: < _a | _b >         /* Check the number of retry-counts for a
partition */
at-attest-dh
at-attest-uuid
at-vboot-state

fastboot getvar すべての機能: デバイス情報の取得 クイックブート set_active < スロット > 機能: 再起動のためのスロットを設定します 例: fastboot set_active _a fastboot 再起動 機能: デバイスを再起動して、通常の起動例: fastboot の再起動-bootloader 関数: デバイスを再起動して、高速モードに入るようにします。

例:fastboot の再起動-ブートローダの fastboot の書き込みのロック機能: デバイスのロックを解除し、ファームウェアのダウンロードを許可する 例: クイックボットの書き込みロック機能: デバイスをロックする、ダウンロード禁止例: クイックブート フラッシュ ロックの fastboot ステージ [ < ファイル名 > ] 機能: デバイスのメモリにデータをダウンロード, メモリ開始アドレスは CONFIG_FASTBOOT_BUF_ADDR です。

例:fastbootステージpermanent_attributes.bin fastboot get_staged [<ファイル名>] 関数:デバイス側からデータを取得する例:fastboot get_staged raw_unlock_challenge.bin fastboot oemヒューズのperm-attr機能:permanent_attributes.binをダウンロードし、ハッシュ.

例:fastbootステージpermanent_attributes.binのfastboot oemはperm-attrでヒューズをfuse

fastboot oem は、perm-attr-data 関数でヒューズします。permanent_attributes.bin だけを安全なストレージエリア (RPMB) 例: 速いステージ permanent_attributes.bin のfastboot oem は、perm-attr-data fastboot oem をオンに-get-ca-request fastboot oem をオンセット-ca-response fastboot oem でロックvboot oem をオンにします 関数: ロック装置例:fastboot oem のロックvboot の fastboot oem の at-unlock-vboot 機能: 装置を解凍して下さい、 認証解除の例:fastboot oem at-get-vboot-unlock-challenge fastboot get_staged raw_unlock_challenge.bin ./make_unlock.sh (参照のためのmake_unlock.shを参照) クイックブートステージunlock_credential.bin fastboot oem at-unlock-vboot 参照できます “how-to-generate-keys-about-avb.md” のファストブートoemヒューズ at-bootloader-vboot-key 機能: bootloaderキーハッシュをダウンロード 事例: fastbootステージbootloader-pub-key.bin fastboot oemヒューズ at-bootloader-vboot-key fastboot oemフォーマット 関数: パーティションをリフォームする, パーティション情報は $ パーティション例に依存します: fastboot oem フォーマット fastboot oem at-get-vboot-unlock-challenge 関数: 認証されたロック解除, チャレンジデータのロック解除を取得するには、例: 16 を参照してください。 fastboot oem at-unlock-vboot oem の at-reset-rollback-index 関数: デバイスのロールバックデータをリセットする 例: fastboot oem at-reset-rollback-index fastboot oem の at-disable-unlock-vboot 関数: fastboot oem をオンロック解除するコマンドで実行可能にします。

例:fastboot oem でdisable-unlock-vboot

4.10 ファイルシステム {#410-filesystem}

4.10.1フレームワークサポート {#4101-framework-support}

FAT と EXT2/4 は、一般的に使用されるファイルシステムフォーマットです。 それらの中で、FATはDOS(MBR)の仕切りテーブルを使用し、一般的なデバイスはSDカード、USBフラッシュドライブです。 これらの2つのファイルシステムは、一般的にU-Bootでより頻繁にアクセスされます。 FAT の設定:

CONFIG_DOS_PARTITION=y
CONFIG_FS_FAT=y
CONFIG_FAT_WRITE=y
CONFIG_FS_FAT_MAX_CLUSTSIZE=65536
CONFIG_CMD_FAT=y
CONFIG_CMD_FS_GENERIC=y

FAT コマンド:

fatinfo fatload fatls fatsize fatwrite

EXT2/4 構成:

CONFIG_CMD_EXT2=y
CONFIG_CMD_EXT4=y
CONFIG_CMD_FS_GENERIC=y

EXT2/4 コマンド:

ext2load ext2ls ext4load ext4ls ext4size

4.10.2 関連するインターフェイス {#4102-relevant-interface}

FAT 関数ヘッダーファイル . /include/fat.h:

int file_fat_detectfs(void);
int fat_exists(const char *filename);
int fat_size(const char *filename, loff_t *size);
int file_fat_read_at(const char *filename, loff_t pos, void *buffer,
             loff_t maxsize, loff_t *actread);
int file_fat_read(const char *filename, void *buffer, int maxsize);
int fat_set_blk_dev(struct blk_desc *rbdd, disk_partition_t *info);
int fat_register_device(struct blk_desc *dev_desc, int part_no);

int file_fat_write(const char *filename, void *buf, loff_t offset, loff_t len,
           loff_t *actwrite);
int fat_read_file(const char *filename, void *buf, loff_t offset, loff_t len,
          loff_t *actread);
int fat_opendir(const char *filename, struct fs_dir_stream **dirsp);
int fat_readdir(struct fs_dir_stream *dirs, struct fs_dirent **dentp);
void fat_closedir(struct fs_dir_stream *dirs);
void fat_close(void);

EXT2/4機能ヘッダー ファイル include/ext4fs.h:

struct ext_filesystem *get_fs(void);
int ext4fs_open(const char *filename, loff_t *len);
int ext4fs_read(char *buf, loff_t offset, loff_t len, loff_t *actread);
int ext4fs_mount(unsigned part_length);
void ext4fs_close(void);
void ext4fs_reinit_global(void);
int ext4fs_ls(const char *dirname);
int ext4fs_exists(const char *filename);
int ext4fs_size(const char *filename, loff_t *size);
void ext4fs_free_node(struct ext2fs_node *node, struct ext2fs_node *currroot);
int ext4fs_devread(lbaint_t sector, int byte_offset, int byte_len, char *buf);
void ext4fs_set_blk_dev(struct blk_desc *rbdd, disk_partition_t *info);
long int read_allocated_block(struct ext2_inode *inode, int fileblock);
int ext4fs_probe(struct blk_desc *fs_dev_desc,
         disk_partition_t *fs_partition);
int ext4_read_file(const char *filename, void *buf, loff_t offset, loff_t len,
           loff_t *actread);
int ext4_read_superblock(char *buffer);
int ext4fs_uuid(char *uuid_str);

4.10.3 コマンド例 {#4103-example-of-command}

// Confirm that the SD card is recognizable(if it is a USB flash drive then use the usb
command for recognition, the device number is usually: usb 0)
=> mmc dev 1
switch to partitions #0, OK
mmc1 is current device

// View Information
=> fatinfo mmc 1
Interface:  MMC
  Device 1: Vendor: Man 000003 Snr e81ec501 Rev: 1.9 Prod: SC16G
  Type: Removable Hard Disk
  Capacity: 15193.5 MB = 14.8 GB (31116288 x 512)
Filesystem: FAT32 "NO NAME    "

// View File
=> fatls mmc 1
            System Volume Information/
       23   hello.txt
       23   linux.txt
2 file(s), 1 dir(s)

// Read the size of the hello.txt file (the result is saved to the variable filesize by
default)
=> fatsize mmc 1 hello.txt
=> echo $filesize
0x17

// Read hello.txt file to address 0x2000000
=> fatload mmc 1 0x2000000 hello.txt
reading hello.txt
23 bytes read in 2 ms (10.7 KiB/s)
// Viewing the contents of read hello.txt
=> md.l 0x2000000
02000000: 6c6c6568 65682d6f 2d6f6c6c 6c6c6568    hello-hello-hell
02000010: 65682d6f ff6f6c6c ffffffff ffffffff    o-hello.........

// Create a new file: hello-copy.txt. Write the contents of addresses 0x2000000~0x2000017 to
hello-copy.txt.
=> fatwrite mmc 1 0x2000000 hello-copy.txt 0x17
writing hello-copy.txt
23 bytes written
// See new file: hello-copy.txt
=> fatls mmc 1
            System Volume Information/
       23   hello.txt
       23   linux.txt
       23   hello-copy.txt

3 file(s), 1 dir(s)

Note: ext2/4 と 脂肪コマンドは同様に使われますので、特定の指示は与えられません。

4.11 HW-ID DTBの特長 {#411-hw-id-dtb}

RKプラットフォームのUボットは、ハードウェア上のGPIOまたはADCステータスを検出して、HW-ID DTB(ハードウェアID DTB)関数と呼ばれる異なるカーネルDTBを動的にロードするサポートをサポートしています。

4.11.1 デザイン原則 {#4111-design-principle}

通常、ハードウェア設計は、画面、無線LANモジュールなどの新しいバージョンやコンポーネントで頻繁に更新されます。 各ハードウェアバージョンがソフトウェアのセットに対応する必要がある場合は、保守に問題があります。 そのため、HW_ID 機能が必要で、ソフトウェアのセットが異なるバージョンのハードウェアに適応できるということを認識しています。 異なるハードウェアバージョンでは、ソフトウェアは対応するdtbファイル、およびADC / GPIOハードウェア固有の値を提供し、現在のハードウェアバージョン(例えば、固定アドク値、固定GPIOレベル)を特徴付ける必要があります。

ユーザーは、ハードウェアバージョンに対応したすべてのdtbファイルを同じresource.imgにパッケージ化します。 U-Boot がカーネルをブートするとき、ハードウェアのユニークネスをチェックし、resource.img から現在のハードウェアバージョンにマッチする dtb を見つけてカーネルに渡します。

4.11.2 ハードウェア参照 {#4112-hardware-reference}

ADCとGPIOの両方が、ハードウェアバージョンの決定に現在サポートされています。 ADC 参照の設計 RK3326-EVB/PX30-EVB マザーボードは予約された電圧ディバイダーの抵抗器、別の抵抗の分光器に異なった ADC の価値があります、従って別のハードウェア版を定めることができます:.

出典図、英語PDF p74

MIPIパネルには、プルダウン抵抗器が搭載されています。

出典図、英語PDF p75

異なる mipi スクリーンは、異なる抵抗値で設定され、独自の ADC パラメータ値が EVB マザーボードと組み合わせて決定されます。 現在のV1バージョンのADC計算方法:ADCパラメータの最大値が1024で、ADC_IN0ピンが1.8Vの供給電圧に直接引き込まれ、EVBボードに接続すると、MIPI画面に10Kプルダウン抵抗器があり、ADC = 1024*10K/(10K + 51K) = 167.8 。 GPIO 参照の設計 現在、GPIO のハードウェア参照の設計はユーザーによってカスタマイズすることができる。

4.11.3 DTB のネーミング {#4113-dtb-naming}

ユーザーは、dtbファイル名のADC/GPIOのハードウェア固有の値情報を反映している必要があります。 命名規則は、HW_ID DTB の ADC です。ファイル名は “.dtb” で終了します。 HW_ID フォーマット: #[controller]_ch[channel]=[adcval] で、完全なユニット: ADC コントローラのノード名は dts 内の ADC チャンネルです。 : ADC の中心値が、実際の有効範囲は: adcval+-30 です。 各ユニットは、内部スペースなしで文字を小文字にする必要があります。 複数のユニットは、# で区切られ、10 単位までサポートされます。

例:

rk3326-evb-lp3-v10#saradc_ch2=111#saradc_ch1=810.dtb
rk3326-evb-lp3-v10#_saradc_ch2=569.dtb

GPIO は HW_ID DTB で: ファイル名は “.dtb” で終了します。 HW_ID フォーマット: #gpio[pin]=[level] は、完全なユニットと呼ばれる : GPIO ピン, 例えば. gpio0a2用 0a2 : GPIOピンレベル。 各ユニットは、内部スペースなしで文字を小文字にする必要があります。 複数ユニットは#で区切られ、10単位までサポートされます。; 例:

rk3326-evb-lp3-v10#gpio0a2=0#gpio0c3=1.dtb

4.11.4 DTB包装 {#4114-dtb-packaging}

カーネルリポジトリ: scripts/mkmultidtb.py. このスクリプトは、同じresource.imgに複数のdtbsをパッケージ化するために使用できます。 ユーザーは、dtbファイルをDTBS辞書に詰めて、対応するADC/GPIO設定情報に記入するためにスクリプトファイルを開く必要があります。

...
DTBS = {}
DTBS['PX30-EVB'] = OrderedDict([('rk3326-evb-lp3-v10', '#_saradc_ch0=166'),
                ('px30-evb-ddr3-lvds-v10', '#_saradc_ch0=512')])
...

上記の例では、scripts/mkmultidtb.py PX30-EVB を実行して、dtb: rk-kernel.dtb: rk’s のデフォルト dtb の 3 コピーで resource.img を生成します。 デフォルトでは、すべての dtb が正常にマッチされていない場合に使用されます。 パッケージングスクリプトは、DTBSの最初のdtbをデフォルトのdtbとして使用します。 rk3326-evb-lp3-v10#_saradc_ch0=166.dtb: ADC情報を含むrk3326 dtbファイル。 px30-evb-ddr3-lvds-v10#_saradc_ch0=512.dtb: ADC情報を含む px30 dtb ファイル; scripts/mkmultidtb.py を手動で実行すると、生成された resource.img を boot.img に手動で置き換える必要があります。 利便性のために、ユーザーは以下のような呼び出しを増加させ、カーネルリポジトリのコンパイルはマルチDTB resource.imgを自動的に含めることができます。

diff --git a/scripts/mkimg b/scripts/mkimg
index 1d895602935..5e1355b9da8 100755
--- a/scripts/mkimg
+++ b/scripts/mkimg
@@ -248,6 +248,7 @@ if [ "${srctree}" != "${objtree}" ]; then
 fi
 scripts/resource_tool ${DTB_PATH} ${LOGO} ${LOGO_KERNEL} >/dev/null
 echo "  Image:  resource.img (with ${DTB} ${LOGO} ${LOGO_KERNEL}) is ready"
+./scripts/mkmultidtb.py PX30-EVB

 if [ -f "${BOOT_IMG}" ]; then
        if file -L -p -b ${BOOT_IMG} | grep -q 'Device Tree Blob' ; then

4.11.5 機能の有効化 {#4115-feature-enablement}

構成オプション:

CONFIG_ROCKCHIP_HWID_DTB=y

ドライバーコード:

./arch/arm/mach-rockchip/resource_img.c // Specific realization: rockchip_read_hwid_dtb()

DTS 構成: GPIO がハードウェア識別として使用される場合、対応する pinctrl と gpio ノードは rkxx-u-boot.dtsi で予約する必要があります。 ADC はデフォルトで有効です。 例えば、gpio0 と gpio1 は同一の識別として使われます。

...

&pinctrl {
    u-boot,dm-spl;  // Append this attribute to allow the node to be retained in the U-Boot
DTB. Same below.
};

&gpio0 {
    u-boot,dm-spl;
};

&gpio1 {
    u-boot,dm-spl;
};

...

4.11.6 ロード結果 {#4116-load-results}

......
mmc0(part 0) is current device
boot mode: None
DTB: rk3326-evb-lp3-v10#_saradc_ch0=166.dtb // Prints the matching DTB, otherwise defaults
to “rk-kernel.dtb”.
Using kernel dtb
......

4.12 SDおよびUSBのフラッシュ ドライブ {#412-sd-and-usb-flash-drives}

この章では、RKプラットフォーム上でSDとUSBフラッシュドライブのファームウェアの起動とアップグレードに焦点を当てています。

4.12.1 メカニズムと原則 {#4121-mechanisms-and-principles}

起動カードとアップグレードカードが作成されると、固定タグは、ブートカードかアップグレードカードであるかを示すために、固定されたストレージオフセット位置でファームウェアヘッダーに配置されます。 U-Bootは、このタグを認識し、対応するブートまたはアップグレードプロセスを進めます。 ここで: ブートカード: カードに1つの完全なファームウェアしか存在しません。 U-Bootは、この完全なファームウェアを使用して、システムが正常に起動します。 アップグレードカード: カードにはファームウェアの2つのコピーが含まれています。 アップグレードカードを作成するとき、PCツールはファームウェアの2つのコピーを記述します。リカバリモード(ファームウェアAとして表記)を入力するために必要なパーティションイメージのみを含むもの、およびupdate.imgファームウェア(ファームウェアBと表記)が完全に含まれているもの。 U-BootはファームウェアAを使用してシステムを回復モードに起動し、回復プログラムはファームウェアBを使用してアップグレード作業を完了します。 特別なノート:SDカード起動/アップグレードは、bootromレベルからサポートされます。 USBディスク起動/アップグレードは、Uブートレベルからのみサポートされています。つまり、ユーザーは少なくともU-Bootが正常に動作していることを確認する必要があります!

4.12.2 ファームウェア作成 {#4122-firmware-creation}

RKプラットフォーム上でSDとUSBディスクのブートカードとアップグレードカードを作成するプロセスは同一であり、2つのステップのみが必要です。SDKディレクトリのRKTools/linux/Linux_Pack_Firmware/rockdev/ツールを使用して、update.imgを生成します。 SDDiskToolを使用して、update.imgをSDまたはUSBディスクにダウンロードします。 映像で示されるように:取り外し可能なディスクを選んで下さい ファームウェアのアップグレードかSDのブートを選んで下さい。

クリック 開始 作成

出典図、英語PDF p79

4.12.3 SD の構成 {#4123-sd-configuration}

SDブート/アップグレード: 各プラットフォームのSDKによってリリースされたUボットは、デフォルトでこの機能を有効にしました。ユーザーは追加で設定する必要はありません。

4.12.4 USB の構成 {#4124-usb-configuration}

USB ブート/アップグレード: 各プラットフォーム SDK がリリースした U ボットはデフォルトでは有効ではありません。 U-BootのネイティブUSBスキャンコマンドは時間がかかりますので、ユーザーが自分でそれを可能にするための方が良いでしょう:ステップ1:アップグレードファームウェアをローカルストレージ(eMMC / Nand / …など)にダウンロードし、ファームウェアが利用可能であることを確認します。

ステップ2:USBフラッシュドライブに接続し、U-Bootコマンドラインモードに起動します。 USBフラッシュドライブが正常に認識されていることを確認するためにUSBの起動とUSB情報コマンドを実行します。それ以外の場合は、USBフラッシュドライブの認識を最初に調整してください。

ステップ3:ステップ1で指定したカーネルDTBのコピーを作成し、kern.dtbという名前を付けてU- Bootの. /dts/ディレクトリに置く。 U-Boot をコンパイルする際に、この kern.dtb は uboot.img に自動的にパックされます。 kern.dtb の目的: U-Boot は、ローカルストレージパーティションのカーネル dtb が破損しているときに USB が正しく初期化されていることを確認するために kern.dtb を使用します。

ステップ4:UブートはUSBのブート/アップグレード構成を可能にします

CONFIG_ROCKCHIP_USB_BOOT=y

uboot.imgのコンパイルとダウンロード. プロセスがubootのファームウェアがパッケージ化され、ステップ3でkern.dtbの追加から結果に大きすぎると、未使用Uブート構成を最初にカットしてください。

4.12.5 効果をとる機能 {#4125-functions-taking-effect}

SD、USBディスクの起動またはアップグレード機能が有効であることを確認する方法。

ユーザーは、カーネル、リソース、ブート、ローカルストレージの回復(eMMC、Nand…)などのキーパーティションを削除して、SD / Uディスクをインサートした後にカーネルを入力することができます。

4.12.6 ノート {#4126-notes}

USBフラッシュドライブが初期化されるとusb startコマンドが呼び出され、プロセス全体が比較的時間がかかります。 boot/upgradeカードがGPTパーティションテーブルをサポートする必要がある場合は、SDDiskToolツールのバージョンは> = v1.59を必要とします。 ブート/アップグレードカードがABシステムをサポートする必要がある場合は、SDDiskToolツールのバージョンは>= v1.61が必要です。 USBディスクブート/アップグレード機能は2019.11で追加された機能であるため、 関連するリポジトリは、次の条件を満たす必要があります。

  1. U-Bootリポジトリは、次のコミットポイント(推奨)に更新されます。
commit 369e944c844f783508b7839ae86a3418e2f63bc7
Author: Joseph Chen <chenjh@rock-chips.com>
Date:   Thu Dec 12 18:07:07 2019 +0800

    fdt/Makefile: make u-boot-dtb.bin 8-byte aligned

    The dts/kern.dtb is appended after u-boot-dtb.bin for U-disk boot.

    Make sure u-boot-dtb.bin is 8-byte aligned to avoid data-abort on
    calling: fdt_check_header(gd->fdt_blob_kern).

    Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
    Change-Id: Id5f2daf0c5446e7ea828cb970d3d4879e3acda86

または個別に次のパッチ変更を加える(おそらくもっと困難):

369e944 fdt/Makefile: make u-boot-dtb.bin 8-byte aligned
b3b57ac rockchip: board: fix always entering recovery on normal boot U-disk
e0cee41 rockchip: resource: add sha1/256 verify for kernel dtb
5e817a0 tools: rockchip: resource_tool: add sha1 for file entry
fc474da lib: sha256: add sha256_csum()
0ed06f1 rockchip: support boot from U-disk
01f0422 common: bootm: skip usb_stop() if usb is boot device
5704c89 fdtdec: support pack "kern.dtb" to the end of u-boot.bin
3bdef7e gpt: return 1 directly when test the mbr sector
  1. rkbinリポジトリには、このコミットが含まれている必要があります。
commit f9c0b0b72673a65865b00a8824908ca6f12ecc32
Author: Joseph Chen <chenjh@rock-chips.com>
Date:   Thu Nov 7 09:21:36 2019 +0800

    tools: resource: add sha1 for file entry

    Base on U-Boot next-dev branch:
    (5e817a0 tools: rockchip: resource_tool: add sha1 for file entry)

    Change-Id: Ife061cabacab488dbecf2a3245d58cc660091dbd
    Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
  1. カーネルリポジトリには、このコミットが含まれている必要があります。
commit 078785057478c789bb033ba06925fa3a07e3130a
Author: Tao Huang <huangtao@rock-chips.com>
Date:   Thu Nov 7 17:53:38 2019 +0800

    rk: scripts/resource_tool: add sha1 for file entry

    From u-boot 5e817a0ea427 ("tools: rockchip: resource_tool: add sha1 for file
entry").
    Merge all C files to one resource_tool.c

    Change-Id: If63ba77d1f5a3660bd6ef87769bb456fa086ae71
    Signed-off-by: Tao Huang <huangtao@rock-chips.com>

ユーザーが保有するSDKが比較的古い場合、上記パッチを個別に追加することに加えて、回復の責任者にエンジニアにチェックして、回復が関連するパッチを持っているかどうかを確認することをお勧めします。

5. .. Chapter-5 ドライバーモジュール {#5-chapter-5-driver-module}

5.1 アンプ {#51-amp}

5.1.1 導入のアイデア {#511-ideas-for-implementation}

U-BootフレームワークはデフォルトではAMP(Asymmetric Multi-Processing)サポートはありませんが、RKはAMPメカニズムのセットを単独で実装しています。異なるCPUは異なるファームウェアを実行します。 実装アイデア: (1)ファームウェアの全てのAMPファームウェア(Linuxを除く)は、CPUの実行状態を指定し、そのファイルを通してファームウェア情報を説明し、最終的にはFITフォーマットamp.imgにパッケージして、AMPパーティションにダウンロードします。 起動中、U-Bootはamp.imgファームウェアをロードし、sha256の整合性チェックを実行するための責任であり、各CPUの実行状態を特定し、対応するエントリアドレスにそれをディスパッチします。 (2)ブートオーダー U-Bootを実行するCPUは、最終的に他のコアの状態の切り替えとファームウェアジャンプを完了した後、それ自体で動作するマスターコアと呼ばれます。 (3)リソース管理U-Bootは、リソースの調整(メモリの分割を含む)を担当しません。 AMP スキームのファームウェア間で割込み等を行うため、開発者は必ずご確認ください。 (4) Trust サポート The AMP 機能は信頼のサポートが必要です。 ユーザ指定の CPU 実行状態がデフォルト状態の場合、SDK の信頼は既にサポートされています。デフォルト状態でないと、トラストには追加のサポートが必要です(ただし、一部のプラットフォームの SDK はデフォルトでサポートしています)。 上記の CPU のデフォルト状態は: 32 ビット チップのデフォルト状態: アーチ = “arm”, thumb = <0>, hyp = 0; 64 ビット チップのデフォルト状態: アーチ = “arm64”, 親指 = <0>, hyp = 1; (5) Linux+AMP の組み合わせ

  1. 互換性を考慮して、組み合わせスキームのLinux関連のファームウェアは、従来のSMPファームウェアと一致しています。 Linux関連のファームウェア+ amp.img。

  2. 開発者は、Linux を実行している CPU の状態を「linux」ノードを追加して amp のノードに指定できます(それなしではデフォルト状態です)。

  3. 主要なコアがLinuxを実行しているか、ファームウェアが指定されていない場合は、メインコアは、他のAMPファームウェアを起動した後、従来のSMPブートファッションでU-BootからLinuxを起動します。

  4. ノンメインコアがLinuxを実行している場合は、Linuxを起動し、最初にLinuxを起動します。

注:CPU0以外のコアで起動したい場合、特別な信頼サポートが必要です。

  1. Linux ファームウェアのロードアドレスは、U ボットの設定のみで決定されます。 rk3568_common.h. の特長

5.1.2フレームワークサポート {#512-framework-support}

構成:

CONFIG_AMP
CONFIG_ROCKCHIP_AMP

フレームワーク コード:

./drivers/cpu/rockchip_amp.c

テンプレート:

./drivers/cpu/amp.its

パッキング用具:

./tools/mkimage  // wil be generated automatically after a full U-Boot compilation

コードコミットポイントは、以下を含みます。

commit c51cf04095dde2df2dd047e70d2c7fb0866ea916
Author: Joseph Chen <chenjh@rock-chips.com>
Date:   Tue Oct 19 03:16:35 2021 +0000

    cpu: amp.its: update amps "arm64" => "arm"

    Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
    Change-Id: I99de02c5b6c62ffdd9b25565acd172801d6e983c

5.1.3 機能有効化 {#513-feature-enablement}

  1. amp.img を作成するには、そのファイルが必要です。ドライバ/cpu/amp.its に基づいて変更してください:次のこと: CPU1/2/3 は AMP、CPU0 が Linux を実行し、メインコアは CPU3 です。 ブートの順序は: CPU0 = > CPU1/2 = > CPU3 ZXZです。
/dts-v1/;
/ {
    description = "FIT source file for rockchip AMP";
    #address-cells = <1>;
    // All AMP firmware (excluding Linux) should be specified under the images node;
    images {
        amp1 {
            description  = "bare-mental-core1";       // Required: Description info
            data         = /incbin/("./amp1.bin");    // Required: amp1 firmware
            type         = "firmware";  // Required: No change
            compression  = "none";      // Required: No change
            arch         = "arm";       // Required: “arm64”: 64-bit, “arm”: 32-bit
            cpu          = <0x100>;     // Required: cpu hardware id (mpidr)
            thumb        = <0>;         // Required: 0: arm or thumb2; 1: pure thumb
            hyp          = <0>;         // Required: 0: el1/svc; 1: el2/hyp
            load         = <0x01800000>;// Required: Firmware load and run address
            udelay       = <1000000>;   // Optional: delay after booting the current CPU and
then start the next CPU.
            hash {                      // Required: No change
                algo = "sha256";
            };
        };

        amp2 {
            description  = "bare-mental-core2";
            data         = /incbin/("./amp2.bin");
            type         = "firmware";
            compression  = "none";
            arch         = "arm";
            cpu          = <0x200>;
            thumb        = <0>;
            hyp          = <0>;
            load         = <0x03800000>;
            udelay       = <1000000>;
            hash {
                algo = "sha256";
            };
        };

        amp3 {
            description  = "bare-mental-core3";
            data         = /incbin/("./amp3.bin");
            type         = "firmware";
            compression  = "none";
            arch         = "arm";
            cpu          = <0x300>;
            thumb        = <0>;
            hyp          = <0>;
            load         = <0x05800000>;
            udelay       = <1000000>;
            hash {
                algo = "sha256";
            };
        };
    };

    configurations {
        default = "conf";
        conf {
            description = "Rockchip AMP images";
            rollback-index = <0x0>;
            // Specifies the firmware to be loaded and the order in which it should be
loaded and booted, but the master core is not subject to this order.
            loadables = "amp1", "amp2", "amp3";

            signature {
                algo = "sha256,rsa2048";
                padding = "pss";
                key-name-hint = "dev";
                sign-images = "loadables";
            };

            // Linux CPU runtime state designation:
            // (1) Only the udelay attribute is optional;
            // (2) The boot address is not assignable and is determined by U-Boot's platform
configuration file, e.g.: rk3568_common.h;
            linux {
                description  = "linux-os";
                arch         = "arm64";
                cpu          = <0x000>;    // CPU0 runs linux
                thumb        = <0>;
                hyp          = <0>;
                udelay       = <1000000>;
            };
        };
    };
};

Note: 説明: 説明情報。. タイプ: デフォルトは “firmware” です。 圧縮: デフォルトは “none” です。 データ: ファームウェアパス。 パスは、AMP.its に基づいて相対パスです。 アーチ: CPU 32/64 モード: ARMv7 は「arm」としてのみ指定できます。 ARMv8 は、それぞれ AArch64 または AArch32 を意味します。 cpu: CPU ハードウェア ID、すなわち mpidr (Multiprocessor Affinity Register) として指定できます。 たとえば:

cpus {
    #address-cells = <2>;
    #size-cells = <0>;

    cpu0: cpu@0 {
        device_type = "cpu";
        compatible = "arm,cortex-a55";
        reg = <0x0 0x0>;    // mpidr
        ......
    };

    cpu1: cpu@100 {
        device_type = "cpu";
        compatible = "arm,cortex-a55";
        reg = <0x0 0x100>;  // mpidr
        ......
    };
    ......
};

親指: CPU の指示モード。 純粋なTHUMB、0 がなければ 1 を指定します。hyp: CPU VM モードです。 load: ファームウェアの読み込みと実行アドレスの udelay: 起動完了後 (オプション) を遅延します。 現在のCPUを起動した後、次のCPUを起動する前に対応する遅延を実行します。 loadables: AMPファームウェアをロードして起動する順番です。 メインCPUは起動する最後のものでなければなりません。ここで注文するものではありません。 linuxノード:Linux + AMPの組み合わせプログラムの場合。 こちらのセクションでは「実装のアイデア」をご覧ください。

  1. ファームウェアのパッキング:
// 0xe00 is the firmware header size and is not recommended to be changed
./tools/mkimage -f ./drivers/cpu/amp.its -E -p 0xe00 amp.img

自動的にmkimageツールを生成するためにU-Bootの完全なコンパイルが必要です。

  1. ampパーティションを分割テーブルに追加 parameter.txtパーティションテーブルファイルに「amp」パーティションを追加し、amp.imgをダウンロードします。 U-Bootは、AMPパーティション全体をメモリに直接読み込むことです。そのため、実際のニーズに応じてAMPパーティションサイズが設定されていることを推奨しています。

  2. U-Bootフレームワークを立ち上げると、自動的にすべてのAMPの起動が正しいタイミングで開始されます。 以下は、メインコアとしてAMPファームウェアを実行しているCPU3のブート情報であり、CPU0 / 1/2は、Linuxファームウェアを実行しています。

......
// the master core loading firmware amp3 firmware
### Loading loadables from FIT Image at 7bdbcf80 ...
   Trying 'amp3' loadables subimage
     Description:  rtthread
     Type:         Firmware
     Compression:  uncompressed
     Data Start:   0x7bdbdd80
     Data Size:    311296 Bytes = 304 KiB
     Architecture: ARM
     Load Address: 0x01800000
     Hash algo:    sha256
     Hash value:   d08db937e4d7bd4125056239154bb30d44a2fcca9e70aa8dea448fabda4838d5
   Verifying Hash Integrity ... sha256+ OK
   Loading loadables from 0x7bdbdd80 to 0x01800000
### Booting FIT Image FIT: No fit blob
FIT: No FIT image
ANDROID: reboot reason: "(none)"
optee api revision: 2.0
TEEC: Waring: Could not find security partition
Not AVB images, AVB skip
ANDROID: Hash OK

// the master core loading Linux firmware
Booting IMAGE kernel at 0x03880000 with fdt at 0x0a100000...

Fdt Ramdisk skip relocation
### Booting Android Image at 0x0387f800 ...
Kernel load addr 0x03880000 size 21655 KiB
### Flattened Device Tree blob at 0x0a100000
   Booting using the fdt blob at 0x0a100000
   XIP Kernel Image from 0x03880000 to 0x03880000 ... OK
  'reserved-memory' ramoops@110000: addr=110000 size=f0000
   Using Device Tree in place at 000000000a100000, end 000000000a12322a
vp1 adjust cursor plane from 0 to 1
vp0, plane_mask:0x2a, primary-id:5, curser-id:1
vp1 adjust cursor plane from 1 to 0
vp1, plane_mask:0x15, primary-id:4, curser-id:0
vp2, plane_mask:0x0, primary-id:0, curser-id:-1
Adding bank(fixed): 0x03880000 - 0x80000000 (size: 0x7c780000)

// At this point, all the firmware is loaded, and it starts to boot each CPU according to
the program's prioritization rules,as follows

// The main core boots CPU0 to run Linux (CPU1/2 subsequently boots via Linux)
AMP: Brought up cpu[0] with state 0x12, entry 0x03880000 ...OK
// The main core boots itself (CPU3) to run the AMP firmware
AMP: Brought up cpu[300, self] with state 0x10, entry 0x01800000 ...OK

// Linux runs on CPU0:
[    0.000000] Booting Linux on physical CPU 0x0000000000 [0x412fd050]
[    0.000000] Linux version 4.19.193 (stevenliu@stevenliu) (gcc version 6.3.1 20170404
(Linaro GCC 6.3-2017.05), GNU ld (Linaro_Binutils-2017.05) 2.27.0.20161019) #5 SMP Mon Sep
13 16:22:51 CST 2021
[    0.000000] Machine model: Rockchip RK3568 EVB1 DDR4 V10 Board
......

上記は、ユーザーの構成により異なる場合がございます。実際の条件に準じます。

5.2 充満 {#52-charge}

5.2.1フレームワークサポート {#521-framework-support}

U-Boot のネイティブコードは充電をサポートしていませんが、RK はセットを実装しました。 充満は表示、PMIC、パワー メーター、充満アニメーション、pwrkey、導かれた、CPUの低電力の hibernation、タイマーを含む多くのモジュールを等含んでいます。 パワーメーターサポート:

RK809/RK816/RK817/RK818/cw201x.

構成:

// Framework
CONFIG_DM_CHARGE_DISPLAY
CONFIG_CHARGE_ANIMATION
CONFIG_DM_FUEL_GAUGE
// Driver
CONFIG_POWER_FG_CW201X
CONFIG_POWER_FG_RK818
CONFIG_POWER_FG_RK817
CONFIG_POWER_FG_RK816

充満フレーム:

./drivers/power/charge-display-uclass.c

充満アニメーションのドライバー:

// Responsible for managing the entire charging process, it will get the power level,
charging type, button events, initiate low-power hibernation, and more.
./drivers/power/charge_animation.c

パワーメーターフレームワーク:

./drivers/power/fuel_gauge/fuel_gauge_uclass.c

パワーメーターのドライバー:

./drivers/power/fuel_gauge/fg_rk818.c
./drivers/power/fuel_gauge/fg_rk817.c   // rk809 re-use
./drivers/power/fuel_gauge/fg_rk816.c
......

論理プロセス:

charge-display-uclass.c
    => charge_animation.c
        => fuel_gauge_uclass.c
            => fg_rkxx.c

5.2.2 包装映像 {#522-packaging-pictures}

充電画像は. /tools/images/ディレクトリにあり、充電フレームで表示されるresource.imgにパッケージ化する必要があります。 カーネルがコンパイルしたresource.imgは、デフォルトで充電画像ではパックされていないため、U-Bootに別途梱包する必要があります。

$ ls tools/images/
battery_0.bmp  battery_1.bmp  battery_2.bmp  battery_3.bmp  battery_4.bmp  battery_bmp
battery_fail.bmp

包装のコマンド:

./pack_resource.sh <input resource.img> or
./scripts/pack_resource.sh <input resource.img>

包装情報:

./pack_resource.sh  /home/cjh/3399/kernel/resource.img

Pack ./tools/images/ & /home/guest/3399/kernel/resource.img to resource.img ...
Unpacking old image(/home/guest/3399/kernel/resource.img):
rk-kernel.dtb logo.bmp logo_kernel.bmp
Pack to resource.img successed!
Packed resources:
rk-kernel.dtb battery_1.bmp battery_2.bmp battery_3.bmp battery_4.bmp battery_bmp
battery_fail.bmp logo.bmp logo_kernel.bmp battery_0.bmp

resource.img is packed ready

成功すると、画像を含むresource.imgがU-Bootルートディレクトリで生成され、HDコマンドで内容を確認することができます。

hd resource.img | less

00000000  52 53 43 45 00 00 00 00  01 01 01 00 0a 00 00 00  |RSCE............|
00000010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
......
*
00000400  45 4e 54 52 62 61 74 74  65 72 79 5f 31 2e 62 6d  |ENTRbattery_1.bm| // picture1
00000410  70 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |p...............|
00000420  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000500  00 00 00 00 4d 00 00 00  9c 18 00 00 00 00 00 00  |....M...........|
00000510  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000600  45 4e 54 52 62 61 74 74  65 72 79 5f 32 2e 62 6d  |ENTRbattery_2.bm| // picture 2
00000610  70 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |p...............|
00000620  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
......

5.2.3 DTSの構成 {#523-dts-configuration}

DTS充満ノード:

charge-animation {
    compatible = "rockchip,uboot-charge";
    status = "okay";

    rockchip,uboot-charge-on = <0>;             // Whether to enable U-Boot charging
    rockchip,android-charge-on = <1>;           // Whether to enable Android charging

    rockchip,uboot-exit-charge-level = <5>;     // Minimum power allowed to power on while
U-Boot is charging.
    rockchip,uboot-exit-charge-voltage = <3650>;// Minimum voltage allowed to power on when
U-Boot is charging.
    rockchip,screen-on-voltage = <3400>;        // Minimum voltage allowed to light up the
screen while U-Boot is charging.

    rockchip,uboot-low-power-voltage = <3350>;  // Minimum voltage for forcing U-Boot to
entry into charging mode unconditionally.

    rockchip,system-suspend = <1>;              // Whether to enter trust low-power standby
when the screen goes off ( need to be supported by ATF)
    rockchip,auto-off-screen-interval = <20>;   // Timeout for automatic screen going off,
in seconds, default 15s
    rockchip,auto-wakeup-interval = <10>;       // Automatic wake-up time from hibernation
in seconds. If the value is 0 or no such attribute,
                                                // hibernation automatic wake-up  is
disabled,
                                                // generally used for stress test.
    rockchip,auto-wakeup-screen-invert = <1>;   // Whether or not to light up the screen
when automatic wake-up from hibernation.
};

5.2.4 システム 高度 {#524-system-hibernation}

押しPwrkey:画面がオフになったときに、画面をオン/オフにするために、pwrkeyを簡潔に押すと、システムが低電力モードに入ります。

pwrkeyを押し、システムに起動します。 ロックチップ、システムサスペンド = <VAL> : VAL は 0: cpu wfi モードです。 今回は、周辺機器の処理は行いません。Cpuは低電力モードにのみ入ります。VALは1:システムサスペンションモードです。ATF/OPTEEは有効です。 カーネルのようなシステムは、SOC全体がスタンバイに入ります。 U-Boot 低電力スタンバイをサポートする ATF/OPTEE の最小バージョン番号:プラットフォーム定義セクションを参照してください。

5.2.5 映像の取り替え {#525-replacement-of-pictures}

  1. . /tools/images/ ディレクトリ(8bitまたは24bit bmp を使用して)に画像を置換し、画像が低電力から高出力にソートされていることを確認するために、コマンド ls | ソートを使用して、pack_resource.sh スクリプトを使用して、画像を resource.img にパッケージ化します。

  2. . /drivers/power/charge_animation.cをイメージおよび充満関係で変更して下さい;

/*
 * IF you want to use your own charge images, please:
 *
 * 1. Update the following 'image[]' to point to your own images;
 * 2. You must set the failed image as last one and soc = -1 !!!
 */
static const struct charge_image image[] = {
    { .name = "battery_0.bmp", .soc = 5, .period = 600 },
    { .name = "battery_1.bmp", .soc = 20, .period = 600 },
    { .name = "battery_2.bmp", .soc = 40, .period = 600 },
    { .name = "battery_3.bmp", .soc = 60, .period = 600 },
    { .name = "battery_4.bmp", .soc = 80, .period = 600 },
    { .name = "battery_bmp", .soc = 100, .period = 600 },
    { .name = "battery_fail.bmp", .soc = -1, .period = 1000 },
};

// @name: Name of the picture;
// @soc: Amount of electricity corresponding to the picture;
// @period: Image refresh time (unit: ms);
// Note: The last image must be a fail image and “soc=-1” cannot be changed.  !!

5.2.6 充満表示器 {#526-charging-indicator}

実際のプロダクトでは、ユーザーは導かれたのための別の制御条件を、従って充満フレームだけ2つの導かれた支えますあります。 充電インジケータ、フル充電インジケータ:充電インジケータ:充電中に電力レベルの変化がある場合、ledは反転されます。 十分に充電インジケータ:バッテリーが100%満たしたときにLEDは点灯します。

上記2つのLed設定は、ユーザーが自分のニーズに応じてコードを変更する必要があります。 構成オプション:

CONFIG_LED_CHARGING_NAME
CONFIG_LED_CHARGING_FULL_NAME

これら2つの設定オプションは、ledのラベル属性を指定するために使用されます。 Ledセクションを参照してください。

5.3 クロック {#53-clock}

5.3.1フレームワークサポート {#531-framework-support}

クロックドライバは、クラスフレームワークと標準インターフェイスを使用します。 構成:

CONFIG_CLK

フレームワークコード:

./drivers/clk/clk-uclass.c

プラットホームのドライバーコード:

./drivers/clk/rockchip/...

5.3.2 関連するインターフェイス {#532-relevant-interface}

// Apply Clock
int clk_get_by_index(struct udevice *dev, int index, struct clk *clk);
int clk_get_by_name(struct udevice *dev, const char *name, struct clk *clk);

// Enable/Disable Clock
int clk_enable(struct clk *clk);
int clk_disable(struct clk *clk);

// Configure/acquire frequency
ulong (*get_rate)(struct clk *clk);
ulong (*set_rate)(struct clk *clk, ulong rate);

// Configure/get phase
int (*get_phase)(struct clk *clk);
int (*set_phase)(struct clk *clk, int degrees);

5.3.3 クロック初期化 {#533-clock-initialization}

時計の初期化に関与するインタフェースの合計3カテゴリがあります。, その後の導入の酒のために, ここでは、最初のリストの原油ノード情報

cru: clock-controller@ff2b0000 {
    compatible = "rockchip,px30-cru";
    ......
    assigned-clocks =
        <&pmucru PLL_GPLL>, <&pmucru PCLK_PMU_PRE>,
        <&pmucru SCLK_WIFI_PMU>, <&cru ARMCLK>,
        <&cru ACLK_BUS_PRE>, <&cru ACLK_PERI_PRE>,
        <&cru HCLK_BUS_PRE>, <&cru HCLK_PERI_PRE>,
        <&cru PCLK_BUS_PRE>, <&cru SCLK_GPU>;
    assigned-clock-rates =
        <1200000000>, <100000000>,
        <26000000>, <600000000>,
        <200000000>, <200000000>,
        <150000000>, <150000000>,
        <100000000>, <200000000>;
    ......
}

プラットフォームベースクロックのデフォルト初期化: rkclk_init()**: 各プラットフォームの原始プローブは、rkclk_init() を呼び出して、cru_rkxxx.hで定義される pll/cpu/bus 周波数の初期化を完了します。 例えば、RK3399:

#define APLL_HZ         (600 * MHz)
#define GPLL_HZ         (800 * MHz)
#define CPLL_HZ         (384 * MHz)
#define NPLL_HZ         (600 * MHz)
#define PPLL_HZ         (676 * MHz)
#define PMU_PCLK_HZ     ( 48 * MHz)
#define ACLKM_CORE_HZ   (300 * MHz)
#define ATCLK_CORE_HZ   (300 * MHz)
#define PCLK_DBG_HZ     (100 * MHz)
#define PERIHP_ACLK_HZ  (150 * MHz)
#define PERIHP_HCLK_HZ  ( 75 * MHz)
#define PERIHP_PCLK_HZ  (37500 * KHz)
#define PERILP0_ACLK_HZ (300 * MHz)
#define PERILP0_HCLK_HZ (100 * MHz)
#define PERILP0_PCLK_HZ ( 50 * MHz)
#define PERILP1_HCLK_HZ (100 * MHz)
#define PERILP1_PCLK_HZ ( 50 * MHz)
......

プラットフォームベースクロックの二次初期化 : clk_set_defaults()

各プラットフォームのクルードライバープローブは、割り当てられたクロック/アサインクロッククロック/アサインクロックレートで指定された周波数(すなわち、周波数を再構成する)を解析および設定するためにclk_set_defaults()を呼び出すことができます。 残ったノード内のレートが、アームの周波数ではありません。 アーム周波数は、set_armclk_rate() が実装されている場合にのみ再構成され、下がる CPU 周波数が確認されます。 原油に加えて、そのプローブでclk_set_defaults()を積極的に呼び出すことができる周辺機器、例えばVop、gmac。 分類 III、各モジュールのクロック初期化: clk_set_rate() ほとんどの周辺モジュールは、clk_set_rate() を呼び出して周波数を設定

5.3.4 CPUの頻度ブースト {#534-cpu-frequency-boost}

各プラットフォームの U ボットでサポートされる CPU 周波数ブースト: プラットフォーム定義セクションを参照してください。.それは、異なる実装メカニズムに応じて、次の 3 つのカテゴリに分けられます。: カテゴリ I: APLL cpu ブート周波数ブースト実装プロセスを使用して CPU: ステップ 1: 十字ノードの割り当てられたクロック内のアームターゲット周波数を指定します。; ステップ 2: プローブを clk_set_defaults() に呼び出して取得します(ただし、設定しません) 腕ターゲット周波数からステップ 1 からステップ 1 からステップ 1 から始まる。 ステップ3:set_armclk_rate()を、ステップ2から得られる腕のターゲット頻度をセットアップして下さい。 デフォルトで既に実装されているプラットフォームは、他のプラットフォームでは、必要に応じて追加する既存の実装を参照することができます。例:arch\arm\mach-rockchip\px30\px30.c;。

int set_armclk_rate(void)
{
    struct px30_clk_priv *priv;
    struct clk clk;
    int ret;

    ret = rockchip_get_clk(&clk.dev);
    if (ret) {
        printf("Failed to get clk dev\n");
        return ret;
    }
    clk.id = ARMCLK;
    priv = dev_get_priv(clk.dev);
    ret = clk_set_rate(&clk, priv->armclk_hz);
    if (ret < 0) {
        printf("Failed to set armclk %lu\n", priv->armclk_hz);
        return ret;
    }
    priv->set_armclk_rate = true;

    return 0;
}

ステップ4: cpu opp-table(周波数と電圧テーブル)を参照し、調整器-init-microvolt = <…>をアームのレギュレータノードにインテット電圧を指定し、ターゲット周波数と電圧が一致できることを確認します。 カテゴリーII: SCMI CLKを使用したCPU たとえば、RK356Xでは、起動ブーストは、CPUクロック関連のパラメータを設定するために、スクラブインターフェイスの使用を必要とします。 cpu ブートの実装プロセスは、ステップ 1: アームターゲット周波数をロックチップで指定します,スクミノードのclk-init; ステップ 2: UBOOT に SCMI があることを確認, CONFIG_CLK_SCMI マクロがオンにしました。ステップ 3: set_armclk_rate() を実行します。, スクミの dts ノードから腕のターゲット周波数を設定します。 デフォルトで既に実装しているプラットフォームは、他のプラットフォームでは、必要に応じて、必要に応じて追加するための既存の実装を参照することができます。例えば、arch\arm\mach- lockchip\rk3568\rk3568.c;

#ifdef CONFIG_CLK_SCMI
#include <dm.h>
/*
 * armclk: 1104M:
 *  rockchip,clk-init = <1104000000>,
 *  vdd_cpu : regulator-init-microvolt = <825000>;
 * armclk: 1416M(by default):
 *  rockchip,clk-init = <1416000000>,
 *  vdd_cpu : regulator-init-microvolt = <900000>;
 * armclk: 1608M:
 *  rockchip,clk-init = <1608000000>,
 *  vdd_cpu : regulator-init-microvolt = <975000>;
 */

int set_armclk_rate(void)
{
    struct clk clk;
    u32 *rates = NULL;
    int ret, size, num_rates;

    ret = rockchip_get_scmi_clk(&clk.dev);
    if (ret) {
        printf("Failed to get scmi clk dev\n");
        return ret;
    }

    size = dev_read_size(clk.dev, "rockchip,clk-init");
    if (size < 0)
        return 0;

    num_rates = size / sizeof(u32);
    rates = calloc(num_rates, sizeof(u32));
    if (!rates)
        return -ENOMEM;

    ret = dev_read_u32_array(clk.dev, "rockchip,clk-init",
                 rates, num_rates);
    if (ret) {
        printf("Cannot get rockchip,clk-init reg\n");
        return -EINVAL;
    }
    clk.id = 0;
    ret = clk_set_rate(&clk, rates[clk.id]);
    if (ret < 0) {
        printf("Failed to set armclk\n");
        return ret;
    }
    return 0;
}
#endif

ステップ4: cpu oppテーブル(周波数と電圧テーブル)を参照し、調整装置-init-microvolt = < … >を、アームのレギュレータノードに、インイ電圧を分離し、ターゲット周波数と電圧が一致できることを確認します。 SCMI:CH17-Appendix のセクションを参照してください。 カテゴリーIII: SCMI CLKを使用したCPU カテゴリIIの違いは、ステップ4を実行するだけである。 cpu周波数は、電圧に応じて自動的に増加されます。

5.3.5 時計の木 {#535-clock-tree}

U-Boot のフレームワークにはクロックツリーの管理機能がありません。各プラットフォームでは、クロック情報を簡単に表示するため soc_clk_dump() を追加しています。

例:

CLK: (sync kernel. arm: enter 1200000 KHz, init 1200000 KHz, kernel 800000 KHz)
  apll 800000 KHz
  dpll 392000 KHz
  cpll 1000000 KHz
  gpll 1188000 KHz
  npll 24000 KHz
  ppll 100000 KHz
  hsclk_bus 297000 KHz
  msclk_bus 198000 KHz
  lsclk_bus 99000 KHz
  msclk_peri 198000 KHz
  lsclk_peri 99000 KHz

最初のプリントラインの意味:カーネルを同期させる: クルードライバーは、カーネルのクロールノード内で指定されたバス周波数の各々の clk_set_defaults() で構成されます(ARM周波数を除く)。それ以外の場合は、uboot を同期するように示されています。

入る 1200000 KHz : 前の loader が U-Boot に入ったアーム周波数; init 1200000 KHz : U-Boot のアーム初期化周波数は APLL_HZ で定義されています。カーネル 800000 KHz : 実装された set_armclk_rate() カーネルの cru ノードに割り当てられたクロックによって指定されたアーム周波数を設定します。それ以外の場合は、表示: “kernel 0N/A”;

5.4 暗号 {#54-crypto}

Crypto モジュールは、主にハードウェアレベルの暗号化とハッシュアルゴリズムを実装し、現在v1およびv2 IPバージョンで利用可能です。

5.4.1フレームワークサポート {#541-framework-support}

U-Boot はデフォルトでは暗号化フレームワークのサポートはありません。RK はセットを単独で実装しています。 構成:

CONFIG_DM_CRYPTO
// choose either one of the below two options, the defconfig of each platform has enabled
the corresponding configuration by default.
CONFIG_ROCKCHIP_CRYPTO_V1
CONFIG_ROCKCHIP_CRYPTO_V2

フレームワーク コード:

./drivers/crypto/crypto-uclass.c
./cmd/crypto.c

ドライバーコード:

// crypto v1:
./drivers/crypto/rockchip/crypto_v1.c

// crytpo v2:
./drivers/crypto/rockchip/crypto_v2.c
./drivers/crypto/rockchip/crypto_v2_pka.c
./drivers/crypto/rockchip/crypto_v2_util.c

5.4.2 関連するインターフェイス {#542-relevant-interface}

// Get crypto:
struct udevice *crypto_get_device(u32 capability);
// SHA interface:
int crypto_sha_init(struct udevice *dev, sha_context *ctx);
int crypto_sha_update(struct udevice *dev, u32 *input, u32 len);
int crypto_sha_final(struct udevice *dev, sha_context *ctx, u8 *output);
int crypto_sha_csum(struct udevice *dev, sha_context *ctx,
            char *input, u32 input_len, u8 *output);
// RSA interface:
int crypto_rsa_verify(struct udevice *dev, rsa_key *ctx, u8 *sign, u8 *output);

インターフェースの使用方法は ./cmd/crypto.c を参照してください。SHA の使用方法は v1 と v2 で異なります。v1 では crypto_sha_init() により、計算対象データの総長を最初に ctx->length に設定する必要がありますが、v2 では不要です。

5.4.3 DTSの構成 {#543-dts-configuration}

暗号ノードは、U-Boot dts で定義する必要があります。主な理由:各プラットフォーム用の古い SDK のカーネル dts には、暗号化ノードがないので、古い SDK との互換性を考慮する必要があります。 U-Bootの安全なブートは暗号化を使用するので、U-Bootが暗号化自体を制御するためにより安全でより合理的です。

  1. 暗号v1構成(例としてRK3399):
crypto: crypto@ff8b0000 {
    u-boot,dm-pre-reloc;

    compatible = "rockchip,rk3399-crypto";
    reg = <0x0 0xff8b0000 0x0 0x10000>;
    clock-names = "sclk_crypto0", "sclk_crypto1";
    clocks = <&cru SCLK_CRYPTO0>, <&cru SCLK_CRYPTO1>; // No need to specify frequency,
default 100M
    status = "disabled";
};
  1. 暗号v2構成(例:px30)
crypto: crypto@ff0b0000 {
    u-boot,dm-pre-reloc;

    compatible = "rockchip,px30-crypto";
    reg = <0x0 0xff0b0000 0x0 0x4000>;
    clock-names = "sclk_crypto", "apkclk_crypto";
    clocks = <&cru SCLK_CRYPTO>, <&cru SCLK_CRYPTO_APK>;
    clock-frequency = <200000000>, <300000000>; // Generally need to specify the frequency
    status = "disabled";
};

暗号化v1とv2のdts設定の違いは、クラック周波数仕様にあります。

5.5 ディスプレイ {#55-display}

5.5.1フレームワークサポート {#551-framework-support}

RK U ボットは、RGB、LVDS、EPD、MIPI、HDMI、CVBS、DPなど、次のディスプレイインタフェースをサポートしています。 U-Boot で表示されるロゴ画像は、カーネルのルートディレクトリ、logo.bmp および logo_kernel.bmp から取り出されます。これは resource.img でパッケージされています。 :画像の要求。 BI_RGB 8bpp/16bpp/24bpp/32bppおよびBI_RLE4/BI_RLE8のフォーマットBMPイメージ;RK312X/PX30/RK3308/RV1126/RV1106および他の破片はVOP LITEの建築に基づいて設計のミラー機能を支えることができません。 表示されるロゴにX/Y方向に鏡面の問題がある場合、期待する効果に先立ってBMPイメージを処理するために、フォトショップやffmpegなどのツールを使用してください。 構成:

CONFIG_DM_VIDEO
CONFIG_DISPLAY
CONFIG_DRM_ROCKCHIP
CONFIG_DRM_ROCKCHIP_PANEL
CONFIG_DRM_ROCKCHIP_DW_HDMI
CONFIG_DRM_ROCKCHIP_DW_HDMI_QP
CONFIG_DRM_ROCKCHIP_INNO_HDMI
CONFIG_ROCKCHIP_INNO_HDMI_PHY
CONFIG_DRM_ROCKCHIP_INNO_MIPI_PHY
CONFIG_DRM_ROCKCHIP_INNO_VIDEO_PHY
CONFIG_DRM_ROCKCHIP_INNO_VIDEO_COMBO_PHY
CONFIG_DRM_ROCKCHIP_DW_MIPI_DSI
CONFIG_DRM_ROCKCHIP_DW_MIPI_DSI2
CONFIG_DRM_ROCKCHIP_DW_DP
CONFIG_DRM_ROCKCHIP_ANALOGIX_DP
CONFIG_DRM_ROCKCHIP_LVDS
CONFIG_DRM_ROCKCHIP_RGB
CONFIG_DRM_ROCKCHIP_RK618
CONFIG_DRM_ROCKCHIP_RK628
CONFIG_DRM_ROCKCHIP_SAMSUNG_MIPI_DCPHY
CONFIG_PHY_ROCKCHIP_SAMSUNG_HDPTX_HDMI
CONFIG_ROCKCHIP_DRM_TVE
CONFIG_SII902X

フレームワーク コード:

drivers/video/drm/rockchip_display.c
drivers/video/drm/rockchip_display.h
drivers/video/drm/rockchip_crtc.c
drivers/video/drm/rockchip_crtc.h
drivers/video/drm/rockchip_connector.c
drivers/video/drm/rockchip_connector.h
drivers/video/drm/rockchip_bridge.c
drivers/video/drm/rockchip_bridge.h
drivers/video/drm/rockchip_panel.c
drivers/video/drm/rockchip_panel.h
drivers/video/drm/rockchip_phy.c
drivers/video/drm/rockchip_phy.h

ドライバーファイル:

vop:
  drivers/video/drm/rockchip_vop.c
  drivers/video/drm/rockchip_vop.h
  drivers/video/drm/rockchip_vop_reg.c
  drivers/video/drm/rockchip_vop_reg.h
  drivers/video/drm/rockchip_vop2.c

rgb:
  drivers/video/drm/rockchip_rgb.c
  drivers/video/drm/rockchip_rgb.h

lvds:
  drivers/video/drm/rockchip_lvds.c
  drivers/video/drm/rockchip_lvds.h

mipi:
  drivers/video/drm/drm_mipi_dsi.c
  drivers/video/drm/dw_mipi_dsi.c
  drivers/video/drm/dw_mipi_dsi2.c

edp:
  drivers/video/drm/rockchip_analogix_dp.c
  drivers/video/drm/rockchip_analogix_dp.h
  drivers/video/drm/rockchip_analogix_dp_reg.c
  drivers/video/drm/rockchip_analogix_dp_reg.h

hdmi:
  drivers/video/drm/dw_hdmi.c
  drivers/video/drm/dw_hdmi.h
  drivers/video/drm/rockchip_dw_hdmi.c
  drivers/video/drm/rockchip_dw_hdmi.h
  drivers/video/drm/dw_hdmi_qp.c
  drivers/video/drm/dw_hdmi_qp.h
  drivers/video/drm/rockchip_dw_hdmi_qp.c
  drivers/video/drm/rockchip_dw_hdmi_qp.h

cvbs:
  drivers/video/drm/rockchip_tve.c
  drivers/video/drm/rockchip_tve.h

dp:
  drivers/video/drm/dw-dp.c

bridge:
  drivers/video/drm/rk618.c
  drivers/video/drm/rk618.h
  drivers/video/drm/rk618_lvds.c
  drivers/video/drm/rk618_lvds.c
  drivers/video/drm/rk628/
  drivers/video/drm/sii902x.c

5.5.2 関連するインターフェイス {#552-relevant-interface}

// Display U-Boot logo and kernel logo:
void rockchip_show_logo(void);

// Display bmp images, currently mainly used for charging image display:
void rockchip_show_bmp(const char *bmp);

// Passes some variables from U-Boot to the kernel via dtb.
// Including kernel logo size, address, format, bcsh/csc configuration, crtc output scan
timing and overscan configuration, etc.
void rockchip_display_fixup(void *blob);

5.5.3 DTS 構成 {#553-dts-configuration}

reserved-memory {
    #address-cells = <2>;
    #size-cells = <2>;
    ranges;

    drm_logo: drm-logo@00000000 {
        compatible = "rockchip,drm-logo";
        // Reserve buffer for kernel logo storage, the exact address and size will be
modified in U-Boot
        reg = <0x0 0x0 0x0 0x0>;
    };
};

&route-edp {
    status = "okay";                      // Enable U-Boot logo display function
    logo,uboot = "logo.bmp";              // Specify the image to display for the U-Boot
logo
    logo,kernel = "logo_kernel.bmp";      // Specify the image to display for the kernel
logo
    logo,mode = "center";                 // center: center display, fullscreen: fullscreen
display
    logo,rotate = <90>;                   // Rotation angle: 90/180/270
    charge_logo,mode = "center";          // center: center display, fullscreen: fullscreen
display
    connect = <&vopb_out_edp>;            // Determine the display path, vopb->edp-
>panelDetermine the display path, vopb->edp->panel
};

&edp {
    status = "okay"; //  enable edp
};

&vopb {
    status = "okay"; // enable vopb
};

&panel {
    "simple-panel";
    ...
    status = "okay";

    disp_timings: display-timings {
        native-mode = <&timing0>;
        timing0: timing0 {
            ...
        };
    };
};

5.5.4 Defconfigの仕様 {#554-defconfig}

現在、起動速度や小さなメモリの要件があるプラットフォームを除き、U-Bootの defconfig はデフォルトで表示をサポートしており、関連する情報は dts で設定されている限りです。 RK3308/RV1103/RV1106 および他のプラットホームはブートの速度のようなある理由によるデフォルトによって表示を支えません、そして次の変更は defconfig に加えられる必要があります:

--- a/configs/evb-rk3308_defconfig
+++ b/configs/evb-rk3308_defconfig
@@ -4,7 +4,6 @@ CONFIG_SYS_MALLOC_F_LEN=0x2000
CONFIG_ROCKCHIP_RK3308=y
CONFIG_ROCKCHIP_SPL_RESERVE_IRAM=0x0
CONFIG_RKIMG_BOOTLOADER=y
-# CONFIG_USING_KERNEL_DTB is not set
CONFIG_TARGET_EVB_RK3308=y
CONFIG_DEFAULT_DEVICE_TREE="rk3308-evb"
CONFIG_DEBUG_UART=y
@@ -55,6 +54,11 @@ CONFIG_USB_GADGET_DOWNLOAD=y
CONFIG_G_DNL_MANUFACTURER="Rockchip"
CONFIG_G_DNL_VENDOR_NUM=0x2207
CONFIG_G_DNL_PRODUCT_NUM=0x330d
+CONFIG_DM_VIDEO=y
+CONFIG_DISPLAY=y
+CONFIG_DRM_ROCKCHIP=y
+CONFIG_DRM_ROCKCHIP_RGB=y
+CONFIG_LCD=y
CONFIG_USE_TINY_PRINTF=y
CONFIG_SPL_TINY_MEMSET=y
CONFIG_ERRNO_STR=y

もしくは、対応する .config 設定を有効にします。

// rk3308
make rk3308_defconfig rk3308-display.config
// rv1103/rv1106
make rv1106_defconfig rv1106-display.config

上流 defconfig 構成上流はRockchip U ボット表示ドライバのセットを維持しています。現在 RK3288 と RK3399 プラットフォームをサポートしています。

./drivers/video/rockchip/

このドライバを使用するには、現在SDKに使用するディスプレイドライバにいくつかの利点があるCONFIG_VIDEO_ROCKCHIPをオンにしてCONFIG_DRM_ROCKCHIPをオフにすることができます:サポートされているプラットフォームとディスプレイインターフェイスはより包括的なです。 HDMI、DP、その他のディスプレイインターフェースは、指定された解像度、過スキャン効果、表示効果、調整効果などを出力できます。したがって、ユーザーの設定に応じて、U-Bootロゴは、システムブートまでカーネルロゴに滑らかに移行できます。

5.5.5 ロゴの仕切り {#555-logo-partition}

動的にパワーアップLOGOを更新する必要があるユーザー(通常、アプリケーションレイヤーで更新を開始)は、別のLOGOパーティションを介して行うことができます。 操作手順: パーティションテーブルに別のロゴパーティションを追加するユーザーは、必要に応じて特定の方法でロゴパーティションに画像を動的に更新することができます。 更新すると、ユーザーは直接パッケージなしでロゴの仕切りに元のイメージを更新できます。 ロゴパーティションのイメージが無効な場合、リソースファイルのデフォルト画像は依然として使用されます。 ロゴの仕切りサポート:

コードが次のコミットだけを含んでいる場合、ロゴのパーティションは1つのイメージのみをサポートし、デフォルトロゴ.bmpを置き換えることができます。

1d30bcc rockchip: resource: support parse "logo" partition picture

コードに次のコミットが含まれている場合、ロゴのパーティションは2つのイメージをサポートしています。image 1はロゴ.bmpを置き換えるために使用されます。そして、イメージ2はlogo_kernel.bmpを置き換えるために使われます。 それぞれに2つの画像が配置され、画像間の512バイトのアライメントが付いており、注文は置換できません。

commit 07f987d8d495380787203e2bc2accd44100e6051
Author: Joseph Chen <chenjh@rock-chips.com>
Date:   Sun Dec 8 18:00:37 2019 +0800

    rockchip: resource: support parse logo_kernel.bmp from logo partition

    "logo" partition layout, not change order:

    |----------------------| 0x00
    | raw logo.bmp         |
    |----------------------| N*512-byte aligned
    | raw logo_kernel.bmp  |
    |----------------------|

    N: the sector count of logo.bmp

    Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
    Change-Id: I2deba013d3963c99664c5bfd69693835a46ba48f

画像を想定したのはロゴマーク.bmpとlogo_kernel.bmpです。 logo.imgパッケージコマンド:

cat logo.bmp > logo.img && truncate -s %512 logo.img && cat logo_kernel.bmp >> logo.img

生成されたlogo.imgをロゴパーティションにダウンロードするだけで、起動後に印刷された「LOGO:」が表示されます。

U-Boot 2017.09-g042c01531e-210512-dirty #cjh (May 14 2021 - 11:25:03 +0800)

Model: Rockchip RK3568 Evaluation Board
PreSerial: 2, raw, 0xfe660000
DRAM:  2 GiB
Sysmem: init
Relocation Offset: 7d34f000, fdt: 7b9f8758
Using default environment

dwmmc@fe2b0000: 1, dwmmc@fe2c0000: 2, sdhci@fe310000: 0
Bootdev(atags): mmc 0
MMC0: HS200, 200Mhz
PartType: EFI
boot mode: normal
FIT: No fdt blob
Android 11.0, Build 2021.4, v2
Found DTB in boot part
// The following printout indicates that the image in the logo.img partition was recognized correctly.
LOGO: logo.bmp
LOGO: logo_kernel.bmp
DTB: rk-kernel.dtb
HASH(c): OK
......

5.5.6 共通の問題の分析 {#556-analysis-of-common-problems}

Q1: X/Y 方向にデフォルトのミラー表示が必要な場合は、任意の方法はありますか? A1:Y方向のデフォルトのミラー表示はサポートされていません。 X方向のデフォルトのミラーディスプレイは、VOP LITEアーキテクチャプラットフォームではサポートされていませんが、RK3568やRK3588などのVOP2アーキテクチャプラットフォームでは、次の構成でX方向がU-Bootからミラーリングされていることを確認することができます。

&vp1 {
    xmirror-enable;
};

Q2:4K解像度でBMPロゴ画像に対応できますか? A2: はい、可能ですが、各プラットフォームの defconfig は 4K ロゴ画像の通常の表示をサポートできません。 次の変更は追加する必要があります(例として rk3576 プラットフォームを処理してください)。

diff --git a/drivers/video/drm/rockchip_display.c b/drivers/video/drm/rockchip_display.c
index b1773ba6942..d1606db1ba5 100644
--- a/drivers/video/drm/rockchip_display.c
+++ b/drivers/video/drm/rockchip_display.c
@@ -52,7 +52,7 @@
 #define RK_BLK_SIZE 512
 #define BMP_PROCESSED_FLAG 8399
 #define BYTES_PER_PIXEL sizeof(uint32_t)
-#define MAX_IMAGE_BYTES (8 * 1024 * 1024)
+#define MAX_IMAGE_BYTES (32 * 1024 * 1024)

 DECLARE_GLOBAL_DATA_PTR;
 static LIST_HEAD(rockchip_display_list);
diff --git a/include/configs/rk3576_common.h b/include/configs/rk3576_common.h
index 16abba314c5..b4a8ec3b898 100644
--- a/include/configs/rk3576_common.h
+++ b/include/configs/rk3576_common.h
@@ -22,7 +22,7 @@
 #endif
 #define CONFIG_SPL_LOAD_FIT_ADDRESS    0x42000000

-#define CONFIG_SYS_MALLOC_LEN          (32 << 20)
+#define CONFIG_SYS_MALLOC_LEN          (32 << 21)
 #define CONFIG_SYS_CBSIZE              1024
#ifdef CONFIG_SUPPORT_USBPLUG

設定項目CONFIG_DRM_MEM_RESERVED_SIZE_MBYTESを64 MBに変更する必要があります。 メモリ使用とデフォルトパラメータのパーティションテーブルの設定により、大きすぎるBMPロゴ画像を使用するのは推奨されません。そのため、MAX_IMAGE_BYTESは8 MBに制限されています。 上記サイズを超えた場合は、BI_RLE4/BI_RLE8形式BMP画像を使用することをお勧めします。 一般的な4K BI_RGB 24bpp BMP画像サイズは、24 MBについてです。 各プラットフォームのデフォルト malloc ヒープ サイズは通常 32 MB で、BMP のデコード関連の関数がメモリに適用できないようになります。 U-BootからKernelロゴ表示へのスムーズな切り替えを確保するために、2つのロゴイメージは通常同じ解像度とフォーマットで、ロゴ表示機能(CONFIG_DRM_MEM_RESERVED_SIZE_MBYTES、32 MBによって決定される)のために予約されたメモリ領域のサイズは十分ではありません。

5.6 のDvfs {#56-dvfs}

この章のDVFSは、広い温度チップに特化したダイナミックな周波数と電圧調整機構であるカーネルとは異なる。

5.6.1 広い温度の作戦 {#561-wide-temperature-strategy}

U-Bootフレームワークは、チップの広い温度機能をサポートするため、DVFSをサポートしていません。RKは、チップ温度に応じてcpu / dmc周波数電圧を調整するために、DVFSワイド温度ドライバのセットを実装しました。 しかし、カーネルの DVFS ドライバーとは異なり、このワイド温度ドライバーは、最大/低温度の閾値がトリガーされる場合にのみ制御を実行します。 広い温度の作戦:

  1. 広い温度のドライバーはcpu/dmcの周波数電圧を調節するのに、制御作戦はcpuおよびdmcのために有効である場合もありますまたはそれらのうちの1つだけ、dts構成によって定められる;制御作戦はcpuおよびdmc両方のために同じです

  2. 広い温度のドライバーは周波数電圧範囲、最高/低い温度のしきい値および許される最高の電圧についての情報を得るためにcpu/dmcのノードのoppのテーブル、調整装置、時計および熱地帯の「ストリップポイント-0」を、分けます;

  3. ロックチップ、低テンプ = <…> またはロックチップ、高テンプ = < … > は、cpu/dmc の opp テーブルで指定され、cpu/dmc は使用できません。 > またはロックチップ、ハイテンプル = < … >、またはcpu/dmcは熱地帯の旅行ノードを参照し、cpu/dmcの広い温度制御方針は効果を取ります;

  4. 主属性: ロックチップ、低テンプ: 最小温度のしきい値、以下TEMP_minとして参照; ロックチップ、ハイテンプおよび熱地帯: 最高温度のしきい値、以下TEMP_maxとして参照される(両方が有効である場合、それらは現在の温度、戦略的に比較されます); ロックチップ、最高電圧: 最高の許容設定電圧は、次V_maxによって示されます。

  5. 境界結束処理:

TEMP_maxよりも温度が高ければ、周波数と電圧を最小ギヤに下げます。温度がTEMP_minの下にある場合は、デフォルトのブーストは50mvです。 50mv による電圧を後押しすると、V_max を超える電圧が発生し、2 ギヤで周波数を下げながら、電圧は V_max に設定されます。

  1. 現在の広い温度戦略は2点で適用されます。調整装置およびクラックフレームワークが初期化されると、広い温度のドライバーは初期化され、board.cファイルでboard_init()で呼ばれる広温度方針は一度に実行されます。プレブートフェーズのローディング中(ファームウェアをロードする前に)、 温度方針は、dtsノード(以下参照)で「repeat」などの属性が指定され、チップ温度は、現在の広い温度ポリシーを実行した後の温度のしきい値内ではなく、システムが起動を停止し、システムを起動する前にチップ温度が温度のしきい値内に戻ってきるまで、広範囲の温度ポリシーが継続的に実行されます。 「repeat」などの属性がない場合、システムが現在の広温度ポリシーが実行された直後に起動します。一般的には、現在ではrepeat属性は必要ありません。

5.6.2フレームワークサポート {#562-framework-support}

フレームワーク コード:

./drivers/power/dvfs/dvfs-uclass.c
./include/dvfs.h
./cmd/dvfs.c

ドライバーコード:

./drivers/power/dvfs/rockchip_wtemp_dvfs.c

5.6.3 関連するインターフェイス {#563-relevant-interface}

// Execute the dvfs policy once
int dvfs_apply(struct udevice *dev);

// If the repeat attribute is specified, the dvfs policy will be executed repeated when the
temperature is not within the threshold range
int dvfs_repeat_apply(struct udevice *dev);

5.6.4 広い温度を有効にして下さい {#564-enable-wide-temperature}

  1. 構成 有効:
CONFIG_DM_DVFS=y
CONFIG_ROCKCHIP_WTEMP_DVFS=y

CONFIG_DM_THERMAL=y
CONFIG_ROCKCHIP_THERMAL=y
CONFIG_USING_KERNEL_DTB=y
  1. CONFIG_PREBOOT を指定する:
#ifdef CONFIG_DM_DVFS
#define CONFIG_PREBOOT  "dvfs repeat"
#else
#define CONFIG_PREBOOT
#endif
  1. カーネル dts は、広い温度ノードを設定します。
uboot-wide-temperature {
    compatible = "rockchip,uboot-wide-temperature";

    // Optional. Indicates whether to have the wide temperature driver stop booting the
system when the maximum/low temperature threshold of the cpu is triggered during the U-Boot
phase,
    // and to keep executing the wide temperature processing strategy until the chip
temperature returns to within the threshold range before continuing to boot the system
    cpu,low-temp-repeat;
    cpu,high-temp-repeat;

    // Optional. Indicates whether to stop the wide temperature driver from booting the
system when the U-Boot stage triggers the dmc's maximum/low temperature threshold,
    // and to keep enforcing the wide temperature processing strategy until the chip
temperature returns to within the threshold range before continuing to boot the system.
    dmc,low-temp-repeat;
    dmc,high-temp-repeat;

    status = "okay";
};

一般的に、上記の繰り返し関連属性は設定する必要はありません。

5.6.5 広い温度の結果 {#565-wide-temperature-results}

cpu 温度制御を有効にしたときに、次の点が印刷されます。

// <NULL> indicates that no low temperature threshold is specified
DVFS: cpu: low=<NULL>'c, high=95'c, Vmax=1350000uV, tz_temp=88.0'c, h_repeat=0, l_repeat=0

cpu の温度制御が高温しきい値を引き起こした場合は、調整メッセージがあります。

DVFS: 90.352'c
DVFS: cpu(high): 600000000->408000000 Hz, 1050000->950000 uV

cpu の温度制御が低温のしきい値を引き起こした場合は、調整メッセージがあります。

DVFS: 10.352'c
DVFS: cpu(low): 600000000->600000000 Hz, 1050000->1100000 uV

同様に、dmc が高温の閾値と高くトリガーすると、上記のメッセージは、接頭辞 “dmc” で印刷されます。

DVFS: dmc: ......
DVFS: dmc(high): ......
DVFS: dmc(low): ......

5.7 ヒューズ/オッペ {#57-efuseotp}

5.7.1フレームワークサポート {#571-framework-support}

efuse/otp ドライバーは、misc-uclass.c フレームワークと標準インターフェイスを使用します。 基本的に、efuse/otp は安全でないセキュリティに分けられ、U-Boot は安全な otp の特定の領域へのアクセスを提供する非保護および U-Boot SPL へのアクセスを提供します。非安全な構成:

CONFIG_MISC
// choose either one of the below two options, the defconfig of each platform has enabled
the corresponding configuration by default.
CONFIG_ROCKCHIP_EFUSE
CONFIG_ROCKCHIP_OTP

安全な構成:

CONFIG_SPL_MISC=y
CONFIG_SPL_ROCKCHIP_SECURE_OTP=y
// Disable maskrom upgrade mode support, only for some platforms.
CONFIG_SPL_OTP_DISABLE_SD=y
CONFIG_SPL_OTP_DISABLE_USB=y
CONFIG_SPL_OTP_DISABLE_UART=y
CONFIG_SPL_OTP_DISABLE_SPI2APB=y
// Revoke rsa pub key hash support, only for some platforms.
CONFIG_SPL_REVOKE_PUB_KEY=y

前方セキュア機能がサポートされているかどうかについては、RV1126B を例にとります。

rv1126b_common.h には、以下の定義が含まれています。

// Maskrom upgrade mode can be disabled, if contains following definitions.
#define OTP_DISABLE_UPGRADE_ADDR    0x154
#define OTP_DISABLE_USB_VAL     0x3
#define OTP_DISABLE_SD_VAL      0xc
#define OTP_DISABLE_UART_VAL        0x30
#define OTP_DISABLE_SPI2APB_VAL     0xc0
// Support revoke rsa pub key hash, if contains following definitions. By default, you can
revoke only once, please contact RK engineers if you need support revoke more times.
#define OTP_NEXT_RSA_HASH_ADDR      0x1a0
#define OTP_NEXT_RSA_HASH_SIZE      32
#define OTP_RSA_HASH_REVOKE_VAL     0x3
#define OTP_RSA_HASH_REVOKE_ADDR    0x23
#define OTP_RSA_HASH_REVOKE_SIZE    1

フレームワーク コード:

./drivers/misc/misc-uclass.c

ドライバーコード:

// non-secure:
./drivers/misc/rockchip-efuse.c
./drivers/misc/rockchip-otp.c
// secure, take RK3588 as an example:
./drivers/misc/rk3588-secure-otp.S

5.7.2 関連するインターフェイス {#572-relevant-interface}

int misc_read(struct udevice *dev, int offset, void *buf, int size)
int misc_write(struct udevice *dev, int offset, void *buf, int size)
// With readback check
int misc_otp_write_verify(struct udevice *dev, int offset, const uint8_t *write_buf, int
size)

5.7.3 DTSの構成 {#573-dts-configuration}

たとえば、rk3308 を取って下さい: 非安全:

otp: otp@ff210000 {
    compatible = "rockchip,rk3308-otp";
    reg = <0x0 0xff210000 0x0 0x4000>;
};

セキュア: u-boot.dtsi で定義され、修正されるべき推奨されていません。

secure_otp: secure_otp@0xff2a8000 {
    compatible = "rockchip,rk3308-secure-otp";
    reg = <0x0 0xff2a8000 0x0 0x4000>;
    secure_conf = <0xff2b0004>;
    mask_addr = <0xff540000>;
};

5.7.4 再コール例 {#574-recall-example}

たとえば、非安全を取って下さい:

char data[10] = {0};
struct udevice *dev;

/* retrieve the device */
ret = uclass_get_device_by_driver(UCLASS_MISC,
                  DM_GET_DRIVER(rockchip_otp), &dev);
if (ret) {
    printf("no misc-device found\n");
    return 0;
}

misc_read(dev, 0x10, &data, 10);

安全な例:

char data[10] = {0};
struct udevice *dev;
int i;

dev = misc_otp_get_device(OTP_S);
if (!dev)
    return -ENODEV;

for (i = 0; i < 10; i++)
    data[i] = i;

// Basic version
misc_otp_write(dev, 0x10, &data, 10);
memset(data, 0, 10);
misc_otp_read(dev, 0x10, &data, 10);
// Optimized version
misc_otp_write_verify(dev, 0x10, &data, 10);

5.7.5 区域を開けて下さい {#575-open-area}

Secure-OTPは、読み書きする地域の一部のみが開きますので、ドキュメントを参照してください。 “RockchipOTP開発ガイド”.

5.8 イーサネット {#58-ethernet}

5.8.1フレームワークサポート {#581-framework-support}

フレームワークコード:

./net/*
./drivers/net/*
./drivers/net/phy/*

ドライバーコード:

./drivers/net/designware.c
./drivers/net/dwc_eth_qos.c
./drivers/net/gmac_rockchip.c

ドライバー構成: ドライバー構成 ドライバー選択に関して疑問にならなければ、Rockchipのイーサネット ドライバーの2セットがあります。対応する sdk config を参照してください。

// designware:
CONFIG_DM_ETH=y
CONFIG_ETH_DESIGNWARE=y
CONFIG_GMAC_ROCKCHIP=y
// dwc_eth_qos:
CONFIG_DM_ETH=y
CONFIG_DM_ETH_PHY=y
CONFIG_DWC_ETH_QOS=y
CONFIG_GMAC_ROCKCHIP=y

また、dwc_eth_qosドライバは、nocacheメモリで設定する必要があります。RV1126を参照してください。

diff --git a/include/configs/rv1126_common.h b/include/configs/rv1126_common.h
index 933917f3f0..9d70795fb8 100644
--- a/include/configs/rv1126_common.h
+++ b/include/configs/rv1126_common.h
@@ -50,6 +50,7 @@
 #define CONFIG_SYS_SDRAM_BASE          0
 #define SDRAM_MAX_SIZE                 0xfd000000

+#define CONFIG_SYS_NONCACHED_MEMORY    (1 << 20)       /* 1 MiB */
 #ifndef CONFIG_SPL_BUILD

cmd の設定 手動で必要な機能を設定します。

Command line interface  ---> Network commands  --->

[*] bootp, tftpboot
[ ] tftp put
[ ] tftp download and bootm
[ ] tftp download and flash
[ ] tftpsrv
[ ] rarpboot
-*- dhcp
-*- pxe
[ ] nfs
-*- mii
-*- ping
[ ] cdp
[ ] sntp
[ ] dns
[ ] linklocal
[ ] ethsw

5.8.2 関連するインターフェイス {#582-relevant-interface}

データ構造の初期化インターフェイス

void net_init(void);
int eth_register(struct eth_device *dev);
int phy_init(void);

デバイス登録インターフェイス

int eth_register(struct eth_device *dev);
int phy_register(struct phy_driver *drv);

ネットワークデータの読み込み/書き込みと phy の読み込み/書き込み

U-Bootのデータ送信と受信は、積極的に呼び出される必要がある, 中断やポーリングメソッドが使用されていない, 特定の実装は、NetLoop()を参照することができます.

int eth_send(void *packet, int length);
int eth_rx(void);

int phy_read(struct phy_device *phydev, int devad, int regnum);
int phy_write(struct phy_device *phydev, int devad, int regnum, u16 val);

5.8.3 DTSの構成 {#583-dts-configuration}

カーネルのような DTS ノード、 フィ・インタフェース構成(phy-mode) phy rresetピンとリセット時間(snps、reset-gpio)(snps、reset-delays-us) クロック出力方向(clock_in_out) クロックソース選択と周波数設定(割り当てられたクロックレート) RGMII 遅延、 RGMIIインターフェイスの要求(tx_delay) (rx_delay)

&gmac {
    phy-mode = "rgmii";
    clock_in_out = "input";

    snps,reset-gpio = <&gpio3 RK_PA0 GPIO_ACTIVE_LOW>;
    snps,reset-active-low;
    /* Reset time is 20ms, 100ms for rtl8211f */
    snps,reset-delays-us = <0 20000 100000>;

    assigned-clocks = <&cru CLK_GMAC_SRC>, <&cru CLK_GMAC_TX_RX>, <&cru
CLK_GMAC_ETHERNET_OUT>;
    assigned-clock-parents = <&cru CLK_GMAC_SRC_M1>, <&cru RGMII_MODE_CLK>;
    assigned-clock-rates = <125000000>, <0>, <25000000>;

    pinctrl-names = "default";
    pinctrl-0 = <&rgmiim1_pins &clk_out_ethernetm1_pins>;

    tx_delay = <0x2a>;
    rx_delay = <0x1a>;

    phy-handle = <&phy>;
    status = "okay";
};

5.8.4 使用例 {#584-usage-example}

一般的に使用されるネットワークコマンド: DHCP

Usage:
dhcp [loadAddress] [[hostIPaddr:]bootfilename]

このコマンドでは、サーバーIP、ipaddr、ゲートウェイの設定は不要です。 dhcp が dhcp サーバーから ip アドレスを正常に取得すると、hostIPaddr アドレスから tftp でファイルを保持します。 100M 環境:

=> dhcp 0x20000000 192.168.0.100:kernel.img
ethernet@ffc40000 Waiting for PHY auto negotiation to complete. done
BOOTP broadcast 1
DHCP client bound to address 192.168.0.106 (2 ms)
Using ethernet@ffc40000 device
TFTP from server 192.168.0.100; our IP address is 192.168.0.106
Filename 'kernel.img'.
Load address: 0x20000000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ###############################################################
         1.5 MiB/s
done
Bytes transferred = 19054084 (122be04 hex)

PING

=> ping 192.168.0.1
ethernet@ffc40000 Waiting for PHY auto negotiation to complete. done
Using ethernet@ffc40000 device
host 192.168.0.1 is alive

TFTP 1000M 環境:

Usage:
tftp [loadAddress] [[hostIPaddr:]bootfilename]

独自のIPアドレスを設定することもできます。

=> setenv ipaddr 192.168.1.101
=> setenv serverip 192.168.1.100

=> tftp kernel.img 0x20000000
ethernet@ffc40000 Waiting for PHY auto negotiation to complete. done
Using ethernet@ffc40000 device
TFTP from server 192.168.1.100; our IP address is 192.168.1.101
Filename 'kernel.img'.
Load address: 0x20000000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################
         12.2 MiB/s
done
Bytes transferred = 20275220 (1356014 hex)

5.8.5 ネットワークのトラブルシューティング {#585-network-troubleshooting}

  1. ネットワーク環境のトラブルは、一般的に次の方向に追跡され、コンピュータ上のファイアウォールがオフにされていないか? ゲートウェイが設定されているか否か確認するクロスネットワークセグメントの場合、TFTPサーバーは正しく構成されています。TFTP機能が一部のルーターで無効になっているかどうか。

  2. コードの問題は、一般的には3つの主要な側面で追跡されます。 ピンクセルの設定が正しいか否かを確認してください。 関連するピンのiomuxと駆動強度が正しいかどうかをチェックし、関連するレジスタをダンプして、カーネルと比較して、一貫性のあるかどうかを確認することができます。 ほとんどの場合、U- Boot を調整する前にカーネルのネットワークを最初に調整します。 時計の設定が正しいか確認します。 時計構成チェックは比較的面倒で、主に分割比、クロックソース、クロック方向、CRUのレジスタのほとんどがGRFにレジスタを登録するチップもいくつかあります。 関連するレジスタをダンプして、カーネルと比較して、一貫性のあるかどうかを確認することもできます。 PHY はピンを調節します。 リセットピンが正しく設定されているか、リセット波形が PHY 要件を満たしているかどうかを主に検出します。

5.9 Gpioの {#59-gpio}

5.9.1フレームワークサポート {#591-framework-support}

gpio-uclass フレームワークと標準インタフェースの構成を使用して GPIO ドライバー:

CONFIG_DM_GPIO
CONFIG_ROCKCHIP_GPIO

フレームワーク コード:

./drivers/gpio/gpio-uclass.c

ドライバーコード:

./drivers/gpio/rk_gpio.c

5.9.2 DMインターフェイス {#592-dm-interface}

DMの標準的なインターフェイス。 gpioにアクセスするには、ユーザーはgpio_descを指示し、推奨するタイプを渡さなければなりません。

// Request/Release GPIO
int gpio_request_by_name(struct udevice *dev, const char *list_name,
                         int index, struct gpio_desc *desc, int flags);
int gpio_request_by_name_nodev(ofnode node, const char *list_name, int index,
                               struct gpio_desc *desc, int flags);
int gpio_request_list_by_name(struct udevice *dev, const char *list_name,
                              struct gpio_desc *desc_list, int max_count, int flags);
int gpio_request_list_by_name_nodev(ofnode node, const char *list_name,
                                    struct gpio_desc *desc_list, int max_count,
                                    int flags);
int dm_gpio_free(struct udevice *dev, struct gpio_desc *desc)

// Configure GPIO direction.@flags: GPIOD_IS_OUT (output) and GPIOD_IS_IN (input)
int dm_gpio_set_dir_flags(struct gpio_desc *desc, ulong flags);

// Set/Get GPIO level
int dm_gpio_get_value(const struct gpio_desc *desc)
int dm_gpio_set_value(const struct gpio_desc *desc, int value)

注: dm_gpio_get_value() の戻り値は、アクティブ状態を表し、高値または低レベルではありません。

例:gpios = <&gpio2 RK_PD0 GPIO_ACTIVE_LOW>、返り値は1で、低レベルと0で高レベルです。 gpios = <&gpio2 RK_PD0 GPIO_ACTIVE_HIGH>、戻り値は0で、低レベルと高レベル1の場合です。 同じは、dm_gpio_set_value() パラメータ値1: atcive, 0: inactive で真のものです。

5.9.3 のレガシー インターフェイス {#593-legacy-interface}

互換性のあるインタフェースタイプ。 このインタフェースタイプは、主に古いU-Boot APIと互換性があり、機能の内部実装は基本的にDMフレームワークを経由していますが、外部にgpio_descを指示してシールドします。 機能が利用可能ですが、DMコードの標準化の観点から推奨されません。

int gpio_request(unsigned gpio, const char *label)
int gpio_free(unsigned gpio)
int gpio_direction_input(unsigned gpio)
int gpio_direction_output(unsigned gpio, int value)
int gpio_get_value(unsigned gpio)
int gpio_set_value(unsigned gpio, int value)

それぞれのGPIOのグループが32ピンと各バンクに8ピンのルールに基づいて、@gpioを計算します。

例:

gpio0_a7 = (0 * 32) + (0 * 8) + 7 = 7
gpio1_b6 = (1 * 32) + (1 * 8) + 6 = 46
gpio3_c2 = (3 * 32) + (2 * 8) + 2 = 114

@value : 上記タイプdm_gpio_のインターフェースと一致しています。

5.10 中断 {#510-interrupt}

5.10.1フレームワークサポート {#5101-framework-support}

U-Boot のネイティブコードには、割込みフレームワークがないので、RK はデフォルトで有効になっている GICv2/v3 をサポートする割込みフレームワークのセットを実装しました。 Scenariosは現在、中断フレームワークが必要です:Pwrkey:U-Bootが充電されると、CPUは低電力のハイバネーションに入り、Pwrkey割込みでCPUを目覚めする必要があります。タイマー:タイマー割込みはU-Boot充電およびテストケースで使用されます。 Debug:CONFIG_ROCKCHIP_DEBUGGERデバッグを有効にします。 構成:

CONFIG_IRQ
CONFIG_GICV2
CONFIG_GICV3

フレームワークコード:

./drivers/irq/irq-gpio-switch.c
./drivers/irq/irq-gpio.c
./drivers/irq/irq-generic.c
./drivers/irq/irq-gic.c
./drivers/irq/virq.c
./include/irq-generic.h
// CPU local interrupt switch
void enable_interrupts(void);
int disable_interrupts(void);

// GPIO converted to Interrupt Number
int gpio_to_irq(struct gpio_desc *gpio);
int phandle_gpio_to_irq(u32 gpio_phandle, u32 pin);
int hard_gpio_to_irq(unsigned gpio);
// Registering/Releasing Interrupt Callbacks
void irq_install_handler(int irq, interrupt_handler_t *handler, void *data);
void irq_free_handler(int irq);

// Enable/disable interrupt
int irq_handler_enable(int irq);
int irq_handler_disable(int irq);

// Interrupt trigger type
int irq_set_irq_type(int irq, unsigned int type);

別のハードウェア割込み番号を持つIRQリクエスト周辺機器は、pwm、タイマーなど追加の変換を必要としません。 GPIOのピンフは別のハードウェア割込み番号を持っていませんし、追加の変換リクエストが必要です。 GPIOのピンの割込み数を要求する3つの方法があります:

  1. 入力struct gpio_descの構造
// This method can dynamically parse the dts configuration, which is more flexible and
commonly used.
int gpio_to_irq(struct gpio_desc *gpio);

例:

battery {
    compatible = "battery,rk817";
    ......
    dc_det_gpio = <&gpio2 7 GPIO_ACTIVE_LOW>;
    ......
};
struct gpio_desc dc_det;
int ret, irq;

ret = gpio_request_by_name_nodev(dev_ofnode(dev), "dc_det_gpio", 0,
                                 &dc_det, GPIOD_IS_IN);
// For the sake of simplicity of the example, the return value judgment is omitted.
if (!ret) {
    irq = gpio_to_irq(&dc_det);
    irq_install_handler(irq, ...);
    irq_set_irq_type(irq, IRQ_TYPE_EDGE_FALLING);
    irq_handler_enable(irq);
}
  1. gpioのハンドルおよびピンを入れて下さい
// This method can dynamically parse the dts configuration, which is more flexible and
commonly used.
int phandle_gpio_to_irq(u32 gpio_phandle, u32 pin);

例(rk817 割込みピンは GPIO0_A7)

rk817: pmic@20 {
    compatible = "rockchip,rk817";
    reg = <0x20>;
    ......
    interrupt-parent = <&gpio0>;             // "&gpio0": the phandle pointing to the gpio0
node;;
    interrupts = <7 IRQ_TYPE_LEVEL_LOW>;     // "7": pin;
    ......
};
u32 interrupt[2], phandle;
int irq, ret;

phandle = dev_read_u32_default(dev->parent, "interrupt-parent", -1);
if (phandle < 0) {
    printf("failed get 'interrupt-parent', ret=%d\n", phandle);
    return phandle;
}

ret = dev_read_u32_array(dev->parent, "interrupts", interrupt, 2);
if (ret) {
    printf("failed get 'interrupt', ret=%d\n", ret);
    return ret;
}

// For the sake of simplicity of the example, the return value judgment is omitted.
irq = phandle_gpio_to_irq(phandle, interrupt[0]);
irq_install_handler(irq, pwrkey_irq_handler, dev);
irq_set_irq_type(irq, IRQ_TYPE_EDGE_FALLING);
irq_handler_enable(irq);
  1. gpioを指定する力
// This method forces the gpio to be specified directly, and the incoming gpio must be
declared by a special macro, which is not flexible enough and is not recommended.
int hard_gpio_to_irq(unsigned gpio);

例(GPIO0_A0リクエストが中断)

int gpio0_a0, irq;

// For the sake of simplicity of the example, the return value judgment is omitted.
gpio0_a0 = RK_IRQ_GPIO(RK_GPIO0, RK_PA0);
irq = hard_gpio_to_irq(gpio0_a0);
irq_install_handler(irq, ...);
irq_handler_enable(irq);

5.11 I2C {#511-i2c}

5.11.1フレームワークサポート {#5111-framework-support}

i2c ドライバーは、i2c-uclass フレームワークと標準インターフェイスを使用します。 構成:

CONFIG_DM_I2C
CONFIG_SYS_I2C_ROCKCHIP

フレームワークコード:

./drivers/i2c/i2c-uclass.c

ドライバーコード:

./drivers/i2c/rk_i2c.c
./drivers/i2c/i2c-gpio.c    // gpio emulates i2c communication, which is not used at the
moment

5.11.2 関連するインタフェース {#5112-relevant-interface}

// i2c read/write
int dm_i2c_read(struct udevice *dev, uint offset, uint8_t *buffer, int len)
int dm_i2c_write(struct udevice *dev, uint offset, const uint8_t *buffer, int len)

// encapsulation of the above interface
int dm_i2c_reg_read(struct udevice *dev, uint offset)
int dm_i2c_reg_write(struct udevice *dev, uint offset, unsigned int val);

5.12 IOドメイン {#512-io-domain}

5.12.1フレームワークサポート {#5121-framework-support}

U-Bootフレームワークはデフォルトではio-domainサポートはありませんが、RKは設定を自身で実装しています。 構成:

CONFIG_IO_DOMAIN
CONFIG_ROCKCHIP_IO_DOMAIN

フレームワークコード:

./drivers/power/io-domain/io-domain-uclass.c

ドライバーの円錐形:

./drivers/power/io-domain/rockchip-io-domain.c

5.12.2 関連するインターフェイス {#5122-relevant-interface}

void io_domain_init(void)

ユーザーは、io_domain_init() を積極的に呼び出す必要はありません。上記の設定を有効にし、U-Bootフレームワークは自動的に初期化されます。

5.13 鍵 {#513-key}

5.13.1フレームワークサポート {#5131-framework-support}

U-Bootフレームワークはデフォルトではキーストロークをサポートしていません。RKは、キーストロークのセットを単独で実装しています。 実現ルール:カーネルとU-BootのDTSですべてのキーが指定されます。 U-Boot は、任意のキーを定義するためにハード コードを使用しません。; U-Boot は、カーネルの dts のキーを検索優先順位付けし、それらが見つからない場合は U-Boot dts のキーを探します。 ダウンロードキーのみU-Boot dtsで定義されます。 ユーザーがキー定義をダウンロードしたbを更新したい場合、カーネルとU-Boot dtsの両方を更新する必要があります。 構成:

CONFIG_DM_KEY
CONFIG_RK8XX_PWRKEY
CONFIG_ADC_KEY
CONFIG_GPIO_KEY
CONFIG_RK_KEY

フレームワークコード:

./include/dt-bindings/input/linux-event-codes.h
./drivers/input/key-uclass.c
./include/key.h

ドライバーコード:

./drivers/input/rk8xx_pwrkey.c    // Support PMIC pwrkey(RK805/RK809/RK816/RK817)
./drivers/input/rk_key.c          // Support compatible = "rockchip,key"
./drivers/input/gpio_key.c        // Support compatible = "gpio-keys"
./drivers/input/adc_key.c         // Support compatible = "adc-keys"

pwrkeyは、割込みモードのみで認識され、gpioキーの残りの部分はポーリングモードで認識されます。

5.13.2 関連するインタフェース {#5132-relevant-interface}

インターフェイス:

int key_read(int code)

コード定義:

/include/dt-bindings/input/linux-event-codes.h

返された値:

enum key_state {
    KEY_PRESS_NONE,     // Non-complete short press (no key release) or non-complete long
press (not pressed long enough);;
    KEY_PRESS_DOWN,     // One complete short press (press => release);
    KEY_PRESS_LONG_DOWN, // One full long press (can be unreleased);
    KEY_NOT_EXIST,      // key does not exist
};

KEY_PRESS_LONG_DOWN のデフォルト持続期間 2000ms、現在Uブート充満pwrkeyの長い出版物イベントのためにだけ使用されて。

#define KEY_LONG_DOWN_MS    2000

例:

int ret;

ret = key_read(KEY_VOLUMEUP);
...

5.14 は導きました {#514-led}

5.14.1フレームワークサポート {#5141-framework-support}

Led ドライバーは、led-uclass.c フレームワークと標準インターフェイスを使用します。 構成:

CONFIG_LED_GPIO

フレームワークコード:

drivers/led/led-uclass // Default Compilation

ドライバーコード:

drivers/led/led_gpio.c // Support compatible = "gpio-leds"

5.14.2 関連するインタフェース {#5142-relevant-interface}

// obtain led device
int led_get_by_label(const char *label, struct udevice **devp);
// set/obtain led status
int led_set_state(struct udevice *dev, enum led_state_t state);
enum led_state_t led_get_state(struct udevice *dev);
// Please ignore this, no underlying driver implementation done currently
int led_set_period(struct udevice *dev, int period_ms);

5.14.3 DTSノード {#5143-dts-node}

U-Bootのled_gpio.cは、導線ノードの3つの属性だけを解析する比較的単純です。 gpios: 制御ピンとアクティブ状態を主導; ラベル: ラベル: ラベルを主導しました。 デフォルト状態: プローブが駆動されるときに設定されます。

leds {
    compatible = "gpio-leds";
    status = "okay";
    blue-led {
        gpios = <&gpio2 RK_PA1 GPIO_ACTIVE_LOW>;
        label = "battery_full";
        default-state = "off";
    };

    green-led {
        gpios = <&gpio2 RK_PA0 GPIO_ACTIVE_LOW>;
        label = "greenled";
        default-state = "off";
    };

    ......
};

5.15 マウント {#515-mtd}

MTD(メモリーテクノロジーデバイス) 記憶技術装置は、平行港のnand、spiのnand、spiを支えます

5.15.15.1フレームワークサポート {#5151-framework-support}

CONFIG_MTD=y
CONFIG_CMD_MTD=y

5.15.2 関連するインタフェース {#5152-relevant-interface}

一般的なインターフェイスは以下にリストされています。

struct mtd_info *get_mtd_device_nm(const char *name);
int mtd_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf);
int mtd_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char
*buf);
int mtd_erase(struct mtd_info *mtd, struct erase_info *instr);
int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs);
int mtd_block_markbad(struct mtd_info *mtd, loff_t ofs);

5.15.3 使用例 {#5153-usage-example}

spi や読み込みファームウェア例 フラッシュオフセット 0x400000 バイト、0x800 バイトのデータからメモリアドレス 0x4000000 へ 例として:

#include <mtd.h>
#define MTD_SPINOR_NAME     "nor0"

static int mtd_demo(void)
{
    char *mtd_name = MTD_SPINOR_NAME;
    struct mtd_info *mtd;
    size_t retlen, off, size;
    u_char *des_buf;
    int ret;

    mtd = get_mtd_device_nm(mtd_name);
    if (IS_ERR_OR_NULL(mtd)) {
        printf("MTD device %s not found, ret %ld\n",
               mtd_name, PTR_ERR(mtd));
        return CMD_RET_FAILURE;
    }

    des_buf = (u_char *)0x4000000;

    off = 0x4000000;
    size = 0x800;

    ret = mtd_read(mtd, off, size, &retlen, des_buf);
    if (ret || size != retlen) {
        pr_err("mtd read fail, ret=%d retlen=%ld size=%ld\n", ret, retlen, size);
    }

    return ret;
}

否定例の推薦:drivers/mtd/nand/nand_util.cを参照して下さい、悪いブロックの同一証明が付いている読まれた/writeeraseインターフェイスを使用して下さい。 少量のデータ(通常、電源を入れた2KB未満)で完全な書き込みのために、このインターフェイスへの頻繁な呼び出しがフラッシュ寿命に影響を及ぼすため、MTD_BLK関連のインタフェースを使用して検討してください。

5.16 Mtd_blk {#516-mtd_blk}

RK は、MTD インターフェイスに基づく MTD ブロックレイヤーを設計しました。これは、並列ポートの nand、spi nand、spi をサポートし、対応する MTD ブロックデバイスをレジスタして、対応するブロックインターフェースをサポートします。 特長:単位はセクター、すなわちです。 512B 単一の書き込みリクエストでどのくらいのデータが書かれているのかに関係なく、データに対応するフラッシュブロックは消去されます。そのため、このインターフェイスを部分的に呼び、頻繁に書き込むと、フラッシュの寿命に影響します。

5.16.1フレームワークサポート {#5161-framework-support}

U ブート構成:

// MTD driver
CONFIG_MTD=y
CONFIG_CMD_MTDPARTS=y
CONFIG_MTD_DEVICE=y

// MTD block device driver
CONFIG_CMD_MTD_BLK=y
CONFIG_MTD_BLK=y

// Other nand device drivers config
......

SPL 構成:

CONFIG_MTD=y
CONFIG_CMD_MTDPARTS=y
CONFIG_MTD_DEVICE=y
CONFIG_SPL_MTD_SUPPORT=y

// Other nand device drivers config
......

フレームワーク コード:

drivers/mtd/mtd-uclass.c
drivers/mtd/mtdcore.c
drivers/mtd/mtd_uboot.c
drivers/mtd/mtd_blk.c

ドライバは、MTDレイヤーへの読み込み/書き込みなどのインターフェイスをホッキングする個々のコントローラードライバーです。

5.16.2 関連するインターフェイス {#5162-relevant-interface}

unsigned long blk_dread(struct blk_desc *block_dev, lbaint_t start,
                        lbaint_t blkcnt, void *buffer)
unsigned long blk_dwrite(struct blk_desc *block_dev, lbaint_t start,
                        lbaint_t blkcnt, const void *buffer)

5.17 Opteeクライアント {#517-optee-client}

U-Bootは、ARM TrustZoneの非セキュアな世界に属し、OPEEクライアントが安全なリソースにアクセスする必要があります。

5.17.1フレームワークサポート {#5171-framework-support}

U-BootフレームワークはデフォルトではOPEE Clientの機能をサポートしていませんが、RKは設定を単独で実装しています。 構成:

// Enabled all the time
CONFIG_OPTEE_CLIENT

// Used on older platforms, such as RK312x, RK322x, RK3288, RK3228H, RK3368, RK3399
CONFIG_OPTEE_V1
// Used on new platforms, such as RK3326, RK3308
CONFIG_OPTEE_V2
// This configuration must be enabled when RPMB for eMMC is not available, i.e., enable
security partitioning!
CONFIG_OPTEE_ALWAYS_USE_SECURITY_PARTITION

フレームワークとドライバ:

lib/optee_clientApi/

5.17.2 ファームウェアの説明 {#5172-firmware-description}

使用するtrust.imgはTAを有効にする必要がありますか、OPEEクライアントとやり取りすることはできません。

5.17.3 インターフェイス記述 {#5173-interface-description}

Optee クライアントドライバーは lib/ optee_client ディレクトリ、Optee Client Api の、 に を に に に に 注意 してください に 、 TEE_Client_API_Specification-V1.0_c.pdf . . . ダウンロードアドレスは: https://globalplatform.org/specs-library/tee-client-api-specification/ Opteeの組み込みTA機能をベースに、Opteeクライアントに内蔵TA機能を使用するインターフェイスをRKがカプセル化します。 インターフェイスのソースコードは lib\ で見つけることができます。 optee_clientApi\OpteeClientInterface.c ご使用の際は、ヘッダファイルinclude\を必ず含めてください。 optee_include\OpteeClientInterface.h … API の解説は下記をご覧ください。

5.17.3.1 適性 {#51731-suitability}

各プラットフォームで次のインターフェースが利用できます。プラットフォーム定義セクションを参照してください。

trusty_base_write_security_data()
trusty_base_read_security_data()
trusty_read_vbootkey_hash()
trusty_write_vbootkey_hash()
trusty_read_vbootkey_enable_flag()
trusty_read_attribute_hash()
trusty_write_attribute_hash()
trusty_write_oem_otp_key()
trusty_oem_otp_key_is_written()
trusty_set_oem_hr_otp_read_lock()
trusty_oem_otp_key_cipher()
trusty_read_oem_ns_otp()
trusty_write_oem_ns_otp()
trusty_write_ta_encryption_key()
trusty_ta_encryption_key_is_written()
trusty_write_oem_encrypt_data()
trusty_oem_encrypt_data_is_written()
trusty_check_security_level_flag()
trusty_write_oem_huk()
5.17.3.2 値を返す {#51732-return-value}

それ以外の場合は、上記の文書の [TEE_Client_API_Specification-V1.0_c.pdf ] の [戻り値] セクションに次の API の戻り値が表示されます。

5.17.3.3 trusty_base_write_security_data {#51733-trusty_base_write_security_data}
uint32_t trusty_base_write_security_data(char *filename,
                        uint32_t filename_size,
                        uint8_t *data,
                        uint32_t data_size)

U-Boot は、ストレージの確保にデータを書き込みます。 EMC/UFS デバイスの場合、NAND などの他のデバイスがセキュリティパーティションに保存されている間、データは RPMB パーティションに保存されます。 CONFIG_OPTEE_ALWAYS_USE_SECURITY_PARTITION が定義されている場合は、セキュリティパーティションに固定されます。 パラメーター [in] filename - ファイル名 [in] filename_size - ファイル名の長さ

[in] データの - 書き込みするデータ - data_size - データの長さ

5.17.3.4 trusty_base_read_security_data {#51734-trusty_base_read_security_data}
uint32_t trusty_base_read_security_data(char *filename,
                           uint32_t filename_size,
                           uint8_t *data,
                           uint32_t data_size)

U-Boot は、安全なストレージからデータを読み込みます。 EMMC/UFS デバイスの場合、NAND などの他のデバイスがセキュリティパーティションから読み込まれている間、データが RPMB パーティションから読み込まれます。 CONFIG_OPTEE_ALWAYS_USE_SECURITY_PARTITION が定義されている場合は、セキュリティパーティションから読み込むように固定されます。 パラメーター [in] ファイル名 - ファイル名 [in] filename_size - ファイル名の長さ [in] データ - 読み込むデータ - [in] data_size - データの長さ

5.17.3.5 trusty_read_vbootkey_hash {#51735-trusty_read_vbootkey_hash}
uint32_t trusty_read_vbootkey_hash(uint32_t *buf, uint32_t length);

関数 OTP または eFuse からセキュアなブート公開鍵のハッシュを取得します。 セキュアブートに関する説明は、Rockchip_Developer_Guide_Secure_Boot_Application_Note_ENにご連絡ください。 パラメータ[out] buf - [in]の長さ - ハッシュ長、サポートされているハッシュアルゴリズムの特定の長さを読み込み、ブート文書を保護する長さユニットは単語(32bit)です。

5.17.3.6 trusty_write_vbootkey_hash {#51736-trusty_write_vbootkey_hash}
uint32_t trusty_write_vbootkey_hash(uint32_t *buf, uint32_t length);

機能

OTP または eFuse でセキュアなブートパブリックキーのハッシュ値を書き、安全なブートフラグを有効にし、安全な起動を有効にします。 セキュアなブート関連のディスクリブションについては、Rockchip_Developer_Guide_Secure_Boot_Application_Note_ENファイルを参照してください。 パラメータ[in] buf - [in]の長さ - ハッシュ長、サポートされているハッシュアルゴリズムの長さは、安全なブート文書に基づいており、長さの単位は単語(32bit)です。

5.17.3.7 trusty_read_vbootkey_enable_flag {#51737-trusty_read_vbootkey_enable_flag}
uint32_t trusty_read_vbootkey_enable_flag(uint8_t *flag);

関数は、安全なブートを示すフラグをオンまたはしない読み込みます。 セキュアなブート関連の説明は、Rockchip_Developer_Guide_Secure_Boot_Application_Note_ENファイルを参照してください。 パラメータ [in] フラグ - 1 バイト、1 は安全なブートがオン、0 はオフを意味します。

5.17.3.8 trusty_read_attribute_hash {#51738-trusty_read_attribute_hash}
uint32_t trusty_read_attribute_hash(uint32_t *buf, uint32_t length)

機能U-Bootはatx_permanta_attributes.binのハッシュを読みます。 atx_personent_attribies.binの合法性を確認するのにこのハッシュを使用します。 パラメーター [out] buf - ハッシュデータ [in] の長さ - ハッシュの長さ

5.17.3.9 trusty_write_attribute_hash {#51739-trusty_write_attribute_hash}
uint32_t trusty_write_attribute_hash(uint32_t *buf, uint32_t length)

関数 U ボットは atx_permanta_attributes.bin のハッシュを書きます。 パラメーター

[in] buf - ハッシュデータ [in] 長 - ハッシュの長さ

5.17.3.10 trusty_write_oem_otp_key {#517310-trusty_write_oem_otp_key}
uint32_t trusty_write_oem_otp_key(enum RK_OEM_OTP_KEYID key_id,
                                  uint8_t *byte_buf,
                                  uint32_t byte_len);

機能 指定されたOEM OTP区域に明白なテキスト キーを書きます。 OEM OTPの関連機能の説明については、Rockchip_Developer_Guide_OTP_CNドキュメントを参照してください。 パラメーター [in] key_id - 書かれる key_id のデフォルト サポート RK_OEM_OTP_KEY0 - 3 の合計 4 キー、rv1126/rv1109 のための、key_id のための追加サポートは RK_OEM_OTP_KEY_FW 鍵です。 RK_OEM_OTP_KEY_FW: ブートROMがローダーを解読するために使用するキー、trusty_oem_otp_key_cipherインターフェイスは、ビジネスデータの暗号化と復号化またはカーネルイメージの復号化を行うために、このキーを使用するようにサポートします。 [in] byte_buf - プレーンテキストキー [in] byte_len - RK_OEM_OTP_KEY_FW、byte_lenは16のみをサポートし、 他キーについては、byte_lenは16, 24, 32をサポートしています。

5.17.3.11 trusty_oem_otp_key_is_written {#517311-trusty_oem_otp_key_is_written}
uint32_t trusty_oem_otp_key_is_written(enum RK_OEM_OTP_KEYID key_id, uint8_t *value);

機能は、キーが指定されたOEM OTPエリアに書かれているかどうかを決定します。 OEM OTPの関連機能の説明については、 Rockchip_Developer_Guide_OTP_CN ドキュメント。 変数 [in] key_id - 記述されるべきキー区域の索引、デフォルト サポート RK_OEM_OTP_KEY0 - rv1126/rv1109のための3つの合計4のキー、付加的にサポート キーとの key_id RK_OEM_OTP_KEY_FW [out] 値 - 秘密鍵が書かれているかどうかを判断します。1 は、それが書かれていることを意味します。0 は、それが書かれていないという意味です。 戻り値 値が #define の場合、返り値が意味があります TEEC_SUCCESS 0x00000000 の RK3588 プラットフォームは、プラットフォームが、プラットフォームが決定するかどうかも判断します。 key_id 対応するかどうかはロックされるか、またはない key_id ロックされ、 #define が返されます。 TEEC_ERROR_ACCESS_DENIED 0xFF0001 エラー。

5.17.3.12 trusty_set_oem_hr_otp_read_lock {#517312-trusty_set_oem_hr_otp_read_lock}
uint32_t trusty_set_oem_hr_otp_read_lock(enum RK_OEM_OTP_KEYID key_id);

機能 指定されたOEM OTP領域の読み取りロックフラグを設定し、成功した設定の後、領域はデータを書き込み禁止され、領域内の既存のデータはCPUソフトウェアでは読み込められず、キーはtrusty_oem_otp_key_cipherインターフェイスを介して使用することができます。 OEM OTPの関連機能の説明については、Rockchip_Developer_Guide_OTP_CNドキュメントを参照してください。

注: key_id が RK_OEM_OTP_KEY0 または RK_OEM_OTP_KEY1 または RK_OEM_OTP_KEY2 に設定されている場合、成功したセットアップ後に他の OTP 領域の属性に影響を及ぼします。例えば、OTP 領域の一部が不利になる、Rockchip_Developer_Guide_OTP_CN ドキュメントパラメーターを参照してください。 [in] key_id - key_id を設定し、設定する RK_OEM_OTP_KEY0 - 3をサポート

5.17.3.13 trusty_oem_otp_key_cipher {#517313-trusty_oem_otp_key_cipher}
uint32_t trusty_oem_otp_key_cipher(enum RK_OEM_OTP_KEYID key_id,
                                   rk_cipher_config *config,
                                   uint32_t src_phys_addr,
                                   uint32_t dst_phys_addr,
                                   uint32_t len);

機能 暗号単一計算を実行するOEM OTP地域のためのキーを選択します。 パラメーター [in] key_id - key_id が使用されるように、RK_OEM_OTP_KEY0 - 3 はデフォルトでサポートされています。rv1126/rv1109、RK_OEM_OTP_KEY_FW は追加でサポートされています。 [in] config - Algorithms、パターン、キー、iv、など AES、SM4アルゴリズムサポートECB/CBC/CTS/CTR/CFB/OFBモード キー長は、rv1109/rv1126プラットフォームである場合、16、24、32バイトをサポートし、キー長は16、32のみをサポートしています。 key_id が RK_OEM_OTP_KEY_FW であるとき、キーの長さは 16 だけを支えます。 [in] src_phys_addr - 計算されるデータの緩衝アドレス、dst_phys_addr と同じサポートします。すなわち、暗号化および復号化のローカル サポート [out] dst_phys_addr - 計算の結果の緩衝アドレス、 これらは、入力と出力データバッファのバイト長であるsrc_phys_addr [in] lenと同じサポートで、使用されるアルゴリズムのブロックと整列する必要があります。

5.17.3.14 trusty_read_oem_ns_otp {#517314-trusty_read_oem_ns_otp}
uint32_t trusty_read_oem_ns_otp(uint32_t byte_off, uint8_t *byte_buf, uint32_t byte_len)

機能Uボットは、安全なOTPから保護されていないOEMゾーンデータを読み取ります。 パラメーター [in] byte_off - OTPエリアのポジションオフセットを[out] byte_buf - 返されたOTPデータ [in] byte_len - 読み込まれる長さ

5.17.3.15 trusty_write_oem_ns_otp {#517315-trusty_write_oem_ns_otp}
uint32_t trusty_write_oem_ns_otp(uint32_t byte_off, uint8_t *byte_buf, uint32_t byte_len)

機能Uボットは、安全なOTPの非保護OEMゾーンにデータを書き込みます。 パラメーター [in] byte_off - OTPエリアのポジションオフセットを[in] byte_buf - OTPに書き込むデータ [in] byte_len - 書き込みの長さ

5.17.3.16 trusty_write_ta_encryption_key {#517316-trusty_write_ta_encryption_key}
uint32_t trusty_write_ta_encryption_key(uint32_t *buf, uint32_t length)

機能 U ボットは TA の暗号化キーを書きます。 パラメーター [in] buf - キーデータ [in] の長さ - キーデータの長さ

5.17.3.17 trusty_ta_encryption_key_is_written {#517317-trusty_ta_encryption_key_is_written}
uint32_t trusty_ta_encryption_key_is_written(uint8_t *value)

機能

U-BootはTA暗号化キーが書かれているかどうかを確認します。 パラメーター [out] 値 - 0 は書かれていません、1 は書き出します

5.17.3.18 trusty_write_oem_encrypt_data {#517318-trusty_write_oem_encrypt_data}
uint32_t trusty_write_oem_encrypt_data(uint32_t *buf, uint32_t length)

機能Uボットは、アンチコピーボード用のプライベートデータを書き込みます。 パラメーター [in] buf - プライベートデータ [in] の長さ - プライベートデータの長さ

5.17.3.19 trusty_oem_encrypt_data_is_written {#517319-trusty_oem_encrypt_data_is_written}
uint32_t trusty_oem_encrypt_data_is_written(uint8_t *value)

機能 U ボットは、プライベートデータが書かれているかどうかを確認します。 パラメーター [out] 値 - 0 は書かれていません、1 は書き出します

5.17.3.20 trusty_check_security_level_flag {#517320-trusty_check_security_level_flag}
uint32_t trusty_check_security_level_flag(uint8_t flag)

機能UボットはTEEのセキュリティレベルを設定します。 パラメーター [in] フラグ - セキュリティレベル

5.17.3.21 trusty_write_oem_huk {#517321-trusty_write_oem_huk}
uint32_t trusty_write_oem_huk(uint32_t *buf, uint32_t length)

機能

U-BootはOEM HUKを書きます。 パラメーター [in] buf - 記述されるデータ - データの長さ - データの長さ

5.17.4 共有メモリ {#5174-shared-memory}

U-Boot が Optee と通信する際には、共有メモリにデータを投入する必要があります。

TEEC_AllocateSharedMemory() でリクエストメモリを共有できますが、1Mを超えると共有メモリを上回らないことをお勧めします。複数のパスのデータ分割や、使用後の共有メモリのリリースには TEEC_ReleaseSharedMemory() を呼び出すことを推奨します。

5.17.5 テストコマンド {#5175-test-command}

目的:安全なストレージ機能をテストするには、U-Bootコマンドライン:

=> mmc testsecurestorage

このテストケースは、ハードウェアがemmcを使用しているときに、安全なストレージ読み取りと書き込み機能を使用して、rpmbとセキュリティパーティションのセキュアストレージの両方をテストし、ハードウェアがnandを使用している場合にのみセキュリティパーティションの安全なストレージをサイクルします。

5.17.6 共通点 {#5176-common-misprints}

emmc や nand デバイスが見つかりませんでした。 U-Bootが構成されていないか、ハードウェアが破損しているかどうかを確認してください。

"TEEC: Could not find device"

セキュリティーのパーティションが見つかりません。 RPMBが利用できない場合は、parameter.txtのセキュリティパーティションを定義する必要があります。

"TEEC: Could not find security partition"

このプリントアウトは、セキュリティパーティションが安全なストレージに使用され、セキュリティパーティションデータが不正に改ざんされていない場合に使用されます。

"TEEC: verify [%d] fail, cleanning ...."

安全なストレージには十分なスペースはありません。 保存したデータが大きすぎるか、大量のデータが保存されたり削除されていないかご確認ください。

"TEEC: Not enough space available in secure storage !"

5.18 PCIeの {#518-pcie}

5.18.1 開発ノート {#5181-development-notes}

u-boot のどのステージが PCIe に適用され、それに応じて dts を設定しているかを確認します。

  1. NVMEは起動装置として、可能な限り初期化する必要があるため、すべての以降のファームウェアはこのNVMEにあるので、PCIeはu-bootのdtsを使用して設定することができます

  2. ネットワークカードをサポートするようなブートデバイスとして使用されていないデバイスは、後で初期化することができます。また、u-bootフレームワークはカーネルdtbの使用をサポートしているため、boot.imgのカーネルdtbの設定を使用します

  3. u-boot フェーズでは、PCIe RC は、mem 64bits のプレッションスペースに適用されない、mem 32bits の範囲のみを登録します。

5.18.2フレームワークサポート {#5182-framework-support}

フレームワークコード:

./drivers/pci/*
./drivers/phy/*

ドライバーコード:

drivers/pci/pcie_dw_rockchip.c
drivers/phy/phy-rockchip-snps-pcie3.c
drivers/phy/phy-rockchip-naneng-combphy.c

設定: ドライバー構成: Rockchip PCIe ドライバーの現在サポートされているプラットフォームについては、 pcie_dw_rockchip.c ファイル内の互換性のある属性をチェックし、ドライバー選択に関して疑問に思っている場合は、対応する sdk 設定を参照してください。

CONFIG_DM_REGULATOR_GPIO=y
CONFIG_DM_REGULATOR_FIXED=y
CONFIG_PCI=y
CONFIG_DM_PCI=y
CONFIG_DM_PCI_COMPAT=y
CONFIG_PCI_PNP=y
CONFIG_PCIE_DW_ROCKCHIP=y
CONFIG_PHY_ROCKCHIP_SNPS_PCIE3=y
CONFIG_PHY_ROCKCHIP_NANENG_COMBOPHY=y
CONFIG_PHY=y
CONFIG_CMD_PCI=y
//Add NVMe support
CONFIG_NVME=y
CONFIG_CMD_NVME=y
// Add PCIe to USB support
CONFIG_USB_XHCI_PCI=y
//Add Embedded DTB support, the image size will be bigger after adding Embedded DTB support.
CONFIG_EMBED_KERNEL_DTB_ALWAYS=y
CONFIG_SPL_FIT_IMAGE_KB=2560

5.18.3 DTS の設定 {#5183-dts-configuration}

読み込みプログラムの選択の推奨事項:フラッシュ+ PCIe NVMeデュアルストレージソリューション: カーネルdtbをロードする前にPCIeを使用して、AMPシナリオでPCIeサポート:埋め込みdtb Common練習をロードした後にPCIeを使用して:カーネルdtbをロードし、PCIeを使用します。 カーネルdtbをロードする前に、PCIe を使うと、 uboot dtsi関連のノードを設定し、 u-boot,dm-pre-reloc 属性を追加するためのカーネル DTB ノード構成を参照することをお勧めします。 phy 電源は、デフォルト vcc 3v3 電源 phy ノード コントローラ ノードが既に有効になっている場合は、 u-boot,dm-pre-reloc 属性を追加します。 例として、RK3588 PCIe3x4 を します。

diff --git a/arch/arm/dts/rk3588-u-boot.dtsi b/arch/arm/dts/rk3588-u-boot.dtsi
index 3fe8054aac..a8e2defbad 100644
--- a/arch/arm/dts/rk3588-u-boot.dtsi
+++ b/arch/arm/dts/rk3588-u-boot.dtsi
@@ -22,6 +22,28 @@
                compatible = "rockchip,rk3588-secure-otp";
                reg = <0x0 0xfe3a0000 0x0 0x4000>;
        };
+
+       vcc12v_dcin: vcc12v-dcin {
+               u-boot,dm-pre-reloc;
+               compatible = "regulator-fixed";
+               regulator-name = "vcc12v_dcin";
+               regulator-always-on;
+               regulator-boot-on;
+               regulator-min-microvolt = <12000000>;
+               regulator-max-microvolt = <12000000>;
+       };
+
+       vcc3v3_pcie30: vcc3v3-pcie30 {
+               u-boot,dm-pre-reloc;
+               compatible = "regulator-fixed";
+               regulator-name = "vcc3v3_pcie30";
+               regulator-min-microvolt = <3300000>;
+               regulator-max-microvolt = <3300000>;
+               enable-active-high;
+               gpio = <&gpio3 RK_PC3 GPIO_ACTIVE_HIGH>;
+               startup-delay-us = <5000>;
+               vin-supply = <&vcc12v_dcin>;
+       };
 };

 &firmware {
@@ -117,6 +139,19 @@
        status = "okay";
 };

+&pcie30phy {
+       u-boot,dm-pre-reloc;
+       rockchip,pcie30-phymode = <PHY_MODE_PCIE_AGGREGATION>;
+       status = "okay";
+};
+
+&pcie3x4 {
+       u-boot,dm-pre-reloc;
+       reset-gpios = <&gpio4 RK_PB6 GPIO_ACTIVE_HIGH>;
+       vpcie3v3-supply = <&vcc3v3_pcie30>;
+       status = "okay";
+};
+
 &uart2 {
        u-boot,dm-spl;
        status = "okay";

たとえば、RK3566 を 取ります。

From b58a47956bbd03de0fcef572fa06cdeea974e2a9 Mon Sep 17 00:00:00 2001
From: Jon Lin <jon.lin@rock-chips.com>
Date: Thu, 9 Mar 2023 15:29:37 +0800
Subject: [PATCH] TEST: uboot: rk3566_evb2_v11: nvme

Change-Id: I87b3786a433691f3c385460fa8636291bce8ed9a
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
---
 arch/arm/dts/rk3568-u-boot.dtsi | 43 +++++++++++++++++++++++++++++++++
 configs/rk3568_defconfig        | 13 ++++++++++
 2 files changed, 56 insertions(+)

diff --git a/arch/arm/dts/rk3568-u-boot.dtsi b/arch/arm/dts/rk3568-u-boot.dtsi
index a0678e35db..1ab8ea4436 100644
--- a/arch/arm/dts/rk3568-u-boot.dtsi
+++ b/arch/arm/dts/rk3568-u-boot.dtsi
@@ -26,6 +26,27 @@
        cru_rst_addr = <0xfdd20470>;
        u-boot,dm-spl;
    };
+
+   dc_12v: dc-12v {
+       compatible = "regulator-fixed";
+       regulator-name = "dc_12v";
+       regulator-always-on;
+       regulator-boot-on;
+       regulator-min-microvolt = <12000000>;
+       regulator-max-microvolt = <12000000>;
+   };
+
+   vcc3v3_pcie: gpio-regulator {
+       u-boot,dm-pre-reloc;
+       compatible = "regulator-fixed";
+       regulator-name = "vcc3v3_pcie";
+       regulator-min-microvolt = <3300000>;
+       regulator-max-microvolt = <3300000>;
+       enable-active-high;
+       gpio = <&gpio0 RK_PC2 GPIO_ACTIVE_HIGH>;
+       startup-delay-us = <5000>;
+       vin-supply = <&dc_12v>;
+   };
 };

 &psci {
@@ -386,6 +407,28 @@
    status = "okay";
 };

+&pipegrf {
+   u-boot,dm-pre-reloc;
+   status = "okay";
+};
+
+&pipe_phy_grf2 {
+   u-boot,dm-pre-reloc;
+   status = "okay";
+};
+
+&combphy2_psq {
+   u-boot,dm-pre-reloc;
+   status = "okay";
+};
+
+&pcie2x1 {
+   u-boot,dm-pre-reloc;
+   reset-gpios = <&gpio1 RK_PB2 GPIO_ACTIVE_HIGH>;
+   vpcie3v3-supply = <&vcc3v3_pcie>;
+   status = "okay";
+};
+
 &pinctrl {
    u-boot,dm-pre-reloc;
    status = "okay";

組み込みdtbをロードした後のPCIeを使う u-bootプロジェクトは、カーネルのサポートなしで製品スキームを含むカーネルdtbの変更の影響を回避する組み込みdtbスキームをサポートしています。 通常、組み込みdtbソースはカーネル標準dtbファイルであり、メインステップは次のとおりです。 Compileカーネルファームウェア、ターゲットdtbファイルを生成します。 U-Bootエンabling組み込みdtb構成

CONFIG_EMBED_KERNEL_DTB=y
CONFIG_EMBED_KERNEL_DTB_ALWAYS=y
CONFIG_EMBED_KERNEL_DTB_PATH=”./dts/rkTarget Chip-Target Device.dtb“  # for example,
CONFIG_EMBED_KERNEL_DTB_PATH="dts/rk3588-evb1.dtb"

コンパイルとu-bootイメージの推奨を生成: いくつかのAMPシナリオでは、PCIe初期の初期の初期のinit要件とカーネルがない、およびAMPがロードされる前にPCIeの列を完了するために、次のパッチは起動プロセス中にPCIeを列挙するのに使用できる

diff --git a/arch/arm/mach-rockchip/board.c b/arch/arm/mach-rockchip/board.c
index 979598ff7b..87d131e118 100644
--- a/arch/arm/mach-rockchip/board.c
+++ b/arch/arm/mach-rockchip/board.c
@@ -537,6 +537,11 @@ int board_init(void)
        io_domain_init();
 #endif
        set_armclk_rate();
+
+#ifdef CONFIG_PCI
+       pci_init();
+#endif
+
 #ifdef CONFIG_DM_DVFS
        dvfs_init(true);
 #endif

カーネルdtbをロードした後にPCIeを使うと、カーネルDTBを直接再利用して、関連するコールを「RK u-boot をカーネルDTBフェーズで配置」することで検討できます。関連説明については、カーネルPCIe設定を参照してください。

5.18.4 使用例 {#5184-usage-example}

一般的なコマンド:

5.18.4.1 PCIe CMD(シーエムピー・エムディー) {#51841-pcie-cmd}
## Chapter-5 PCI enumeration, where CFG maps to memory address 0x00000000f0000000
=> pci enum
pcie@fe150000: PCIe Linking... LTSSM is 0x1
pcie@fe150000: PCIe Linking... LTSSM is 0x6
pcie@fe150000: PCIe Linking... LTSSM is 0x4
pcie@fe150000: PCIe Linking... LTSSM is 0x210023
pcie@fe150000: PCIe Link up, LTSSM is 0x230011
pcie@fe150000: PCIE-0: Link up (Gen3-x2, Bus0)
pcie@fe150000: invalid flags type!
pcie@fe150000: Config space: [0x00000000f0000000 - 0x00000000f0100000, size 0x100000]

## Chapter-5 Scanning all devices
=> pci
BusDevFun  VendorId   DeviceId   Device Class       Sub-Class
_____________________________________________________________
00.00.00   0x1d87     0x3588     Bridge device           0x04
01.00.00   0x144d     0xa809     Mass storage controller 0x08

## Chapter-5 Display bus 01 device details
=> pci 01 long
Scanning PCI devices on bus 1

Found PCI device 01.00.00:
  vendor ID =                   0x144d
  device ID =                   0xa809
  command register ID =         0x0006
  status register =             0x0010
  revision ID =                 0x00
  class code =                  0x01 (Mass storage controller)
  sub class code =              0x08
  programming interface =       0x02
  cache line =                  0x08
  latency time =                0x00
  header type =                 0x00
  BIST =                        0x00
  base address 0 =              0xf0300004
  base address 1 =              0x00000000
  base address 2 =              0x00000000
  base address 3 =              0x00000000
  base address 4 =              0x00000000
  base address 5 =              0x00000000
  cardBus CIS pointer =         0x00000000
  sub system vendor ID =        0x144d
  sub system ID =               0xa801
  expansion ROM base address =  0x00000000
  interrupt line =              0xff
  interrupt pin =               0x01
  min Grant =                   0x00
  max Latency =                 0x00
## Chapter-5 display bdf 01.00.00 device bar mapping address, sample code shows bar0 mapping
memory address 0xf0300000, size 0x4000.
=> pci bar 01.00.00
ID   Base                Size                Width  Type
----------------------------------------------------------
 0   0x00000000f0300000  0x0000000000004000  64     MEM

## Chapter-5 Read bdf 01.00.00 device CFG space information
=> pci d.w 01.00.00 0
00000000: 144d a809 0006 0010 0200 0108 0008 0000
00000010: 0004 f030 0000 0000 0000 0000 0000 0000
00000020: 0000 0000 0000 0000 0000 0000 144d a801
00000030: 0000 0000 0040 0000 0000 0000 01ff 0000

## Chapter-5 AER function, used to read the AER register information of the specified
device, with the output format consistent with that of the Linux lspci tool.
=> pci aer 01.00.0
    AER Capability found at offset 0x40
    UESta: DLP-- SDES-- TLP-- FCP-- CmpltTO-- CmpltAbrt-- UnxCmplt-- RxOF-- MalfTLP-- ECRC--
UnsupReq-- ACSViol--
    UEMsk: DLP-- SDES-- TLP-- FCP-- CmpltTO-- CmpltAbrt-- UnxCmplt-- RxOF-- MalfTLP-- ECRC--
UnsupReq-- ACSViol--
    UESvrt: DLP+ SDES- TLP+ FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC-
UnsupReq- ACSViol-
    CESta: RxErr-- BadTLP-- BadDLLP-- Rollover-- Timeout-- NonFatalErr--
    CEMsk: RxErr-- BadTLP-- BadDLLP-- Rollover-- Timeout-- NonFatalErr--
    AERCap: First Error Pointer: 00, GenCap- CGenEn- ChkCap- ChkEn-

## Chapter-5 The retrain link function is used for link re-establishment.
=> pci x 01.00.0
    Retrain triggered for device 0001:0000
    Link Status for device 0001:0000: 0x1022
    Speed: Gen3
    Width: x2
    Link Up: Yes

## Chapter-5 The FLR (Function Level Reset) function is used to reset peripheral functions.
=> pci flr 01.00.0
    FLR completed and state restored for device 01:00.0
5.18.4.2 NVMeの特長 {#51842-nvme}
## Chapter-5 Initiate nvme scan
=> nvme scan

## Chapter-5 List nvme equipment details
=> nvme details
    Blk device 0: Optional Admin Command Support:
            Namespace Management/Attachment: no
            Firmware Commit/Image download: yes
            Format NVM: yes
            Security Send/Receive: no
    Blk device 0: Optional NVM Command Support:
            Reservation: yes
            Save/Select field in the Set/Get features: yes
            Write Zeroes: yes
            Dataset Management: yes
            Write Uncorrectable: yes
    Blk device 0: Format NVM Attributes:
            Support Cryptographic Erase: No
            Support erase a particular namespace: Yes
            Support format a particular namespace: Yes
    Blk device 0: LBA Format Support:
    Blk device 0: End-to-End DataProtect Capabilities:
            As last eight bytes: No
            As first eight bytes: No
            Support Type3: No
            Support Type2: No
            Support Type1: No
    Blk device 0: Metadata capabilities:
            As part of a separate buffer: No
            As part of an extended data LBA: No

## Chapter-5 Seeing a 256GB NVMe, if you cannot see the capacity, you need to unplug the
device to make sure it's completely powered down and start over.
=> nvme info
    Device 0: Vendor: 0x144d Rev: EXD7201Q Prod: S444NA0M384608
                Type: Hard Disk
                Capacity: 244198.3 MB = 238.4 GB (500118192 x 512)

## Chapter-5 Select the nvme device with ID 0
=> nvme device 0

Device 0: Vendor: 0x144d Rev: EXD7201Q Prod: S444NA0M384608
            Type: Hard Disk
            Capacity: 244198.3 MB = 238.4 GB (500118192 x 512)
... is now current device

## Chapter-5 Set 0x40000000 memory to bit 0x55aa55aa
=> md.l 0x40000000 1
    40000000: d08ec033                               3...
=> mw.l 0x40000000 0x55aa55aa
=> md.l 0x40000000 1
    40000000: 55aa55aa                               .U.U

## Chapter-5 Take 1 block of data starting at 0x40000000 memory and write it to the NVME LBA
0 address
=> nvme write 0x40000000 0x0 0x1

    nvme write: device 0 block # 0, count 1 ... 1 blocks written: OK

## Chapter-5 Check the 0x44000000 memory to confirm the raw data
=> md.l 0x44000000 1
    44000000: ffffffff                               ....
## Chapter-5 Read 1 block of data from NVMe's LBA 0 address and write to memory 0x44000000
=> nvme read 0x44000000 0x0 0x1

    nvme read: device 0 block # 0, count 1 ... 1 blocks read: OK

## Chapter-5 Confirm that 0x44000000 memory data is read back from NVMe
=> md.l 0x44000000 1
    44000000: 55aa55aa

## Chapter-5 Erase a block starting from address 0.
=> nvme erase 0x0 0x1
    nvme erase: device 0 block # 0, count 1 ... 1 blocks erased: OK

## Chapter-5 Read 1 block of data from the LBA (Logical Block Address) 0 of the NVMe device
and write it to the memory address 0x44000000.
=> nvme read 0x44000000 0x0 0x1
    nvme read: device 0 block # 0, count 1 ... 1 blocks read: OK

## Chapter-5 Confirm that the data in the memory at address 0x44000000 is read from the NVMe
device.
=> md.l 0x44000000 0x200   #The first block on the NVMe device has been cleared.
    44000000: 00000000 00000000 00000000 00000000    ................
    44000010: 00000000 00000000 00000000 00000000    ................
    44000020: 00000000 00000000 00000000 00000000    ................
    ...

## Chapter-5 Use the write zero function to clear the data of one block starting from
address 0x100.
=> nvme write_zeroes 0x100 0x1
    nvme write_zeroes: device 0 block # 0x100, count 1 ... 1 blocks write_zeroed: OK
5.18.4.3 RK3588 RC dma {#51843-rk3588-rc-dma}
=> pci
BusDevFun  VendorId   DeviceId   Device Class       Sub-Class
_____________________________________________________________
00.00.00   0x1d87     0x3588     Bridge device           0x04
01.00.00   0x1d87     0x356a     ???                     0x00
=> pci 1 long
Scanning PCI devices on bus 1

Found PCI device 01.00.00:
  vendor ID =                   0x1d87
  device ID =                   0x356a
  command register ID =         0x0006
  status register =             0x0010
  revision ID =                 0x01
  class code =                  0x12 (???)
  sub class code =              0x00
  programming interface =       0x00
  cache line =                  0x08
  latency time =                0x00
  header type =                 0x00
  BIST =                        0x00
  base address 0 =              0xf0400000    # CPU address mapped by BAR0. Since RK PCIe
uses CPU-BUS one-to-one mapping, the bus addr is the same value.
  base address 1 =              0x00000000
  base address 2 =              0x0400000c
  base address 3 =              0x00000000
  base address 4 =              0xf0800000
  base address 5 =              0x00000000
  cardBus CIS pointer =         0x00000000
  sub system vendor ID =        0x0000
  sub system ID =               0x0000
  expansion ROM base address =  0x00000000
  interrupt line =              0xff
  interrupt pin =               0x01
  min Grant =                   0x00
  max Latency =                 0x00
=>

## Chapter-5 BAR CPU Access, PIO Access
md.l 0xf0400000 0x40

## Chapter-5 DMA read
mw.l 0x3c000000 0xffffffff
dcache flush 0x3c000000 0x100      # flush
mw.l 0xf538002c 0x1
mw.l 0xf5380300 0x4000008
mw.l 0xf5380304 0x0
mw.l 0xf5380308 0x100
mw.l 0xf538030c 0xf0400000
mw.l 0xf5380310 0x0
mw.l 0xf5380314 0x3c000000
mw.l 0xf5380318 0x0
mw.l 0xf5380030 0x0
dcache invalidate 0x3c000000 0x100  # invalidate
md.l 0x3c000000

## Chapter-5 DMA write
mw.l 0x3c000000 0xffffffff
dcache flush 0x3c000000 0x100 # flush
mw.l 0xf538000c 0x1
mw.l 0xf5380200 0x4000008
mw.l 0xf5380204 0x0
mw.l 0xf5380208 0x100
mw.l 0xf538020c 0x3c000000
mw.l 0xf5380210 0x0
mw.l 0xf5380214 0xf0400000
mw.l 0xf5380218 0x0
mw.l 0xf5380010 0x0
md.l 0x3c000000 0x40

注意: dcache フラッシュ/クリーンなマクロスイッチ、CONFIG_CMD_CACHE は、以下のサポートパッチを追加する必要があります。

commit b46a81a12dd4a1514a6522e33a1d16194f242d62
Author: Joseph Chen <chenjh@rock-chips.com>
Date:   Wed Sep 28 01:36:45 2022 +0000

    cmd: cache: Add flush/invalidate dcache range support

    Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
    Change-Id: Id0e0cd9019072e8c557ebd2987b439057cb4ae3b
5.18.4.4 RK3568 RC dma {#51844-rk3568-rc-dma}
=> pci
BusDevFun  VendorId   DeviceId   Device Class       Sub-Class
_____________________________________________________________
00.00.00   0x1d87     0x356a     Bridge device           0x04
01.00.00   0x1d87     0x356a     ???                     0x00
=> pci 1 long
Scanning PCI devices on bus 1

Found PCI device 01.00.00:
  vendor ID =                   0x1d87
  device ID =                   0x356a
  command register ID =         0x0006
  status register =             0x0010
  revision ID =                 0x01
  class code =                  0x12 (???)
  sub class code =              0x00
  programming interface =       0x00
  cache line =                  0x08
  latency time =                0x00
  header type =                 0x00
  BIST =                        0x00
  base address 0 =              0xf0400000    # CPU address mapped by BAR0. Since RK PCIe
uses CPU-BUS one-to-one mapping, the bus addr is the same value.
  base address 1 =              0x00000000
  base address 2 =              0x0400000c
  base address 3 =              0x00000000
  base address 4 =              0xf0800000
  base address 5 =              0x00000000
  cardBus CIS pointer =         0x00000000
  sub system vendor ID =        0x0000
  sub system ID =               0x0000
  expansion ROM base address =  0x00000000
  interrupt line =              0xff
  interrupt pin =               0x01
  min Grant =                   0x00
  max Latency =                 0x00
=>

## Chapter-5 BAR CPU access, PIO access
md.l 0xf0400000 0x40

## Chapter-5 DMA read
mw.l 0x3c000000 0xffffffff
dcache flush 0x3c000000 0x100      # flush
mw.l 0xf638002c 0x1
mw.l 0xf6380300 0x4000008
mw.l 0xf6380304 0x0
mw.l 0xf6380308 0x100
mw.l 0xf638030c 0xf0400000
mw.l 0xf6380310 0x0
mw.l 0xf6380314 0x3c000000
mw.l 0xf6380318 0x0
mw.l 0xf6380030 0x0
dcache invalidate 0x3c000000 0x100  # invalidate
md.l 0x3c000000

## Chapter-5 DMA write
mw.l 0x3c000000 0xffffffff
dcache flush 0x3c000000 0x100 # flush
mw.l 0xf638000c 0x1
mw.l 0xf6380200 0x4000008
mw.l 0xf6380204 0x0
mw.l 0xf6380208 0x100
mw.l 0xf638020c 0x3c000000
mw.l 0xf6380210 0x0
mw.l 0xf6380214 0xf0400000
mw.l 0xf6380218 0x0
mw.l 0xf6380010 0x0
md.l 0x3c000000 0x40

注意: dcache フラッシュ/クリーンなマクロスイッチ、CONFIG_CMD_CACHE は、以下のサポートパッチを追加する必要があります。

commit b46a81a12dd4a1514a6522e33a1d16194f242d62
Author: Joseph Chen <chenjh@rock-chips.com>
Date:   Wed Sep 28 01:36:45 2022 +0000

    cmd: cache: Add flush/invalidate dcache range support

    Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
    Change-Id: Id0e0cd9019072e8c557ebd2987b439057cb4ae3b

5.18.5 共通の問題の分析 {#5185-analysis-of-common-problems}

RK3568 Linux 5.10 ubootシャットダウン PCIE ASPM のデフォルトコントローラーは、ASPM サポートがオフになっているため、PCIe3x2 uboot シェルの下のコマンドモードがオフになっていることを確認してください。

pci display.l 20.00.00 0x80 1

BITS[1:0] PCIE_CAP_ACTIVE_STATE_LINK_PM_CONTROLのところ:

Values:
0x0 (DISABLED): Disabled
0x1 (L0S_ENTRY_EN): L0s Entry Enabled
0x2 (L1_ENTRY_En): L1 Entry Enabled
0x3 (L0S_L1_ENTRY_EN): L0s and L1 Entry Enabled

RC DMA は、FPGA とほとんどの周辺機器の BAR アクセスを制限する FPGA へのアクセスが異なる: 一部のデバイスは、メモリ読み取り/書き込み TLP パケットを異なる長さのバックアップをサポートしています。一部のデバイスは、4Bytes メモリ読み取り/書き込み TLP パケットのみをサポートしているため、 4Bytes メモリ読み込み/書き込み TLP のみがサポートされ、BAR スペースへのアクセスが CPU には通常、RC DMA 起動リクエストが 4B アドレス転送長を超えると、異なるエラーが現れます。

## Chapter-5 RK3568 DMA read ca abort info
=> md.l 0xf63800b8 1
f63800b8: 00000100                               ....

他のメモ: この種類の問題をキャッチするには、PCIe プロトコルアナライザは TLP トリガーを使用する必要があります。メモリトリガーではなく、エラー後にトリガーする cpl はありません。 周辺機器が4B以上のTLPリクエストを受信した後、PCIeアクセスがバスに制限されていると疑われていますが、特定の要件は、周辺機器メーカーの支援を分析する必要があります

5.19 ピクチャー {#519-pinctrl}

5.19.1フレームワークサポート {#5191-framework-support}

pinctrl ドライバーは、ピンクセルクラスフレームワークと標準インターフェイスを使用します。 構成:

CONFIG_PINCTRL_GENERIC
CONFIG_PINCTRL_ROCKCHIP

フレームワークコード:

./drivers/pinctrl/pinctrl-uclass.c

ドライバーコード:

./drivers/pinctrl/pinctrl-rockchip.c

5.19.2 関連するインターフェイス {#5192-relevant-interface}

int pinctrl_select_state(struct udevice *dev, const char *statename)    // set status
int pinctrl_get_gpio_mux(struct udevice *dev, int banknum, int index)   // Get Status

ピンクセルフレームワークは、プローブ時に各ドライバーの「デフォルト」状態を自動的に設定し、一般的にピンクサーインターフェイスを呼び出す必要はありません。

5.20 マイク/レギュレータ {#520-pmicregulator}

5.20.1フレームワークサポート {#5201-framework-support}

PMIC/Regulator ドライバーは、レミッククラス、レギュレータクラスフレームワーク、標準インターフェースを使用します。 PMICサポート:

rk805/rk808/rk809/rk816/rk817/rk818

調整装置サポート:

rk805/rk808/rk809/rk816/rk817/rk818/syr82x/tcs452x/fan53555/pwm/gpio/fixed

構成:

CONFIG_DM_PMIC
CONFIG_PMIC_CHILDREN
CONFIG_PMIC_RK8XX        // Suitable for all current RK8XX series chips
CONFIG_DM_REGULATOR
CONFIG_REGULATOR_PWM
CONFIG_REGULATOR_RK8XX   // Suitable for all current RK8XX series chips
CONFIG_REGULATOR_FAN53555

フレームワーク コード:

./drivers/power/pmic/pmic-uclass.c
./drivers/power/regulator/regulator-uclass.c

ドライバーファイル:

./drivers/power/pmic/rk8xx.c
./drivers/power/regulator/rk8xx.c
./drivers/power/regulator/fixed.c
./drivers/power/regulator/gpio-regulator.c
./drivers/power/regulator/pwm_regulator.c
./drivers/power/regulator/fan53555_regulator.c

5.20.2 関連するインターフェイス {#5202-relevant-interface}

// ger regulator. @platname: name specified by“regulator-name”, e.g: vdd_arm, vdd_logic;
int regulator_get_by_platname(const char *platname, struct udevice **devp);

// Enable/Disable
int regulator_get_enable(struct udevice *dev);
int regulator_set_enable(struct udevice *dev, bool enable);
int regulator_set_suspend_enable(struct udevice *dev, bool enable);
int regulator_get_suspend_enable(struct udevice *dev);

// Configure/Get Voltage
int regulator_get_value(struct udevice *dev);
int regulator_set_value(struct udevice *dev, int uV);
int regulator_set_suspend_value(struct udevice *dev, int uV);
int regulator_get_suspend_value(struct udevice *dev);

5.20.3 入口の電圧 {#5203-init-voltage}

現在、規制-boot-on が構成されていることを示す特定の規制当局の初期化電圧出力を設定する方法は次のとおりです。 規制当局-min-microvolt と規制-min-microvolt を同じ値に設定します。 規制-init-microvolt = <…>

vdd_arm: DCDC_REG1 {
    regulator-name = "vdd_arm";
    regulator-boot-on;                     // Must be configured
    regulator-min-microvolt = <712500>;
    regulator-max-microvolt = <1450000>;
    regulator-init-microvolt = <1100000>;   // Set initialization voltage to 1.1v
    ......
};

5.20.4 スキップ初期化 {#5204-skip-initialization}

特定の方法規制当局の初期化をスキップしたい場合は、レギュレータ・ローダー・イニコールを追加します。

vdd_arm: DCDC_REG1 {
    regulator-name = "vdd_arm";
    regulator-loader-ignore;// Only valid for regulator initialization in U-Boot phase, not
for kernel.
    ......
};

5.21 リセット {#521-reset}

5.21.1フレームワークサポート {#5211-framework-support}

リセットドライバーは、reset-uclass.cフレームワークと標準インタフェースを使用します。 RKプラットフォームでリセットすることは、基本的にCRUのソフトリセットです。 構成:

CONFIG_DM_RESET
CONFIG_RESET_ROCKCHIP

フレームワークコード:

./drivers/reset/reset-uclass.c

ドライバーコード:

./drivers/reset/reset-rockchip.c

5.21.2 の Relervant インターフェイス {#5212-relervant-interface}

// Get reset handle
int reset_get_by_index(struct udevice *dev, int index, struct reset_ctl *reset_ctl);
int reset_get_by_name(struct udevice *dev, const char *name,
                      struct reset_ctl *reset_ctl);
// release reset
int reset_free(struct reset_ctl *reset_ctl);
// requesr reset
int reset_request(struct reset_ctl *reset_ctl);
// trigger reset, release reset
int reset_assert(struct reset_ctl *reset_ctl);
int reset_deassert(struct reset_ctl *reset_ctl);

例:

struct reset_ctl reset_ctl;

ret = reset_get_by_name(dev, "mac-phy", &reset_ctl);
if (ret) {
    debug("reset_get_by_name() failed: %d\n", ret);
    return ret;
}

ret = reset_request(&reset_ctl);
if (ret)
    return ret;

ret = reset_assert(&reset_ctl);
if (ret)
    return ret;

......

ret = reset_deassert(&reset_ctl);
if (ret)
    return ret;

......

ret = reset_free(&reset_ctl);
if (ret)
    return ret;

5.21.3 DTS の設定 {#5213-dts-configuration}

U-Boot はデフォルトでリセット機能を有効にします。ユーザーは、周辺ノードで動作するリセットオブジェクトを指定する必要があります。

// format:
reset-names = <name-string-list>
resets = <cru-phandle-list>

gmac2phy を例に挙げる:

gmac2phy: ethernet@ff550000 {
    compatible = "rockchip,rk3328-gmac";
    ......

    // specify reset attribute
    reset-names = "stmmaceth", "mac-phy";
    resets = <&cru SRST_GMAC2PHY_A>, <&cru SRST_MACPHY>;
};

5.22 の ng {#522-rng}

5.22.1フレームワークサポート {#5221-framework-support}

RNG はハードウェアの任意数機能の実装に使用されます。 フレームワークコード:

./drivers/rng/rng-uclass.c

ドライバーコード:

./drivers/rng/rockchip_rng.c

構成:

CONFIG_DM_RNG=y
CONFIG_RNG_ROCKCHIP=y

5.22.2 関連するインターフェイス {#5222-relevant-interface}

// @buffer: Save random number output
// @size: Random number length, Unit: byte
int dm_rng_read(struct udevice *dev, void *buffer, size_t size)

5.22.3 DTS の設定 {#5223-dts-configuration}

RNG は、暗号化ハードウェアモジュールの特長の 1 つであるため、RNG ノードは、暗号化ノードと同じように V1/2 を持っています。 RNG ノードには 2 つの種類の互換性フィールドがあります。

compatible = "rockchip,cryptov1-rng";
compatible = "rockchip,cryptov2-rng";

ノード構成を完成させるには、rv1126.dtsi、rk3568.dtsi、rk3399.dtsiファイルを参照してください。

5.23 スパイ {#523-spi}

5.23.1フレームワークサポート {#5231-framework-support}

フレームワークコード:

./drivers/spi/spi-uclass.c

ドライバーコード:

./drivers/spi/rk_spi.c

メニュー設定 :

CONFIG_ROCKCHIP_SPI=y
CONFIG_CMD_SPI=y

5.23.2 関連するインタフェース {#5232-relevant-interface}

./include/spi.h

// Initialize the corresponding SPI bus
struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs, unsigned int max_hz,
unsigned int mode);

//  Get/Release Bus
int spi_claim_bus(struct spi_slave *slave);
void spi_release_bus(struct spi_slave *slave);

// Common Read/Write Interfaces
int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
                void *din, unsigned long flags);
int spi_write_then_read(struct spi_slave *slave, const u8 *opcode,
                        size_t n_opcode, const u8 *txbuf, u8 *rxbuf,
                        size_t n_buf);

5.23.3 DTS の設定 {#5233-dts-configuration}

&spi0 {
        u-boot,dm-pre-reloc;
        status = "okay";
};

5.23.4 再コール例 {#5234-recall-example}

drivers/power/power_spi.c を参照することをお勧めします。 簡単な参照のために、このデモを確認することができます:

static u32 spi_bus_test(int bus, int cs)
{
    struct spi_slave *spi_slave;
    u32 tx_data, rx_data;
    int ret;

#ifdef CONFIG_DM_SPI
    struct udevice *dev;
    char name[30], *str;

    snprintf(name, sizeof(name), "generic_%d:%d", bus, cs);
    str = strdup(name);
    if (!str)
        return -ENOMEM;
    ret = spi_get_bus_and_cs(bus, cs, 50000000, SPI_MODE_0, "spi_generic_drv", str, &dev,
&spi_slave);
    if (ret)
        return ret;
#else
    spi_slave = spi_setup_slave(bus, cs, 50000000, SPI_MODE_0);
    if (!spi_slave) {
        /*
         * Invalid bus 1 (err=-19) means that spi1 is disabled in dts
         * Invalid chip select 1:0 (err=-19) means that there is no dev under spi1 bus in
dts
         * check it in uboot dtb or kernel dtb(if is enabled)
         *
         * btw, spi_get_bus_and_cs support no sub dev operation but spi_setup_slave can't
         */
        return -ENODEV;
    }
#endif

    if (spi_claim_bus(spi_slave))
        return -ENODEV;

    tx_data = 0x12345678;
    ret = spi_xfer(spi_slave, 32, &tx_data, &rx_data, SPI_XFER_BEGIN | SPI_XFER_END);

    spi_release_bus(spi_slave);

    pr_err("%s succuss\n", __func__);

    return ret;
}

注: spi 周辺機器は、dts デバイスの子ノードの spi-max-frequency 属性を介した速度を指定するとともに、spi_get_bus_and_cs/spi_setup_slave のセットアップ速度を伝送するなどをサポートしています。

5.23.5 テストコマンド {#5235-test-command}

cmd_spi関連のコマンドを使用します。

sspi 3:0.0 24 AAA           # bus3:cs0:mode0 Transmission length is 24bits Transmission data
is “AAA”

5.23.6 共通の問題の分析 {#5236-analysis-of-common-problems}

Q1:信号無しか。 A1:対応するiomuxとクロックが適切に設定されていることを確認してください。 Q2: RK3399 cmd_spi例外? A2: デフォルトでは、cmd ステージはカーネル dtb を使用します。 対応する spi がカーネル rk3399.dtsi aliases で指定されているかどうかを確認してください。 Q3: SPIがspi_setup_slaveを呼び出すのに失敗したのはなぜですか? A3: SPI バス ノードは、spi_setup_slave が正常に動作する可能性がある前にデバイスで行く必要がありますが、u-boot はバスの spi_generic_drv ドライバーの標準 dev を持っており、デバイス名は generic_1:0 です。これは spi_setup_slave の呼び出しで宣言されます。 Q4:ubootステージでspiの頻度を確認する方法か。 Q4: デバッグスイッチをオンにします

diff --git a/drivers/spi/rk_spi.c b/drivers/spi/rk_spi.c
index 836b94a24ec..8aaa51b9e84 100644
--- a/drivers/spi/rk_spi.c
+++ b/drivers/spi/rk_spi.c
@@ -24,6 +24,8 @@

 DECLARE_GLOBAL_DATA_PTR;

+#undef _DEBUG
+#define _DEBUG 1
 /* Change to 1 to output registers at the start of each transaction */
 #define DEBUG_RK_SPI   0

cmd/spi.c、主デバッギングのログ記述が付いている力をテストして下さい:

=> sspi 0:0.0 24 AAA
rockchip_spi_ofdata_to_platdata: base=ff500000, max-frequency=50000000, deactivate_delay=0
rsd=0
rockchip_spi_probe: probe
rockchip_spi_probe: rate = 200000000        # Controller Operating Clock
spi speed 50000000, div 4                   # io clock, io clock is output from the
controller's operating clock in 4 divisions
rockchip_spi_xfer: dout=07fd640c, din=07fd63ec, len=3, flags=3
activate cs0
deactivate cs0
000000

5.24 貯蔵 {#524-storage}

: ストレージドライバは標準ストレージフレームワークを使用し、アクセスインターフェースはBLKレイヤーにファイルシステムサポート用のインタフェースです。 現在、サポートされているストレージデバイスは、eMMC、Nand flash、SPI Nand flash、SPI Nor flash、フラッシュ関連のフレームワークは次のとおりです。

頭文字 主な対応粒子タイプ ホスト制御のドライバー フラッシュフレームワーク デバイス登録タイプ 主なサポートされているファイルシステム
rknandソリューション MLC TLC のナンド ドライバー/マンド ドライバー/マンド ブロックデバイス FAT、EXT、SquashFS
rkflashソリューション SLC のナンド、SPI のナンド ドライバー/ rkflash ドライバー/ rkflash ブロックデバイス FAT、EXT、SquashFS
rkflashソリューション(SPI Norサポート) SPI ノル ドライバー/ rkflash ドライバー/ rkflash ブロックまたはmtd装置 スカッシュFS、JFFS2
SLC の Nand のオープンソースの解決 SLC のナンド ドライバー/mtd/nand/raw ドライバー/mtd/nand/raw mtd装置 UBI
SPI の Nand のオープンソースの解決 SPI ナンド drivers/spi/rockchip_sfc.c ドライバー/mtd/nand/raw mtd装置 UBI
SPI の Nor のオープンソースの解決 SPI ノル drivers/spi/rockchip_sfc.c ドライバー/mtd/spi mtd または mtd ブロック装置 スカッシュFS、JFFS2

注:

  1. CNフラッシュとオープンソースのNandフラッシュサポートの主な違いは、rkflashがストレージドライバにrk ftl(Flash Transfer Layer)を統合するということです。オープンソースのftlは、ファイルシステム独自のフラッシュ管理に依存しています。例えば、UBIファイルシステムは、Nandフラッシュファイルシステムの特性に適した悪いブロック管理、ウェアのレベリングなどをサポートしています。 たとえば、UBIファイルシステムは、Nandフラッシュに適した悪いブロック管理、ウェアレベリング、その他のファイルシステムをサポートしています。

5.24.1フレームワークサポート {#5241-framework-support}

rknand rknandは、Nandcホストを介してNandフラッシュデバイスと通信する大容量のNandフラッシュデバイス用に設計されたストレージドライバです。 該当する粒子の選択については「RKNandFlashSupportList」を参照し、次の粒子が適用されます。 SLC、MLC、TLC Nandフラッシュ構成:

CONFIG_RKNAND

ドライバーファイル:

./drivers/rknand/

rkflash rkflashは、小型容量ストレージを使用するデバイス用に設計されたストレージドライバです。 ナンドフラッシュサポートは、NandcホストとNandフラッシュデバイス間の通信を通じて達成され、SFCホストとSPIフラッシュデバイス間の通信によってSPIフラッシュサポートが実現し、適用粒子の特定の選択は「RK SpiNorおよびSLC Nand SupportList」で見つけることができます。次の粒子に適用される128MB、 256MBおよび512MB SLCのNandのフラッシュ部分的なSPIのNandのフラッシュ部分的なSPIのNorのフラッシュ粒子の構成:

CONFIG_RKFLASH

CONFIG_RKNANDC_NAND  /* Small-capacity parallel port Nand flash */
CONFIG_RKSFC_NOR     /* SPI Nor flash */
CONFIG_RKSFC_NAND    /* SPI Nand flash */

ドライバーファイル:

./drivers/rkflash/

注:

  1. SFC(シリアルフラッシュコントローラー)は、Spiフラッシュの簡単なサポートのためにRockchipによって設計された特殊なモジュールです。

  2. rknandドライバは、rkflashドライバのNandコードのftlと互換性がないため、CONFIG_RKNANDとCONFIG_RKNANDC_NANDは同時に設定できません。 CONFIG_RKNAND と CONFIG_RKSFC_NAND は同時に設定できません。 MMC & SD MMCは、eMMCなどのマルチメディアカードです。SDは、半導体フラッシュメモリに基づく新しいメモリデバイスです。 ロックチッププラットフォームでは、一般的なdw_mmcコントローラー(rk3399、rk3399proを除く)を共有しています。 構成:

CONFIG_MMC_DW=y
CONFIG_MMC_DW_ROCKCHIP=y
CONFIG_CMD_MMC=y

ドライバーファイル:

./drivers/mmc/

SLC Nand & SPI Nand & SPI オープンソース プログラムのオープン ソース コミュニティの継続的な改善と UBI ファイル システムの機能の両立性のため、RK は、よりオープンソース コード プログラムと組み合わせるフラッシュを改良しました。また、オープンソース プログラムのデフォルトでは SPL スタートアップ プログラムのプリ ローダが SPL 起動プログラムのプログラムで、ほとんどの構成は SPL 関連の構成と組み合わせることによって完了します。 構成:

// MTD driver support
CONFIG_MTD=y
CONFIG_CMD_MTD_BLK=y
CONFIG_SPL_MTD_SUPPORT=y
CONFIG_MTD_BLK=y
CONFIG_MTD_DEVICE=y

// spi nand driver support
CONFIG_MTD_SPI_NAND=y
CONFIG_ROCKCHIP_SFC=y
CONFIG_SPL_SPI_FLASH_SUPPORT=y
CONFIG_SPL_SPI_SUPPORT=y

// nand driver support
CONFIG_NAND=y
CONFIG_CMD_NAND=y
CONFIG_NAND_ROCKCHIP=y /* NandC v6 can be cinfirmed basing on the register TRM NANDC-
>NANDC_NANDC_VER,0x00000801 */
//CONFIG_NAND_ROCKCHIP_V9=y  /* NandC v9 can be confirmed basing on the register TRM NANDC-
>NANDC_NANDC_VER, 0x56393030, For example: the version for RK3326/PX30  */
CONFIG_SPL_NAND_SUPPORT=y
CONFIG_SYS_NAND_U_BOOT_LOCATIONS=y
// The nand page size needs to be defined according to the real size, if you use NAND with
capacity greater than or equal to 512MB, you generally need to configure it as 4096.
#define CONFIG_SYS_NAND_PAGE_SIZE   2048

// spi nor driver support
CONFIG_CMD_SF=y
CONFIG_CMD_SPI=y
CONFIG_SPI_FLASH=y
CONFIG_SF_DEFAULT_MODE=0x1
CONFIG_SF_DEFAULT_SPEED=50000000
CONFIG_SPI_FLASH_GIGADEVICE=y
CONFIG_SPI_FLASH_MACRONIX=y
CONFIG_SPI_FLASH_WINBOND=y
CONFIG_SPI_FLASH_MTD=y
CONFIG_ROCKCHIP_SFC=y
CONFIG_SPL_SPI_SUPPORT=y
CONFIG_SPL_MTD_SUPPORT=y
CONFIG_SPL_SPI_FLASH_SUPPORT=y

rkflash/rknandマクロの設定を削除します。

CONFIG_RKFLASH=n
CONFIG_RKNAND=n

ドライバーファイル:

./drivers/mtd/nand/raw          //SLC Nand Master Driver and Protocol Layer
./drivers/mtd/nand/spi          //SPI Nand Protocol Layer
./drivers/spi/rockchip_sfc.c    //SPI Flash Master Driver
./drivers/mtd/spi               //SPI Nor Protocol Layer

5.24.2 関連するインタフェース {#5242-relevant-interface}

ストレージドライバのアクセスインターフェイスはBLKレイヤーにすべて差し込みます。そのため、どのストレージにアクセスするかは、次のインターフェースでアクセスされます。

// Getting a Storage Handle
struct blk_desc *rockchip_get_bootdev(void)

// Access interface
unsigned long blk_dread(struct blk_desc *block_dev, lbaint_t start,
                        lbaint_t blkcnt, void *buffer)
unsigned long blk_dwrite(struct blk_desc *block_dev, lbaint_t start,
                         lbaint_t blkcnt, const void *buffer)
unsigned long blk_derase(struct blk_desc *block_dev, lbaint_t start,
                         lbaint_t blkcnt)

5.24.3 ブートの貯蔵のタイプ差別化 {#5243-boot-storage-type-differentiation}

U-Bootの現在のブートストレージタイプは、環境変数に対応する文字列を介して2つの方法で区別されます。 devtypeとdevnum 。 if_typeおよびdevnumメンバー変数を介して、現在のstruct blk_desc構造(ハンドル)内の。

開発型 if_type コンテンツ ストレージタイプ 備考
ミリアンス IF_TYPE_MMC 0 eMMC -
ミリアンス IF_TYPE_MMC 1 SDカード -
mtdの IF_TYPE_MTD 0 ナンド mtd オープンソース プログラム
mtdの IF_TYPE_MTD 1 SPI ナンド mtd オープンソース プログラム
mtdの IF_TYPE_MTD 2 SPI ノル mtd オープンソース プログラム
キルンガンド IF_TYPE_RKNAND 0 ナンド rkflashプログラム
スピンアンド IF_TYPE_SPINAND 0 SPI ナンド rkflashプログラム
スピナー IF_TYPE_SPINOR 1 SPI ノル rkflashプログラム
ネヴメ IF_TYPE_NVME 0 SSD -
スカシ IF_TYPE_SCSI 0 SATA -

5.24.4 DTS の設定 {#5244-dts-configuration}

eMMC の設定:

// rkxxxx.dtsi configuration
emmc: dwmmc@ff390000 {
    compatible = "rockchip,px30-dw-mshc", "rockchip,rk3288-dw-mshc";
    reg = <0x0 0xff390000 0x0 0x4000>;      // Controller register base address and length
    max-frequency = <150000000>;            // eMMCThe eMMC normal mode clock is 50MHz, when
configured as eMMC
                                            //  HS200 mode, this max-frequency is in effect
    clocks = <&cru HCLK_EMMC>, <&cru SCLK_EMMC>,
         <&cru SCLK_EMMC_DRV>, <&cru SCLK_EMMC_SAMPLE>;   // Controller Clock Number
Corresponding to the controler
    clock-names = "biu", "ciu", "ciu-drv", "ciu-sample";  //  Controller Clock Name
    fifo-depth = <0x100>;                                 // fifo depth, default
configuration
    interrupts = <GIC_SPI 53 IRQ_TYPE_LEVEL_HIGH>;        // Interrupt Configuration
    status = "disabled";
};

// rkxxxx-u-boot.dtsi
&emmc {
    u-boot,dm-pre-reloc;
    status = "okay";
}

// rkxxxx.dts
&emmc {
    bus-width = <8>;                   // Device Bus Bit Width
    cap-mmc-highspeed;                 // Identifies this card slot as supporting highspeed
mmc
    mmc-hs200-1_8v;                    // Support for HS200
    supports-emmc;                     // Identifies this slot as eMMC capable, must be
added or peripheral cannot be initialized
    disable-wp;                        // For no physical WP pins, you need to configure
    non-removable;                     // This item indicates that the slot is a non-
removable device. This item is mandatory
    num-slots = <1>;                   // Marked as Slot No.
    status = "okay";
};

Nandc の設定:

&nandc0 {
    u-boot,dm-pre-reloc;
    status = "okay";
    #address-cells = <1>;
    #size-cells = <0>;

    nand@0 {
        u-boot,dm-pre-reloc;
        reg = <0>;
        nand-ecc-mode = "hw_syndrome";
        nand-ecc-strength = <16>;
        nand-ecc-step-size = <1024>;
    };
}

SFC の設定:

&sfc {
    u-boot,dm-pre-reloc;
    status = "okay";
    spi_nand: flash@0 {
        u-boot,dm-spl;
        compatible = "spi-nand";
        reg = <0>;
        spi-tx-bus-width = <1>;
        spi-rx-bus-width = <4>;
        spi-max-frequency = <96000000>;
    };
    spi_nor: flash@1 {
        u-boot,dm-spl;
        compatible = "jedec,spi-nor";
        reg = <0>;
        spi-tx-bus-width = <1>;
        spi-rx-bus-width = <4>;
        spi-max-frequency = <96000000>;
    };
};

注:

  1. ソフトウェアの互換性を考慮して、SPI-tx-bus-width = <1> と 1 つのライン SPI フラッシュ転送のみ u-boot でサポートされています。

5.24.5デュアルストレージ拡張 {#5245-dual-storage-expansion}

詳細はRockchip_Developer_Guide_Dual_Storage_CN.pdfドキュメントを参照してください。

5.24.6 共通問題の分析 {#5246-analysis-of-common-problems}

Q1: オープンソースソリューションFSPI/SFCコントローラのクロック周波数を調節して確認する方法は? A1: spi-max-frequency 属性の値を rkxxxx-u- boot.dtsi の sfc ノードの下に置き、無効なサブデバイスをオフにし、ドライバー内のデバッグメッセージに変わります。

diff --git a/drivers/spi/rockchip_sfc.c b/drivers/spi/rockchip_sfc.c
index 939b48e377c..62a425a29f4 100644
--- a/drivers/spi/rockchip_sfc.c
+++ b/drivers/spi/rockchip_sfc.c
@@ -790,7 +790,7 @@ static int rockchip_sfc_set_speed(struct udevice *bus, uint speed)
        sfc->cur_speed = speed;
        sfc->cur_real_speed = clk_get_rate(&sfc->clk);

-       dev_dbg(sfc->dev, "set_freq=%dHz real_freq=%dHz\n",
+       dev_err(sfc->dev, "set_freq=%dHz real_freq=%dHz\n",
                sfc->cur_speed, sfc->cur_real_speed);
 #else
        dev_dbg(sfc->dev, "sfc failed, CLK not support\n");

5.25 熱 {#525-thermal}

5.25.1フレームワークサポート {#5251-framework-support}

サーマルモジュールは、tsadcによって収集されたチップの温度を取得するために使用されます。デフォルトはCPU温度です。 フレームワークコード:

./drivers/thermal/thermal-uclass.c

ドライバーコード:

./drivers/thermal/rockchip_thermal.c

構成:

CONFIG_DM_THERMAL=y
CONFIG_ROCKCHIP_THERMAL=y

5.25.25.2 関連するインタフェース {#5252-relevant-interface}

// @temp: Save the acquired temperature
int thermal_get_temp(struct udevice *dev, int *temp)

5.25.3 DTS の設定 {#5253-dts-configuration}

カーネルの dts は、デフォルトで完全に設定され、有効になっています。

5.26 ユーアール {#526-uart}

シリアルはserial-uclass.cフレームワークと標準インタフェースを使用し、現在UARTデバッグを中心に使用されています。 構成:

// Enable configuration
CONFIG_DEBUG_UART
CONFIG_SYS_NS16550

// Parameter configuration
CONFIG_DEBUG_UART_BASE
CONFIG_DEBUG_UART_CLOCK
CONFIG_BAUDRATE

フレームワークコード:

./drivers/serial/serial-uclass.c

ドライバーコード:

./drivers/serial/ns16550.c

5.26.1 個人交換 {#5261-individual-replacement}

U-Boot フェーズの UART デバッグの個々の置換のプロセスは、次のようにします(uart2 を例に示します): CONFIG_ROCKCHIP_PRELOADER_SERIAL 無効; board_debug_uart_init() で uart iomux の設定 (注: 一部のプラットフォームには m0, m1… 設定するモードがあります)。 クロックソースが24Mhzであることを確認するために、board_debug_uart_init()でuart時計を設定してください。 defconfigはCONFIG_BAUDRATEを更新します。 defconfigはCONFIG_DEBUG_UART_BASEを更新します。 U-Bootのuartノードに2つの必須属性を追加し、有効にします。

&uart2 {
    u-boot,dm-pre-reloc;
    clock-frequency = <24000000>;
    status = "okay";
};

U-Boot 選択したノードで stdout-path を指定します。

chosen {
    stdout-path = &uart2;
};

5.26.2 グローバル置換 {#5262-global-replacement}

プリローダーシリアルは、以前のファームウェア間でUARTデバッグ構成の共有を実現する仕組みです。:ddr、miniloader、b31、op-tee、U-Bootなど。 その原則: UART デバッグは、最も早い ddr bin によって構成され、ATAGS パラメータの渡るメカニズムを継承し、ファームウェアのすべてのレベルが UART デバッグ構成を取得し、それを使用する(カーネルを除く)。

ユーザーは、ddr bin のシリアルポート構成を変更することで UART デバッグのグローバル置換を実現できます。DDR bin の設定は次のようになります。

rkbinリポジトリは、シリアルポートの置換を含む異なるパラメータを設定するためにユーザーのためのツールを提供します。

tools/ddrbin_tool
tools/ddrbin_param.txt
tools/ddrbin_tool_user_guide.txt

U-Boot 設定 1 では、設定を有効にします。

CONFIG_ROCKCHIP_PRELOADER_SERIAL  // Already enabled by default

2 rkxx-u-boot.dtsi は、uart ノードに “u-boot,dm-pre-reloc” という属性を「u-boot,dm-pre-reloc」に追加します。;3 エイリアスは、U-Boot がターゲットノードを見つけ、エイリアスを介して初期化するため、シリアルエイリアスを確立します。 例えば: . /arch/arm/dts/rk1808-u-boot.dtsi は、すべてのuarts のエイリアスを利便性のために作成します。

aliases {
    mmc0 = &emmc;
    mmc1 = &sdmmc;

// Alias must be created
    serial0 = &uart0;
    serial1 = &uart1;
    serial2 = &uart2;
    serial3 = &uart3;
    serial4 = &uart4;
    serial5 = &uart5;
    serial6 = &uart6;
    serial7 = &uart7;
};

.....

// Must add u-boot,dm-pre-reloc attribute
&uart0 {
    u-boot,dm-pre-reloc;
};
&uart1 {
    u-boot,dm-pre-reloc;
};
&uart2 {
    u-boot,dm-pre-reloc;
    clock-frequency = <24000000>;
    status = "okay";
};
&uart3 {
    u-boot,dm-pre-reloc;
};
&uart4 {
    u-boot,dm-pre-reloc;
};

5.26.3 印刷を断ち切って下さい {#5263-turn-off-printing}

CONFIG_DISABLE_CONSOLE=y

5.26.4 の関連したインターフェイス {#5264-relevant-interface}

// UART debug interface
void putc(const char c);
void puts(const char *s);
int printf(const char *fmt, ...);
void flushc(void);

// General UART interface for communication with peripherals
int serial_dev_getc(struct udevice *dev);
int serial_dev_tstc(struct udevice *dev);
void serial_dev_putc(struct udevice *dev, char ch);
void serial_dev_puts(struct udevice *dev, const char *str);
void serial_dev_setbrg(struct udevice *dev, int baudrate);
void serial_dev_clear(struct udevice *dev);

5.27 USB {#527-usb}

U-Boot USBは、主にDevcie、Host、PHY、USB周辺ドライバを含み、フレームワーク構成、ボードレベルの構成、関連するコマンドの使用について詳しく説明します。

5.27.1フレームワークサポート {#5271-framework-support}

デバイスデバイスデバイスは、一般的にファームウェアのアップグレード、ファームウェア検証などのロックスブまたはファストブートモードとして構成されているGadgetフレームワーク(DM_USBなし)に基づいています。 ロックスブプロトコルは、UMSプロトコルに基づいており、ロックスブドライバの実装で参照できるHOOKの形でUMSフレームワークにその状態マシンが埋め込まれています。 現在、USBデバイスコントローラー、DWC2、DWC3の2種類があります。通常、チップはOTGコントローラの1つだけを統合するので、コンフィグのコントローラー関連構成を1種類有効化するだけで、設定が必要なコントローラーはチップのTRMやRockchipUSB開発ガイドを参照してください。 構成:

CONFIG_USB=y
// gadget configuration
CONFIG_USB_GADGET=y
CONFIG_USB_GADGET_MANUFACTURER="Rockchip"
CONFIG_USB_GADGET_VENDOR_NUM=0x2207
CONFIG_USB_GADGET_PRODUCT_NUM=0x330a // Configured based on chip ID
CONFIG_USB_GADGET_VBUS_DRAW=2
CONFIG_USB_GADGET_DUALSPEED=y

// rockusb configuration
#define CONFIG_USB_FUNCTION_MASS_STORAGE // placed in include/configs/rkxxx_common.h
CONFIG_USB_GADGET_DOWNLOAD=y
CONFIG_CMD_ROCKUSB=y

// DWC3 Controller Configuration
CONFIG_USB_DWC3=y
CONFIG_USB_DWC3_GADGET=y

// DWC2 Controller Configuration
CONFIG_USB_GADGET_DWC2_OTG=y

フレームワークコード:

// gadget framework
drivers/usb/gadget/g_dnl.c
drivers/usb/gadget/g_dnl.c
drivers/usb/gadget/config.c
drivers/usb/gadget/epautoconf.c
drivers/usb/gadget/usbstring.c
drivers/usb/gadget/f_mass_storage.c

ドライバーコード:

// rockusb
cmd/rockusb.c
drivers/usb/gadget/f_rockusb.c

// controller
drivers/usb/gadget/dwc2_udc_otg* // dwc2 OTG controller
drivers/usb/dwc3 // dwc3 OTG controller

ホストホスト・コントローラーには、xHCI デバイスをサポートできる USB3 と EHCI と xHCI が組み込まれていますが、すべてのチップは xHCI コントローラを統合しています。特定の統合状況は、チップ TRM または Rockchip USB 開発ガイドを参照する必要があります。 ホスト開発は、主にDTSにコントローラーの適応についてです。 構成:

CONFIG_USB=y
CONFIG_DM_USB=y
// xHCI
CONFIG_USB_HOST=y
CONFIG_USB_XHCI_HCD=y
CONFIG_USB_XHCI_DWC3=y
CONFIG_USB_DWC3_GENERIC=y

// EHCI
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_EHCI_GENERIC=y

// OHCI
#define CONFIG_USB_OHCI_NEW // in the include/configs/rkxxx_common.h
#define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS      1
CONFIG_USB_OHCI_HCD=y
CONFIG_USB_OHCI_GENERIC=y

フラムワークコード:

// Framwork code
cmd/usb.c
drivers/usb/host/usb-uclass.c

// EHCI
drivers/usb/host/ehci-generic.c
drivers/usb/host/ehci-hcd.c

// OHCI
drivers/usb/host/ohci-generic.c
drivers/usb/host/ohci-hcd.c

// xHCI
drivers/usb/host/xhci.c
drivers/usb/host/xhci-dwc3.c
drivers/usb/host/xhci-mem.c
drivers/usb/host/xhci-ring.c

PHY U-Boot USB PHY は、USB2 と USB3 PHY ドライバーから構成されており、DM_USB の設定で Linux カーネル DTB と互換性があります。 特定の PHY IP の統合のために、チップ TRM または Rockchip USB PHY 開発ガイドを参照する必要があります。 構成:

CONFIG_PHY=y

// INNO USB2
CONFIG_PHY_ROCKCHIP_INNO_USB2=y
// INNO USB3
CONFIG_PHY_ROCKCHIP_INNO_USB3=y
// NANENG USB2
CONFIG_PHY_ROCKCHIP_NANENG_USB2=y
// NANENG COMBOPHY
CONFIG_PHY_ROCKCHIP_NANENG_COMBOPHY=y
// RK3399 USBDP PHY
CONFIG_PHY_ROCKCHIP_TYPEC=y

フレームワークコード:

drivers/phy/phy-uclass.c

ドライバーコード:

// INNO USB2
drivers/phy/phy-rockchip-inno-usb2.c
// INNO USB3
drivers/phy/phy-rockchip-inno-usb3.c
// NANENG USB2
drivers/phy/phy-rockchip-naneng-usb2.c
// NANENG COMBOPHY
drivers/phy/phy-rockchip-naneng-combphy.c
// RK3399 USBDP PHY
drivers/phy/phy-rockchip-typec.c

** その他の周辺機器** U-Boot USB周辺サポートは、主にUSBハブ、USBキーボード、UMSデバイスについてです。 構成:

// USB Keyboard
CONFIG_USB_KEYBOARD=y
CONFIG_USB_KEYBOARD_FN_KEYS=y // Support F1-F12, INS, HOME and other shortcuts.

// USB storage device
CONFIG_USB_STORAGE=y

フレームワークコード:

// Framework code
common/usb.c
drivers/usb/host/usb-uclass.c

// USB keyboard
drivers/input/usb_kbd.c
drivers/input/keyboard-uclass.c

// USB storage device
common/usb/usb_storage.c

5.27.2 ボード構成 {#5272-board-configuration}

USBデバイスがDM_USBメソッドを使用しないので、USBコントローラーのアドレスやTX FIFOのサイズなど、ボードファイル内の対応するコントローラのプロパティーを設定する必要があります。

// DWC3 Controller Configuration
// board/rockchip/evb_rk3399/evb_rk3399.c
#ifdef CONFIG_USB_DWC3
static struct dwc3_device dwc3_device_data = {
    .maximum_speed = USB_SPEED_HIGH,
    .base = 0xfe800000, // Modified according to different chip USB OTG controller base
address
    .dr_mode = USB_DR_MODE_PERIPHERAL,
    .index = 0,
    .dis_u2_susphy_quirk = 1,
    .usb2_phyif_utmi_width = 16,
};

int usb_gadget_handle_interrupts(void)
{
    dwc3_uboot_handle_interrupt(0);
    return 0;
}

int board_usb_init(int index, enum usb_init_type init)
{
    return dwc3_uboot_init(&dwc3_device_data);
}
#endif

// The DWC2 controller configuration is implemented in the rockchip generic board.c file and
generally does not need to be modified
// arch/arm/mach-rockchip/board.c

USBキーボード

U-Boot標準入力デバイスとしてUSBキーボードを使用する場合は、stdin環境変数にusbkbdを追加する必要があります。参照コードは以下の通りです。

// Environment variable configuration is located in each board header file
// include/configs/evb_rk3568.h

#define ROCKCHIP_DEVICE_SETTINGS \
        "stdin=serial,usbkbd\0" \

5.27.3 DTS の設定 {#5273-dts-configuration}

前述したように、USBデバイスはDM_USBメソッドを使用しないため、関連するDTノードの設定を必要としません。 USBホストとUSB PHYドライバはLinuxカーネルDTBと互換性がありますので、LinuxカーネルDTBを直接使用でき、U-Boot DTBの使用を設定したい場合は、Linuxカーネル内の関連ノードの実装を参照できます。

岩スブ

rockusb - Use the rockusb Protocol

Usage:
rockusb <USB_controller> <devtype> <dev[:part]>  e.g. rockusb 0 mmc 0

U-Boot の loader のアップグレードモードを以下のように入力する3つの方法があります。リセット + revovery キーストロークでアクセスされた U-Boot コマンドラインを入力し、上記のコマンドを実行して、rockusb をオンにしてアップグレードモードに入ります。システムに入った後、コマンド行で「reboot loader」を実行して、アップグレードモードにソフトリブートします。 usb

usb - USB sub-system

Usage:
usb start - start (scan) USB controller
usb reset - reset (rescan) USB controller
usb stop [f] - stop USB [f]=force stop
usb tree - show USB device tree
usb info [dev] - show available USB devices
usb test [dev] [port] [mode] - set USB 2.0 test mode
    (specify port 0 to indicate the device's upstream port)
    Available modes: J, K, S[E0_NAK], P[acket], F[orce_Enable]
usb storage - show details of USB storage devices
usb dev [dev] - show or set current USB storage device
usb part [dev] - print partition table of one or all USB storage    devices
usb read addr blk# cnt - read `cnt' blocks starting at block `blk#'
    to memory address `addr'
usb write addr blk# cnt - write `cnt' blocks starting at block `blk#'
    from memory address `addr'

U-Boot USBは、デバイスのホットプラグとプラグを差し込み、接続を解除するサポートをしていません。そのため、USBコマンドを実行してデバイスを列挙および切断する必要があります。 コントローラーノードをパースし、デバイスを「usb start」または「usb reset」コマンドですべてのポートにコンネントするスキャンを行います。 デバイスを全て切断し、コントローラデバイスを「usb stop」コマンドで分解します。 現在接続しているデバイスに関する情報と情報(usb info)と「usb tree」コマンドで確認できます。 UMS 関数の「usb ストレージ」と次のコマンドは、コマンドの説明を参照してください。fastboot セクション CH04 システム モジュール、ファストブートの構成と使用を参照してください。

5.28 ベンダーの貯蔵 {#528-vendor-storage}

SN、MACなどの小さなデータを暗号化する必要はありません。 データを更新する際に、複数のバックアップでNVM(eMMC、NANDなど)の保存されたパーティションに保存されているため、データが高信頼性で保持され、失われません。 詳細は「appnote rkベンダーストレージ」を参照してください。

5.28.1 原則概要 {#5281-principle-overview}

ベンダーブロックは、4つのパーティション、vendor0、vendor1、vendor2、およびvendor3に分割され、各vendorX(X=0、1,2、3)は、vendorXが更新されたときに時間を示すために、そのHDrの単方向に増分バージョンフィールドを持っています。 各読み取り操作は、最新のvendorX(最大バージョン)のみを読み、書き込み操作はバージョンを更新し、すべての既存および新しい情報をvendorX+1パーティションに移動します。 例えば、vendor2 から読み込まれると、それを修正して、それを返しすると、vendor3 に書きます。 シンプルで簡単なセキュリティ対策です。

5.28.2フレームワークサポート {#5282-framework-support}

U-Bootフレームワークは、ベンダーストレージ機能をサポートしていません。Rockchipは、Vendor Storageドライバの独自のセットを実装しています。 設定:

CONFIG_ROCKCHIP_VENDOR_PARTITION

ドライバーファイル:

./arch/arm/mach-rockchip/vendor.c
./arch/arm/include/asm/arch-rockchip/vendor.h

5.28.3 関連するインターフェイス {#5283-relevant-interface}

int vendor_storage_read(u16 id, void *pbuf, u16 size)
int vendor_storage_write(u16 id, void *pbuf, u16 size)

idの定義と使用については、appnote rkベンダーのストレージを参照してください。

5.28.4 機能自己テスト {#5284-functionality-self-test}

ベンダーストレージ機能は、U-Bootシリアルコマンドラインから「rktestvener」コマンドを使用して自動テストできます。

5.29 ウォッチドッグ {#529-watchdog}

5.29.1フレームワークサポート {#5291-framework-support}

watchdog ドライバーは、wdt-uclass.c フレームワークと標準インターフェイスを使用します。 設定:

CONFIG_WDT
CONFIG_ROCKCHIP_WATCHDOG

フレームワーク コード:

./drivers/watchdog/wdt-uclass.c

ドライバーコード

./drivers/watchdog/rockchip_wdt.c

5.29.2 関連するインターフェイス {#5292-relevant-interface}

// Set the timeout for feeding the dog and start wdt (@flags is 0 by default)
int wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags);
// Close wdt
int wdt_stop(struct udevice *dev);
// feed the dog
int wdt_reset(struct udevice *dev);
// Ignore this please, no underlying driver implementation done at this time
int wdt_expire_now(struct udevice *dev, ulong flags)

現在、U-Bootはデフォルトプロセスでwdt関数を有効または使用していません。ユーザーは自社の製品要件に従って有効にすることができます。

6. .. 第6章 上級原則 {#6-chapter-6-advanced-principle}

6.1 カーネルDTB {#61-kernel-dtb}

6.1.1 デザインの背景 {#611-design-background}

U-Bootのネイティブアーキテクチャは、U-Boot dts が 1 つのボードに 1 つの U-Boot dts に対応する必要があり、U-Boot dts によって生成された dtb は U-Boot 独自のイメージにパッケージ化されます。 それぞれのSoCプラットフォーム上でU-BootイメージのNコピーを必要とするNボードで結果が出ます。 SoCプラットフォームの異なる基板間の大きな違いは、周辺機器であり、SoCのコア部分が同じであることは分かりにくいわけではありません。 RKプラットフォームは、SoCプラットフォームが1つのU-Bootイメージだけを必要とすることを実現するために、カーネルDTBメカニズムを追加しました。 本質は、以前の段階でカーネルDTBにカットし、その設定情報で周辺機器を初期化することです。 そのため、RKプラットフォームは、カーネルDTBをサポートすることで、ディスプレイ、レミック/レギュレータ、ピンクセル、クなど、ボードの差分と互換性を得ることができます。 カーネルDTBの有効化は、OF_LIVE(ライブデバイスツリー、ショート:ライブドット)に依存しています。

config USING_KERNEL_DTB
        bool "Using dtb from Kernel/resource for U-Boot"
        depends on RKIMG_BOOTLOADER && OF_LIVE
        default y
        help
          This enable support to read dtb from resource and use it for U-Boot,
          the uart and emmc will still using U-Boot dtb, but other devices like
          regulator/pmic, display, usb will use dts node from kernel.

6.1.2 ライブデバイスツリー {#612-live-device-tree}

背景と合理:カーネルDTBの導入後、U-BootステージのDTBの2つのコピーが2つあります。ストレージ、シリアル、暗号などのモジュールはU-Boot DTBに関係しており、残りのモジュールはカーネルDTBに関連しています。 U-Boot ステージでは、異なる瞬間にこれらの 2 つのタイプのモジュールへのアクセスをクロスする必要があるかもしれません。また同時に、モジュールは独自の DTB ノード情報にアクセスする必要があります。 そのため、これらの2つのモジュールは異なるDTBに属し、gd->fdt_blobはそれらのいずれかを指すことができ、それらの間で切り替えるのは簡単です。 カーネルの dts は最終的にカーネルに渡されるため、U-Boot dts から 1 つのコピーを作成するカーネル dts まで、いくつかのノードをオーバーレイするだけではいけません。

ライブdtは、この問題を解決することができます。ライブdtの原則は次のとおりです。初期化フェーズでは、U-BootはDTB全体を直接スキャンし、すべてのDTBノードをdevice_nodeノードリストに変換し、特定のデバイスドライバにそれらを結合します。 将来的に、デバイスドライバがDTBノードにアクセスしたいと考えているとき、それは直接独自のdevice_nodeにアクセスすることができ、元のDTBに再びアクセスする必要はありません。 つまり、U-BootとカーネルDTBの両方がそれぞれのデバイスドライバグループにバインドされていることと同等であり、DTBファイルに直接アクセスする必要はありません。 DTB の2セットにアクセスすることで、その競合を解決します。 より多くの参照:

./doc/driver-model/livetree.txt

fdt とライブ dt 変換: ノードタイプ (include/dm/ofnode.h) は、両方のタイプの dt でサポートされているカプセル化フォーマットです。 ライブdt を使用する場合、device_node は dt ノードにアクセスし、fdt を使用するときには、 dt ノードにアクセスするために offset を使用します。 ドライバーの種類を両方サポートする必要がある場合は、ノードタイプを使用してください。 ノード構造:

/*
 * @np: Pointer to device node, used for live tree
 * @of_offset: Pointer into flat device tree, used for flat tree. Note that this
 *      is not a really a pointer to a node: it is an offset value. See above.
 */
typedef union ofnode_union {
        const struct device_node *np;   /* will be used for future live tree */
        long of_offset;
} ofnode;

関数は「dev_」、“ofnode_” で始まる関数は、dt アクセスメソッドの両方をサポートする関数です。 関数は、ライブdt をサポートするインターフェイスです。 関数は「fdtdec_」から始まり、fdt_ は、 適合をサポートするインタフェースです。

6.1.3 達成するメカニズム {#613-mechanisms-to-achieve}

カーネルdtbスイッチは、init_kernel_dtb()の. /arch/arm/mach-rockchip/board.cで実装されています。 今回は、U-Bootのdtsをスキャンし、mmc/nand/norストレージドライバが正常に動作している。 この点で、ファームウェアからカーネルのdtbを読み、ライブdtテーブルを作成し、すべてのデバイスドライバをバインドし、最終的にgd->fdt_blobポインターをカーネルdtbに指すように更新します。

6.1.4 Uボット {#614-u-boot}

U-Boot がコンパイルされた後、 . /dts/ ディレクトリの 2 dtbs が生成されます。: dt.dtb: dt.dtb: dtb で指定された dts からコンパイルされる defconfig で CONFIG_DEFAULT_DEVICE_TREE で指定された dtb からコンパイルします。 dt-spl.dtb: u-boot,dm-pre-reloc プロパティを持つすべてのノードを抽出することで dtb から取得します。 defconfig で CONFIG_OF_SPL_REMOVE_PROPS で指定されたプロパティを削除します。 一般的に、シリアルポート、DDR、ストレージなどドライバで確実に接続する必要があるノードのみが含まれている:DMC、UART、MC、NAND、GRF、CRUなど。 CONFIG_USING_KERNEL_DTBが有効になっていないとき、システムではdt.dtbが使われます。CONFIG_USING_KERNEL_DTBが有効になっていると、システムではdt-spl.dtbを使用します。 dt.dtb または dt-spl.dtb は U-Boot コンパイルの最後に u-boot.dtb と名付けられ、その後 u-boot.bin の終了に付属しています。

ユーザーは、fdtdumpコマンドでu-boot.dtbの内容を確認できます。

6.2カーネルパスパラメータ {#62-kernel-pass-parameter}

この章では、U-Bootがカーネルにパラメータを渡す方法について説明します。

6.2.1 シンドリン {#621-cmdline}

U-Boot は、カーネル DTB から /chosen/bootargs を読み込み、新しいコンテンツで修正/追加し、cmdline を渡す目的で /chosen/bootargs ノードに戻します。

6.2.2 記憶容量 {#622-memory-capacity}

U-Boot は、カーネル DTB の /memory ノードを 変更し、利用可能なメモリ容量情報を入力します。 ブート情報を印刷します。

......
## Chapter-6 Booting Android Image at 0x0027f800 ...
Kernel load addr 0x00280000 size 23387 KiB
RAM disk load addr 0x0a200000 size 782 KiB
## Chapter-6 Flattened Device Tree blob at 08300000
   Booting using the fdt blob at 0x8300000
   XIP Kernel Image ... OK
  'reserved-memory' ramoops@110000: addr=110000 size=f0000
   Using Device Tree in place at 0000000008300000, end 0000000008314648

// Memory space available to the kernel
Adding bank: 0x00200000 - 0x08400000 (size: 0x08200000)
Adding bank: 0x0a200000 - 0x80000000 (size: 0x75e00000)
Total: 473.217 ms

Starting kernel ...

6.2.3 他の方法 {#623-other-ways}

パラメータを渡す他のすべての方法は、カーネルDTBを基本的に変更します。

ノデックス/アトリビュート 操作 効果
/serial-number(シリアル番号) 作成する シリアル番号
インフォメーション 変更する カーネルの可視性記憶
/display-subsystem/route/route-edp/ を出力する おすすめ 関連パラメータ(例:edp)を表示
/chosen/linuxのinitrd開始 作成する ramdisk の開始アドレス
/chosen/linuxのinitrdエンド 作成する ラムディスクエンドアドレス
ブータルグ 変更する カーネルに表示されているcmdline
GMACノード内のmac-addressまたはローカルmac-address 変更する macアドレス
arch/arm/mach-rockchip/board.c: board_fdt_fixup() 変更する ボードfdtの修正

6.3 ABシステム {#63-ab-system}

6.3.1 ABデータフォーマット {#631-ab-data-format}

A/B のデータ構造は、誤ったパーティションから 2KB オフセット にあります。

/* Magic for the A/B struct when serialized. */
#define AVB_AB_MAGIC "\0AB0"
#define AVB_AB_MAGIC_LEN 4

/* Versioning for the on-disk A/B metadata - keep in sync with avbtool. */
#define AVB_AB_MAJOR_VERSION 1
#define AVB_AB_MINOR_VERSION 0

/* Size of AvbABData struct. */
#define AVB_AB_DATA_SIZE 32

/* Maximum values for slot data */
#define AVB_AB_MAX_PRIORITY 15
#define AVB_AB_MAX_TRIES_REMAINING 7

typedef struct AvbABSlotData {
  /* Slot priority. Valid values range from 0 to AVB_AB_MAX_PRIORITY,
   * both inclusive with 1 being the lowest and AVB_AB_MAX_PRIORITY
   * being the highest. The special value 0 is used to indicate the
   * slot is unbootable.
   */
  uint8_t priority;

  /* Number of times left attempting to boot this slot ranging from 0
   * to AVB_AB_MAX_TRIES_REMAINING.
   */
  uint8_t tries_remaining;

  /* Non-zero if this slot has booted successfully, 0 otherwise. */
  uint8_t successful_boot;

  /* Reserved for future use. */
  uint8_t reserved[1];
} AVB_ATTR_PACKED AvbABSlotData;

/* Struct used for recording A/B metadata.
 *
 * When serialized, data is stored in network byte-order.
 */
typedef struct AvbABData {
  /* Magic number used for identification - see AVB_AB_MAGIC. */
  uint8_t magic[AVB_AB_MAGIC_LEN];

  /* Version of on-disk struct - see AVB_AB_{MAJOR,MINOR}_VERSION. */
  uint8_t version_major;
  uint8_t version_minor;

  /* Padding to ensure |slots| field start eight bytes in. */
  uint8_t reserved1[2];

  /* Per-slot metadata. */
  AvbABSlotData slots[2];

  /* Reserved for future use. */
  uint8_t reserved2[12];

  /* CRC32 of all 28 bytes preceding this field. */
  uint32_t crc32;
} AVB_ATTR_PACKED AvbABData;

誤ったパーティションを持たない大容量ストレージの場合、ベンダーのパーティションがない場合、ベンダーに保存を検討してください。 最後の起動可能なファームウェアをマークするためにLastbootを追加します。 主に、再試行カウントが使用され、boot_ctrlサービスはシステムによってまだ呼ばれていない場合、低電力状況や工場生産テストで使用されます。 参照は次のようにします。

typedef struct AvbABData {
  /* Magic number used for identification - see AVB_AB_MAGIC. */
  uint8_t magic[AVB_AB_MAGIC_LEN];

  /* Version of on-disk struct - see AVB_AB_{MAJOR,MINOR}_VERSION. */
  uint8_t version_major;
  uint8_t version_minor;

  /* Padding to ensure |slots| field start eight bytes in. */
  uint8_t reserved1[2];

  /* Per-slot metadata. */
  AvbABSlotData slots[2];

  /* mark last boot slot */
  uint8_t last_boot;
  /* Reserved for future use. */
  uint8_t reserved2[11];

  /* CRC32 of all 28 bytes preceding this field. */
  uint32_t crc32;
} AVB_ATTR_PACKED AvbABData;

また、is_update フラグビットを AvbABSlotData に追加して、システムアップグレードのステータスをフラグ付けし、次のように変更します。

typedef struct AvbABSlotData {
  /* Slot priority. Valid values range from 0 to AVB_AB_MAX_PRIORITY,
   * both inclusive with 1 being the lowest and AVB_AB_MAX_PRIORITY
   * being the highest. The special value 0 is used to indicate the
   * slot is unbootable.
   */
  uint8_t priority;

  /* Number of times left attempting to boot this slot ranging from 0
   * to AVB_AB_MAX_TRIES_REMAINING.
   */
  uint8_t tries_remaining;

  /* Non-zero if this slot has booted successfully, 0 otherwise. */
  uint8_t successful_boot;

  /* Mark update state, mark 1 if the slot is in update state, 0 otherwise. */
  uint8_t is_update : 1;
  /* Reserved for future use. */
  uint8_t reserved : 7;
} AVB_ATTR_PACKED AvbABSlotData;

表は、各パラメータの意味を示します。AvbABData:

パラメータ 意味
優先順位 フラグスロット優先順位、0は起動できません。15は最優先
tries_remaining 開始する試みの数、7に設定
successful_boot このパラメータは、システムが正常に起動した後に構成されます。 1: スロットは正常に起動します。 0: スロットは正常に起動しません
is_update スロットのアップグレード状況をマークします。1:スロットはアップグレードされています。0:スロットはアップグレードされていないか、正常にアップグレードされた状態です。

AvbABSlotData: 仕様:

パラメータ 意味
魔法の魔法 構造のヘッダー情報:\0AB0
version_major メジャーバージョン情報
version_minor マイナーバージョン情報
スロット スロット ブート情報、AvbABData を参照してください。
last_boot 最後の成功したブートスロット、0:スロットAの最後のブートが成功しました、1:スロットBは最後のブートを成功させました
サーキュ32 データ検証

6.3.2 ABの活発化モード {#632-ab-activation-mode}

現在、システムブートタルは2つの制御モードで設計されており、ブートローダは両方のモードをサポートしています。

6.3.2.1 成功するブート {#6321-successful-boot}

正常にシステムに入ると、boot_ctrlはandroidboot.slot_suffixに基づいており、現在のスロット変数を設定します。

successful_boot = 1;
priority = 15;
tries_remaining = 0;
is_update = 0;
last_boot = 0 or 1;     :refer to androidboot.slot_suffix

boot_ctrlの設定でシステムを更新して下さい:

Upgraded slot settings:
successful_boot = 0;
priority = 14;
tries_remaining = 7;
is_update = 1;
lastboot = 0 or 1;     :refer to androidboot.slot_suffix

Current Slot Settings:
successful_boot = 1;
priority = 15;
tries_remaining = 0;
is_update = 0;
last_boot = 0 or 1;     :refer to androidboot.slot_suffix

システム アップグレードが完了しました、boot_ctrl セット:

Upgraded slot settings:
successful_boot = 0;
priority = 15;
tries_remaining = 7;
is_update = 0;
lastboot = 0 or 1;     :refer to androidboot.slot_suffix

Current Slot Settings:
successful_boot = 1;
priority = 14;
tries_remaining = 0;
is_update = 0;
last_boot = 0 or 1;     :refer to androidboot.slot_suffix
6.3.2.2 リセットリトリー {#6322-reset-retry}

正常にシステムに入ると、boot_ctrlはandroidboot.slot_suffixに基づいており、現在のスロット変数を設定します。

successful_boot = 0;
priority = 15;
tries_remaining = 7;
is_update = 0;
last_boot = 0 or 1;     :refer to androidboot.slot_suffix

boot_ctrlの設定でシステムを更新して下さい:

Upgraded slot settings:
successful_boot = 0;
priority = 14;
tries_remaining = 7;
is_update = 1;
lastboot = 0 or 1;     :refer to androidboot.slot_suffix

Current Slot Settings:
successful_boot = 0;
priority = 15;
tries_remaining = 7;
is_update = 0;
last_boot = 0 or 1;     :refer to androidboot.slot_suffix

改善システム完了、boot_ctrlセット:

Upgraded slot settings:
successful_boot = 0;
priority = 15;
tries_remaining = 7;
is_update = 0;
lastboot = 0 or 1;     :refer to androidboot.slot_suffix

Current Slot Settings:
successful_boot = 0;
priority = 14;
tries_remaining = 7;
is_update = 0;
last_boot = 0 or 1;     :refer to androidboot.slot_suffix
6.3.2.3モードの比較 {#6323-mode-comparison}

successful_bootモード 利点:システムが正常に起動している限り、システムbootctrlが構成されていない限り、それは古いファームウェアバージョンに戻りません 欠点:デバイスが異常に粒子を格納している場合は、デバイスが長時間作業してきた後、システムがすべての時間のリセット再試行モードを再起動する原因となります 利点:常にリトライ機構を維持し、ストレージ例外の問題に対処することができます 欠点: 古いファームウェアバージョンに戻る 5月 以前のファームウェアバージョンに落ちる

6.3.3 ブートプロセス {#633-boot-process}

AB successful_bootモードデータフロー:

AB は再試行モードのデータフローをリセットします。

6.3.4 アップグレードと例外 {#634-upgrade-and-exceptions}

システムアップグレード: RockchipLinuxアップグレードプログラム開発ガイドを参照してください。 回復アップグレード:ABシステムは、回復のアップグレードをサポートしていません。

6.3.5 検証方法 {#635-validation-methods}

6.3.5.1 成功フルブート {#6351-successful-boot}
  1. スロットAのみを書き込み、システムがスロットAから起動します。 スロットBから起動するセットアップ、スロットAからシステムブート。 完了したテストは、誤ったパーティションをクリアします。

  2. スロット A とスロット B を書き込み、システムを起動し、現在のシステムは A のスロットです。 スロットBから起動するシステムを設定し、システムを再起動すると、現在のシステムはBスロットです。 完了したテストは、誤ったパーティションをクリアします。

  3. スロットAとスロットBを書いて、システム14回を素早くリセットすると、再試行カウンターが実行され、システムはまだlast_bootで指定されたシステムから起動することができます。つまり、通常はスロットAから起動できます。 完了テスト、誤ったパーティションをクリア

  4. スロット A とスロット B を書き込み、システムを起動し、現在のシステムは A のスロットです。 スロットBから起動するシステムを設定し、システムを再起動し、現在のシステムはBスロットです。 スロットAから起動するシステムを設定し、システムを再起動し、現在のシステムはAスロットです。 完了したテストは、誤ったパーティションをクリアします。

6.3.5.2 リセットリトリー {#6352-reset-retry}
  1. スロットAのみを書き込み、システムがスロットAから起動します。 スロットBから起動するセットアップ、スロットAからシステムブート。 完了したテスト、明確な誤った仕切り

  2. スロット A とスロット B を書き込み、システムを起動し、現在のシステムは A のスロットです。 スロットBから起動するシステムを設定し、システムを再起動すると、現在のシステムはBスロットです。 完了したテストは、誤ったパーティションをクリアします。

  3. スロットAとスロットBを書いて、システム14回を素早くリセットすると、再試行カウンターが実行され、システムはまだlast_bootで指定されたシステムから起動することができます。つまり、通常はスロットAから起動できます。 完了テスト、誤ったパーティションをクリア

  4. スロットBのboot.imgが破損しているスロットAとスロットBを書き、システム、現在のシステムを起動します

スロット A. システムをスロットBから起動し、システムを再ブートするように設定して下さい、システムは7回再起動し、そしてスロットAから通常システムをブートします。 完了テスト、誤ったパーティションをクリア

  1. スロット A とスロット B を書き込み、システムを起動し、現在のシステムは A のスロットです。 スロットBから起動するシステムを設定し、システムを再起動し、現在のシステムはBスロットです。 スロットAから起動するシステムを設定し、システムを再起動し、現在のシステムはAスロットです。 完了したテストは、誤ったパーティションをクリアします。

6.3.6 参照 {#636-references}

Rockchip-セキュアブート2.0.mdRockchip-セキュアブート-アプリケーション-ノート.md Android 検証ブート2.0

6.4 AVBセキュアブート {#64-avb-secure-boot}

6.4.1 参照 {#641-references}

Rockchip-セキュアブート-アプリケーション-Note.md Android 検証済みブート 2.0 Rockchip_Developer_Guide_Linux4.4_SecureBoot_CN.pdf

6.4.2 用語集 {#642-terminology}

AVB : Android 検証済みのブート OTP & のヒューズ : 1 時間プログラム可能な製品 RootKey (PRK): AVB のルートキーは、署名のローダーによって検証されます。uboot & はroot キーを信頼します。 製品中間キー(PIK): 中間キー、中間キー、製品署名キー(PSK): ファームウェアに署名するために使用されるキー(PUK): さまざまなキーのデバイス分離をロック解除し、明確な責任は、キー漏れのリスクを減らすことができます。

6.4.3 簡単な紹介 {#643-brief-introduction}

この章では、Rockchipのセキュリティ検証ブートストラッププロセスについて説明します。 いわゆるセキュリティ検証ブートストラッププロセスは、セキュリティ検証と完全性検証に分けられます。 セキュリティ検証は、暗号化されたパブリックキーの検証です。このプロセスは、セキュアなストレージ(OTP & のヒューズ)から公開鍵ハッシュを読み、計算された公開鍵ハッシュと比較して、同じかどうかを確認します。そして、公開鍵はファームウェアのハッシュを復号化するために使われます。 完全性検証は、ファームウェアの完全性、プロセスを検証することです

ファームウェアをストレージから読み込むことで、ファームウェアのハッシュと復号化ハッシュを同じかどうか確認します。

6.4.4 暗号化例 {#644-encryption-example}

デバイスのセキュリティ検証の開始プロセスは、通信におけるデータの暗号化検証プロセスと似ています。例えば、avb 検証プロセスの理解を加速することができます。 Alice がメッセージ送信の機密性、信頼性、完全性、非再現性を確保するために、Bob にデジタルメッセージを送信する場合、送信されたメッセージをデジタルで暗号化して署名する必要があります。伝送プロセスは次のとおりです。

1.Aliceは、送信するデジタル情報(プレーンテキスト)を用意します。

2.Aliceはメッセージの消化を得るためにデジタル メッセージでハッシュ操作を実行します。

3.Aliceは、メッセージをAliceのデジタル署名を取得し、デジタルメッセージに添付する目的で、自分の秘密鍵でメッセージダイジェストを暗号化します。

4.Aliceは暗号化キーをランダムに生成し、この暗号を使用して、メッセージが暗号文を形成するために送信されるように暗号化します。

5.Alice は、ボブの公開鍵を使用して、ランダムに生成された暗号化キーを暗号化し、暗号化された DES キーをボブに送る。

6.Bob は、Alice から暗号文と暗号化された DES キーを受信し、最初に、Alice によって生成された暗号化キーをランダムに取得するために、独自の秘密鍵で暗号化された DES キーを解読します。

7.Bob は、受信した暗号文をランダムキーで解読し、テキスト内のデジタル情報を取得し、ランダムキーを破棄します。

8.Bob はアリスのデジタル署名をアリスの公開鍵で解読し、メッセージの消化を促します。

9.Bob は、受信したプレーンテキストを再びハッシュする同じハッシュアルゴリズムを使用して、新しいメッセージのダイジェストを取得

10.Bob は、受信したメッセージの要約を新しく生成されたメッセージのまとめと比較し、同意すると、受信したメッセージは変更されていない。 上記のDESアルゴリズムは、AES暗号化アルゴリズムやパブリックプライベートキーアルゴリズムなど、他のアルゴリズムと交換でき、RSAアルゴリズムに置き換えられます。

出典図, 英語PDF p196

6.4.5 AVBの {#645-avb}

AVBは、主にブートシステムやその他のファームウェアを検証するために使用し、Googleによって設計されたファームウェア検証プロセスのセットであるAndroid Verified Bootの略です。 ロックチップセキュアブートは、AVBと通信で使用される検証方法を参照して、セキュアブート検証プログラムの完全なセットを実現します。

6.4.5.1 AVBの特徴 {#6451-avb-characteristics}

安全点検完全性は反ロールバックの保護永続的な仕切りサポート チェーンを付けられた仕切りサポートを、ブートと一致して、システム署名の秘密鍵かoemはそれ自体によって私用キーを救うことができますがPRKによって署名されなければなりません点検します。

6.4.5.2 キー+署名+証明書 {#6452-keysignaturecertificate}
#!/bin/sh
touch temp.bin
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:4096 -outform PEM -out
testkey_prk.pem
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:4096 -outform PEM -out
testkey_psk.pem
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:4096 -outform PEM -out
testkey_pik.pem
python avbtool make_atx_certificate --output=pik_certificate.bin --subject=temp.bin --
subject_key=testkey_pik.pem --subject_is_intermediate_authority --subject_key_version 42 --
authority_key=testkey_prk.pem
python avbtool make_atx_certificate --output=psk_certificate.bin --subject=product_id.bin --
subject_key=testkey_psk.pem --subject_key_version 42 --authority_key=testkey_pik.pem
python avbtool make_atx_metadata --output=metadata.bin --
intermediate_key_certificate=pik_certificate.bin --
product_key_certificate=psk_certificate.bin

permanent_attributes.binのgernerate:

python avbtool make_atx_permanent_attributes --output=permanent_attributes.bin --
product_id=product_id.bin --root_authority_key=testkey_prk.pem

それらの中、product_id.binは、16バイトを占有し、製品ID定義として使用できる、自分で定義する必要があります。 boot.img のシグネチャ例:

avbtool add_hash_footer --image boot.img --partition_size 33554432 --partition_name boot --
key testkey_psk.pem --algorithm SHA256_RSA4096

注: パーティションサイズは、元のファームウェアよりも少なくとも64K大きいはずです。サイズは4K整列され、parameter.txtで定義されたパーティションサイズよりも大きくなるはずです。 sytem.img のシグネチャ例:

avbtool add_hashtree_footer --partition_size 536870912 --partition_name system --image
system.img --algorithm SHA256_RSA4096 --key testkey_psk.pem

コマンド例であるmetadata.binを含むvbmetaを生成します。

python avbtool make_vbmeta_image --public_key_metadata metadata.bin --
include_descriptors_from_image boot.img --include_descriptors_from_image system.img --
generate_dm_verity_cmdline_from_hashtree system.img --algorithm SHA256_RSA4096 --key
testkey_psk.pem  --output vbmeta.img

その結果、vbmeta.imgは、vbmetaパーティションなど、対応するパーティションに最終的に書かれています。 PrivateKey.pem と PublicKey.pem を SecureBootTool で生成します。

出典図, 英語 PDF p198

署名 permanent_attributes.bin:

openssl dgst -sha256 -out permanent_attributes_cer.bin -sign PrivateKey.pem
permanent_attributes.bin

permanent_attributes.binは、システム全体で安全な認証データであり、そのハッシュをFuseやOTPに書き込む必要があります。また、以前のレベル(プリロード)によってデータを安全に認証します。 ロックチッププラットフォームで作られた不十分なヒューズがあるので、permanent_attributes.binの認証は、プレロードの公開鍵とpermanent_attributes.binの証明書によって認証されます。 十分なセキュアなデータ空間を備えたOTPのプラットフォームでは、permanent_attributes.binのハッシュは、OTPに直接書き込まれます。プラットフォームによるFuseとOTPのサポート:ドライバモジュールセクションを参照してください。

efuseプラットフォームpub_keyのダウンロード:

fastboot stage permanent_attributes.bin
fastboot oem fuse at-perm-attr
fastboot stage permanent_attributes_cer.bin
fastboot oem fuse at-rsa-perm-attr

OTPプラットフォームpub_keyのダウンロード:

fastboot stage permanent_attributes.bin
fastboot oem fuse at-perm-attr

署名プロセス全体:

出典図, 英語PDF p199

6.4.5.3 AVBロック {#6453-avb-lock}
fastboot oem at-lock-vboot

Fastboot の入力方法は? fastboot コマンドサポートセクションを参照してください。

6.4.5.4 AVBアンロック {#6454-avb-unlock}

現在、Rockchipは厳しいセキュリティチェックサムを利用しています。これで、対応するデフコンフィグに追加する必要があります。

CONFIG_RK_AVB_LIBAVB_ENABLE_ATH_UNLOCK=y

それ以外の場合は、デバイスをロック解除するためにfastboot oem at-unlock-vbootを入力し、vbmeta.img検証を起動し、デバイスはboot.imgが失敗しても正常に起動されます。 まず、PUK は生成する必要があります。

openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:4096 -outform PEM -out
testkey_puk.pem

unlock_credential.binは、デバイスにロック解除される必要がある証明書であり、その生成プロセスは次のとおりです。

python avbtool make_atx_certificate --output=puk_certificate.bin --subject=product_id.bin --
subject_key=testkey_puk.pem --usage=com.google.android.things.vboot.unlock --
subject_key_version 42 --authority_key=testkey_pik.pem

デバイスから unlock_credential.bin を入手し、avb-challenge-verify.py スクリプトを使用して unlock_credential.bin を取得するには、次のコマンドを実行して unlock_credential.bin を取得:

python avbtool make_atx_unlock_credential --output=unlock_credential.bin --
intermediate_key_certificate=pik_certificate.bin --
unlock_key_certificate=puk_certificate.bin --challenge=unlock_challenge.bin --
unlock_key=testkey_puk.pem

最終的に、証明書をデバイスにダウンロードし、デバイスをfastbootコマンドでロック解除することができます。

fastboot stage unlock_credential.bin
fastboot oem at-unlock-vboot

最終的なOTP装置はプロセスの鍵を開けます:

出典図、英語PDF p201

最終的なヒューズ装置はプロセスの鍵を開けます:

出典図, 英語PDF p202

最終的な操作手順は次のとおりです。

  1. デバイスは、高速ブートモードに入り、コンピュータ側で入力します。
fastboot oem at-get-vboot-unlock-challenge
fastboot get_staged raw_unlock_challenge.bin

バージョン、製品ID、16バイトのランダム番号でデータを取得し、unlock_challenge.binとしてランダム番号を取り出します。

  1. avbtool を使用して unlock_credential.bin を生成し、make_unlock.sh を参照します。

  2. PCから次の入力

fastboot stage unlock_credential.bin
fastboot oem at-unlock-vboot

注意: この時点で、デバイスは初めての高速ブートモードにあり、電源オフ、シャットダウン、またはこの期間に再起動することはできません。 ステップ1以降では、生成されたランダム番号が格納されます。電源オフや再起動すると、ランダム番号が失われ、その後のチャレンジシグネチャの検証はランダムな番号の不一致で失敗します。 有効にすれば:

CONFIG_MISC=y
CONFIG_ROCKCHIP_EFUSE=y
CONFIG_ROCKCHIP_OTP=y

CPUID はチャレンジ番号として使用し、CPUID はマシンと一致しているので、シャットダウンでデータが失われず、生成された unlock_credential.bin は再利用できます。 unlock_challenge.binを生成し、unlock_credential.binを繰り返して作る手順を保存します。 再びアンロックする手順は、次のようになります。

fastboot oem at-get-vboot-unlock-challenge
fastboot stage unlock_credential.bin
fastboot oem at-unlock-vboot
  1. デバイスはロック解除された状態に入り、ロック解除を開始します。 make_unlock.sh 参照
#!/bin/sh
python avb-challenge-verify.py raw_unlock_challenge.bin product_id.bin
python avbtool make_unlock_credential --output=unlock_credential.bin --
intermediate_key_certificate=pik_certificate.bin --
unlock_key_certificate=puk_certificate.bin --challenge=unlock_challenge.bin --
unlock_key=testkey_puk.pem

avb-challenge-verify.pyソースコード

#/user/bin/env python
"This is a test module for getting unlock_challenge.bin"
import sys
import  os
from hashlib import sha256

def challenge_verify():
    if (len(sys.argv) != 3) :
        print "Usage: rkpublickey.py [challenge_file] [product_id_file]"
        return
    if ((sys.argv[1] == "-h") or (sys.argv[1] == "--h")):
        print "Usage: rkpublickey.py [challenge_file] [product_id_file]"
        return
    try:
        challenge_file = open(sys.argv[1], 'rb')
        product_id_file = open(sys.argv[2], 'rb')
        challenge_random_file = open('unlock_challenge.bin', 'wb')
        challenge_data = challenge_file.read(52)
        product_id_data = product_id_file.read(16)
        product_id_hash = sha256(product_id_data).digest()
        print("The challege version is %d" %ord(challenge_data[0]))
        if (product_id_hash != challenge_data[4:36]) :
            print("Product id verify error!")
            return
        challenge_random_file.write(challenge_data[36:52])
        print("Success!")

    finally:
        if challenge_file:
            challenge_file.close()
        if product_id_file:
            product_id_file.close()
        if challenge_random_file:
            challenge_random_file.close()

if __name__ == '__main__':
    challenge_verify()

4.5.5 U-boot エンバブリング avb を有効にするには、デフコンフィグファイルで U-Boot によって構成される必要がある信頼のサポートが必要です。

CONFIG_OPTEE_CLIENT=y
CONFIG_OPTEE_V1=y
CONFIG_OPTEE_ALWAYS_USE_SECURITY_PARTITION=y  // Security data is stored in the security
partition

CONFIG_OPTEE_V1: 312x、322x、3288、3228H、3368、3399のプラットホームのために適した。 CONFIG_OPTEE_V2:3326,3308のプラットホームのために適した。 CONFIG_OPTEE_ALWAYS_USE_SECURITY_PARTITION: このマクロは、emmc の rpmb が利用できなくなったときにオンになっています。デフォルトでは無効になっています。 avb の有効化は defconfig ファイルで設定する必要があります。

CONFIG_AVB_LIBAVB=y
CONFIG_AVB_LIBAVB_AB=y
CONFIG_AVB_LIBAVB_ATX=y
CONFIG_AVB_LIBAVB_USER=y
CONFIG_RK_AVB_LIBAVB_USER=y
// The above options are mandatory, the following options support AVB and A/B features, the
two features can be used separately.
CONFIG_ANDROID_AB=y //This supports A/B
CONFIG_ANDROID_AVB=y //This supports A/B
// The following macros are for efuse-only platforms
CONFIG_ROCKCHIP_PRELOADER_PUB_KEY=y
// The following macros need to be turned on for strict unlock checksums
CONFIG_RK_AVB_LIBAVB_ENABLE_ATH_UNLOCK=y
// Enable security check
CONFIG_AVB_VBMETA_PUBLIC_KEY_VALIDATE=y
// If you need the cpuid as a challenge number, enable the following macro
CONFIG_MISC=y
CONFIG_ROCKCHIP_EFUSE=y
CONFIG_ROCKCHIP_OTP=y
6.4.5.5カーネルの構成 {#6455-kernel-configuration}

システム、ベンダー、oem などのチェックサムは、カーネルの dm-verify モジュールによって読み込まれるので、このモジュールを有効にする必要があります。 AVBを有効にするには、カーネルのdtsでパラメータavbを以下のように設定する必要があります。

&firmware_android {
    compatible = "android,firmware";
    boot_devices = "fe330000.sdhci";
    vbmeta {
        compatible = "android,vbmeta";
        parts = "vbmeta,boot,system,vendor,dtbo";
    };
    fstab {
        compatible = "android,fstab";
        vendor {
            compatible = "android,vendor";
            dev = "/dev/block/by-name/vendor";
            type = "ext4";
            mnt_flags = "ro,barrier=1,inode_readahead_blks=8";
            fsmgr_flags = "wait,avb";
        };
    };
};

A/B システムを有効にするには、以下のように、slotselect パラメータを設定する必要があります。

firmware {
    android {
        compatible = "android,firmware";
        fstab {
            compatible = "android,fstab";
            system {
                compatible = "android,system";
                dev = "/dev/block/by-name/system";
                type = "ext4";
                mnt_flags = "ro,barrier=1,inode_readahead_blks=8";
                fsmgr_flags = "wait,verify,slotselect";
            };
            vendor {
                compatible = "android,vendor";
                dev = "/dev/block/by-name/vendor";
                type = "ext4";
                mnt_flags = "ro,barrier=1,inode_readahead_blks=8";
                fsmgr_flags = "wait,verify,slotselect";
            };
        };
    };
};
6.4.5.6 Android SDK のリリース {#6456-android-sdk}

以下は、Android SDK の設定手順の一部を説明します。 AVB を有効にする BOARD_AVB_ENABLE A/B システム これら変数の3つの主なカテゴリがあります。A/B システムで定義しなければならない変数 AB_OTA_UPDATER :=true AB_OTA_PARTITIONS := ブートシステムベンダー BOARD_BUILD_SYSTEM_ROOT_IMAGE :=true TARGET_NO_RECOVERY :=true BOARD_USES_RECOVERY_AS_BOOT :=true PRODUCT_PACKAGES += update_engine update_verifier A/B システムでオプションで定義される変数 PRODUCT_PACKAGES_DEBUG += update_engine_client A/B システムで定義できない変数 BOARD_RECOVERYIMAGE_PARTITION_SIZE BOARD_CACHEIMAGE_PARTITION_SIZE BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE

6.4.5.7 シンドリン新コンテンツ {#6457-cmdline-new-content}
Kernel command line: androidboot.verifiedbootstate=green androidboot.slot_suffix=_a dm="1
vroot none ro 1,0 1031864 verity 1 PARTUUID=b2110000-0000-455a-8000-44780000706f
PARTUUID=b2110000-0000-455a-8000-44780000706f 4096 4096 128983 128983 sha1
90d1d406caac04b7e3fbf48b9a4dcd6992cc628e 4172683f0d6b6085c09f6ce165cf152fe3523c89 10
restart_on_corruption ignore_zero_blocks use_fec_from_device PARTUUID=b2110000-0000-455a-
8000-44780000706f fec_roots 2 fec_blocks 130000 fec_start 130000" root=/dev/dm-0
androidboot.vbmeta.device=PARTUUID=f24f0000-0000-4e1b-8000-791700006a98
androidboot.vbmeta.avb_version=1.1 androidboot.vbmeta.device_state=unlocked
androidboot.vbmeta.hash_alg=sha512 androidboot.vbmeta.size=6528
androidboot.vbmeta.digest=41991c02c82ea1191545c645e2ac9cc7ca08b3da0a2e3115aff479d2df61feaccd
d35b6360cfa936f6f4381e4557ef18e381f4b236000e6ecc9ada401eda4cae
androidboot.vbmeta.invalidate_on_error=yes androidboot.veritymode=enforcing

いくつかのパラメータのメモ:

  1. なぜ、vbmetaのPARTUIDを渡しますか? vbmetaハッシュツリーのその後の使用の正当な理由を確保するために、カーネルは、androidboot.vbmeta.digest として消化器を再び検証する必要があります。

  2. skip_initramfs: ブートラムディスクは、A/Bシステムでboot.imgにパックされているか、A / Bシステムでは、ラムディスクはboot.imgに詰まりません。

  3. root=/dev/dm-0 は、dm-verify を有効にし、システムを指定します。

  4. androidboot.vbmeta.device_state:アンドロイドの州は確認します。

  5. androidboot.verifiedbootstate: 検証結果。緑色: LOCKED状態と検証に使用されるキーがエンドユーザによって設定されていない場合。黄色: LOCKED状態と検証に使用されるキーがエンドユーザによって設定された場合。オレンジ: UNLOCKED状態の場合。 dm=「1 vroot none ro.」パラメータの特別な備考が生成されます。

avbtool make_vbmeta_image --include_descriptors_from_image boot.img --
include_descriptors_from_image system.img --generate_dm_verity_cmdline_from_hashtree
system.img --include_descriptors_from_image vendor.img --algorithm SHA512_RSA4096 --key
testkey_psk.pem --public_key_metadata metadata.bin --output vbmeta.img

avbtool が vbmeta を生成したら、-generate_dm_verity_cmdline_from_hashtree をシステムファームウェアに追加します。dm=「1 vroot none ro…….」は vbmeta に保存されます。 この部分は、パーティションがboot.imgにチェックサムだけチェックサムだけなら、このパラメータを追加する必要はありません。 Android SDK で BOARD_AVB_ENABLE を有効にすると、この情報は vbmeta に追加されます。

6.4.6 仕切りの参照 {#646-partition-reference}

新しく追加されたvbmetaパーティションとセキュリティパーティション、vbmetaパーティションはファームウェア検証情報、セキュリティパーティションが暗号化されたセキュリティデータを格納します。

FIRMWARE_VER:8.0
MACHINE_MODEL:RK3326
MACHINE_ID:007
MANUFACTURER: RK3326
MAGIC: 0x5041524B
ATAG: 0x00200800
MACHINE: 3326
CHECK_MASK: 0x80
PWR_HLD: 0,0,A,0,1
TYPE: GPT
CMDLINE:mtdparts=rk29xxnand:0x00002000@0x00004000(uboot),0x00002000@0x00006000(trust),0x0000
2000@0x00008000(misc),0x00008000@0x0000a000(resource),0x00010000@0x00012000(kernel),0x000020
00@0x00022000(dtb),0x00002000@0x00024000(dtbo),0x00000800@0x00026000(vbmeta),0x00010000@0x00
026800(boot),0x00020000@0x00036800(recovery),0x00038000@0x00056800(backup),0x00002000@0x0008
e800(security),0x000c0000@0x00090800(cache),0x00514000@0x00150800(system),0x00008000@0x00664
800(metadata),0x000c0000@0x0066c800(vendor),0x00040000@0x0072c800(oem),0x00000400@0x0076c800
(frp),-@0x0076cc00(userdata:grow)
uuid:system=af01642c-9b84-11e8-9b2a-234eb5e198a0

A/B システム仕切りの定義参照:

FIRMWARE_VER:8.1
MACHINE_MODEL:RK3326
MACHINE_ID:007
MANUFACTURER: RK3326
MAGIC: 0x5041524B
ATAG: 0x00200800
MACHINE: 3326
CHECK_MASK: 0x80
PWR_HLD: 0,0,A,0,1
TYPE: GPT
CMDLINE:
mtdparts=rk29xxnand:0x00002000@0x00004000(uboot_a),0x00002000@0x00006000(uboot_b),0x00002000
@0x00008000(trust_a),0x00002000@0x0000a000(trust_b),0x00001000@0x0000c000(misc),0x00001000@0
x0000d000(vbmeta_a),0x00001000@0x0000e000(vbmeta_b),0x00020000@0x0000e000(boot_a),0x00020000
@0x0002e000(boot_b),0x00100000@0x0004e000(system_a),0x00300000@0x0032e000(system_b),0x001000
00@0x0062e000(vendor_a),0x00100000@0x0072e000(vendor_b),0x00002000@0x0082e000(oem_a),0x00002
000@0x00830000(oem_b),0x0010000@0x00832000(factory),0x00008000@0x842000(factory_bootloader),
0x00080000@0x008ca000(oem),-@0x0094a000(userdata)

6.4.7 Fastbootコマンド {#647-fastboot-command}

U-Boot では、コマンドを入力すると、fastboot を入力することができます。

fastboot usb 0
6.4.7.1 コマンドのクイック概要 {#6471-quick-overview-of-commands}
fastboot flash < partition > [ < filename > ]
fastboot erase < partition >
fastboot getvar < variable > | all
fastboot set_active < slot >
fastboot reboot
fastboot reboot-bootloader
fastboot flashing unlock
fastboot flashing lock
fastboot stage [ < filename > ]
fastboot get_staged [ < filename > ]
fastboot oem fuse at-perm-attr-data
fastboot oem fuse at-perm-attr
fastboot oem fuse at-rsa-perm-attr
fastboot oem at-get-ca-request
fastboot oem at-set-ca-response
fastboot oem at-lock-vboot
fastboot oem at-unlock-vboot
fastboot oem at-disable-unlock-vboot
fastboot oem fuse at-bootloader-vboot-key
fastboot oem format
fastboot oem at-get-vboot-unlock-challenge
fastboot oem at-reset-rollback-index
6.4.7.2 コマンド使用 {#6472-command-usage}
  1. fastboot フラッシュ < の仕切り > [ < ファイル名 > ] 機能: 仕切りを書きます。

例:fastboot フラッシュ ブート boot.img

  1. 速いブートは<の仕切り>機能を消去します:仕切りを消去して下さい。

例:fastboot 消去ブート

  1. fastboot getvar < 変数 > | すべての機能: デバイス情報の取得 例:fastboot getvar all (デバイスに関するすべての情報を取得する) 変数で持ち込むことができるパラメーター:
version                               /* fastboot version */
version-bootloader                    /* U-Boot version */
version-baseband
product                               /* Product Information */
serialno                              /* Serial number*/
secure                                /* Whether to enable security checking */
max-download-size                     /* maximum number of bytes supported by fastboot in a
single transfer */
logical-block-size                    /* Number of logical blocks */
erase-block-size                      /* Number of erased blocks*/
partition-type : < partition >        /* Partition type */
partition-size : < partition >        /* Partition size*/
unlocked                              /* Device lock status */
off-mode-charge
battery-voltage
variant
battery-soc-ok
slot-count                            /* Number of slots*/
has-slot: < partition >               /* Check if the partition name is in the slot*/
current-slot                          /* Currently booted slots */
slot-suffixes                         /* The current slot of the device, print its name. */
slot-successful: < _a | _b >          /* Check if the partition is properly verified and
booted*/
slot-unbootable: < _a | _b >          /* Check if the partition is set to unbootable */
slot-retry-count: < _a | _b >         /* Checkthe number of retry-counts for partition */
at-attest-dh
at-attest-uuid
at-vboot-state

fastboot getvar は、以下の例をすべて説明します。

PS E:\U-Boot-AVB\adb> .\fastboot.exe getvar all
(bootloader) version:0.4
(bootloader) version-bootloader:U-Boot 2017.09-gc277677
(bootloader) version-baseband:N/A
(bootloader) product:rk3229
(bootloader) serialno:7b2239270042f8b8
(bootloader) secure:yes
(bootloader) max-download-size:0x04000000
(bootloader) logical-block-size:0x512
(bootloader) erase-block-size:0x80000
(bootloader) partition-type:bootloader_a:U-Boot
(bootloader) partition-type:bootloader_b:U-Boot
(bootloader) partition-type:tos_a:U-Boot
(bootloader) partition-type:tos_b:U-Boot
(bootloader) partition-type:boot_a:U-Boot
(bootloader) partition-type:boot_b:U-Boot
(bootloader) partition-type:system_a:ext4
(bootloader) partition-type:system_b:ext4
(bootloader) partition-type:vbmeta_a:U-Boot
(bootloader) partition-type:vbmeta_b:U-Boot
(bootloader) partition-type:misc:U-Boot
(bootloader) partition-type:vendor_a:ext4
(bootloader) partition-type:vendor_b:ext4
(bootloader) partition-type:oem_bootloader_a:U-Boot
(bootloader) partition-type:oem_bootloader_b:U-Boot
(bootloader) partition-type:factory:U-Boot
(bootloader) partition-type:factory_bootloader:U-Boot
(bootloader) partition-type:oem_a:ext4
(bootloader) partition-type:oem_b:ext4
(bootloader) partition-type:userdata:ext4
(bootloader) partition-size:bootloader_a:0x400000
(bootloader) partition-size:bootloader_b:0x400000
(bootloader) partition-size:tos_a:0x400000
(bootloader) partition-size:tos_b:0x400000
(bootloader) partition-size:boot_a:0x2000000
(bootloader) partition-size:boot_b:0x2000000
(bootloader) partition-size:system_a:0x20000000
(bootloader) partition-size:system_b:0x20000000
(bootloader) partition-size:vbmeta_a:0x10000
(bootloader) partition-size:vbmeta_b:0x10000
(bootloader) partition-size:misc:0x100000
(bootloader) partition-size:vendor_a:0x4000000
(bootloader) partition-size:vendor_b:0x4000000
(bootloader) partition-size:oem_bootloader_a:0x400000
(bootloader) partition-size:oem_bootloader_b:0x400000
(bootloader) partition-size:factory:0x2000000
(bootloader) partition-size:factory_bootloader:0x1000000
(bootloader) partition-size:oem_a:0x10000000
(bootloader) partition-size:oem_b:0x10000000
(bootloader) partition-size:userdata:0x7ad80000
(bootloader) unlocked:no
(bootloader) off-mode-charge:0
(bootloader) battery-voltage:0mv
(bootloader) variant:rk3229_evb
(bootloader) battery-soc-ok:no
(bootloader) slot-count:2
(bootloader) has-slot:bootloader:yes
(bootloader) has-slot:tos:yes
(bootloader) has-slot:boot:yes
(bootloader) has-slot:system:yes
(bootloader) has-slot:vbmeta:yes
(bootloader) has-slot:misc:no
(bootloader) has-slot:vendor:yes
(bootloader) has-slot:oem_bootloader:yes
(bootloader) has-slot:factory:no
(bootloader) has-slot:factory_bootloader:no
(bootloader) has-slot:oem:yes
(bootloader) has-slot:userdata:no
(bootloader) current-slot:a
(bootloader) slot-suffixes:a,b
(bootloader) slot-successful:a:yes
(bootloader) slot-successful:b:no
(bootloader) slot-unbootable:a:no
(bootloader) slot-unbootable:b:yes
(bootloader) slot-retry-count:a:0
(bootloader) slot-retry-count:b:0
(bootloader) at-attest-dh:1:P256
(bootloader) at-attest-uuid:
all: Done!
finished. total time: 0.636s
  1. fastboot set_active <スロット>機能: 再起動のためのスロットを設定します。

例:fastboot set_active _a

  1. fastboot の再起動機能: 通常の起動のためのデバイスを再起動します。例: fastboot の再起動

  2. fastboot の reboot-bootloader 機能: デバイスを再起動して、fastboot モードに入ります。

例:fastboot 再起動-bootloader

  1. クイックブート書き込みロック機能:デバイスをロック解除し、ファームウェアのダウンロード例を許可します:ファストブートの書き込みロック解除

  2. 書き込みロック機能:デバイスをロックし、ドウロードを禁止します。ファストブートはロックを書き込みします

  3. fastboot ステージ [ < ファイル名 > ] 機能: デバイスのメモリにデータをダウンロードし、メモリの開始アドレスは CONFIG_FASTBOOT_BUF_ADDR です。

例:fastbootステージpermanent_attributes.bin

  1. fastboot get_staged [ <ファイル名 > ] 関数: デバイス側からデータを取得する例:fastboot get_staged raw_unlock_challenge.bin

  2. 速いブープオエムは、perm-attr 関数でヒューズします: permanent_attributes.bin とハッシュ例を書く: fastboot ステージ permanent_attributes.bin のfastboot oem ヒューズ at-perm-attr

  3. fastboot oem は、perm-attr-data 関数でヒューズします。permanent_attributes.bin だけをセキュアなストレージエリア(RPMB)例に書き込む:fastboot ステージ permanent_attributes.bin の fastboot oem は、perm-attr-data でヒューズします。

  4. 速いブートoem at-get-ca-request

  5. 速いブームoem でセット-ca-response

  6. fastboot oem のロックvboot 機能: ロック装置例:fastboot oem at-lock-vboot

  7. fastboot oem の in-unlock-vboot 機能: 装置を鍵を開けて下さい、 認証されたロック解除例:fastboot oem at-get-vboot-unlock-challenge fastboot get_staged raw_unlock_challenge.bin ./make_unlock.sh(make_unlock.sh を参照) クイックブートステージ unlock_credential.bin クイックブートoem at-unlock-vboot

  8. fastboot oem ヒューズ at-bootloader-vboot-key 機能: bootloader キーハッシュをダウンロード: fastboot ステージ bootloader-pub-key.bin fastboot oem ヒューズ at-bootloader-vboot-key

  9. fastboot oem 形式 関数: パーティションをリフォーマットする、パーティション情報は $ パーティション例に依存します: fastboot oem 形式

  10. fastboot oem at-get-vboot-unlock-challenge 関数: 認証解除, チャレンジデータのロック解除を取得する必要性 例: 16を参照してください。 fastboot oem で-unlock-vboot

  11. fastboot oem の at-reset-rollback-index 関数: デバイスのロールバックデータをリセットする 例: fastboot oem を at-reset-rollback-index で設定します。

  12. fastboot oem の非ディスカブル・アンロック・ヴァンボット関数: fastboot oem をオンロック・ヴァンブートコマンドで無効化します。

例:fastboot oem でdisable-unlock-vboot

6.4.8 ファームウェアのダウンロード {#648-firmware-downloading}

以下は、Windowsファームウェアのダウンロードツールです

出典図, 英語PDF p213

A/B システムのダウンロード

出典図, 英語 PDF p214

6.4.9 プリローダー検証済み {#649-pre-loader-verified}

詳しくは「Rockchip・セキュア・ブート・アプリケーション・ノート」をご覧ください。

出典図, 英語PDF p215

6.4.10 U-boot 検証済み {#6410-u-boot-verified}

OTP装置検証プロセス:

装置検証プロセスの活用:

6.4.11 システム検証ブート {#6411-system-verification-boot}

出典図, 英語PDF p220

U-Bootが渡したcmdlineパラメータを解析し、dm-verifyでシステムブートを検証し、システムfs_mgrサービスをロードして有効化する。 fs_mgr は、ファームウェアがfsmgr_flags パラメーターに基づいてロードされることを検証します。 ファームウェアハッシュ&ハッシュツリーは、次のパラメータavbでvbmeta.imgに保存されます。 avbモードスロットでパーティションをロードして検証します。 スロットセレクトはA / B用であり、cmdlineのパラメータ「androidboot.slot_suffix=_a」で読み込まれます。

6.4.12 Linux AVB のリリース {#6412-linux-avb}

以下は、Linux環境に基づくAVBの動作と検証プロセスについて説明しています。

6.4.12.1 ワークフローの運用 {#64121-operating-workflow}
  1. 完全なファームウェアを生成

  2. 下記のコマンドで、rk_sign_tool と SecureBootConsole を使用して PrivateKey.pem と PublicKey.pem を生成します。

rk_sign_tool cc --chip 3399
rk_sign_tool kk --out .
  1. ロードキー
rk_sign_tool lk --key privateKey.pem --pubkey publicKey.pem
  1. 署名の積込み機
rk_sign_tool sl --loader loader.bin
  1. 署名 uboot.img & trust.img
rk_sign_tool si --img uboot.img
rk_sign_tool si --img trust.img
  1. avb の署名ファームウェアの準備: 空の temp.bin を準備します。, 16 バイト product_id.bin, boot.img 署名される, 次のコードを実行します
#!/bin/bash
touch temp.bin
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:4096 -outform PEM -out
testkey_prk.pem
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:4096 -outform PEM -out
testkey_psk.pem
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:4096 -outform PEM -out
testkey_pik.pem
python avbtool make_atx_certificate --output=pik_certificate.bin --subject=temp.bin --
subject_key=testkey_pik.pem --subject_is_intermediate_authority --subject_key_version 42 --
authority_key=testkey_prk.pem
python avbtool make_atx_certificate --output=psk_certificate.bin --subject=product_id.bin --
subject_key=testkey_psk.pem --subject_key_version 42 --authority_key=testkey_pik.pem
python avbtool make_atx_metadata --output=metadata.bin --
intermediate_key_certificate=pik_certificate.bin --
product_key_certificate=psk_certificate.bin
python avbtool make_atx_permanent_attributes --output=permanent_attributes.bin --
product_id=product_id.bin --root_authority_key=testkey_prk.pem
python avbtool add_hash_footer --image boot.img --partition_size 33554432 --partition_name
boot --key testkey_psk.pem --algorithm SHA256_RSA4096
python avbtool make_vbmeta_image --public_key_metadata metadata.bin --
include_descriptors_from_image boot.img --algorithm SHA256_RSA4096 --key testkey_psk.pem  --
output vbmeta.img
openssl dgst -sha256 -out permanent_attributes_cer.bin -sign PrivateKey.pem
permanent_attributes.bin

vbmeta.img、permanent_attributes_cer.bin、permanent_attributes.bin を生成します。 このステップは、boot.img …

7.ファームウェアのダウンロード

rkdeveloptool db loader.bin
rkdeveloptool ul loader.bin
rkdeveloptool gpt parameter.txt
rkdeveloptool wlx uboot uboot.img
rkdeveloptool wlx trust trust.img
rkdeveloptool wlx boot boot.img
rkdeveloptool wlx system system.img

rkdeveloptool は、https://github.com/rockchip-linux/rkdeveloptool> を参照して下さい

  1. permanent_attributes_cer.bin、permanent_attributes.bin OTPのプラットホームを利用できるダウンロードして下さい:
fastboot stage permanent_attributes.bin
fastboot oem fuse at-perm-attr

利用できるefuseのプラットホーム:

fastboot stage permanent_attributes.bin
fastboot oem fuse at-perm-attr
fastboot stage permanent_attributes_cer.bin
fastboot oem fuse at-rsa-perm-attr
  1. EFUSEのダウンロード(エフェクトツールはウィンドウバージョンでのみ使用可能)、特定のローダーを選択し、対応するデバイスを選択し、ダウンロードを開始をクリックします。

出典図, 英語PDF p223

  1. OTPプラットフォームローダー公開鍵のダウンロード 参照してください Rockchip-Secure-Boot-Application-Note.md
6.4.12.2 検証プロセス {#64122-verification-process}

[TODO] インフォメーション

6.5 SDブートおよび改善 {#65-sd-boot-and-upgrade}

6.5.1 短い導入 {#651-brief-introduction}

RockchipはSDカードを正規のSDカード、SDのアップグレード カード、SDのブート カードおよびSDの修理カードに分類します。 update.imgをRockchipを介してSDカードにダウンロードして、アップグレードディスクツールを作成してさまざまなカードタイプを作成できます

SDカードカテゴリ 機能
普通SDカード 一般的なストレージデバイス
SDのアップグレード カード SDカードから回復までのデバイスブート。これは、sdのファームウェアをデバイスのメモリに更新する責任です。
SDのブート カード SDカードから直接デバイスブート
SD修理カード ファームウェアをSDカードからデバイスメモリにコピーし、プレローダーから起動します。

6.5.2 SDカードカテゴリ {#652-sd-card-category}

6.5.2.1 普通SDカード {#6521-regular-sd-card}

通常のSDカードはPCと同じで正確に使用され、SDカードで何かを行うためのツールなしでUブートおよびカーネルシステム内の正常な記憶空間として使用することができます。

6.5.2.2 SDのアップグレード カード {#6522-sd-upgrade-card}

SDカードはRKのツールでSDカードからローカルストレージへのファームウェアアップグレードを実現しています(例: eMMC、ナンドフラッシュ)。 SDカードのアップグレードは、PCやネットワークから取り外すことができるファームウェアのアップグレード方法です。 具体的には、SDカードのブートコードはSDカードの予約済み領域に書かれており、ファームウェアはSDカードのマスターコントロールブートからSDカードのマスターコントロールブートをコピーすると、SDカードのブートコードとアップグレードコードは、ローカルマスターストレージにファームウェアをダウンロードします。 同時に、SDのアップグレードカードはデモファイルのPCBAのテストそしてコピーを支えます。 SDのアップグレード カードのこれらの機能はPCのファームウェアのアップグレードをし、生産の効率を改善できます。 SDカードにファームウェアとデモファイルを更新する必要がある場合は、以下の手順に従ってプロセスを完了できます。

  1. ファームウェアをSDカードのルートディレクトリにコピーし、sdupdate.imgの名前を変更します

  2. SDカードのルートディレクトリにあるデモディレクトリに、デモファイルをコピーします。 SD の起動可能な改善カード フォーマット(GPT ではない)

オフセット データセグメント
ディスクセクター 0 MBR
ディスクセクター 64-4M IDBLOCK(0 に設定されたフラグの開始)
4M-8M パラメータ
12M-16M ユーブート
16M-20M 信頼
…… その他
…… リソース
…… カーネル
…… 回復
左部屋 Fat32 店舗 update.img

SD の起動可能な改善カード フォーマット(GPT)

オフセット データセグメント
ディスクセクター 0 MBR
ディスクセクター 1-34 GPTの仕切り
ディスクセクター 64-4M IDBLOCK(0 に設定されたフラグの開始)
4M-8M パラメータ
…… ユーブート
…… 信頼
…… その他
…… リソース
…… カーネル
…… 回復
左部屋 Fat32 店舗 update.img
6.5.2.3 SDのブート カード {#6523-sd-boot-card}

SDカードはRKのツールによって作られています。SDカードから直接起動を実現するため、ユーザーはファームウェアをデバイスストレージに再ダウンロードすることなく新しいファームウェアを更新し、起動するのを非常に容易にします。 特定の実現は、ファームウェアをSDカードにダウンレイドし、SDカードをメインストレージとして使用することです。 マスターコントロールがSDカードから始まると、ファームウェアと一時ファイルがSDカードに保存されます。

ローカルマスターのストレージなしで、または通常の作業ができます。 現在、SDカードから起動するデバイスシステムやPCBAテスト用など、主に使用しています。

注:PCBAテストは回復の下の機能だけ、SDのアップグレード カードおよびSDのブート カードのために使用することができますです。 SD のブート カードのフォーマット(GPT 無し)

オフセット データセグメント
ディスクセクター 0 MBR
ディスクセクター 64-4M IDBLOCK(0 に設定されたフラグの開始)
4M-8M パラメータ
8M-12M ユーブート
12M-16M 信頼
…… その他
…… リソース
…… ブート
…… カーネル
…… 回復
…… システム
…… ユーザー

SD ブート カードのフォーマット(GPT)

オフセット データセグメント
ディスクセクター 0 MBR
ディスクセクター 1-34 GPTの仕切り
ディスクセクター 64-4M IDBLOCK(スタートフラグを1に設定)
…… ユーブート
…… ブート
…… 信頼
…… リソース
…… カーネル
…… 回復
…… システム
…… ベンダー
…… OEM
…… ユーザー
最後の33ディスクセクター GPTのバックアップ
6.5.2.4 SD修理カード {#6524-sd-repair-card}

SDカードはSDのアップグレード カードの機能と類似していますが、ファームウェアのアップグレードはミニローダーによって行われます。 まず、ツールはSDカードの保存エリアにブートコードを書き、ファームウェアをSDカードの可視パーティションにコピーし、マスターがSDカードから起動すると、SDカードのアップグレードコードは、ローカルマスターストレージにファームウェアをアップグレードします。 主に、デバイスのファームウェアが破損してSDカードがデバイスを修復できるときに使用されます。 SD修理カードフォーマット(GPTではありません)

オフセット データセグメント
ディスクセクター 0 MBR
ディスクセクター 64-4M IDBLOCK(2 にセットされたフラグの開始)
4M-8M パラメータ
8M-12M ユーブート
12M-16M 信頼
…… その他
…… リソース
…… ブート
…… カーネル
…… 回復
…… システム
…… ユーザー

SDカードフォーマット(GPT)

オフセット データセグメント
ディスクセクター 0 MBR
ディスクセクター 1-34 GPT の仕切り
ディスクセクター 64-4M IDBLOCK(2 にセットされたフラグの開始)
…… ユーブート
…… ブート
…… 信頼
…… リソース
…… カーネル
…… 回復
…… システム
…… ベンダー
…… OEM
…… ユーザー
最後の33セクター GPTのバックアップ

SDカードはさまざまな機能として使用され、SDカードの中の印をなします。 SDカードのセクター64では、スタートフラグ(数値)が0xFCDC8C3Bの場合、SDカードからファームウェアを読み、デバイスを起動する特別なカードです。 ない場合は、通常のSDカードとして扱われます。 業界(64×616バイト)では、カードロゴが保存されます。 現在3種類あります。

カードロゴ カードカテゴリ
0 SDのアップグレード カードかPCBAのテスト カード
1 SDのブート カード
2 SD修理カード

6.5.4 ブート プロセス {#654-boot-process}

SDカードの起動プロセスは、プリローダーブートプロセスとubootブートプロセスに分けることができます。 SDカードのIDBブロックにSDカードと起動フラグをロードして検出し、これらのフラグに従って異なる機能を実行します。 プロセスは次の通りです:

出典図, 英語 PDF p229

6.5.4.1 プリローダーブート {#6541-pre-loader-boot}

出典図、英語PDF p230

マスクROMは、利用可能なミニローダーファームウェアのコピー(TRMからマスクROMによってサポートされているブートストレージメディアを決定し、それらを優先順位付けし、マスクROMはファームウェアの利用可能なストレージをスキャン)、ミニローダーにジャンプします。 ストレージデバイスを再読み込みし、SDカードを検出すると、SDBフォーマットファームウェアが含まれているかどうかが検出されます。 SDカードが検出された場合、SDカードにIDB形式のファームウェアが含まれているか確認してください。 もしそうなら、カードのフラグを決定します。 SDカードが利用可能で、フラグビットが「0」または「1」の場合、U-BootファームウェアをSDカードから読み、U-Bootをロードして起動すると、フラグが「2」の場合は、カードの修理プロセスを入力し、ローダーの下にファームウェアを更新します。 通常のブートプロセスは、他のストレージとロードのためにスキャンし、次のレベルのローダーを起動することです。

6.5.4.2 Uブートブート {#6542-u-boot-boot}

UボットSDのブートの流れ、英語PDF p232

U-Boot SD のブートの流れは継続しました、英語 PDF p233

SDカードがIDBフォーマットのファームウェアを含んでいるかどうかSDカードが検出された場合、Uブートは貯蔵装置を、再調査します。 もしそうなら、カードバイアスフラグが0であるかどうかを決定し、カーネルに渡されたcmdlineに’sdfwupdate’を追加してください。 最後に、SDカードの誤ったパーティションを読み、回復モードである場合は、カードのブートモードを読んで、ロードして回復を開始します。 SD のブート カード: U ボットは記憶装置を、SD カードを検出すれば再調査します、SD カードが IDB のフォーマット ファームウェアを含んでいるかどうか確認します、そうなら、カード旗が 1 であるかどうかを。 最後に、SDカードの誤ったパーティションを読み、それが回復である場合、それが通常のモードであれば、カードのブートモードを読み、ブートカーネルをロードします。

6.5.4.3 回復および PCBA {#6543-recovery-and-pcba}

詳細は、Rockchipの回復ユーザー操作ガイドV1.03.pdfを参照してください。

6.5.5 ノート {#655-notes}

U-Bootは、非GPT形式のファームウェアを作成するときにCONFIG_RKPARM_PARTITIONを設定する必要があります。 SD のアップグレード カードを作るとき、update.img は MiniloaderAll.bin、parameter.txt、uboot.img、trust.img、misc.img、resource.img、recovery.img 、または update.img を記述する失敗します。

7. . Chapter-7 構成 トリミング {#7-chapter-7-configuration-trimming}

TODO

8. . Chapter-8 デバッグツール {#8-chapter-8-debugging-tools}

このセクションでは、コマンド、スクリプト、設定オプション、ブート印刷などの使用を含むU-Bootステージで使用される一般的なデバッグツールの一部に焦点を当てています。

8.1 デブグ {#81-debug}

関数: グローバルな debug() 印刷を有効にします。 各プラットフォームのrkxxx_common.hにマクロ定義を追加することで有効化できます。

#define DEBUG

8.2 インタコール {#82-initcall}

関数: ブート プロセスを印刷して下さい。 U-Bootの起動は、基本的には、initcall_run_list() 関数内の printf() に debug() を変換する一連のインシコールです。

例:

U-Boot 2017.09-01725-g03b8d3b-dirty (Jul 06 2018 - 10:08:27 +0800)

initcall: 0000000000214388
initcall: 0000000000214724
Model: Rockchip RK3399 Evaluation Board
initcall: 0000000000214300
DRAM:  initcall: 0000000000203f68
initcall: 0000000000214410  // Combine with disassembly to find the function corresponding
to the address
initcall: 00000000002140dc
....
3.8 GiB
initcall: 00000000002143b8
....
Relocation Offset is: f5c03000
initcall: 00000000f5e176bc
initcall: 00000000002146a4 (relocated to 00000000f5e176a4)
initcall: 0000000000214668 (relocated to 00000000f5e17668)

...

8.3 IOコマンド {#83-io-command}

機能: 読書し、記憶を書きます。

// read
md - memory display
Usage: md [.b, .w, .l, .q] address [# of objects]

// write
mw - memory write (fill)
Usage: mw [.b, .w, .l, .q] address value [count]

操作を読む。

例: 0x10 連続データがアドレス 0x76000000 で始まる表示します。

=> md.l 0x76000000 0x10
76000000: fffffffe ffffffff ffffffff ffffffff    ................
76000010: ffffffdf ffffffff feffffff ffffffff    ................
76000020: ffffffff ffffffff ffffffff ffffffff    ................
76000030: ffffffff ffffffff ffffffff ffffffff    ................

操作を書きます。

例: 0x1234 を 0x76000000 に割り当てる。

=> mw.l 0x76000000 0xffff1234 // Higher 16 bits have mask
=> md.l 0x76000000 0x10       // readback
76000000: ffff1234 ffffffff ffffffff ffffffff    ................
76000010: ffffffdf ffffffff feffffff ffffffff    ................
76000020: ffffffff ffffffff ffffffff ffffffff    ................
76000030: ffffffff ffffffff ffffffff ffffffff    ................

8.4 IOMEMコマンド {#84-iomem-command}

機能: 記憶を読んで下さい。 md コマンドよりも柔軟で、DTS ノードを自動的に解析することで、ベースアドレス情報を取得できます。

=> iomem
iomem - Show iomem data by device compatible

Usage:
// @<compatible>: Keyword matching for the compatible part of the node
iomem <compatible> <start offset>  <end offset>
eg: iomem -grf 0x0 0x200

例:RK3228はGRFの0x00から0x20までのデータを読み込みます。

// The keyword “-grf” is used here to distinguish it from “rockchip, rk3288-pmugrf”.
=> iomem -grf 0x0 0x20
rockchip,rk3228-grf:
11000000:  00000000 00000000 00004000 00002000
11000010:  00000000 00005028 0000a5a5 0000aaaa
11000020:  00009955

8.5 I2Cコマンド {#85-i2c-command}

関数: i2c 装置を読まれる/書きて下さい。

=> i2c
i2c - I2C sub-system

Usage:
i2c dev [dev] - show or set current I2C bus
i2c md chip address[.0, .1, .2] [# of objects] - read from I2C device
i2c mw chip address[.0, .1, .2] value [count] ‐ write to I2C device (fill)
......

操作を読む。

例:

=> i2c dev 0                     //  Switch to i2c0 (just specify once)
Setting bus to 0

=> i2c md 0x1b 0x2e 0x20         //  The i2c device address is 1b (7-bit address) and reads
0x20 consecutive register values starting at 0x2e
002e: 11 0f 00 00 11 0f 00 00 01 00 00 00 09 00 00 0c    ................
003e: 00 0a 0a 0c 0c 0c 00 07 07 0a 00 0c 0c 00 00 00    ................

操作を書きます。

例:

=> i2c dev 0                     // Switch to i2c0 (just specify once)
Setting bus to 0

=> i2c mw 0x1b 0x2e 0x10         // The i2c device address is 1b (7-bit address), and the
0x2e register is assigned the value 0x10
=> i2c md 0x1b 0x2e 0x20         // readback
002e: 10 0f 00 00 11 0f 00 00 01 00 00 00 09 00 00 0c    ................
003e: 00 0a 0a 0c 0c 0c 00 07 07 0a 00 0c 0c 00 00 00    ................

8.6 GPIOコマンド {#86-gpio-command}

関数: 読み書きピン入出力

=> gpio
gpio - query and control gpio pins

Usage:
gpio <input|set|clear|toggle> <pin>
    - input/set/clear/toggle the specified pin
gpio status [-a] [<bank> | <pin>]  - show [all/claimed] GPIOs

ピンの状態をチェック:例 RV1126

=> gpio status -a
Bank A:
A0: input: 0 [ ]
A1: output: 1 [ ]
A2: input: 1 [ ]
...
A29: unused: 1 [ ]
A30: unknown
A31: unused: 0 [ ]
...
D6: input: 0 [ ]
D7: output: 1 [x] vcc18-lcd-n.gpio
...
D31: input: 0 [ ]

Bank E:
E0: input: 0 [ ]
E1: input: 0 [ ]

ピン入力:

=> gpio input A7

ピン出力のInACTIVE:

=> gpio clear A7

ピン出力 ACTIVE:

=> gpio set A7

ピン状態の切換え:例えば。 A7: 入力: 0 から A7: 出力: 1

=> gpio toggle A7

8.7 FDTコマンド {#87-fdt-command}

関数: DTB の内容を印刷物で印刷して下さい。

=> fdt
fdt - flattened device tree utility commands

Usage:
fdt addr [-c]  <addr> [<length>]    - Set the [control] fdt location to <addr>
fdt print  <path> [<prop>]          - Recursive print starting at <path>
fdt list   <path> [<prop>]          - Print one level starting at <path>
......
NOTE: Dereference aliases by omitting the leading '/', e.g. fdt print ethernet0.

下記の2つのコマンドは、デバイスツリーを完全にダンプできます。

=> fdt addr $fdt_addr_r   // Specify fdt address
=> fdt print              // Print out the entire contents of the fdt

8.8 MMCコマンド {#88-mmc-command}

機能: MMC 装置は/、転換読みましたり/書きます。 MMC装置の眺め:

=> mmc info
Device: dwmmc@ff0f0000                  // device node
Manufacturer ID: 15
OEM: 100
Name: 8GME4
Timing Interface: High Speed            // Speed Mode
Tran Speed: 52000000                    // current speed
Rd Block Len: 512
MMC version 5.1
High Capacity: Yes
Capacity: 7.3 GiB                       // storage capacity
Bus Width: 8-bit                        // Bus width
Erase Group Size: 512 KiB
HC WP Group Size: 8 MiB
User Capacity: 7.3 GiB WRREL
Boot Capacity: 4 MiB ENH
RPMB Capacity: 512 KiB ENH

MMC装置スイッチ:

=> mmc dev 0                            // Switch to eMMC
=> mmc dev 1                            // Switch to sd card

MMCデバイスは、読み込み、書き込み:

mmc read addr blk# cnt
mmc write addr blk# cnt
mmc erase blk# cnt
Example:
=> mmc read 0x70000000 0 1    // Read the first block of the MMC device, data size - 1
sector, into memory 0x70000000
=> mmc write 0x70000000 0 1   // Write 1 sector of data from memory 0x70000000 to the first
block of memory
=> mmc erase 0 1              // Erase 1 sector of data from the first block of memory.

MMCデバイスが異常に読み書きする場合、これらの簡単な手順に従ってすぐに見つけることができます。drivers/mmc/dw_mmc.cでprintf() を変更し、recompile と ダウンロードします。 MMCデバイスのプリント情報を見る:最後のプリントがCMD0を送信する場合は、ハードウェア電源、ピン接続を確認してください。ソフトウェアIOMUXが他のIPによって切断されているかどうかを確認します。最後のプリントがCMD8を送信している場合は、セキュリティソフトウェアセクションで、MMCデバイスを構成して安全なストレージへのアクセスを許可します。すべての初期化コマンドが渡され、最後のプリントアウトがCMD18を送信します。MMCハードウェア電源、 または、MC側に近くで電源の容量が十分であるかどうかをチェックしてください(より大きいコンデンサーに交換できます)、ソフトウェアをチェックしてください(クロック周波数を削減することができます)、またはMMCデバイスの速度モードを切り替える試してみてください。

8.9 タイムスタンプ {#89-timestamp}

関数: U ボットのプリントメッセージにタイムスタンプ (相対時間) を追加します。

CONFIG_BOOTSTAGE_PRINTF_TIMESTAMP

例:

[    0.259266] U-Boot 2017.09-01739-g856f373-dirty (Jul 10 2018 - 20:26:05 +0800)
[    0.260596] Model: Rockchip RK3399 Evaluation Board
[    0.261332] DRAM:  3.8 GiB
Relocation Offset is: f5bfd000
Using default environment

[    0.354038] dwmmc@fe320000: 1, sdhci@fe330000: 0
[    0.521125] Card did not respond to voltage select!
[    0.521188] mmc_init: -95, time 9
[    0.671451] switch to partitions #0, OK
[    0.671500] mmc0(part 0) is current device
[    0.675507] boot mode: None
[    0.683738] DTB: rk-kernel.dtb
[    0.706940] Using kernel dtb
......

タイムスタンプは、現在のシステムタイマーの時刻のみを出力し、0からタイミングをしない。 そのため、タイムスタンプは相対的な時間だけ、絶対時間だけをプリントします。

8.10 DMの木 {#810-dm-tree}

関数: すべてのデバイスドライバ間でバインディングとプローブのステータスを表示します。

=> dm tree

 Class      Probed        Driver               Name
----------------------------------------------------------
 root       [ + ]   root_driver                root_driver
 syscon     [   ]   rk322x_syscon              |-- syscon@11000000
 serial     [ + ]   ns16550_serial             |-- serial@11030000 *
 clk        [ + ]   clk_rk322x                 |-- clock-controller@110e0000
 sysreset   [   ]   rockchip_sysreset          |   |-- sysreset
 reset      [   ]   rockchip_reset             |   `-- reset
 mmc        [ + ]   rockchip_rk3288_dw_mshc    |-- dwmmc@30020000 *
 blk        [ + ]   mmc_blk                    |   `-- dwmmc@30020000.blk *
 ram        [   ]   rockchip_rk322x_dmc        |-- dmc@11200000
 serial     [ + ]   ns16550_serial             |-- serial@11020000
 i2c        [ + ]   i2c_rockchip               |-- i2c@11050000
 ......

印刷意味:バインドを完了したすべてのデバイスドライバをリストします。 すべての uclass-device-driver [ + ] の関連性を一覧表示します。現在のドライバーが、現在のデバイスドライバが U-Boot DTB から来ることを示しているので、それ以外の場合はカーネル DTB から来る。

8.11 DM Uclassの {#811-dm-uclass}

関数: 特定のクラスのuclassの下のすべての装置を見て下さい。

=> dm uclass

uclass 0: root
- * root_driver @ 7be54c88, seq 0, (req -1)

uclass 11: adc
- * saradc@ff100000 @ 7be56220, seq 0, (req -1)
......
uclass 40: backlight
- * backlight @ 7be81178, seq 0, (req -1)
uclass 77: key
-   rockchip-key @ 7be811f0
......

8.12 Stacktrace.sh {#812-stacktracesh}

コールスタックバック機構を使用して、abort、dump_stack() のサイトを分析します。 RKアーキテクチャセクションを参照してください。

8.13 システム クラッシュ {#813-system-crash}

関数: システムが詰まっているとき使用のために適した現在のCPUの場面および呼出しの積み重ねを印刷して下さい。 シリアルポートは、すべての5秒に飽きない情報として同様の情報をダンプします。

CONFIG_ROCKCHIP_DEBUGGER

コールスタック情報を取得し、それを変換するために stacktrace スクリプトを使用します。 RKアーキテクチャセクションを参照してください。

8.14 クルーズチェック {#814-crc-check}

関数: RK 形式のファームウェアの完全性を確認します。 RK 形式のイメージヘッダには、以下のマクロを開くことでファームウェアの完全性を検証するために使用できる画像の CRC32 が含まれている

CONFIG_ROCKCHIP_CRC

例:

=Booting Rockchip format image=
kernel image CRC32 verify... okay.      // kernel verifies success (or prints “fail!” if it
fails)
boot image CRC32 verify... okay.        // boot verifies success (prints “fail!” if it
fails)
kernel   @ 0x02080000 (0x01249808)
ramdisk  @ 0x0a200000 (0x001e6650)
## Chapter-8 Flattened Device Tree blob at 01f00000
   Booting using the fdt blob at 0x1f00000
  'reserved-memory' secure-memory@20000000: addr=20000000 size=10000000
   Loading Ramdisk to 08019000, end 081ff650 ... OK
   Loading Device Tree to 0000000008003000, end 0000000008018c97 ... OK
Adding bank: start=0x00200000, size=0x08200000
Adding bank: start=0x0a200000, size=0xede00000
Starting kernel ...

8.15 ハッシュチェック {#815-hash-check}

関数: Android 形式のファームウェアの完全性を確認します。

ANDROID_BOOT_IMAGE_HASH

この設定が有効になっている場合、ファームウェアの完全性はAndroid形式のファームウェアをロードする際に検証されます。 以前の理由から、上記の設定がファームウェアを正しく確認しない場合は、次の設定を同時にオンにしてください。

HASH_ROCKCHIP_LEGACY

8.16 DDR容量を変更 {#816-modify-ddr-capacity}

ブート中のDDR初期化コードは、U-BootにDDR容量を渡します。これにより、カーネルに渡る前に、いくつかの安全なメモリが削除されます。 U-Boot ステージ中にカーネルに渡される DDR 容量を変更できます。 渡る例:

......
// The block of available memory passed to the kernel (with the safe memory block removed).
Adding bank: 0x00200000 - 0x08400000 (size: 0x08200000)
Adding bank: 0x0a200000 - 0x40000000 (size: 0x35e00000)
Total: 895.411 ms

Starting kernel ...
[    0.000000] Booting Linux on physical CPU 0x0

コードの場所:

./arch/arm/mach-rockchip/param.c

位置を変更します。

struct memblock *param_parse_ddr_mem(int *out_count)
{
    ......

    // Here is the capacity information that ddr passes to U-Boot.
    // Because of the possibility of discontinuous addresses, they are passed in blocks,
specifying the starting address and size of each memory block separately.
    // PS: It's usually contiguous memory and won't need to be chunked.
    for (i = 0, n = 0; i < count; i++, n++) {
        // For example, for a 2GB capacity (contiguous addresses): count = 1, base = 0, size
= 0x80000000.
        // when debugging, users can modify here as needed.
        base = t->u.ddr_mem.bank[i];
        size = t->u.ddr_mem.bank[i + count];

        /* 0~4GB */
        if (base < SZ_4GB) {
            mem[n].base = base;
            mem[n].size = ddr_mem_get_usable_size(base, size);
            if (base + size > SZ_4GB) {
                n++;
                mem[n].base_u64 = SZ_4GB;
                mem[n].size_u64 = base + size - SZ_4GB;
            }
        } else {
            /* 4GB+ */
            mem[n].base_u64 = base;
            mem[n].size_u64 = size;
        }

        assert(n < count + MEM_RESV_COUNT);
    }
    ......
}

8.17 ジャンプ情報 {#817-jump-information}

機能:ファームウェアバージョンとプロセスを確認します。 場合によっては、ブート情報もユーザーがクラッシュ問題を見つけるのを助けることができます

  1. 実行後に立ち往生する信頼のポジシビリティを実行した後に立ち往生:ファームウェアパッケージやダウンロードの問題があり、信頼が間違ったUブートアドレスにジャンプする。 この場合、信頼で印刷されたU-ブートのブートアドレスを確認できます。 64ビット プラットフォーム U ボット ブート アドレスは通常、0x200000 をオフセットします (DRAM は 0x0 で起動します)
NOTICE:  BL31: v1.3(debug):d98d16e
NOTICE:  BL31: Built : 15:03:07, May 10 2018
NOTICE:  BL31: Rockchip release version: v1.1
INFO:    GICv3 with legacy support detected. ARM GICV3 driver initialized in EL3
INFO:    Using opteed sec cpu_context!
INFO:    boot cpu mask: 0
INFO:    plat_rockchip_pmu_init(1151): pd status 3e
INFO:    BL31: Initializing runtime services
INFO:    BL31: Initializing BL32
INFO:    BL31: Preparing for EL3 exit to normal world
INFO:    Entry point address = 0x200000  // U-Boot address
INFO:    SPSR = 0x3c9

32ビットプラットフォーム U ボット ブート アドレスは通常、0x0 をオフセットします (DRAM は 0x60000000 から始まります):

INF [0x0] TEE-CORE:init_primary_helper:378: Release version: 1.9
INF [0x0] TEE-CORE:init_primary_helper:379: Next entry point address: 0x60000000  // U-Boot
address
INF [0x0] TEE-CORE:init_teecore:83: teecore inits done
  1. U-Bootバージョンのバックトラッキング:U-Bootブート情報はビルドバージョンを追跡するために使用できます。 コミットポイントは、b34f08b のコミットに対応します。
U-Boot 2017.09-01730-gb34f08b (Jul 06 2018 - 17:47:52 +0800)

ブートメッセージに「汚い」が表示されるという事実は、コンパイル中にリポジトリにコミットされていないローカル変更があり、コンパイルポイントはクリーンではありません。

U-Boot 2017.09-01730-gb34f08b-dirty (Jul 06 2018 - 17:35:04 +0800)

8.18 ブート情報 {#818-boot-information}

ユーザーは、現在のUボットプロセスと各周辺機器の状態をUブートブートの起動情報で把握できます。これにより、異常が迅速に発見できます。 現在、U-Bootはファームウェアの起動の3種類をサポートしています: Android形式 > RKフォーマット > DISTROフォーマット。 RKでリリースされたSDKは、主に最初の2つのファームウェアフォーマットで、DISTROはオープンソースユーザーが一般的に使用されます。

注意: ユーザのコードが全く新しいものではない場合、一部のプリントは表示できないため、U-Boot のブートメッセージのユーザーの全体的な理解には影響しません。

17.1 Androidファームウェア

// The first line of U-Boot prints, containing information such as commit version, compiling
time, etc.
// Note: This is only  “relatively early” first regular line printout from U-Boot, not the
earliest printout that U-Boot can make.
// Open the debug message, you can see earlier debug prints
U-Boot 2017.09-03033-g81b79f7-dirty (Jul 04 2019 - 15:04:00 +0800)

// The content of the “model” field of the U-Boot dts, which tells us which U-Boot dts we
are using.
Model: Rockchip RK3399 Evaluation Board
// The preloader-serial function is enabled, i.e., it follows the serial port configuration
of the previous loader, and the print port currently used is UART2.
PreSerial: 2
// The total memory capacity of the board is 2GB
DRAM: 2 GiB
// The current version supports the sysmem memory card management mechanism
Sysmem: init
// U-Boot will self-move its own code from the current ddr forward position to a backward
position (see the U-Boot development documentation for details on the boot process)
// The starting address of the self-moved code is 0x7dbe2000, which may be useful for
disassembly and debugging.
Relocation Offset is: 7dbe2000
// ENV is saved in ddr by default. If you choose to save it in eMMC, Nand, etc., it will not
be printed.
Using default environment

// The current storage medium is mmc0, i.e. eMMC (or mmc1 if it is a sd card)
dwmmc@fe320000: 1, sdhci@fe330000: 0
// The storage media type is informed to U-Boot via atags, passed as a parameters by the
previous miniloader
Bootdev(atags): mmc 0
// Current eMMC operates in HS400 mode with a clock frequency of 150M
MMC0: HS400, 150Mhz
// Currently using GPT partition table (if RK parameter partition table used, print: RKPARM)
PartType: EFI
// It's currently in recovery mode
// The “reboot xxx” command executed in the kernel is ultimately represented by this
printout
boot mode: recovery
// The Kernel DTB comes from recovery.img, which is loaded normally
Load FDT from recovery part
DTB: rk-kernel.dtb
HASH: OK(c)

// ==> Note: Since then, U-Boot has swithed to the kernel dtb and all subsequent peripheral
drivers use information from the kernel dtb!

// DTBO executed successfully
ANDROID: fdt overlay OK
// I2C speed, this is one of the influencing factors of U-Boot boot speed, especially for
PMICs with very many DCDCs and LDOs, if the I2C speed is slow,
// Then it will hinder the booting speed to some extent. If users care about boot speed,
they can pay attention to this information
I2c speed: 400000Hz
// Current PMIC is RK818
// The on value corresponds to the ON_SOURCE register and indicates the reason for this
current PMIC power-up
// The off value corresponds to the OFF_SOURCE register and indicates the reason for the
previous shutdown or power loss
// on and off information, which is valuable in the event of an abnormal reboot or shutdown
of the system
PMIC: RK818 (on=0x20 off=0x40)
// The current voltage value of each regulator, is generally DCDC and corresponding to the
RK platform arm, logic, center and other voltages.
// vdd_center 900000 uV- This is valuable information in the event of problems such as
abnormal system startups, erratic booting, etc.
vdd_cpu_l 900000 uV
vdd_log 900000 uV
// The content of the “model” field of the Kernel dts, which tells us which Kernel dts we
are using.
Model: Rockchip RK3399 Excavator Board edp avb (Android)
enter Recovery mode!
// Display driver related information
Rockchip UBOOT DRM driver version: v1.0.1
Using display timing dts
Detailed mode clock 200000 kHz, flags[a]
  H: 1536 1548 1564 1612
  V: 2048 2056 2060 2068
bus_format: 100e
// clk-tree information, please refer to the CLK section of the U-Boot development
documentation for details.
CLK: (uboot. arml: enter 816000 KHz, init 816000 KHz, kernel 0N/A)
CLK: (uboot. armb: enter 24000 KHz, init 24000 KHz, kernel 0N/A)
 aplll 816000 KHz
 apllb 24000 KHz
 dpll 800000 KHz
 cpll 200000 KHz
 gpll 800000 KHz
 npll 600000 KHz
 vpll 24000 KHz
 aclk_perihp 133333 KHz
 hclk_perihp 66666 KHz
 pclk_perihp 33333 KHz
 aclk_perilp0 266666 KHz
 hclk_perilp0 88888 KHz
 pclk_perilp0 44444 KHz
 hclk_perilp1 100000 KHz
 pclk_perilp1 50000 KHz
// GMAC driver enable
Net:  eth0: ethernet@fe300000
// Boot and long press ctrl+c to enter U-Boot command line mode after the following printout
Hit key to stop autoboot('CTRL+C'): 0
// Once again, we know that we are currently in recovery mode.
ANDROID: reboot reason: "recovery"
// vboot=0 means secureboot is not enabled; it's currently AVB firmware, so it will go
through AVB's regular checking flow
Vboot=0, AVB images, AVB verify
// kWhether the device is unlocked
read_is_device_unlocked() ops returned that device is UNLOCKED
// Native U-Boot by default loads the entire boot.img/recovery.img, and then ramdisk, fdt,
kernel
// A single move (called relocation) to an address predetermined by the user, which is time-
consuming, especially if the ramdisk is very large.
// The RK platform was modified to move ramdisk, fdt, and kernel directly from storage to
the intended memory address all at once.
// A printout such as the following indicates that this one-time move is enabled, saving you
time
Fdt Ramdisk skip relocation

// Load the firmware in Android format, load kernel to 0x00280000, fdt to 0x8300000
// If it is an LZ4 compressed kernel, it may print here:
// Booting LZ4 kernel at 0x00680000(Uncompress to 0x00280000) with fdt at 0x8300000...
Booting IMAGE kernel at 0x00280000 with fdt at 0x8300000...

// Ignore, no need to concern.
### Booting Android Image at 0x0027f800 ...
// \kernel and ramdisk load address and size
Kernel load addr 0x00280000 size 19081 KiB
RAM disk load addr 0x0a200000 size 9627 KiB
// fdt load address
### Flattened Device Tree blob at 08300000
   Booting using the fdt blob at 0x8300000
// Ignore, no need to concern
   XIP Kernel Image ... OK
// This simply prints the reserved-memory specified by the kernel dts, which can be used as
a piece of information to analyze if the kernel has problems booting.
   'reserved-memory' secure-memory@20000000: addr=20000000 size=10000000
// Start and end address of fdt
   Using Device Tree in place at 0000000008300000, end 000000000831c6f7
// Passed to the kernel to inform the kernel of the range of memory space available to the
kernel (ATF, optee, etc. space has been removed)
Adding bank: 0x00200000 - 0x08400000 (size: 0x08200000)
Adding bank: 0x0a200000 - 0x80000000 (size: 0x75e00000)
// U-Boot phase boot time consuming
Total: 367.128 ms

// Printed by U-Boot, after this print, U-Boot will complete some ARM architecture related
(e.g., clearing cache, turning off interrupts,
// cpu state switching, etc.) and U-Boot's dm device logout and other clearing work, the
probability of problems is extremely low.
// Once the above work's done, it jump to the kernel, so it can also be understood as that
this printout means you've reached the kernel stage.
Starting kernel ...

// Printed information from the kernel phase
[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Initializing cgroup subsys cpuacct
[    0.000000] Initializing cgroup subsys schedtune
[    0.000000] Linux version 4.4.167 (hgc@ubuntu) (gcc version 6.3.1 20170404 (Linaro
GCC 6.3-2017.05) ) #83 SMP PREEMPT Thu Mar 21 09:31:08 CST 2019
[    0.000000] Boot CPU: AArch64 Processor [410fd034]
[    0.000000] earlycon: Early serial console at MMIO32 0xff1a0000 (options '')
[    0.000000] bootconsole [uart0] enabled
[    0.000000] Reserved memory: failed to reserve memory for node 'stb-
devinfo@00000000': base 0x0000000000000000, size 0 MiB
[    0.000000] cma: Reserved 16 MiB at 0x000000007f000000
......

8.18.1 RKのファームウェア {#8181-rk-firmware}

U-Boot 2017.09-03352-gb1265b5 (Jul 12 2019 - 09:57:24 +0800)

Model: Rockchip RK3399 Evaluation Board
PreSerial: 2
DRAM:  2 GiB
Sysmem: init
Relocation Offset is: 7dbe2000
Using default environment
......

Hit key to stop autoboot('CTRL+C'):  0
ANDROID: reboot reason: "recovery"
// Since it's RK format firmware, it can't be AVB format
Not AVB images, AVB skip
// Because it is RK format firmware, so here will prompt that load android format firmware
fails
// Because the current startup priority is: android format > RK format > distro format
** Invalid Android Image header **
Android image load failed
Android boot failed, error -1.
// Currently in recovery mode
boot mode: recovery
// Boot RK-formatted firmware, load ramdis, kernel, fdt
=Booting Rockchip format image=
fdt      @ 0x08300000 (0x00012dd0)
kernel   @ 0x00280000 (0x0119e008)
ramdisk  @ 0x0a200000 (0x00754540)

// The following is basically similar to the boot information for android-formatted firmware
Fdt Ramdisk skip relocation
### Flattened Device Tree blob at 08300000
   Booting using the fdt blob at 0x8300000
   Using Device Tree in place at 0000000008300000, end 0000000008315dcf
Adding bank: 0x00200000 - 0x08400000 (size: 0x08200000)
Adding bank: 0x0a200000 - 0x80000000 (size: 0x75e00000)
Total: 508.11 ms

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
......

8.18.2 ファームウェアのディストロ {#8182-distro-firmware}

U-Boot 2017.09-03352-gb1265b5 (Jul 12 2019 - 09:57:24 +0800)

Model: Rockchip RK3399 Evaluation Board
PreSerial: 2
DRAM:  2 GiB
Sysmem: init
Relocation Offset is: 7dbe2000
Using default environment

......

//  find mmc0, i.e. eMMCswitch to partitions #0, OK
mmc0(part 0) is current device
// Find the firmware for the 6th partition on the eMMC storage (in the GPT partition table,
6 corresponds to the boot.img partition, which is indicated by the “-bootable” attribute in
the GPT)
Scanning mmc 0:6...
// Found the configuration file extlinux.conf
Found /extlinux/extlinux.conf
Retrieving file: /extlinux/extlinux.conf

// Loading kernel
205 bytes read in 82 ms (2 KiB/s)
1:      rockchip-kernel-4.4
Retrieving file: /Image
13484040 bytes read in 1833 ms (7 MiB/s)

// Specified cmdline information when packaging
append: earlycon=uart8250,mmio32,0xff1a0000 console=ttyS2,1500000n8 rw
root=/dev/mmcblk0p7 rootwait rootfstype=ext4 init=/sbin/init

// Loading fdtLoad fdt
Retrieving file: /rk3399.dtb
61714 bytes read in 54 ms (1.1 MiB/s)

// ==> If there is no ramdisk at the time of packing, no ramdisk information will be
printed; otherwise it will be printed here as well.

### Flattened Device Tree blob at 01f00000
   Booting using the fdt blob at 0x1f00000
   Loading Device Tree to 000000007df14000, end 000000007df26111 ... OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
......

8.18.3 有効なファームウェア無し {#8183-no-valid-firmware}

U-Boot 2017.09-03352-gb1265b5 (Jul 12 2019 - 09:57:24 +0800)

Model: Rockchip RK3399 Evaluation Board
PreSerial: 2
DRAM:  2 GiB
Sysmem: init
Relocation Offset is: 7dbe2000
Using default environment

......

// Find mmc0, the eMMCFind mmc0, the eMMC
Can't find boot message for firmware
switch to partitions Can't find boot message for firmware#0, OK
mmc0(part 0) is current device
// Find the firmware for the 6th partition on the eMMC storage (in the GPT partition table,
6 corresponds to the boot.img partition, which is indicated by the “-bootable” attribute in
the GPT)
Scanning mmc 0:6...
// Found the configuration file extlinux.conf
Found /extlinux/extlinux.conf
Retrieving file: /extlinux/extlinux.conf

// Loading kernel Load kernel
205 bytes read in 82 ms (2 KiB/s)
1:      rockchip-kernel-4.4
Retrieving file: /Image
13484040 bytes read in 1833 ms (7 MiB/s)

// Specified cmdline information when packaging
append: earlycon=uart8250,mmio32,0xff1a0000 console=ttyS2,1500000n8 rw
root=/dev/mmcblk0p7 rootwait rootfstype=ext4 init=/sbin/init

// Loading fdt  Load fdt
Retrieving file: /rk3399.dtb
61714 bytes read in 54 ms (1.1 MiB/s)

// ==> If there is no ramdisk at the time of packing, no ramdisk information will be
printed; otherwise it will be printed here as well.

### Flattened Device Tree blob at 01f00000
   Booting using the fdt blob at 0x1f00000
   Loading Device Tree to 000000007df14000, end 000000007df26111 ... OK

Starting kernel ...
[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
......
U-Boot 2017.09-03352-gb1265b5 (Jul 12 2019 - 09:57:24 +0800)

Model: Rockchip RK3399 Evaluation Board
PreSerial: 2
DRAM:  2 GiB
Sysmem: init
Relocation Offset is: 7dbe2000
Using default environment

......

Net:   eth0: ethernet@fe300000
Hit key to stop autoboot('CTRL+C'):  0 ANDROID: reboot reason: "recovery"
// Not Android format firmware
Not AVB images, AVB skip
** Invalid Android Image header **
Android image load failed
Android boot failed, error -1.
boot mode: recovery

// Not RK format firmware
=Booting Rockchip format image=
kernel: invalid image tag(0x45435352)
boot_rockchip_image kernel part read error

// Not DISTRO format firmware. All of the latter prints come in the distro load command
because the distro command will try to get from mmc, nand, net,
// usb and all our predefined devices (see the macro definition in rockchip-common.h:
BOOT_TARGET_DEVICES).
// Looking for distro firmware, i.e. scanning one by one to search
switch to partitions #0, OK
mmc0(part 0) is current device
Failed to mount ext2 filesystem...
** Unrecognized filesystem type **
starting USB...
USB0:   Register 2000140 NbrPorts 2
Starting the controller
USB XHCI 1.10
USB1:   Register 2000140 NbrPorts 2
Starting the controller
USB XHCI 1.10
USB2:   USB EHCI 1.00
USB3:   USB OHCI 1.0
USB4:   USB EHCI 1.00
USB5:   USB OHCI 1.0
scanning bus 0 for devices... 1 USB Device(s) found
scanning bus 1 for devices... 1 USB Device(s) found
scanning bus 2 for devices... 1 USB Device(s) found
scanning bus 3 for devices... 1 USB Device(s) found
scanning bus 4 for devices... 1 USB Device(s) found
scanning bus 5 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found

Device 0: unknown device
ethernet@fe300000 Waiting for PHY auto negotiation to complete......... TIMEOUT !
Could not initialize PHY ethernet@fe300000
missing environment variable: pxeuuid
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/01-7a-1d-33-50-3d-a1
ethernet@fe300000 Waiting for PHY auto negotiation to complete..
......

// Eventually the distro command scanned all possible storage media and couldn't find the
firmware, so it stopped in U-Boot command line mode
=>

9. . Chapter-9 試験ケース {#9-chapter-9-test-case}

日 時 チャプター10 SPL {#10-chapter-10-spl}

10.1 ファームウェアのブート {#101-firmware-boot}

SPLは、trust.imgとuboot.imgをロードして起動するミニローダーを交換します。 SPLは現在、デフォルトで有効になっているファームウェアの2種類のファームウェアFITファームウェアの起動をサポートしています: デフォルトでは無効に、設定され、ユーザー別に有効化する必要があります。

10.1.1 FIT ファームウェア {#1011-fit-firmware}

FIT(フラットイメージツリー)フォーマットは、SPLがサポートする比較的新しいファームウェア形式で、複数の画像がパッケージ化および検証されるようにサポートします。FITは、DTSの構文を使用して、パッケージされたイメージを記述し、説明ファイルはu-boot.itsであり、生成されたFITファームウェアはu-boot.itbです。 FITの利点: dts の構文とコンパイルルールを再使用, より柔軟, ファームウェアの解析は、直接libfdt ライブラリ u-boot.its ファイルを使用する: /images : 静的にすべてのアクセス可能なリソース構成を定義します (利用可能な, オプション), dtsi の役割に似ています; /configurations : 各コンフィグノードは、起動可能な設定のセットを記述します, ボードレベルの dts と同様に デフォルト 指定されたデフォルト設定 = を使用されます; テンプレート:

/dts-v1/;

/ {
    description = "Configuration to load ATF before U-Boot";
    #address-cells = <1>;

    images {
        uboot@1 {
            description = "U-Boot (64-bit)";
            data = /incbin/("u-boot-nodtb.bin");
            type = "standalone";
            os = "U-Boot";
            arch = "arm64";
            compression = "none";
            load = <0x00200000>;
        };
        atf@1 {
            description = "ARM Trusted Firmware";
            data = /incbin/("bl31_0x00010000.bin");
            type = "firmware";
            arch = "arm64";
            os = "arm-trusted-firmware";
            compression = "none";
            load = <0x00010000>;
            entry = <0x00010000>;
        };

        atf@2 {
            description = "ARM Trusted Firmware";
            data = /incbin/("bl31_0xff091000.bin");
            type = "firmware";
            arch = "arm64";
            os = "arm-trusted-firmware";
            compression = "none";
            load = <0xff091000>;
        };

        optee@1 {
            description = "OP-TEE";
            data = /incbin/("bl32.bin");
            type = "firmware";
            arch = "arm64";
            os = "op-tee";
            compression = "none";
            load = <0x08400000>;
        };

        fdt@1 {
            description = "rk3328-evb.dtb";
            data = /incbin/("arch/arm/dts/rk3328-evb.dtb");
            type = "flat_dt";
            compression = "none";
        };
    };

    configurations {
        default = "config@1";
        config@1 {
            description = "rk3328-evb.dtb";
            firmware = "atf@1";
            loadables = "uboot@1", "atf@2", "optee@1" ;
            fdt = "fdt@1";
        };
    };
};

u-boot.itb ファイル:

                          mkimage + dtc
[u-boot.its] + [images]        ==>         [u-boot.itb]

上記は、その内容がイメージである場合を除き、FITファームウェアは特別な種類のDTBファイルとして理解することができます。ユーザーはfdtdumpコマンドでイブファイルを閲覧できます。

cjh@ubuntu:~/uboot-nextdev/u-boot$ fdtdump u-boot.itb | less

/dts-v1/;
// magic:               0xd00dfeed
// totalsize:           0x497 (1175)
// off_dt_struct:       0x38
// off_dt_strings:      0x414
// off_mem_rsvmap:      0x28
// version:             17
// last_comp_version:   16
// boot_cpuid_phys:     0x0
// size_dt_strings:     0x83
// size_dt_struct:      0x3dc

/ {
    timestamp = <0x5d099c85>;
    description = "Configuration to load ATF before U-Boot";
    #address-cells = <0x00000001>;
    images {
        uboot@1 {
            data-size = <0x0009f8a8>;
            data-offset = <0x00000000>;
            description = "U-Boot (64-bit)";
            type = "standalone";
            os = "U-Boot";
            arch = "arm64";
            compression = "none";
            load = <0x00600000>;
        };
        atf@1 {
            data-size = <0x0000c048>;   // This field is automatically added by the
compilation process to describe the atf@1 firmware size
            data-offset = <0x0009f8a8>; // This field is automatically added by the
compilation process to describe the atf@1 firmware offset
            description = "ARM Trusted Firmware";
            type = "firmware";
            arch = "arm64";
            os = "arm-trusted-firmware";
            compression = "none";
            load = <0x00010000>;
            entry = <0x00010000>;
        };
        atf@2 {
            data-size = <0x00002000>;
            data-offset = <0x000ab8f0>;
            description = "ARM Trusted Firmware";
            type = "firmware";
            arch = "arm64";
            os = "arm-trusted-firmware";
            compression = "none";
            load = <0xfff82000>;
        };
        fdt@1 {
            data-size = <0x00005793>;
            data-offset = <0x000ad8f0>;
            description = "rk3308-evb.dtb";
            type = "flat_dt";
            ......
        };
        ......
    };
};

FITの詳細については、以下を参照してください。

./doc/uImage.FIT/

10.1.2 RKFWのファームウェア {#1012-rkfw-firmware}

後続ファームウェアのパーティションとパッケージフォーマットを変更することなく、ミニローダーを直接交換するために、RKプラットフォームはRKFW形式(つまり、独立してパーティションされたファームウェア:trust.imgとuboot.img)をブートに追加します。 構成:

CONFIG_SPL_LOAD_RKFW           // Enable switch
CONFIG_RKFW_TRUST_SECTOR       // trust.img partition address, shall be consistent with the
definition of the partition table
CONFIG_RKFW_U_BOOT_SECTOR      // uboot.img partition address, shall be consistent with the
definition of the partition table

コード:

./include/spl_rkfw.h
./common/spl/spl_rkfw.c

10.1.3 ストレージ優先度 {#1013-storage-priority}

ストレージデバイスの起動優先度は、u-boot、spl-boot-order を介して U-Boot dts で指定されます。

/ {
    aliases {
        mmc0 = &emmc;
        mmc1 = &sdmmc;
    };

    chosen {
        u-boot,spl-boot-order = &sdmmc, &nandc, &emmc;
        stdout-path = &uart2;
    };
    ......
};

10.2 コンパイルと包装 {#102-compilation-and-packaging}

10.2.1 コード 編集 {#1021-code-compilation}

U-Boot は、SPL ファームウェアを取得する別のコンパイルパスに従って同じ U-Boot コードをコンパイルし、SPL コンパイル時に CONFIG_SPL_BUILD マクロを自動的に生成します。 U-Bootは、u-boot.bin コンパイル後 SPL をコンパイルし、別の出力ディレクトリを作成します。 /spl/ .

  // compile u-boot
  ......
  DTC     arch/arm/dts/rk3399-puma-ddr1866.dtb
  DTC     arch/arm/dts/rv1108-evb.dtb
make[2]: `arch/arm/dts/rk3328-evb.dtb' is up to date.
  SHIPPED dts/dt.dtb
  FDTGREP dts/dt-spl.dtb
  CAT     u-boot-dtb.bin
  MKIMAGE u-boot.img
  COPY    u-boot.dtb
  MKIMAGE u-boot-dtb.img
  COPY    u-boot.bin

  // Compile spl, with separate spl/ directory
  LD      spl/arch/arm/cpu/built-in.o
  CC      spl/board/rockchip/evb_rk3328/evb-rk3328.o
  LD      spl/dts/built-in.o
  CC      spl/common/init/board_init.o
  COPY    tpl/u-boot-tpl.dtb
  CC      spl/cmd/nvedit.o
  CC      spl/env/common.o
  CC      spl/env/env.o
  .....
  LD      spl/drivers/block/built-in.o

  ......

コンパイルの最後に、取得します

./spl/u-boot-spl.bin

10.2.2 ファームウェア包装 {#1022-firmware-packaging}

10.3 システム モジュール {#103-system-module}

10.3.1 GPTの特長 {#1031-gpt}

SPLはGPTの仕切りテーブルを使用します。 構成:

CONFIG_SPL_LIBDISK_SUPPORT=y
CONFIG_SPL_EFI_PARTITION=y
CONFIG_PARTITION_TYPE_GUID=y

ドライバー:

./disk/part.c
./disk/part_efi.c

インターフェイス:

int part_get_info(struct blk_desc *dev_desc, int part, disk_partition_t *info);
int part_get_info_by_name(struct blk_desc *dev_desc,
                          const char *name, disk_partition_t *info);

10.3.2 A/B システム {#1032-ab-system}

SPLはA/Bシステム ブート、構成を支えます:

CONFIG_SPL_AB=y

ドライバー:

./common/spl/spl_ab.c

インターフェイス:

int spl_get_current_slot(struct blk_desc *dev_desc, char *partition, char *slot);
int spl_get_partitions_sector(struct blk_desc *dev_desc, char *partition,u32 *sectors);

10.3.3 ブート優先度 {#1033-boot-priority}

SPL は、u-boot,spl-boot-order で定義されたブートオーダーを rkxxxx-u-boot.dtsi に指定します。

chosen {
stdout-path = &uart2;
u-boot,spl-boot-order = &sdmmc, &sfc, &nandc, &emmc;
};

マスロムのブート優先順位:

spi nor > spi nand > emmc > sd

プレローダー(SPL) 起動優先:

sd > spi nor > spi nand > emmc

sd カードの優先度を最大化すると、システムがsdカードから起動するのが容易になります。

10.3.4 データシート {#1034-atags}

SPLとU-Bootは、ATAGSメカニズムを介したパラメータの渡渡しを実行します。 渡された情報は、ストレージデバイスが起動し、印刷シリアルポートなどです。 構成:

CONFIG_ROCKCHIP_PRELOADER_ATAGS=y

ドライバー:

./arch/arm/include/asm/arch-rockchip/rk_atags.h
./arch/arm/mach-rockchip/rk_atags.c

インターフェイス:

int atags_set_tag(u32 magic, void *tagdata);
struct tag *atags_get_tag(u32 magic);

10.3.5 カーネルブート {#1035-kernel-boot}

通常カーネルは、U-Bootによってロードされ、起動されます。SPLは、現在、Androidヘッドバージョン2 boot.imgをロードするサポート、RKフォーマットファームウェアをサポートしています。 ブートシーケンス

Maskrom -> ddr -> SPL -> Trust -> Kernel

10.3.6 ピクチャー {#1036-pinctrl}

構成:

CONFIG_SPL_PINCTRL_GENERIC=y
CONFIG_SPL_PINCTRL=y

ドライバー:

./drivers/pinctrl/pinctrl-uclass.c
./drivers/pinctrl/pinctrl-generic.c
./drivers/pinctrl/pinctrl-rockchip.c

DTS の設定: sdmmc を例に取ります

&pinctrl {
    u-boot,dm-spl;
};

&pcfg_pull_none_4ma {
    u-boot,dm-spl;
};

&pcfg_pull_up_4ma {
    u-boot,dm-spl;
};

&sdmmc {
    u-boot,dm-spl;
};

&sdmmc_pin {
    u-boot,dm-spl;
};

&sdmmc_clk {
    u-boot,dm-spl;
};

&sdmmc_cmd {
    u-boot,dm-spl;
};

&sdmmc_bus4 {
    u-boot,dm-spl;
};
&sdmmc_pwren {
    u-boot,dm-spl;
};

注意: SPL 用の pinctrl を有効にするには、 defconfig の CONFIG_OF_SPL_REMOVE_PROPS 定義を変更して、 ピンクセル-0 ピンクサー の名前フィールドを削除します。

10.3.7 セキュアブート {#1037-secure-boot}

[TODO] インフォメーション

10.4 ドライバー モジュール {#104-driver-module}

10.4.1 MMC(エムシーエム) {#1041-mmc}

構成:

CONFIG_SPL_MMC_SUPPORT=y  // Enabled by default

ドライバー:

./common/spl/spl_mmc.c

インターフェイス:

int spl_mmc_load_image(struct spl_image_info *spl_image,
                       struct spl_boot_device *bootdev);

10.4.2 MTDブロック {#1042-mtd-block}

SPL は、nand、spi nand、spi およびブロックレイヤーへのインターフェイスを統一します。 構成:

// MTD driver support
CONFIG_MTD=y
CONFIG_CMD_MTD_BLK=y
CONFIG_SPL_MTD_SUPPORT=y
CONFIG_MTD_BLK=y
CONFIG_MTD_DEVICE=y

// spi nand driver support
CONFIG_MTD_SPI_NAND=y
CONFIG_ROCKCHIP_SFC=y
CONFIG_SPL_SPI_FLASH_SUPPORT=y
CONFIG_SPL_SPI_SUPPORT=y

// nand driver support
CONFIG_NAND=y
CONFIG_CMD_NAND=y
CONFIG_NAND_ROCKCHIP=y /* NandC v6 can be confirmed based on TRM NANDC->NANDC_NANDC_VER
register, 0x00000801 */
//CONFIG_NAND_ROCKCHIP_V9=y  /* NandC v9 can be confirmed based on TRM NANDC-
>NANDC_NANDC_VER register, 0x56393030, Take RK3326/PX30 as an example */
CONFIG_SPL_NAND_SUPPORT=y
CONFIG_SYS_NAND_U_BOOT_LOCATIONS=y
CONFIG_SYS_NAND_U_BOOT_OFFS=0x8000
CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND=0x10000
// The nand page size needs to be defined according to the real size, if you use NAND with a
capacity greater than or equal to 512MB, you generally need to configure it as 4096.
#define CONFIG_SYS_NAND_PAGE_SIZE   2048

// spi nor driver support
CONFIG_CMD_SF=y
CONFIG_CMD_SPI=y
CONFIG_SPI_FLASH=y
CONFIG_SF_DEFAULT_MODE=0x1
CONFIG_SF_DEFAULT_SPEED=50000000
CONFIG_SPI_FLASH_GIGADEVICE=y
CONFIG_SPI_FLASH_MACRONIX=y
CONFIG_SPI_FLASH_WINBOND=y
CONFIG_SPI_FLASH_MTD=y
CONFIG_ROCKCHIP_SFC=y
CONFIG_SPL_SPI_SUPPORT=y
CONFIG_SPL_MTD_SUPPORT=y
CONFIG_SPL_SPI_FLASH_SUPPORT=y

ドライバー:

./common/spl/spl_mtd_blk.c

インターフェイス:

int spl_mtd_load_image(struct spl_image_info *spl_image,
                       struct spl_boot_device *bootdev);

10.4.3 OTP(オタク) {#1043-otp}

安全な起動で使用される非修飾データを保存するために使用されます。 構成:

CONFIG_SPL_MISC=y
CONFIG_SPL_ROCKCHIP_SECURE_OTP=y

ドライバー:

./drivers/misc/misc-uclass.c
./drivers/misc/rockchip-secure-otp.S

インターフェイス:

int misc_read(struct udevice *dev, int offset, void *buf, int size);
int misc_write(struct udevice *dev, int offset, void *buf, int size);

10.4.4 暗号化 {#1044-crypto}

Secure-boot は、ハッシュ、ras の計算を完了するために、暗号化を使用します。 構成:

CONFIG_SPL_DM_CRYPTO=y

// The defconfig of each platform has enabled the corresponding configuration by default.
CONFIG_SPL_ROCKCHIP_CRYPTO_V1=y
or
CONFIG_SPL_ROCKCHIP_CRYPTO_V2=y

ドライバー:

./drivers/crypto/crypto-uclass.c
./drivers/crypto/rockchip/crypto_v1.c
./drivers/crypto/rockchip/crypto_v2.c
./drivers/crypto/rockchip/crypto_v2_pka.c
./drivers/crypto/rockchip/crypto_v2_util.c

インターフェイス:

u32 crypto_algo_nbits(u32 algo);
struct udevice *crypto_get_device(u32 capability);
int crypto_sha_init(struct udevice *dev, sha_context *ctx);
int crypto_sha_update(struct udevice *dev, u32 *input, u32 len);
int crypto_sha_final(struct udevice *dev, sha_context *ctx, u8 *output);
int crypto_sha_csum(struct udevice *dev, sha_context *ctx,
                    char *input, u32 input_len, u8 *output);
int crypto_rsa_verify(struct udevice *dev, rsa_key *ctx, u8 *sign, u8 *output);

10.4.5 カート {#1045-uart}

SPL シリアルポートは、rkxxxx-u-boot.dtsi の選択したノードで指定されます。 rk3308を例に挙げる:

chosen {
    stdout-path = &uart2;
};

&uart2 {
    u-boot,dm-pre-reloc;
    clock-frequency = <24000000>;
    status = "okay";
};

11.11.11 第11章 TPL {#11-chapter-11-tpl}

TPLはU-Bootよりも初期の段階で loader で、TPL は SRAM で実行され、その役割は DRAM.TPL の初期化を完了する責任がある ddr bin を置き換えることです。コードと ddr bin のオープンソース バージョンは、コードのクローズドソースバージョンです。

11.1 コンパイルとパッケージング {#111-compiling-and-packaging}

11.1.1 設定 {#1111-configuration}

UART構成CONFIG_DEBUG_UART_BASE:UARTベースアドレスCONFIG_ROCKCHIP_UART_MUX_SEL_M:UART IOMUX GROUP.

例:RV1126はDEBUG LOGを印刷するためのUART2 M2を構成します。 方法 1)rv1126_defconfigファイルの変更による

CONFIG_DEBUG_UART_BASE=0xff570000
CONFIG_ROCKCHIP_UART_MUX_SEL_M=2

方法 2)メニュー設定をすることで

Device Drivers ---> Serial drivers ---> (0xff570000) Base address of UART
ARM architecture ---> (2) UART mux select

DRAM TYPE 設定は、TPL が CONFIG_ROCKCHIP_TPL_INIT_DRAM_TYPE 経由でサポートする DRAM タイプを構成する。

DDRタイプ 設定値
DDR2 2
DDR3 3
DDR4 0
LPDDR2 5
LPDDR3 6
LPDDR4 7

例:RV1126 TPL DRAM Type の設定で DDR3 をサポート。 方法 1)rv1126_defconfigファイルの変更による

CONFIG_ROCKCHIP_TPL_INIT_DRAM_TYPE=3

方法 2)メニュー設定を行うことで、コンパイル時にmake.shがチップモデル番号を追っていれば、設定時にxxxdefconfigアクションが作成されるので、メニュー設定の変更を上書きすることが重要です。 オーバーライドされるメニュー設定の変更を防ぐため、パラメータなしでmake.shをコンパイルできます。

Device Drivers ---> (3) TPL select DRAM type

例: rv1126_defconfig または . /make.sh rv1126 -> は、関連する構成を変更するためにメニュー設定を作ります -> . /make.sh。 クイックブート設定 コンパイルし、クイックブートをサポートするtpl.binを生成する必要がある場合は、CONFIG_SPL_KERNEL_BOOTを開くことで行うことができます。 現在RV1126/RV1109プラットフォームのみ対応しています。 広い温度サポート 広範囲の温度をサポートするtpl.binをコンパイルして生成する必要がある場合は、CONFIG_ROCKCHIP_DRAM_EXTENDED_TEMP_SUPPORTを開くことで行うことができます。 RV1126/RV1109 プラットフォームのみ対応 他のパラメータ変更 ddr初期化ソースコードは、ドライバ/ram/rockchipディレクトリ、周波数、ドライブ強度、ODT強度などの他のddr関連のパラメーターにソースコードで修正する必要があります。 RV1126/RV1109 では、ddr 関連のパラメーターは「sdram_inc/rv1126/sdram-rv1126- loader_params.inc」で一元化され、対応するパラメータはこのファイルに直接変更することができます。 その他のプラットフォームパラメータは、対応するsdram_xxx.cで変更する必要があります。

11.1.2 コンパイル {#1112-compiling}

U-Boot は、異なるコンパイルパスに従って同じ U-Boot コードをコンパイルし、TPL ファームウェアを取得すると自動的に CONFIG_TPL_BUILD マクロを生成します。 U-Bootは、u-boot.bin コンパイル後、TPL をコンパイルし、別の出力ディレクトリを作成します。 /tpl/ .

// Compile u-boot
......
DTC     arch/arm/dts/rv1108-evb.dtb
DTC     arch/arm/dts/rk3399-puma-ddr1866.dtb
DTC     arch/arm/dts/rv1126-evb.dtb
FDTGREP dts/dt.dtb
FDTGREP dts/dt-spl.dtb
FDTGREP dts/dt-tpl.dtb
CAT     u-boot-dtb.bin
MKIMAGE u-boot.img
COPY    u-boot.dtb
MKIMAGE u-boot-dtb.img
COPY    u-boot.bin
ALIGN   u-boot.bin

// Compile tpl, with a separate tpl/directory
......
CC      tpl/common/init/board_init.o
CC      tpl/disk/part.o
LD      tpl/common/init/built-in.o
......
LD      tpl/u-boot-tpl
......
OBJCOPY tpl/u-boot-tpl-nodtb.bin
COPY    tpl/u-boot-tpl.bin

コンパイルの最後に、次のようになります。

./tpl/u-boot-tpl.bin

例:コンパイル RV1126 uboot.

./make.sh rv1126

11.1.3 包装 {#1113-packaging}

  1. コンパイルから生成されるu-boot-tpl.binは、対応するプラットフォームのタグで最初の4バイトを交換し、RV1126 / RV1109プラットフォーム用のタグ「110B」など、法的ダービンである必要があります。 ddr bin だけが必要な場合は、タグの置換アクションを手動で完了する必要があります。このアクションは、scripts/spl.shスクリプトを参照できます。

例:RV1126 u-boot-tpl.binのtageを取り替えて下さい

dd bs=4 skip=1 if=tpl/u-boot-tpl.bin of=tpl/u-boot-tpl-tag.bin && sed -i '1s/^/110B&/'
tpl/u-boot-tpl-tag.bin
  1. ボードにダウンロードできる完全なLoaderファイルを生成する必要がある場合は、次のコマンドを使用して、u-boot-tpl.binタグを自動置換し、spl.binでパッケージして、完全なLoaderファイルを形成することができます。
./make.sh tpl

日 時 第12章 フィット {#12-chapter-12-fit}

12.1 プレファス {#121-preface}

このセクションでは、FIT フォーマットに基づくセキュア/非安全なブートスキームの FIT 形式と詳細について説明します。 プレゼンテーションの酒は、boot.imgを中心にしていますが、recovery.imgには同じことが当てはまります。

12.2 簡単な紹介 {#122-brief-introduction}

12.2.1 基本紹介 {#1221-basic-introduction}

FIT(フラットイメージツリー)は、U-Bootがサポートする新しいファームウェアタイプのブートスキームで、任意の数の画像パッケージとチェックサムをサポートしています。 FITは、画像情報(画像ソースファイル)を記述し、mkimageツールで画像(フラットイメージツリーのブロブ)画像を生成します。 ファイルが DTS の構文ルールを使用しており、非常に柔軟で libfdt ライブラリと関連ツールを使用して直接使用できます。 FITは、U-Bootがサポートするデフォルトで推奨されるファームウェアフォーマットであり、SPLとU-Bootフェーズの両方がFITフォーマットのファームウェアに起動をサポートする。 詳しくは、下記をご覧ください。

./doc/uImage.FIT/

オフィシャルFIT機能が実際の製品需要に対応できないため、RKプラットフォームはFITを適応・最適化しました。 そのため、RK U-BootでコンパイルされたmkimageツールはFITプログラムで使用しなければならないが、PCに付属するmkimageではない。

12.2.2 導入事例 {#1222-example-introduction}

以下は、u-boot.its と u-boot.itb を例として紹介します。 /images : 静的に全てのリソースを定義し、dtsi ファイルと同じです。 /configurations : 各コンフィグノードは、ボードレベルのdtsファイルと同じ、起動可能な設定のセットを記述しています。デフォルト = : デフォルトで有効になっているコンフィグを指定します。

/dts-v1/;

/ {
    description = "Simple image with OP-TEE support";
    #address-cells = <1>;

    images {
        uboot {
            description = "U-Boot";
            data = /incbin/("./u-boot-nodtb.bin");
            type = "standalone";
            os = "U-Boot";
            arch = "arm";
            compression = "none";
            load = <0x00400000>;
            hash {
                algo = "sha256";
            };
        };
        optee {
            description = "OP-TEE";
            data = /incbin/("./tee.bin");
            type = "firmware";
            arch = "arm";
            os = "op-tee";
            compression = "none";
            load = <0x8400000>;
            entry = <0x8400000>;
            hash {
                algo = "sha256";
            };
        };
        fdt {
            description = "U-Boot dtb";
            data = /incbin/("./u-boot.dtb");
            type = "flat_dt";
            compression = "none";
            hash {
                algo = "sha256";
            };
        };
    };

    // configurations Any number of different conf nodes can be defined under the node, but
in the actual product scenario we only need one conf.
    configurations {
        default = "conf";
        conf {
            description = "Rockchip armv7 with OP-TEE";
            rollback-index = <0x0>;
            firmware = "optee";
            loadables = "uboot";
            fdt = "fdt";
            signature {
                algo = "sha256,rsa2048";
                padding = "pss";
                key-name-hint = "dev";
                sign-images = "fdt", "firmware", "loadables";
            };
        };
    };
};

mkimage ツールとそのファイルを使用して、itb ファイルが生成できます。

                          mkimage + dtc
[u-boot.its] + [images]    =========>      [u-boot.itb]

fdtdump コマンドは、そのファイルの内容を表示することができます。

cjh@ubuntu:~/uboot-nextdev/u-boot$ fdtdump fit/u-boot.itb | less

/dts-v1/;
// magic:       0xd00dfeed
// totalsize:       0x600 (1536)
// off_dt_struct:   0x48
// off_dt_strings:  0x48c
// off_mem_rsvmap:  0x28
// version:     17
// last_comp_version:   16
// boot_cpuid_phys: 0x0
// size_dt_strings: 0xc3
// size_dt_struct:  0x444

/memreserve/ 7f34d3411000 600;
/ {
    version = <0x00000001>;               // Add firmware version number
    totalsize = <0x000bb600>;             // Add new field to describe the size of the
entire itb file
    timestamp = <0x5ecb3553>;             // Add timestamp for current firmware generation
moment
    description = "Simple image with OP-TEE support";
    #address-cells = <0x00000001>;
    images {
        uboot {
            data-size = <0x0007ed54>;     // Add new field to describe firmware size
            data-position = <0x00000a00>; // Add new field to describe firmware offsets
            description = "U-Boot";
            type = "standalone";
            os = "U-Boot";
            arch = "arm";
            compression = "none";
            load = <0x00400000>;
            hash {
                // Added sha256 checksum for firmware
                value = <0xeda8cd52 0x8f058118 0x00000003 0x35360000 0x6f707465 0x0000009f
0x00000091 0x00000000>;
                algo = "sha256";
            };
        };
        optee {
            data-size = <0x0003a058>;
            data-position = <0x0007f800>;
            description = "OP-TEE";
            type = "firmware";
            arch = "arm";
            os = "op-tee";
            compression = "none";
            load = <0x08400000>;
            entry = <0x08400000>;
            hash {
                value = <0xa569b7fc 0x2450ed39 0x00000003 0x35360000 0x66647400 0x00001686
0x000b9a00 0x552d426f>;
                algo = "sha256";
            };
        };
        fdt {
            data-size = <0x00001686>;
            data-position = <0x000b9a00>;
            description = "U-Boot dtb";
            type = "flat_dt";
            compression = "none";
            hash {
                value = <0x0f718794 0x78ece7b2 0x00000003 0x35360000 0x00000001 0x6e730000
0x636f6e66 0x00000000>;
                algo = "sha256";
            };
        };
    };
    configurations {
        default = "conf";
        conf {
            description = "Rockchip armv7 with OP-TEE";
            rollback-index = <0x00000001>; // Firmware anti-rollback version number,
defaults to 0 if not specified manually.
            firmware = "optee";
            loadables = "uboot";
            fdt = "fdt";
            signature {
                algo = "sha256,rsa2048";
                padding = "pss";
                key-name-hint = "dev";
                sign-images = "fdt", "firmware", "loadables";
            };
        };
    };
};

12.2.3 ITB 構造 {#1223-itb-structure}

基本的には、fdt_blob +画像ファイルと以下の2つのパッケージ方法が収集され、RKプラットフォームソリューションは構造2を採用しています。

            fdt blob
|-----------------------------------|
|   |------|  |------|  |------|    |
|   | img0 |  | img1 |  | img2 |    | Structure 1: image within fdt_blob, i.e. itb =
|   |------|  |------|  |------|    |              fdt_blob( including img)
|-----------------------------------|

|--------------|------|------|------|
|              |      |      |      |
|   fdt blob   | img0 | img1 | img2 |Structure 2: image is outside the fdt_blob, i.e. itb =
|              |      |      |      |             fdt_blob + img
|--------------|------|------|------|

12.3 プラットホーム構成 {#123-platform-configuration}

12.3.1 破片サポート {#1231-chip-support}

SDKのプラットフォーム上での公式機能としてリリースされました。各チップ機能のサポート状況については、ホームページセクションを参照してください。

12.3.2 コード構成 {#1232-code-configuration}

コードのコーディング:

// Framework Code:
./common/image.c
./common/image-fit.c
./common/spl/spl_fit.c

// Platform Code:
./arch/arm/mack-rockchip/fit.c
./cmd/bootfit.c

// Tool Code:
./tools/mkimage.c
./tools/fit_image.c

構成:

// U-Boot phase supports FIT
CONFIG_ROCKCHIP_FIT_IMAGE=y

// U-Boot phase: secure boot, anti-rollback, hardware crypto
CONFIG_FIT_SIGNATURE=y
CONFIG_FIT_ROLLBACK_PROTECT=y
CONFIG_DM_CRYPTO=y
CONFIG_FIT_HW_CRYPTO=y
// SPL phase: secure boot, anti-rollback, hardware crypto
CONFIG_SPL_FIT_SIGNATURE=y
CONFIG_SPL_FIT_ROLLBACK_PROTECT=y
CONFIG_SPL_DM_CRYPTO=y
CONFIG_SPL_FIT_HW_CRYPTO=y

// How many copies of uboot.itb does the uboot.img image contain, and how big is a single
copy of uboot.itb?
CONFIG_SPL_FIT_IMAGE_KB=2048
CONFIG_SPL_FIT_IMAGE_MULTIPLE=2

//The default output of uboot project after compilation is uboot.img in fit format;
otherwise it is the traditional RK formats uboot.img and trust.img.
CONFIG_ROCKCHIP_FIT_IMAGE_PACK=y

異なるプラットフォームでは、暗号化が異なるため、RSA 機能の構成パラメータも異なります。 詳しくは、現在のプラットフォームの一般的な defconfig を参照してください。

CONFIG_RSA_N_SIZE
CONFIG_RSA_E_SIZE
CONFIG_RSA_C_SIZE

一般的な defconfig: [chip]_defconfig, 例えば. rv1126_defconifg、rk3568_defconifg。 FITソリューションがSDKとして正式にリリースされた機能であれば、ベース構成のほとんどは既に有効になっています。また、ユーザーが自身を構成する必要があるオプションは次のとおりです。

// U-Boot Secure Boot and Anti-Rollback Mechanisms
CONFIG_FIT_SIGNATURE=y
CONFIG_FIT_ROLLBACK_PROTECT=y

// SPL Secure Boot and Anti-Rollback Mechanism
CONFIG_SPL_FIT_SIGNATURE=y
CONFIG_SPL_FIT_ROLLBACK_PROTECT=y

CONFIG_FIT_SIGNATUREは有効にしていません:ubootは、アンドロイド、uimage、および適合の3つのフォーマットを同時に起動するサポートをすることができます(リリースされたSDKはプラットフォーム要件に基づいて有効にするものを選択します)。 CONFIG_FIT_SIGNATURE が有効: uboot は、ブート フィット ファームウェアのみをサポートしています。

12.3.3 ミラー ファイル {#1233-mirror-file}

FITスキームの最終出力は、uboot.img(trust.imgなし)とboot.img、およびSPLファイルのダウンロードのための2つのFITフォーマットファームウェアです。 uboot.imgファイルuboot.itb = 信頼+ u-boot.bin + mcu.bin(オプション) uboot.img = uboot.itb * N(Nは普通2コピーです)

信頼とmcuファイルは、rkbinプロジェクトから来ており、ビルドスクリプトは自動的にインデックス化し、rkbinプロジェクトから取得します。 boot.imgファイル boot.itb = カーネル + fdt + リソース + ramdisk(オプション) boot.img = boot.itb * M (Mは通常1コピーです) MCU構成 異なる製品に対応するTRUSTのini設定に基づいて、MCUファームウェアが付属している場合があります。

例:

// File: RKTRUST/RV1126TOS_TB.ini, for quick boot products, MCU enabled
[TOS]
TOSTA=bin/rv11/rv1126_tee_ta_tb_v1.04.bin
ADDR=0x00040000

// MCU configuration format: firmware path, boot address, status (okay or disabled).
// If disabled, mcu will not be packed into uboot.img.
[MCU]
MCU=bin/rv11/rv1126_mcu_v1.02.bin,0x108000,okay

ファームウェアの圧縮 現在、一部のプラットフォームでは、uboot.img 内のサブファームウェアの圧縮をサポートしており、以下のサポートも行っています。

プラットフォーム 圧縮のフォーマット ファームウェア
RV1126 gzip, なし u-boot.bin、信頼、mcu (任意)

ユーザーは、この属性を rkbin プロジェクトで対応する TRUST ini に追加することで有効にすることができます。

例:

// RKTRUST/RV1126TOS_SPI_NOR_TINY.ini, for small capacity SPI Nor products.
[TOS]
TOS=bin/rv11/rv1126_tee_v1.02.bin
ADDR=0x08400000
[MCU]
MCU=bin/rv11/rv1126_mcu_v1.00.bin,0x208000,disabled

// Compression format: gzip or none, defaults to uncompressed if the following
configuration fields are not present.
[COMPRESSION]
COMPRESSION=gzip

SPLファイルSPLファイルは、コンパイル後に生成されたspl/u-boot-spl.binを参照します。これは、FITフォーマットでuboot.imgを起動する責任です。ユーザーは、RKプラットフォーム上で非オープンソースのミニローダーを交換し、最終的にはローダーとしてパッケージ化する必要があります。 ./fitディレクトリ

U-Boot がコンパイルで行われると、ディレクトリ内の . /fit フォルダーが生成され、その後のセクションで説明されているように中間ファイルの数が含まれている。 boot.img と uboot.img はそれぞれ sdk プロジェクトと uboot プロジェクトでコンパイルおよび生成されます。 ただし、以下のセクションで説明されているように、安全なブートサポートを備えたboot.imgは、U-Bootプロジェクトの下に再パッケージ化および署名する必要があります。

12.3.4 ITSファイル {#1234-its-file}

uboot のファイルが . /fit/u-boot.it で、 defconfig で CONFIG_SPL_FIT_GENERATOR によって指定されたスクリプトによって動的に作成され、ファームウェアが正常にコンパイルされた後に表示されます。 起動するファイルはSDKプロジェクトの下にあります。

device/rockchip/[platform]/xxx.its  // [platform] is the platform directory:
// Kernel packaging tools, which‘s automatically generated after compilation, exist under
both U-Boot and rkbin repositories(the one under U-Boot is generated in real-time
compilation).
./tools/mkimage
// Firmware Packaging Script
./make.sh
// Firmware re-signing script
scripts/fit-resign.sh
// Firmware Unpacking Script
scripts/fit-unpack.sh
// Firmware Replacement Script
./scripts/fit-repack.sh

スクリプトツールの使用は、次の章でカバーされます。ここでは、make.shのパラメータを最初に焦点を合わせてみましょう。 オプション(ケースバイケースベースで渡るかどうかをユーザが決定) –spl-new : このパラメータを渡すことで、現在コンパイルした spl ファイルを使用して loader をパックすることを意味します。 そうしないと、 rkbinプロジェクトでsplファイルを使用します。 –version-uboot [n] : uboot.imgのファームウェアバージョン番号を指定します。 nは、正の整数でなければなりません。 –version-boot [n] : boot.imgのファームウェアバージョン番号を指定します。 nは、正の整数でなければなりません。 –version-recovery [n] : recovery.imgのファームウェアバージョン番号を指定します。 nは、正式整数でなければなりません。 必須 (安全な起動が有効になっている場合)): –rollback-index-uboot [n] : uboot.imgファームウェアのアンチロールバックバージョン番号を指定します。 nは、

正の非相続整数である –rollback-index-boot [n] : boot.imgファームウェアアンチロールバックバージョン番号を指定します。 nは正の小数整数でなければなりません。 –rollback-index-recovery [n] : recovery.imgファームウェアアンチロールバックバージョン番号を指定します。 nは正の決定整数でなければなりません。 –no-check : 安全なファームウェアをパッケージ化して、安全なファームウェアのセルフチェックをスキップするときに使用します。 注意:

  1. ファームウェアのアンチロールバックバージョン番号:セキュアブートが有効になっている場合にのみ、使用のためにアクティブにすることができ、バージョン番号はOTPまたは他の安全なストレージに保存されます。 主な機能:ファームウェアバージョンが脆弱性攻撃のためにロールバックされるのを防ぐため。

  2. ファームウェアバージョン番号: オプション、デフォルトは0に設定されていない場合。 主な機能:ファームウェアバージョンの識別子として、ファームウェアのユーザーのバージョン管理を容易にします。

12.4 非安全なブート {#124-non-secure-boot}

12.4.1 uboot.img {#1241-ubootimg}

Compile コマンド:

./make.sh rv1126 --spl-new --uboot-version 10  // You may not specify --spl-new and --uboot-
version

コンパイル結果:

  ......
  CC      spl/common/spl/spl.o
  CC      spl/lib/display_options.o
  LD      spl/common/spl/built-in.o
  LD      spl/lib/built-in.o
  LD      spl/u-boot-spl
  OBJCOPY spl/u-boot-spl-nodtb.bin
  CAT     spl/u-boot-spl-dtb.bin
  COPY    spl/u-boot-spl.bin
  CFGCHK  u-boot.cfg

out:rv1126_spl_loader_v1.00.100.bin
fix opt:rv1126_spl_loader_v1.00.100.bin
merge success(rv1126_spl_loader_v1.00.100.bin)
/home4/cjh/uboot-nextdev

// generate rv1126_spl_loader_v1.00.100.bin (Replaced the traditional miniloader of the RK
platform with spl
// loader ini file source
pack loader(SPL) okay! Input: /home4/cjh/rkbin/RKBOOT/RV1126MINIALL.ini
//  Hints from the --spl-new parameter; users can choose not to add this parameter.
pack loader with new: spl/u-boot-spl.bin

// Generate uboot.img (with trust and uboot) with version 10
Image(no-signed, version=10):  uboot.img (FIT with uboot, trust...) is ready
// trust ini file source
pack uboot.img okay! Input: /home4/cjh/rkbin/RKTRUST/RV1126TOS.ini

Platform RV1126 is build OK, with exist .config

パッケージングバックアップ: 複数のバックアップを defconfig 設定で uboot.img に指定します。

CONFIG_SPL_FIT_IMAGE_KB=2048    // the size of one itb
CONFIG_SPL_FIT_IMAGE_MULTIPLE=2 // Number of copies packaged

SPLは、OTAアップグレード中に異常な電力損失によって引き起こされる不動ファームウェアの破損の問題に対処するために、主にこの設定に従ってUブートと信頼を検出し、ブートをブートします。

12.4.2 boot.img {#1242-bootimg}

FITソリューションがSDKの特徴として正式にリリースされると、SDKがコンパイルされた後にFIT形式のboot.imgが生成されます。 boot.imgをセキュアブート用に生成したい場合、U-Bootプロジェクトで生成したSDKで生成されたboot.imgをそのままに、boot.imgを再パッケージ化し、安全なファームウェアパッケージの署名ツール、設定、パラメータなどはU-Bootプロジェクトからすべて発信します。

12.5 セキュアブート {#125-secure-boot}

FITプログラムは、安全なブートをサポートし、関連する特徴は次のとおりです。 SHA256 + rsa2048 + pkcs-v2.1(pss) パッド ファームウェア アンチロールバック ファームウェア再署名(リモート署名) 暗号化ハードウェアアクセラレーション

12.5.1 原則 {#1251-principle}

12.5.1.1 プロセスのチェック {#12511-checking-process}

Maskrom は loader (SPL、ddr、usbplug を含む) SPL チェック uboot.img (信頼、U-Boot…) U-Boot は boot.img (カーネル、fdt、ramdisk… を含む) を、現在のみ sha256+rsa2048+pkcs-v2.1(pss) のパディングセキュリティチェックサムモードがデフォルトでサポートされています。

12.5.1.2 キー ストレージ {#12512-key-storage}

RSAキーは、u-boot.dtbとu-boot-spl.dtbのmkimageでパッケージ化され、u- boot.binとu-boot-spl.binにパッケージされます。 u-boot.dtbのRSAキーの形式は、次のようにします(u-boot-spl.dtbのディット):

cjh@ubuntu:~/uboot-nextdev$ fdtdump u-boot.dtb | less
/dts-v1/;
....

/ {
    #address-cells = <0x00000001>;
    #size-cells = <0x00000001>;
    compatible = "rockchip,rv1126-evb", "rockchip,rv1126";
    model = "Rockchip RV1126 Evaluation Board";

    // Signature nodes are automatically inserted and generated by the mkimage tool. The
nodes hold information such as RSA-SHA algorithm type, RSA core factor parameters, and so
on.
    signature {
        key-dev {
            required = "conf";
            algo = "sha256,rsa2048";
            rsa,np = <0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x00000000 0x1327f633 0x00000003 0x00000003 0x00000003 0xc7aead6a 0xb4c79f40 0xa82bdf76
0xfb2f8387 0xa1e06dce 0xd451a706 0xc7f865e3 0x3e2d7ca8 0x6a71762e 0x125f1828 0x36ab1a41
0xb7e9e852 0x7bd0011a 0x7279e0b8 0xf37e189c 0x8cf00963 0x00000100 0x00000000 0x00000000
0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000377 0x00000004
0x00000004 0x00000004 0x00000002 0x00000003 0x69616c40 0x00000003 0x6d634066 0x00000010
0x66633630 0x73797363>;
            rsa,c = <0x00000000>;
            rsa,r-squared = <0x00000000>;
            rsa,modulus = <0xc25ae693 0xc359f2a4 0xa866c89d 0xb7b1994f 0xf9f9f690 0x518d54a7
0xda0b83e8 0x06606e12 0x6ad1cbf9 0x92438edd 0x81e039c0 0x5d7322cc 0x124cdc80 0xa0c3288a
0x9265c3ae 0x6ac47a4b 0x00000003 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x00000000 0x00000000 0x00000000 0x00000008 0x00000003 0x00000003 0x00000003 0x00000002
0x73657300 0x2f736572 0x00000000 0x2f64776d 0x00000003 0x6d634066 0x00000001 0x30303000
0x726f636b 0x67726600 0x00000008 0x00000003 0x00000004 0x00000001 0x30303000 0x726f636b
0x706d7567 0x00000003 0x00001000 0x00000003 0x00000002 0x6e616765 0x30000000 0x726f636b
0x706d7500 0x00000008>;
            rsa,exponent-BN = <0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x00000000 0x00000000 0x00000000 0x00000003 0x00010001 0xe95771c5 0x00000800 0x64657600
0x616c6961 0x0000002c 0x30303030 0x00000034 0x30303000 0x2f64776d 0x00000002 0x65303030
0x0000001b 0x3132362d 0x00000003 0x00020000 0x00000003 0x00000002 0x65303230 0x0000001b
0x3132362d 0x6e000000 0xfe020000 0x00000042 0x0000006d 0x722d6d61 0x65303030 0x0000001b
0x3132362d 0x00000003 0x00001000 0x00000002 0x6e74726f 0x30000000 0x726f636b 0x706d7563
0x0000003e 0x00000004 0x00000004 0x00000004 0x00000000 0x00000050 0x636c6f63 0x40666634
0x00000014 0x2c727631 0x00000008>;
            rsa,exponent = <0x00000000 0x00000368>;
            rsa,n0-inverse = <0xe95771c5>;
            rsa,num-bits = <0x00000800>;
            key-name-hint = "dev";
        };
    };

SPLは、u-boot-spl.dtbのキー開発者であるキーハッシュをダウンロードし、追加バーンキーハッシュ= <0x00000001>; .

12.5.1.3 主使用法 {#12513-key-usage}

マスロムからカーネルへのセキュアなブートは、RSAのパブリックキーを使用して、セキュリティチェックを完了します。: マスロムは、ローダーをチェックします。 RSA の公開鍵は、PC ツール rk_sign_tool を使用して loader のヘッダーに書き込む必要があります。 安全な起動中に、Massromは最初にローダーファームウェアのヘッダーからRSAの公開鍵を得、その正当な認証を検証します。その後、キーを使用してローダーのファームウェアの署名を確認します。 rk_sign_toolは、rkbinリポジトリから利用できます。 U-Boot は loader に自動的に署名します。 SPLはUボットと信頼をチェックします。 SPLは、u-boot-spl.dtb の RSA 公開鍵を保存し、u-boot-spl.dtb が u-boot-spl.bin ファイル (そして最後に loader にパックされます) にパックされます。SPL は、安全なブート中に uboot.img でセキュリティチェックを実行する独自の dtb ファイルから RSA パブリックキーを取ります。 U-Boot チェック ブート. U-Bootは、u-boot.dtbのRSAパブリックキーを保存し、u-boot.dtbはu-boot.binファイル(そして最終的にuboot.imgにパックされます)に詰まります。 U-Bootは、安全なブート中にboot.imgを検証するために、独自のdtbファイルからRSAパブリックキーを取ります。 そのため、現在のレベルのRSAキーは、以前のローダーが、独自のファームウェアの一部として検証されているため、キーのセキュリティを保証します。

12.5.1.4 署名ストレージ {#12514-signature-storage}

RSA 署名結果は、そのファイルに保存されます。 署名されたコンテンツは、ハッシュドノードで指定されたもので、conf ノード全体、パッケージ化されたファームウェアのノードなど、その属性を含みます。 以下の情報は、u-boot.itb、boot.itb のシグネチャ情報です。

cjh@ubuntu:~/uboot-nextdev$ fdtdump uboot.img | less
/dts-v1/;
......

    configurations {
        default = "conf";
        conf {
            description = "Rockchip armv7 with OP-TEE";
            // Current firmware version number
            rollback-index = <0x0000001c>;
            firmware = "optee";
            loadables = "uboot";
            fdt = "fdt";

            // Signed content and signature result, automatically inserted by mkimage
            signature {
                hashed-strings = <0x00000000 0x000000da>;
                // Specify the content to be signed
                hashed-nodes = "/", "/configurations", "/configurations/conf",
"/images/fdt", "/images/fdt/hash", "/images/optee", "/images/optee/hash", "/images/uboot",
"/images/uboot/hash";
                // Time of signing, signer, version
                timestamp = <0x5e9427b4>;
                signer-version = "2017.09-g8bb63db-200413-dirty #cjh";
                signer-name = "mkimage";
                // signature results!!(using sha256+rsa2048)
                value = <0x78397d5d 0xb9219a0b 0xa7cb91a7 0xe1f32867 0x62719d9b 0x8901200c
0xfcbac03a 0x1295ccc8 0x1cff9608 0xdf5f69d2 0x21391225 0x7af10ca7 0x5527864f 0xb13f527e
0xddf9ee62 0xea50199d 0x00000003 0x35362c72 0x00000004 0x00000017 0x77617265 0x00000002
0x00000009 0x23616464 0x6d616765 0x73006172 0x6f6e006c 0x72790064 0x61636b2d 0x7265006c
0x006b6579 0x69676e2d 0x706f7369 0x7a650074 0x75650073 0x69676e65 0x73686564 0x642d7374
0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x00000000 0x00000000>;
                algo = "sha256,rsa2048";
                key-name-hint = "dev";
                sign-images = "fdt", "firmware", "loadables";
            };
        };
    };
12.5.1.5 反ロールバック {#12515-anti-rollback}

セキュアブートは、boot.imgとuboot.imgのファームウェアバージョン番号をそれぞれ指定する現在のファームウェアのバージョン番号を指定するサポートをサポートし、現在のファームウェアバージョン番号が機械の最小バージョン数よりも少ない場合は、起動は許可されません。 最小バージョン番号の更新:セキュリティ検証を完了した後、システムが正常に起動できることを確認します。 OTP または安全なストレージに更新されます。

12.5.2 予備準備 {#1252-preliminary-preparation}

12.5.2.1 キー {#12521-key}

U-Boot プロジェクトで次の3つのコマンドを実行して、署名用のRSAキーペアを生成します。 通常、キーペアを一度だけ生成し、このキーペアを使用してファームウェアの署名と検証を行いますので、そのことをよくお取りください。

// 1. Directory for keys: keys
mkdir -p keys

// 2. Use “rk_sign_tool” to generate privateKey.pem and publicKey.pem for RSA2048 (please
refer to the manual of rk_sign_tool), and rename them as: keys/dev.key and keys/dev.pubkey
respectively.

// 3. Generate a self-signed certificate using -x509 and a private key: keys/dev.crt
(essentially equivalent to a public key)
openssl req -batch -new -x509 -key keys/dev.key -out keys/dev.crt

エラーが報告された場合、ユーザディレクトリに.rndファイルはありません。 /home4/cjh/.rndをRNG 140522933268928にロードできません:error:2406F079:random番号ジェネレータ:RAND_load_file:ファイルを開くことができないファイルを開く:../crypto/rand/randfile.c:88:Filename=/home4/cjh/.rnd 最初に手動で作成してください: touch/rnd. lsのキー/眺めの結果:

dev.crt  dev.key  dev.pubkey

注意: 「keys」、 “dev.key”、 “dev.crt”、 “dev.pubkey” は変更できません。 これらの名前は、そのファイルで静的に定義されるため、変更するとパッケージは失敗します。

12.5.2.2 構成 {#12522-configuration}

U-Boot の defconfig の次の設定を有効にします。

// Required
CONFIG_FIT_SIGNATURE=y
CONFIG_SPL_FIT_SIGNATURE=y

// Optional
CONFIG_FIT_ROLLBACK_PROTECT=y       // boot.img anti-rollback
CONFIG_SPL_FIT_ROLLBACK_PROTECT=y   // uboot.img anti-rollback

設定をメニュー設定で確認し、保存する defconfig ファイルを元の defconfig を更新して、savedefconfig を 更新することをお勧めします。 これにより、defconfig の設定を非表示にし、コンパイル失敗につながる可能性のある不適切な依存性が生じることがあります。

12.5.2.3 ファームウェア {#12523-firmware}

SDK プロジェクトで生成したboot.imgをU-Bootルートディレクトリにコピーします。

12.5.3 コンパイルとパッケージング {#1253-compiling-and-packaging}

(1) 基本コマンド(反ロールバックなし):

./make.sh rv1126 --spl-new --boot_img boot.img --recovery_img recovery.img

コンパイル結果:

......

// After compilation, generate signed uboot.img and boot.img.
start to sign rv1126_spl_loader_v1.00.100.bin
......
sign loader ok.
......
Image(signed, version=0):  uboot.img (FIT with uboot, trust...) is ready
Image(signed, version=0):  recovery.img (FIT with kernel, fdt, resource...) is ready
Image(signed, version=0):  boot.img (FIT with kernel, fdt, resource...) is ready
Image(signed):  rv1126_spl_loader_v1.05.106.bin (with spl, ddr, usbplug) is ready
pack uboot.img okay! Input: /home4/cjh/rkbin/RKTRUST/RV1126TOS.ini

Platform RV1126 is build OK, with new .config(make rv1126-secure_defconfig)

(2) 拡張コマンド 1: 反ロールバックがオンになっている場合、ロールバックパラメータは (1) で aforesaid に付加する必要があります。

例:

// Specify the minimum version numbers of uboot.img and boot.img as 10 and 12, respectively.
./make.sh rv1126 --spl-new --boot_img boot.img --recovery_img recovery.img --rollback-index-
uboot 10 --rollback-index-boot 12 --rollback-index-recovery 12

コンパイル結果:

......

// After compilation, the signed uboot.img and boot.img are generated and contain the anti-
rollback version number.
start to sign rv1126_spl_loader_v1.00.100.bin
......
sign loader ok.
......
Image(signed, version=0, rollback-index=10):  uboot.img (FIT with uboot, trust) is ready
Image(signed, version=0, rollback-index=12):  recovery.img (FIT with kernel, fdt,
resource...) is ready
Image(signed, version=0, rollback-index=12):  boot.img (FIT with kernel, fdt, resource...)
is ready
Image(signed):  rv1126_spl_loader_v1.00.100.bin (with spl, ddr, usbplug) is ready

(3) コマンド 2 パブリックキーハッシュを OTP/eFUSE にダウンロードしたい場合、上記(1) または (2) に –burn-key- ハッシュを付加する必要があります。

例:

// Specify the minimum version numbers of uboot.img and boot.img as 10 and 12, respectively.
// it is require to download  the public key hash into OTP/eFUSE at SPL stage
./make.sh rv1126 --spl-new --boot_img boot.img --recovery_img recovery.img --rollback-index-
uboot 10 --rollback-index-boot 12 --rollback-index-recovery 12 --burn-key-hash

コンパイル結果:

......

// enable burn-key-hash
### spl/u-boot-spl.dtb: burn-key-hash=1

// After compilation, the signed uboot.img and boot.img are generated and contain the anti-
rollback version number.
start to sign rv1126_spl_loader_v1.00.100.bin
......
sign loader ok.
......
Image(signed, version=0, rollback-index=10):  uboot.img (FIT with uboot, trust) is ready
Image(signed, version=0, rollback-index=12):  recovery.img (FIT with kernel, fdt,
resource...) is ready
Image(signed, version=0, rollback-index=12):  boot.img (FIT with kernel, fdt, resource...)
is ready
Image(signed):  rv1126_spl_loader_v1.00.100.bin (with spl, ddr, usbplug) is ready

電源を上げて起動すると、SPLは印刷します:RSA:キーハッシュを正常に書き込みます。 (4) 注意すべきメモ: –boot_img : オプション、署名されるboot.imgを指定します。 –recovery_img:オプションで、recovery.imgが署名されるように指定します。

–rollback-index-uboot , –rollback-index-boot , –rollback-index-recovery : オプションで、反ロールバックバージョン番号を指定します。 –spl-new : コンパイルコマンドがこのパラメータを持っていない場合、 loader はデフォルトで rkbin の spl ファイルでパッケージ化されます。そうしないと、 loader は現在のコンパイルの spl ファイルでパッケージ化されます。 u-boot-spl.dtb は RSA の公開鍵(ユーザーから)にパックする必要があるため、RK がリリースした SDK は、安全な起動をサポートする rkbin リポジトリに spl ファイルを送信しません。 そのため、コンパイル時にこのパラメータを指定する必要があります。 しかし、ユーザーは独自のsplバージョンをrkbinプロジェクトに送信することもできます。その後、このパラメータを指定せずにファームウェアをコンパイルでき、毎回splファイルの安定したバージョンを使用することもできます。 コンパイルは、 loader、uboot.img、boot.img の3つのファームウェアを生成します。RSA キーが変更されていない限り、それぞれ個別に更新できます。

12.5.4 原則の確認 {#1254-checking-principles}

(1) マスロムは、キーをダウンロードせずにSPL OTPをチェックします。: マスクロームは、非安全なブートプロセスを実行します。 鍵をダウンロードしたOTP: マスロムは、ローダーのキーをチェックします。, それは、セキュリティチェックを開始するOTPの1と同じでなければなりません, そうでない場合, それは起動しません. (2) SPLは、UボットCONFIG_SPL_FIT_SIGNATURE=yをチェックします: SPLは、確実にuboot.imgのセキュリティチェックを実行します, そして、チェックがブートが実行できる場合にのみ; uboot.imgがシグネチャやチェックが失敗しない場合は、起動は実行されません。 CONFIG_SPL_FIT_SIGNATURE=n: SPL自体は安全なブート関連コードを含んでいませんし、uboot.img(署名されていないか否か)をチェックしてはいけません。 (3) U-Bootは、ブート/回復CONFIG_FIT_SIGNATURE =yをチェックします: U-Bootは間違いなくboot.img/recovery.imgのセキュリティチェックを実行し、チェックが成功したときにのみ起動します。 boot.img/recovery.imgは署名またはチェックに失敗しません。 起動しない。 CONFIG_FIT_SIGNATURE=n: U-Boot自体は安全なブート関連コードを含まず、boot.img/recovery.img(署名されていないか、署名されていない)をチェックしてはならない。

注意: 現在のレベルかどうかは、後続レベルがファームウェアの現在のレベルが署名されているかどうかで何も確認しません。 上記の設定がyに設定されているか、またはそうでないか、セキュアブート用のコードを含むかどうかだけに依存します。

12.5.5 情報のブート {#1255-booting-information}

以下は、セキュアブートの情報は、次のとおりです。

BW=32 Col=10 Bk=8 CS0 Row=15 CS=1 Die BW=16 Size=1024MB
out
U-Boot SPL board init
U-Boot SPL 2017.09-gacb99c5-200408-dirty #cjh (Apr 09 2020 - 20:51:21)
unrecognized JEDEC id bytes: 00, 00, 00

Trying to boot from MMC1
// SPL completes signature checking
sha256,rsa2048:dev+
// Anti-rollback detection: the current uboot.img firmware version number is 10, the minimum
version number of this machine is 9.
rollback index: 10 >= 9, OK
// SPL completes hash checkings for each sub-mirror
### Checking optee ... sha256+ OK
### Checking uboot ... sha256+ OK
### Checking fdt ... sha256+ OK

Jumping to U-Boot via OP-TEE
I/TC:
E/TC:0 0 plat_rockchip_pmu_init:2003 0
E/TC:0 0 plat_rockchip_pmu_init:2006 cpu off
E/TC:0 0 plat_rockchip_pmusram_prepare:1945 pmu sram prepare 0x14b10000 0x8400880 0x1c
E/TC:0 0 plat_rockchip_pmu_init:2020 pmu sram prepare
E/TC:0 0 plat_rockchip_pmu_init:2056 remap
I/TC: OP-TEE version: 3.6.0-233-g35ecf936 #1 Tue Mar 31 08:46:13 UTC 2020 arm
I/TC: Next entry point address: 0x00400000
I/TC: Initialized

U-Boot 2017.09-gacb99c5-200408-dirty #cjh (Apr 09 2020 - 20:51:21 +0800)

Model: Rockchip RV1126 Evaluation Board
PreSerial: 2
DRAM:  1023.5 MiB
Sysmem: init
Relocation Offset: 00000000, fdt: 3df404e0
Using default environment

dwmmc@ffc50000: 0
Bootdev(atags): mmc 0
MMC0: HS200, 200Mhz
PartType: EFI
boot mode: normal
conf: sha256,rsa2048:dev+
resource: sha256+
DTB: rk-kernel.dtb
FIT: signed, conf required
HASH(c): OK

I2c0 speed: 400000Hz
PMIC:  RK8090 (on=0x10, off=0x00)
vdd_logic 800000 uV
vdd_arm 800000 uV
vdd_npu init 800000 uV
vdd_vepu init 800000 uV
......

Hit key to stop autoboot('CTRL+C'):  0
### Booting FIT Image at 0x3d8122c0 with size 0x0052b200
Fdt Ramdisk skip relocation
### Loading kernel from FIT Image at 3d8122c0 ...
   Using 'conf' configuration
   // uboot completes signature checking
   Verifying Hash Integrity ... sha256,rsa2048:dev+ OK
   // Anti-rollback detection: the current boot.img firmware version number is 22, the
minimum version number of this machine is 21
   Verifying Rollback-index ... 22 >= 21, OK
   Trying 'kernel' kernel subimage
     Description:  Kernel for arm
     Type:         Kernel Image
     Compression:  uncompressed
     Data Start:   0x3d8234c0
     Data Size:    5349248 Bytes = 5.1 MiB
     Architecture: ARM
     OS:           Linux
     Load Address: 0x02008000
     Entry Point:  0x02008000
     Hash algo:    sha256
     Hash value:   64b4a0333f7862967be052a67ee3858884fcefebf4565db5c3828a941a15f34a
   Verifying Hash Integrity ... sha256+ OK  // Complete the kernel's hash verifications
### Loading ramdisk from FIT Image at 3d8122c0 ...
   Using 'conf' configuration
   Trying 'ramdisk' ramdisk subimage
     Description:  Ramdisk for arm
     Type:         RAMDisk Image
     Compression:  uncompressed
     Data Start:   0x3dd3d4c0
     Data Size:    0 Bytes = 0 Bytes
     Architecture: ARM
     OS:           Linux
     Load Address: 0x0a200000
     Entry Point:  unavailable
     Hash algo:    sha256
     Hash value:   e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
   Verifying Hash Integrity ... sha256+ OK  // Complete the verification for Hash of the
ramdisk
   Loading ramdisk from 0x3dd3d4c0 to 0x0a200000
### Loading fdt from FIT Image at 3d8122c0 ...
   Using 'conf' configuration
   Trying 'fdt' fdt subimage
     Description:  Device tree blob for arm
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x3d812ec0
     Data Size:    66974 Bytes = 65.4 KiB
     Architecture: ARM
     Load Address: 0x08300000
     Hash algo:    sha256
     Hash value:   8fb1f170766270ed4f37cce4b082a51614cb346c223f96ddfe3526fafc5729d7
   Verifying Hash Integrity ... sha256+ OK // Complete the verification for hash of fdt
   Loading fdt from 0x3d812ec0 to 0x08300000
   Booting using the fdt blob at 0x8300000
   Loading Kernel Image from 0x3d8234c0 to 0x02008000 ... OK
   Using Device Tree in place at 08300000, end 0831359d
Adding bank: 0x00000000 - 0x08400000 (size: 0x08400000)
Adding bank: 0x0848a000 - 0x40000000 (size: 0x37b76000)
Total: 236.327 ms

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0xf00
[    0.000000] Linux version 4.19.111 (cjh@ubuntu) (gcc version 6.3.1 20170404 (Linaro GCC
6.3-2017.05)) #28 SMP PREEMPT Wed Mar 25 16:03:27 CST 2020
[    0.000000] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c5387d

12.6 独立した署名 {#126-independent-signature}

FIT フォーマットの特徴に基づいて、独立した署名は、荷を下す、再梱包、署名されていないファームウェアの署名を含みます。 この章では、まず、その操作プロセスを、関連ツールで紹介します。 独立したシグネチャ機能は、XNUMX月2025から始まります。 したがって、ubootとrkbinリポジトリには関連するパッチが含まれていることを確認してください。 ubootリポジトリ:

91b5d8722da scripts: Add fit-sign.sh
554ddf99bfb scripts: fit-core.sh: Add fit_signcfg export support
cb458c93a05 scripts: fit-core.sh: Add --no-sign support
bc02f36c3b2 scripts: fit-unpack: Support none digest node

rkbinリポジトリ:

44216040fad tools: build mkimage/fit_check_sign with -static
88d46662a9b tools: Add fit sign tools support

12.6.1 署名プロセス {#1261-signature-process}

ファームウェアをコンパイルする人:

  1. セキュアブートセクションを参照してください。関連する設定を開きます。

  2. コンパイル:

./make.sh rk3588 --spl-new --no-sign   # must append --spl-new --no-sign

コンパイル後に生成します。

uboot.img
rk3588_spl_loader_v1.18.113.bin
fit/fit_signcfg/
  1. 生成された3つのファイルとFITファイルを署名する(例: 署名を担当する人またはサーバーに boot.img、recovery.img)。

Note: 生成された loader と uboot は、fit_signcfg との厳密なマッチング関係を持ち、署名に参加するためにいつでもコンパイルされた同じ名前の他のファームウェアと混在することはできません。そうしないと、Signature script はエラーを報告します。 署名に責任のある人またはサーバー:

  1. 作業ディレクトリ(名前)を作成します。
$ mkdir workspace
$ cd workspace
$ mkdir keys src output
  1. rkbinリポジトリをダウンロードし、 rkbin のツールディレクトリをワークスペースディレクトリにコピーまたはソフトリンクします。
$ cp ~/rkbin/tools/ ./ -R
  1. 以前のセキュアブートチャプトを参照し、キーディレクトリにRSAキーペアを置き、ファームウェアとfit_signcfgディレクトリをsrcディレクトリに署名します。 ローダー、uboot、fit_signcfg が必要です。また、FIT ファームウェアの署名(boot.img、recovery.img)なども行えます。 たとえば:
cjh@sys2:/home4/cjh/rkbin/workspace$ tree
├── keys
│   ├── dev.crt
│   ├── dev.key
│   └── dev.pubkey
├── output
├── src
│   ├── fit_signcfg
│   │   ├── MINIALL.ini
│   │   ├── sign.readonly_config
│   │   └── test_images.tar.gz
│   ├── boot.img
│   ├── recovery.img
│   ├── rk3588_spl_loader_v1.18.113.bin
│   └── uboot.img
└── tools
    ├── bmp2gray16
    ├── boot_merger
    ├── burner_image_kits
    │   ├── make.sh
    │   ├── make_slc_nand.sh
    ......
  1. 署名を実行します。
$ ./tools/fit-sign.sh --key-dir keys/ --src-dir src/ --out-dir output/

署名プロセスは、src ディレクトリのソースファイルへの変更を行わない。 署名が成功すると、署名されたファームウェアは出力ディレクトリに生成されます。

$ tree output/
output/
├── boot.img
├── recovery.img
├── rk3588_spl_loader_v1.18.113.bin
└── uboot.img

12.6.2 署名スクリプト {#1262-signature-script}

独自に署名されたツールは、rkbinリポジトリに送信され、開発者が呼び出すスクリプトは./tools/fit-sign.shです。

$ ./tools/fit-sign.sh -h

Usage:
    ./tools/fit-sign.sh [args]

Args:
    --key-dir                  <dir>                         | Mandatory
    --src-dir                  <dir>                         | Mandatory
    --out-dir                  <dir>                         | Mandatory
    --burn-key-hash                                          | Optional
    --rollback-index           <image1 n1> <image2 n2> ...   | Optional
    --version                  <image1 n1> <image2 n2> ...   | Optional

–key-dir: 必須。 RSA キーディレクトリのポイント。 –src-dir: 必須。 署名するファームウェアディレクトリのポイント, ローダーを含む必要があります。, uboot, fit_signcfg ディレクトリ. –out-dir: 必須. 署名された出力ディレクトリへのポイント。 –burn-key-hash: オプション。 SPL が OTP に RSA の公開鍵をハッシュ化できるようにするには、追加のパラメーターは必要ありません。 –rollback-index: オプションです。 反ロールバックバージョン番号を、小数の形式で表現する対応するファームウェアに割り当てます。 –version: オプション。 特定のファイルバージョン番号を、小数の形成で表す、対応するファームウェアに割り当てます。 たとえば:

./tools/fit-sign.sh --key-dir keys/ --src-dir src/ --out-dir output/ --version uboot.img 1
boot.img 3 --rollback-index uboot.img 3 boot.img 5

12.6.3 署名構成 {#1263-signature-configuration}

署名時に指定された機能がSPLおよびUBOOTコードで有効になっていることを厳密に確認するために、ファームウェアコンパイル時に設定レコードに関連する追加ファイルが生成されます。 署名スクリプトは、これらのファイルを使用する必要があります。

$ tree fit_signcfg/
fit_signcfg/
├── MINIALL.ini # Package the ini file for loader.
├── sign.readonly_config # Record files related to the current compilation configuration,
uboot, and loader version.
└── test_images.tar.gz # Temporarily useless, ignore.

12.7 リモートシグネチャ {#127-remote-signature}

独立した署名は、署名を担当する人やサーバーに完全なファームウェアをアップロードする必要があります。これは、リモート署名メカニズムがより軽いソリューションである間、送信されたデータの量と速度に特定の影響を持っています。 どちらのスキームも、独自の利点と欠点を持っています。あなたのニーズに応じて選択してください。

12.7.1 実装アイデア {#1271-implementation-idea}

サーバの公開鍵のみを取得することができるので、ユーザーはまず、ローカルPC上でファームウェアをパックし、署名されたデータと安全なファームウェアを生成するために、一時的なプライベートキー+サーバーパブリックキーを使用して、最初に、一時的な秘密鍵と署名されたデータを生成します。 公開鍵の目的は、安全なブートプロセス中に使用されるdtbファイルに公開鍵をパッケージ化することです。 プライベートキーの目的は一時的な署名のためにあります。 ユーザーは、署名されたデータをサーバーに送信します(時間を節約し、ファームウェア全体を送信する必要はありません)、サーバーは署名されたデータを署名するためにプライベートキーを使用し、署名をユーザーに返します。 ユーザーは、この署名で安全なファームウェアに仮署名を置き換えて、ダウンロード用の最終セキュアなファームウェアを入手します。

12.7.2 署名されたデータ {#1272-signed-data}

上記のセクションで述べた署名されたデータは、fdt blob 構成 + サブミラーハッシュセットです。fdt blob ノード構成 `hashed-nodes は、コンテンツが署名されたデータに組み込まれている一連のノードを指定します。

cjh@ubuntu:~/uboot-nextdev$ fdtdump uboot.img | less
/dts-v1/;
......

configurations {
        default = "conf";
        conf {
            description = "Rockchip armv7 with OP-TEE";
            rollback-index = <0x0000001c>;
            firmware = "optee";
            loadables = "uboot";
            fdt = "fdt";

            signature {
                hashed-strings = <0x00000000 0x000000da>;
                // The contents of these nodes are incorporated into the signed data
                hashed-nodes = "/", "/configurations/conf", "/images/fdt",
"/images/fdt/hash", "/images/optee", "/images/optee/hash", "/images/uboot",
"/images/uboot/hash";
                ......

サブミラーハッシュのセット。 mkimage は、各サブミラーに対してハッシュ値を自動的に生成し、ハッシュノードにそれらを追加します。 署名画像で指定されたサブミラーハッシュ値はすべて、署名されたデータに組み込まれています(必須として、ハッシュノードはハッシュドノードによって指定されます)。

例:

cjh@ubuntu:~/uboot-nextdev/u-boot$ fdtdump fit/u-boot.itb | less

/dts-v1/;
......

/ {
    totalsize = <0x000bb600>;
    timestamp = <0x5ecb3553>;
    description = "Simple image with OP-TEE support";
    #address-cells = <0x00000001>;
    images {
        uboot {
            data-size = <0x0007ed54>;
            data-position = <0x00000a00>;
            description = "U-Boot";
            type = "standalone";
            os = "U-Boot";
            arch = "arm";
            compression = "none";
            load = <0x00400000>;
            hash {
                // The hash of the uboot image, automatically calculated and generated
by the mkimage tool
                value = <0xeda8cd52 0x8f058118 0x00000003 0x35360000 0x6f707465
0x0000009f 0x00000091 0x00000000>;
                algo = "sha256";
            };
};
......

12.7.3 詳細な手順 {#1273-detailed-steps}

ファームウェアに署名するために使用されるRSAキーペアは、dev.key、dev.pubkey、およびdev.crtです。 dev.keyは、リモートサーバがプライベートキーとして保持され、ユーザーはdev.pubkeyとdev.crtのみを持っています。

ステップ1:ローカルU-Bootプロジェクト環境で: dev.crtをキーディレクトリに入れ、RKの「rk_sign_tool」ツールを使用して、ランダムな一時的な秘密鍵を生成し、dev.keyという名前を付けて、それをキーディレクトリに入れます。 上記のセクションを参照してください(ただし、コンパイルパラメータに –no-check を追加)署名されたファームウェア uboot.img と boot.img を生成します (これは実際には最後に使用されません。, ユーザーが必要とするものは中間ファイルです).

Note: コンパイルコマンドは、 dev.key と dev.crt の間の不一致により、 packingスクリプトの自己チェックが失敗するパラメータ –no-check を指定する必要があります。 たとえば:

./make.sh rv1126 --spl-new --boot_img boot.img --rollback-index-uboot 10 --rollback-index-
boot 12 --no-check

署名されたファームウェア uboot.img と boot.img を生成するだけでなく、ユーザーは適合/ディレクトリに中間ファイルを取得することもできます。

// Signed content (data2sign means: data to sign)
fit/uboot.data2sign
fit/boot.data2sign

// Signed itb files (using a temporary private key), our img files are obtained from
multiple backups of them
fit/uboot.itb
fit/boot.itb

ステップ2: ユーザーはリモートサーバにuboot.data2signを送信します。 リモートサーバが秘密鍵の dev.key を保持していると仮定して、次のコマンドを使用して署名結果を出力します。uboot.sig

openssl dgst -sha256 -sign dev.key -sigopt rsa_padding_mode:pss -out uboot.sig
uboot.data2sign

サーバは、ユーザに uboot.sig というシグネチャの結果を返し、 uboot.sig を使って一時的なシグネチャを uboot.itb に置き換えます。

./scripts/fit-resign.sh -f fit/uboot.itb -s uboot.sig // A new uboot.img will be generated
and used for downloading.

boot.itb ファイル用の Ditto です。 このユーザーから、最終有効な署名されたファームウェア uboot.img と boot.img を取得します。 注意:

fit-resign.sh で -f によって指定された itb ファイルは img ファイルではありません。 スクリプトは、そのファイルを再署名した後にimgファイルを生成します。 fit-resign.shを実行するために使用されるイブファイルは、ステップ1でコンパイルされている必要があります。つまり、イブファイルとdata2signファイルが1対1の対応になります。なぜなら、データ2sign情報は、イブファイルが生成されたタイムスタンプが含まれているためです。すなわち、/timestamp = <… > 。 そのため、現在のコードが変更されていない場合でも、新しい uboot.itb を取得し、 uboot.sig を新しい uboot.itb に置き換えるのもセキュアなブート障害を引き起こします! 秘密鍵がないため、署名のサーバー側へローダーを別途送信する必要があります。

12.8 ファームウェア パック {#128-firmware-unpacking}

ユーザーは、boot.imgなどのスクリプトの助けを借りてファームウェアをアンパックすることができます。

cjh@ubuntu:~/uboot-nextdev$ ./scripts/fit-unpack.sh -f boot.img -o out
Unpack to directory out:
  fdt                 : 82813 bytes... sha256+
  kernel              : 5844640 bytes... sha256+
  ramdisk             : 0 bytes... sha256+
  resource            : 120832 bytes... sha256+

img が複数のバックアップを含む場合、スクリプトは最初の itb だけをアンパックします。sha256+ はファームウェアが破損していないことを意味します。そうしないと sha256- が表示されます。

12.9 ファームウェアの取り替え {#129-firmware-replacement}

ユーザーは、サブファームウェアをスクリプトの助けに置き換えることができます。 例えば、自家用bl31.elfを他の’uboot_legacy.imgに置き換えます。

  1. 独自のbl31.elfでuboot.imgをコンパイル

  2. uboot_legacy.imgをfit-unpack.shで出力/ディレクトリに解凍

cjh@ubuntu:~/uboot-nextdev$ ./scripts/fit-unpack.sh -f uboot_legacy.img -o out/

uboot_legacy.img: Device Tree Blob version 17, size=2560, boot CPU=0, string block
size=197, DT structure block size=2204
Unpack to directory out:
  uboot               : 576352 bytes... sha256+
  atf-1               : 69089 bytes... sha256+
  atf-2               : 36864 bytes... sha256+
  atf-3               : 24576 bytes... sha256+
  optee               : 228134 bytes... sha256+
  fdt                 : 8867 bytes... sha256+
  1. アウト/ディレクトリからすべてのatf-xxxファイルを削除します。

  2. fit-repack.sh を使用して、すべてのサブミラーを自分の uboot.img に置き換えます。 今回は、新しい

uboot.imgは、希望する交換効果を達成するuboot_legacy.imgのあなた自身のb31と他のサブミラーを含んでいます。

cjh@ubuntu:~/uboot-nextdev$ ./scripts/fit-repack.sh -f uboot.img -d out/

uboot.img: Device Tree Blob version 17, size=2560, boot CPU=0, string block size=197,
DT structure block size=2204
Unpack to directory out/repack/:
  uboot               : 576352 bytes... sha256+
  atf-1               : 69089 bytes... sha256+
  atf-2               : 36864 bytes... sha256+
  atf-3               : 24576 bytes... sha256+
  optee               : 228134 bytes... sha256+
  fdt                 : 8867 bytes... sha256+
  ......
Image(repack):  uboot.img is ready

原則の説明: サブミラーの交換戦略は「私のサブミラーをuboot.imgに置き換える」ではなく、「私のサブミラーをuboot.imgに置き換える」ではありません。 理由:uboot.imgのatf-xxxはbl31.elfから来ています、古いと新しいbl31.elfに含まれているatf-xxxの数が異なるかもしれません、そしてそれが異なっているならば、それは等しく取り替えることができません。 u-boot、b32、mcuなどのatf-xxx以外のサブミラーの数が固定されていますが、bl31.elfの交換をサポートするため、この逆置換戦略が使用されます。 上記はbl31.elfの代替品を記述し、他のサブミラーの交換には同じ戦略が適用されます。

12.10 安全チェックステップバイステップ {#1210-safety-checking-step-by-step}

  1. u-bootディレクトリを入力し、対応するプラットフォームのconfigs/rxxxxx_defconfigを開き、次の設定を選択します。
// Required
CONFIG_FIT_SIGNATURE=y
CONFIG_SPL_FIT_SIGNATURE=y

// Optional
CONFIG_FIT_ROLLBACK_PROTECT=y       // boot.img anti-rollback
CONFIG_SPL_FIT_ROLLBACK_PROTECT=y   // uboot.img anti-rollback
  1. キーを生成するには、次のキーを実行します。
mkdir -p keys
../rkbin/tools/rk_sign_tool kk --bits 2048 --out .
cp privateKey.pem keys/dev.key && cp publicKey.pem keys/dev.pubkey
openssl req -batch -new -x509 -key keys/dev.key -out keys/dev.crt

注意: このステップは一度だけ実行でき、これらのキーを適切に保存します。

  1. コンパイルと署名、rv1126 を例に取ります(rk3566 などの他のチップファームウェアのコンパイルと署名を行う場合は、rv1126 を rk3566 に次のコマンドで変更してください)。
// Linux: Copy boot.img and recovery.img to the u-boot file, execute the following script to
sign loader,uboot,boot,recovery, set the anti-version rollback number of
uboot,boot,recovery, and note that the anti-rollback version number is configured according
to the need.
./make.sh rv1126 --spl-new --boot_img boot.img --recovery_img recovery.img --rollback-index-
uboot 1 --rollback-index-boot 2

// Android: signature loader, uboot, set uboot anti-version rollback number, and note that
the anti-rollback version number is configured according to the need.
./make.sh rv1126 --spl-new --rollback-index-uboot 1

コンパイルが現れた場合:

Can't load XXXXXX//.rnd into RNG

実行:

touch ~/.rnd
  1. 公開鍵ハッシュのダウンロード:
// Linux: Copy boot.img and recovery.img to the u-boot file, execute the following script to
sign loader,uboot,boot,recovery, set the anti-rollback version number of
uboot,boot,recovery, note that the anti-rollback version number is configured according to
the need to enable the downloading of the key hash
./make.sh rv1126 --spl-new --boot_img boot.img --recovery_img recovery.img --rollback-index-
uboot 1 --rollback-index-boot 2 --burn-key-hash

// Android: Sign loader,uboot, set the anti-rollback version number of uboot, note that the
anti-rollback version number is configured according to the need to enable the downloading
of the key hash
./make.sh rv1126 --spl-new --rollback-index-uboot 1 --burn-key-hash

注:このステップは、製品開発全体が検証された後、-burn-key-hash を設定し、それ以外のセキュリティがオンになっている。 製品の開発中に、ファームウェアの登録は完了です。

  1. アンドロイド用その他のファームウェアのシグネチャ:《Rockchip_Developer_Guide_Secure_Boot_for_UBoot_Next_Dev_CN.md》を参照してください。

日 時 Chapter-13 高速ブート {#13-chapter-13-fast-boot}

13.1 破片サポート {#131-chip-support}

rv1126の特長

13.2 ストレージサポート {#132-storage-support}

eMMCのspi も

13.3 bootrom サポート {#133-bootrom-support}

現在、bootromのspiやドライバは、低レベルのファームウェアをロードするために4線のDMAモードをサポートしており、このサポートは、ファームウェアを燃焼するときにusbplugに直接設定されています。顧客は再び設定する必要はありません。 eMMCは、このために最適化されていない。

13.4 UボットSPLサポート {#134-u-boot-spl-support}

FITフォーマットのクイックブートは、U-Boot SPL、およびローダーモードへのキーストローク入力と低バッテリー検出でサポートされています。 構成:

CONFIG_SPL_KERNEL_BOOT=y             // Enable quick boot function
CONFIG_SPL_BLK_READ_PREPARE=y        // Enable preloading function
CONFIG_SPL_MISC_DECOMPRESS=y         // Enable decompression function
CONFIG_SPL_ROCKCHIP_HW_DECOMPRESS=y

U-Boot SPLは、プレロード機能を有効にした後、プリロード機能をサポートし、他のプログラムを実行しているときにファームウェアをロードすることができます。 現在、主にラムディスクをプリロードするために使用されます。 例えば、gzip圧縮のラムディスク、圧縮コマンドをプリロードします。

cat ramdisk | gzip -n -f -9 > ramdisk.gz

ファイルが以下のように設定されます。

ramdisk {
    data = /incbin/("./images-tb/ramdisk.gz");
    compression = "gzip"; // compression format
    type = "ramdisk";
    arch = "arm";
    os = "linux";
    preload = <1>;        // preloaded symbol
    comp = <0x5800000>;   // loading address
    load = <0x2800000>;   // decompression address
    decomp-async;         // asynchronous decompression
    hash {
        algo = "sha256";
        uboot-ignore = <1>; // No hash checks.
    };
};

コンパイルファームウェア、例えば、rv1126 eMMC ファームウェアをコンパイル:

./make.sh rv1126-emmc-tb && ./make.sh --spl

13.5 MCUの構成 {#135-mcu-configuration}

現在、mcu の主な役割は、システムが起動し、事前に ISP や他のモジュールを初期化できるように支援することです。カーネルは、起動後にこれらのハードウェアモジュールの制御を引き継ぎます。 rv1126 を例として使用して、rkbin/RKTRUST に対応するチップファイル内で構成します。

[MCU]
MCU=bin/rv11/rv1126_mcu_v1.02.bin,0x108000,okay // Configure the corresponding firmware
location, boot address and enable flag

MCCプログラムのアドレス:

https://10.10.10.29/admin/repos/rtos/rt-thread/rt-thread-amp
https://10.10.10.29/admin/repos/rk/mcu/hal

U-Boot がコンパイルされた後、mcu ファームウェアを uboot.img にパッケージ化します。 システムブートがSPLを解析し、uboot.imgからmcuファームウェアを読み込むと、

13.6 カーネルサポート {#136-kernel-support}

構成:

CONFIG_ROCKCHIP_THUNDER_BOOT=y           // Enable quick boot function
CONFIG_ROCKCHIP_THUNDER_BOOT_MMC=y       // Enable the support for emmc
                        quick boot optimization
CONFIG_ROCKCHIP_THUNDER_BOOT_SFC=y       // Enable the support for spi
                        nor quick boot optimization
CONFIG_VIDEO_ROCKCHIP_THUNDER_BOOT_ISP=y // Enable the support for ISP
                        nor quick boot optimization

クイックブートでは、SPLは実際のハードウェアパラメータに基づいてカーネルdtbのパラメータを変更しません。そのため、一部のパラメーターはユーザーによって構成される必要があります。特にRAMdiskのメモリサイズは、以前のとデコンプレッション後のものです。詳細は、kernel/arch/arm/boot/dts/rv1126-thunder-boot.dtsiを参照してください。

memory: memory {
    device_type = "memory";
    reg = <0x00000000 0x20000000>; //Need to be pre-defined based on real DDR capacity, SPL
does not correct it
};

reserved-memory {
    trust@0 {
        reg = <0x00000000 0x00200000>; // trust space
        no-map;
    };

    trust@200000 {
        reg = <0x00200000 0x00008000>;
    };

    ramoops@210000 {
        compatible = "ramoops";
        reg = <0x00210000 0x000f0000>;
        record-size = <0x20000>;
        console-size = <0x20000>;
        ftrace-size = <0x00000>;
        pmsg-size = <0x50000>;
    };

    rtos@300000 {
        reg = <0x00300000 0x00100000>; // Reserved for use on the client side, can be
deleted if not in use
        no-map;
    };

    ramdisk_r: ramdisk@2800000 {
        reg = <0x02800000 (48 * 0x00100000)>; // Decompression source address, can be
changed according to the actual size
    };
    ramdisk_c: ramdisk@5800000 {
        reg = <0x05800000 (20 * 0x00100000)>; // Compression source address, can be changed
based on actual size
    };
};

emmc の構成:

/ {
        reserved-memory {
                mmc_ecsd: mmc@20f000 {
                        reg = <0x0020f000 0x00001000>; // SPL upload ecsd region to kernel
                };

                mmc_idmac: mmc@500000 {
                        reg = <0x00500000 0x00100000>; //When preloading the ramdisk, the
memory area of idmac is reserved, and when the preloading is finished, the memory in this
area is released.
                };
        };

        thunder_boot_mmc: thunder-boot-mmc {
                compatible = "rockchip,thunder-boot-mmc";
                reg = <0xffc50000 0x4000>;
                memory-region-src = <&ramdisk_c>;
                memory-region-dst = <&ramdisk_r>;
                memory-region-idmac = <&mmc_idmac>;
        };
};

spi の構成か:

/ {
        thunder_boot_spi_nor: thunder-boot-spi-nor {
                compatible = "rockchip,thunder-boot-sfc";
                reg = <0xffc90000 0x4000>;
                memory-region-src = <&ramdisk_c>;
                memory-region-dst = <&ramdisk_r>;
        };
};

13.7 速いブート プロセス {#137-fast-boot-process}

日 時 Chapter-14 プラットフォーム定義 {#14-chapter-14-platform-definition}

14.1 ATF/OPTEE(アット・ティー・オプティー) {#141-atfoptee}

  1. U ブートの充電スタンバイ要件のための ATF/OPTEE の最小バージョン
チップの種類 最小バージョン番号
RV1108 N/A
RK1808 N/A
RK1806 N/A
RK3036 N/A
RK3128x N/A
RK3126 rk3126_tee_ta_v1.39.bin
RK322x N/A
RK3288 rk3288_tee_ta_v1.43.bin
RK3368 rk3368h_bl31_v2.22.elf
RK3328 N/A
RK3399 rk3399_bl31_v1.32.elf
RK3399Pro rk3399_bl31_v1.32.elf
RK3399Pro-npuの特長 rk3399_bl31_v1.32.elf
RK3308 rk3308_bl31_v2.00.elf rk3308_bl31_aarch32_v2.20.elf
PX30 px30_bl31_v1.05.elf
RK3326 rk3326_bl31_v1.05.elf
RV1126/RV1109 N/A
RK3568 rk3588_bl31_v1.26.elf rk3588_bl31_ultra_v2.06.elf
RK3566 rk3588_bl31_v1.26.elf rk3588_bl31_ultra_v2.06.elf
RK3588 rk3588_bl31_v1.24.elf
RV1106/RV1103 N/A
RK3528 N/A
RK3562 プロセス
RK3576 rk3576_bl31_v1.04.elf
RV1106B/RV1103B N/A
RK3506 プロセス
チップの種類 最小バージョン番号
RV1126B N/A

14.2 クロック {#142-clock}

  1. CPU クロック サポート リスト
チップス クロック 頻度高められたプロセッサ
RV1108 N/A N/A
RK1808 N/A N/A
RK1806 N/A N/A
RK3036 N/A N/A
RK3128x N/A N/A
RK3126 N/A N/A
RK322x N/A N/A
RK3288 N/A N/A
RK3368 N/A N/A
RK3328 N/A N/A
RK3399 N/A N/A
RK3399Pro N/A N/A
RK3399Pro-npuの特長 N/A N/A
RK3308 N/A N/A
PX30 普通時計 電圧 + 頻度
RK3326 普通時計 電圧 + 頻度
RV1126/RV1109 N/A N/A
RK3568 SCMIクロック 電圧 + 頻度
RK3566 SCMIクロック 電圧 + 頻度
RK3588 N/A N/A
RV1106/RV1103 N/A N/A
RK3528 SCMIクロック 電圧
RK3562 SCMIクロック 電圧
RK3576 N/A N/A
RV1106B/RV1103B N/A N/A
RK3506 N/A N/A
RV1126B N/A N/A

14.3 Defconfigの仕様 {#143-defconfig}

  1. プラットフォームによる Defconfig サポート (SDK リリースへサブジェクト) “[チップ]_defconfig” または ‘[チップ].config’ は通常、フル機能の異なるバージョンです。
チップス defconfig の仕様 カーネルdtbをサポート 備考
RV1108 evb-rv1108_defconfigの特長 N ジェネリック版
RK1808 rk1808_defconfig Y ジェネリック版
RK1806 rk1806_defconfig Y ジェネリック版
RK3036 rk3036_defconfig Y ジェネリック版
RK3128x rk3128x_defconfig Y ジェネリック版
RK3126 rk3126_defconfig Y ジェネリック版
RK322x rk322x_defconfig Y ジェネリック版
RK3288 rk3288_defconfig Y ジェネリック版
RK3368 rk3368_defconfig Y ジェネリック版
RK3328 rk3328_defconfig Y ジェネリック版
RK3399 rk3399_defconfig Y ジェネリック版
RK3399Pro rk3399pro_defconfig Y ジェネリック版
RK3399Pro-npuの特長 rknpu-lion_defconfigの特長 Y ジェネリック版
RK3308 rk3308_defconfig rk3308-aarch32_defconfig Y 汎用バージョン サポート aarch32 モード
PX30 px30_defconfig Y ジェネリック版
RK3326 rk3326_defconfig rk3326-aarch32_defconfig Y 汎用バージョン サポート aarch32 モード
RV1126 rv1126_defconfig rv1126-ab.config rv1126-spi-nor- tiny_defconfig rv1126-ramboot.config rv1126-usbplug.config rv1126-dfu.config rv1126-ipc.config Y 汎用版 ジェネリック版+supportA/B Spi Nor 容量 メモリデバイス(メモリー起動) USBplug 機能 ipc sdk でサポート dfu 使用
RV1126 rv1126-emmc-tb.config rv1126-lp3-emmc-tb.config rv1126-spi-nor-tb.config Y eMMC+DDR3雷ブートeMMC+LP3雷逆襲撃スパイNor+DDR3雷雷
チップス defconfig の仕様 カーネルdtbをサポート 備考
RK3568 rk3568_defconfig rk3568-dfu.config rk3568-nand.config rk3568-spl-spi- nand_defconfig rk3568-aarch32.config rk3568-usbplug.config   汎用版 サポート dfu サポート MLC/TLC/ eMMC SPI ナンド 専用 SPL サポート aarch32 モード サポート usbplug モード
RK3566 rk3566.config rk3566-eink.config の仕様 Y ジェネリック版 E-book版
RK3588 rk3588_defconfig rk3588-ramboot.config rk3588-sata.config rk3588-aarch32.config rk3588-ipc.config Y 汎用版 いいえ メモリデバイス (メモリーブート) aarch32 モードの sata 起動サポート用のデュアルストレージ サポート ipc sdk で使用
RV1106/RV1103 rv1106_defconfig rv1106-emmc-tb_defconfig rv1106-spi-nor- tb_defconfig rv1106-spi-nor_defconfig Rv1106-display.config rv1106-dfu.config rv1106-ipc.config Y 汎用版 eMMC雷ブートスピノーサー雷ブートスパイノーラ起動ロゴの小さな容量サポート ipc sdkでの使用をサポートする
RK3528 rk3528_defconfig Y ジェネリック版
RK3562 rk3562_defconfig Y ジェネリック版
RK3576 rk3576_defconfig rk3576-usbplug.config rk3576-car.config rk3576-ab-car.config rk3576-eink.config Y 一般的なバージョン オープンソース usbplug In-vehicle version Support ab システム in-vehicle version E-book version
RV1106B rv1106b_defconfig rv1106b-emmc- tb_defconfig rv1106b-spi-nand- tb_defconfig Y 汎用版 eMMC雷ブートSpi Nand雷ブート
RV1103B rv1103b_defconfig rv1103b-optee.config rv1103b-spi-nor_defconfig Y 汎用版 サポート OP-TEE Spi Nor 容量
チップス defconfig の仕様 カーネルdtbをサポート 備考
RK3506 rk3506_defconfig rk3506_tb.config rk3506-amp.config rk3506b.config の特長 Y 一般的なバージョンのthunderbootバージョンは、RK3506BでサンプSDKの使用
RV1126B rv1126b_defconfig rv1126b-usbplug.config rv1126b-ipc.config rv1126b-spi-nor_defconfig Y 一般的なバージョン オープンソースのusbplug 使用上の ipc sdk Spi Norの小型容量

14.4 DFUの {#144-dfu}

  1. DFUの特徴 サポート リスト:
チップス defconfig の仕様
RV1108 N/A
RK1808 N/A
RK1806 N/A
RK3036 N/A
RK3128x N/A
RK3126 N/A
RK322x N/A
RK3288 N/A
RK3368 N/A
RK3328 N/A
RK3399 N/A
RK3399Pro N/A
RK3399Pro-npuの特長 N/A
RK3308 N/A
PX30 N/A
RK3326 N/A
RV1126/RV1109 rv1126-dfu.config の使い方
RK3568 N/A
RK3566 N/A
RK3588 rk3568-dfu.config(オプション)
RV1106/RV1103 rv1106-dfu.config の使い方
RK3528 N/A
RK3562 N/A
RK3576 N/A
RV1106B/RV1103B N/A
RK3506 N/A
RV1126B N/A

14.5 オプトティー {#145-optee}

  1. プラットフォーム全体でオプトイクライアントインターフェイスのアプリケーパビリティ
API RV1109/RV1126 RK3566/RK3568 RK3588 RV1106/RV1103 RK3528 RK3562 RK3576 RV1106B/RV1103B RK3506 RV1126B その他
trusty_read_vbootkey_hash √ √ √ N/A √ √ √ √ N/A √ √
trusty_write_vbootkey_hash √ √ √ N/A √ √ √ √ N/A √ √
trusty_read_vbootkey_enable_flag √ √ √ N/A √ √ √ √ N/A √ √
trusty_write_oem_otp_key √ √ √ N/A √ √ √ √ N/A √ N/A
trusty_oem_otp_key_is_written √ √ √ N/A √ √ √ √ N/A √ N/A
trusty_set_oem_hr_otp_read_lock N/A N/A √ N/A √ √ √ N/A N/A √ N/A
trusty_oem_otp_key_cipher √ √ √ N/A √ √ √ √ N/A √ N/A

15. . Chapter-15 注目 {#15-chapter-15-remarks}

15.1 SDKの互換性 {#151-sdk-compatibility}

15.1.1 androidboot.mode 互換性 {#1511-androidbootmode-compatibility}

Android 8.1 より以前の SDK バージョンでは、U-Boot が正常に起動するAndroid の次の設定を有効にする必要があります。

CONFIG_RKIMG_ANDROID_BOOTMODE_LEGACY

理由の提出については、下記を参照してください。

commit a7774f5911624928ed1d9cfed5453aab206c512e
Author: Zhangbin Tong <zebulun.tong@rock-chips.com>
Date:   Thu Sep 6 17:35:16 2018 +0800

    common: boot_rkimg: set "androidboot.mode=" as "normal" or "charger"

    - The legacy setting rule is deprecated(Android SDK < 8.1).
    - Provide CONFIG_RKIMG_ANDROID_BOOTMODE_LEGACY to enable legacy setting.

    Change-Id: I5c8b442b02df068a0ab98ccc81a4f008ebe540c1
    Signed-off-by: Zhangbin Tong <zebulun.tong@rock-chips.com>
    Signed-off-by: Joseph Chen <chenjh@rock-chips.com>

15.1.2 MISCの互換性 {#1512-misc-compatibility}

misc.imgの目的はUブートとAndroidの間でブート相互作用として機能し、メインコンテンツはBCB(ボトローダコントロールブロック)です。 RKプラットフォームの履歴により、SDKバージョンがAndroid-10.0よりも大きく、または等しくなっているため、misc.imgのBCBはオフセット0でDCパーティションに保存する必要があります。バージョンがAndroid-10.0未満の場合、BCBはオフセット16KBで誤ったパーティションに保存する必要があります。

リリースされたSDKを受け取ったときに、ユーザーは追加の処理を必要としません。 U-Bootは、互換性のあるものに適応します。 ただし、異なるSDKのmisc.imgを取り込んで混ぜると問題が発生する場合があります。 現象は、一般的にAndroidが回復モードに入ることを継続します。

16.16.(日) Chapter-16 ツール {#16-chapter-16-tools}

この章に関連する開発ツールへのパス(U-Bootのルートディレクトリを参考として使用)

./scripts/mkbootimg
./scripts/unpack_bootimg
./scripts/repack-bootimg
./scripts/unpack_resource.sh
./scripts/stacktrace.sh
./tools/patman/patman
./tools/buildman/buildman

../rkbin/tools/resource_tool
../rkbin/tools/loaderimage
../rkbin/tools/trust_merger
../rkbin/tools/boot_merger

16.1 trust_merger {#161-trust_merger}

関数: ini 設定ファイルによると 64 ビット プラットフォーム用の bl30、b31、b32 bin ファイルをパックし、trust.img を生成します。 ini ファイル: RK3368TRUST.ini を例に挙げます:

[VERSION]
MAJOR=0                     ----major version number
MINOR=1                     ----minor version number
[BL30_OPTION]               ----bl30, Currently set to mcu bin
SEC=1                       ----BL30 bin exists
PATH=tools/rk_tools/bin/rk33/rk3368bl30_v2.00.bin   ----Specify the bin path
ADDR=0xff8c0000             ----Load and run addresses in firmware DDRs
[BL31_OPTION]               ----bl31, currently set to multi-core and power management
related bin
SEC=1                       ----BL31 bin exists
PATH=tools/rk_tools/bin/rk33/rk3368bl31-20150401-v0.1.bin----Specify the bin path
ADDR=0x00008000             ----Load and run address in firmware DDR
[BL32_OPTION]
SEC=0                       ----BL32 bin does not exist
[BL33_OPTION]
SEC=0                       ----BL33 bin does not exist
[OUTPUT]
PATH=trust.img [OUTPUT]     ----Output firmware name

パッキング コマンド:

/*
 * @<sha>: optional. sha related, refer to make.sh
 * @<rsa>: optional. rsa related, refer to make.sh
 * @<size>: optional, formats: --size [KB] [count].the size of the output file, When
omitted, the default is 2M for a single copy and 2 copies for a package.
 * @[ini file]: mandatory. ini file
 */

./tools/trust_merger <sha> <rsa> <size> [ini file]

テンプレート:

./tools/trust_merger --rsa 3 --sha 2 ./ RKTRUST/RK3399TRUST.ini
out:trust.img
merge success(trust.img)

コマンドをアンパック:

// @[input image]: Mandatory, firmware for unpacking, typically trust.img

./tools/trust_merger --unpack [input image]

テンプレート:

./tools/trust_merger --unpack trust.img

File Size = 4194304
Header Tag:BL3X
Header version:256
Header flag:35
SrcFileNum:4
SignOffset:992
Component 0:
ComponentID:BL31
StorageAddr:0x4
ImageSize:0x1c0
LoadAddr:0x10000
Component 1:
ComponentID:BL31
StorageAddr:0x1c4
ImageSize:0x10
LoadAddr:0xff8c0000
Component 2:
ComponentID:BL31
StorageAddr:0x1d4
ImageSize:0x48
LoadAddr:0xff8c2000
Component 3:
ComponentID:BL32
StorageAddr:0x21c
ImageSize:0x2e0
LoadAddr:0x8400000
unpack success

16.2 boot_merger {#162-boot_merger}

関数: パックのミニローダー + ddr + usb プラグインは、ini の設定ファイルによると、 loader ファームウェアを生成します。 ini ファイル: RK3288MINIALL.ini ファイルを例として取ります:

[CHIP_NAME]
NAME=RK320A                 ----Chip Name: “RK” plus the 4B chip type number agreed with
maskrom
[VERSION]
MAJOR=2                     ----Major version number
MINOR=36                    ----Minor version number
[CODE471_OPTION]            ----code471, currently set to ddr bin
NUM=1
Path1=tools/rk_tools/bin/rk32/rk3288_ddr_400MHz_v1.06.bin
[CODE472_OPTION]            ----code472, currently set to usbplug bin
NUM=1
Path1=tools/rk_tools/bin/rk32/rk3288_usbplug_v2.36.bin
[LOADER_OPTION]
NUM=2
LOADER1=FlashData           ----flash data, currently set to ddr bin
LOADER2=FlashBoot           ----flash boot, Currently set to miniloader bin
FlashData=tools/rk_tools/bin/rk32/rk3288_ddr_400MHz_v1.06.bin
FlashBoot=tools/rk_tools/bin/rk32/rk3288_miniloader_v2.36.bin
[OUTPUT]                    ----Output file name
PATH=rk3288_loader_v1.06.236.bin

パッキング コマンド:

// @[ini file]: mandatory. ini file

./tools/boot_merger [ini file]

テンプレート:

./tools/boot_merger ./RKBOOT/RK3399MINIALL.ini
out:rk3399_loader_v1.17.115.bin
fix opt:rk3399_loader_v1.17.115.bin
merge success(rk3399_loader_v1.17.115.bin)

コマンドのアンパック:

// @[input image]: Mandatory. Firmware for unpacking, usually a loader file

./tools/boot_merger --unpack [input image]

テンプレート:

./tools/boot_merger --unpack rk3399_loader_v1.17.115.bin
unpack entry(rk3399_ddr_800MHz_v1.17)
unpack entry(rk3399_usbplug_v1.15)
unpack entry(FlashData)
unpack entry(FlashBoot)
unpack success

16.3 積込み機画像 {#163-loaderimage}

機能:パッケージu-boot.binは、uboot.imgパッケージティービンを32ビットプラットフォーム用に生成し、trust.imgパッケージu-bootを生成します。

/*
 * @[input bin]: Required. bin source file
 * @[output image]: Required. Output File
 * @[load_addr]: Required. the load Address
 * @<size>: Optional, Format: --size [KB] [count]. Output file size, when it is ommitted,
defaulted as 1M for one copy, and four copies for a package.
 */

./tools/loaderimage --pack --uboot [input bin] [output image] [load_addr] <size>

テンプレート

./tools/loaderimage --pack --uboot ./u-boot.bin uboot.img 0x60000000 --size 1024 2

 load addr is 0x60000000!
pack input u-boot.bin
pack file size: 701981
crc = 0xc595eb85
uboot version: U-Boot 2017.09-02593-gb6e59d9 (Feb 18 2019 - 13:58:53)
pack uboot.img success!

u-boot をアンパック:

/*
 * @[input image]: Required. Unpacking source files
 * @[output bin]: Required. Unpack the output file, any name will do
 */

./tools/loaderimage --unpack --uboot [input image] [output bin]

テンプレート:

./tools/loaderimage --unpack --uboot uboot.img uboot.bin
unpack input uboot.img
unpack uboot.bin success!

包装の信頼:

/*
 * @[input bin]: Required. bin file
 * @[output image]: Required, output File
 * @[load_addr]: Required, the load Address
 * @<size>: Optional, Format: --size [KB] [count]. Output file size, when it is ommitted,
defaulted as 1M for one copy, and four copies for a package.
 */

./tools/loaderimage --pack --trustos [input bin] [output image] [load_addr] <size>

テンプレート:

./tools/loaderimage --pack --trustos ./bin/rk32/rk322x_tee_v2.00.bin trust.img \
                       0x80000000  --size 1024 2

 load addr is 0x80000000!
pack input bin/rk32/rk322x_tee_v2.00.bin
pack file size: 333896
crc = 0x2de93b46
pack trust.img success!

信頼を荷を下す:

/*
 * @[input image]: Required. Unpacking source files
 * @[output bin]: Required. the output file after unoacking, any name will do
 */

./tools/loaderimage --unpack --trustos [input image] [output bin]

テンプレート

./tools/loaderimage --unpack --trustos trust.img tee.bin
unpack input trust.img
unpack tee.bin success!

16.4 resource_tool {#164-resource_tool}

関数: resource.img を生成するために任意のリソースファイルをパックします。 パッキング コマンド:

./tools/resource_tool [--pack] [--image=<resource.img>] <file list>

テンプレート:

./scripts/resource_tool ./arch/arm/boot/dts/rk3126-evb.dtb logo.bmp logo_kernel.bmp
Pack to resource.img successed!

コマンドのアンパック:

./tools/resource_tool --unpack --image=<resource.img> [output dir]

テンプレート:

./tools/resource_tool --unpack --image=resource.img ./out/

Dump header:
partition version:0.0
header size:1
index tbl:
        offset:1        entry size:1    entry num:3
Dump Index table:
entry(0):
        path:rk-kernel.dtb
        offset:4        size:33728
entry(1):
        path:logo.bmp
        offset:70       size:170326
entry(2):
        path:logo_kernel.bmp
        offset:403      size:19160
Unack resource.img to ./out successed!

16.5mkimageの {#165-mkimage}

関数: SPLモードのLoaderファームウェアを生成します。 例えば、Rockchipのbootromで必要なIDBLOCK形式を生成します。 このコマンドは、ブートロームで必要なIDであるために、u-boot-tpl.binの最初の4バイトを変更します。

./tools/mkimage -n rk3328 -T rksd -d tpl/u-boot-tpl.bin idbloader.img

詳しい参照:

./doc/mkimage.1

16.6 stacktrace.sh {#166-stacktracesh}

関数: コールスタック情報を解析し、RKアーキテクチャの章を参照してください。

16.7 mkbootimg {#167-mkbootimg}

機能: パッケージファームウェアは、起動とrecovery.img、ソースファイルをAndroidプロジェクトに来るように生成します。 テンプレート:

./scripts/mkbootimg --kernel zImage --second resource.img --ramdisk ramdisk.img --out
boot.img

16.8 unpack_bootimg {#168-unpack_bootimg}

機能:ブートおよびrecovery.imgの荷を下すために使用される、源ファイルは人間の特徴をもつプロジェクトで来ます。 テンプレート:

./scripts/unpack_bootimg --boot_img boot.img --out out/

16.9 再パック-ブーティム {#169-repack-bootimg}

機能:ブートおよびrecovery.imgのファームウェアを取り替えて下さい。 テンプレート:

// For example, replace only the kernel
./scripts/repack-bootimg --boot_img boot.img --kernel zImage -o boot_repack.img

//Example: Replace only resource
./scripts/repack-bootimg --boot_img boot.img --second resource.img -o boot_repack.img

16.10 pack_resource.sh {#1610-pack_resourcesh}

関数: . /tools/images/ ディレクトリから resource.img に、充電画像をパックします。 テンプレート:

./scripts/pack_resource.sh resource.img

Pack ./tools/images/ & resource.img to resource.img ...
Unpacking old image(resource.img):
rk-kernel.dtb 1
Pack to resource.img successed!
Packed resources:
rk-kernel.dtb battery_1.bmp battery_2.bmp battery_3.bmp battery_4.bmp battery_5.bmp
battery_fail.bmp battery_0.bmp 8

resource.img is packed ready

16.11 ビルドマン {#1611-buildman}

関数: バッチコンパイルコード、現在のプラットフォームにコミットする検証には、他のプラットフォームに影響を及ぼすのに理想的です。 詳しい参照:

./tools/buildman/README

ビルドマンを使用するには、あらかじめツールチェーンパスを設定し、’~/.buildman’ファイルを編集する必要があります。

[toolchain]
arm: ~/prebuilts/gcc/linux-x86/arm/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf/
aarch64: ~/prebuilts/gcc/linux-x86/aarch64/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-
gnu/

すべてのRockchipプラットフォームのU-Bootコードをコンパイルするなどの典型的なユースケース:

./tools/buildman/buildman rockchip

理想的な結果は以下の通りです。

$ ./tools/buildman/buildman rockchip
boards.cfg is up to date. Nothing to do.
Building current source for 34 boards (4 threads, 1 job per thread)
   34    0    0 /34     evb-rk3326

最初に、完全に(緑色)渡するプラットフォームの数で、2つ目は警告出力(黄色)のプラットフォーム数であり、3つ目はエラー(赤)でコンパイルできないプラットフォームの数です。 コンパイルプロセス中に警告やエラーがあった場合は、端末に表示します。

16.12 人 {#1612-patman}

関数: パッチチェックと送信を完了するために他のツールを呼び出すことで、pythonで書かれているツールは、パッチアップストリーム(U-Boot、カーネル)をパッチを行うための非常に良いと必要なツールです。 主要関数: パラメータに基づいてパッチを自動的にフォーマットする; チェックパッチを呼び出してチェックをします。 コミット情報から抽出を行い、それらを表題リストのアップストリームに必要なカバーレター、パッチバージョン、バージョン変更などに変換します。 自動的にコミットから変更 ID を削除します。 メンテナーとファイル送信情報に基づいて各パッチに必要な受信者を自動的に抽出します。 ‘~/.gitconfig’ または ‘.gitconfig’ 設定に従って、すべてのパッチを送信します。 詳細情報

./tools/patman/README

‘-h’ オプションを使用して、すべてのコマンドオプションが表示されます。

$ patman -h
Usage: patman [options]

Create patches from commits in a branch, check them and email them as
specified by tags you place in the commits. Use -n to do a dry run first.

Options:
  -h, --help            show this help message and exit
  -H, --full-help       Display the README file
  -c COUNT, --count=COUNT
                        Automatically create patches from top n commits
  -i, --ignore-errors   Send patches email even if patch errors are found
  -m, --no-maintainers  Don't cc the file maintainers automatically
  -n, --dry-run         Do a dry run (create but don't email patches)
  -p PROJECT, --project=PROJECT
                        Project name; affects default option values and
                        aliases [default: u-boot]
  -r IN_REPLY_TO, --in-reply-to=IN_REPLY_TO
                        Message ID that this series is in reply to
-s START, --start=START
                      Commit to start creating patches from (0 = HEAD)
-t, --ignore-bad-tags
                      Ignore bad tags / aliases
--test                run tests
-v, --verbose         Verbose output of errors and warnings
--cc-cmd=CC_CMD       Output cc list for patch file (used by git)
--no-check            Don't check for patch compliance
--no-tags             Don't process subject tags as aliaes
-T, --thread          Create patches as a single thread

典型的なユースケース:最新の3パッチをコミット

patman -t -c3

コマンドを実行した後、エラーや警告がある場合は、チェックパッチは自動的に中止されます。パッチを変更して問題を解決し、再度実行する必要があります。 ‘-t’ の他の一般的なオプションは、 “:” 前の任意のテキストは、タグとして扱われます。ほとんどのものは、パットマンによって認識されず、’-t’ オプションを必要としません。 ‘-i’ は、いくつかの警告(例えば 80 文字以上)がある場合、私たちが固定する必要があると考える場合は、パッチを提出する ‘-i’ オプションを追加することができます。 ‘-s’, コミットしたいパッチが現在のツリーの一番上にない場合、’-s’ でトップ N パッチをスキップできます。’-n’ はパッチをコミットしたくない場合は、パッチがチェックパッチを通過する最新のパッチがチェックパッチを渡すかどうかを確認したい場合は、’-n’ オプションを使用します。パッチマンは、コミットメッセージのキーワードに従って上流メーリングリストに必要な情報を生成します。 典型的なコミット:

commit 72aa9e3085e64e785680c3fa50a28651a8961feb
Author: Kever Yang <kever.yang@rock-chips.com>
Date:   Wed Sep 6 09:22:42 2017 +0800

    spl: add support to booting with OP-TEE

    OP-TEE is an open source trusted OS, in armv7, its loading and
    running are like this:
    loading:
    - SPL load both OP-TEE and U-Boot
    running:
    - SPL run into OP-TEE in secure mode;
    - OP-TEE run into U-Boot in non-secure mode;

    More detail:
    <https://github.com/OP-TEE/optee_os>
    and search for 'boot arguments' for detail entry parameter in:
    core/arch/arm/kernel/generic_entry_a32.S
Cover-letter:
rockchip: add tpl and OPTEE support for rk3229

Add some generic options for TPL support for arm 32bit, and then
and TPL support for rk3229(cortex-A7), and then add OPTEE support
in SPL.

Tested on latest u-boot-rockchip master.

END

Series-version: 4
Series-changes: 4
- use NULL instead of '0'
- add fdt_addr as arg2 of entry

Series-changes: 2
- Using new image type for op-tee

Change-Id: I3fd2b8305ba8fa9ea687ab7f3fd1ffd2fac9ece6
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>

patman コマンドでこのパッチが送信されると、 Cover-letter が生成されます。

[PATCH v4 00/11] rockchip: add tpl and OPTEE support for rk3229

対応するパッチのタイトルは、バージョン情報とシリーズの現在のパッチの数を含む次の通りです。

[PATCH v4,07/11] spl: add support to booting with OP-TEE

パッチコミットメッセージは既に処理され、変更 ID を削除、カバーレター削除、バージョン変更は非テキスト情報に変換されます。

OP-TEE is an open source trusted OS, in armv7, its loading and
running are like this:
loading:
- SPL load both OP-TEE and U-Boot
running:
- SPL run into OP-TEE in secure mode;
- OP-TEE run into U-Boot in non-secure mode;

More detail:
<https://github.com/OP-TEE/optee_os>
and search for 'boot arguments' for detail entry parameter in:
core/arch/arm/kernel/generic_entry_a32.S

Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
---
Changes in v4:
- use NULL instead of '0'
- add fdt_addr as arg2 of entry

Changes in v3: None
Changes in v2:
- Using new image type for op-tee

 common/spl/Kconfig     |  7 +++++++
 common/spl/Makefile    |  1 +
 common/spl/spl.c       |  9 +++++++++
 common/spl/spl_optee.S | 13 +++++++++++++
 include/spl.h          | 13 +++++++++++++
 5 files changed, 43 insertions(+)
 create mode 100644 common/spl/spl_optee.S

README は「シリーズプレフィックス」「シリーズ-cc」などのキーワードの使用に関する詳細情報をご覧ください。

17. . Chapter-17 付録 {#17-chapter-17-appendix}

17.1 アドレスをダウンロード {#171-download-address}

17.1.1 リリース {#1711-rkbin}

RK内部エンジニア: gerrit にログインして検索: “rk/rkbin” 外部エンジニア: RK がリリースしたフル SDK をダウンロードし、Github からダウンロード: https://github.com/rockchip-linux/rkbin

17.1.2 GCCの特長 {#1712-gcc}

RK内部エンジニア: gerrit にログインして検索: “gcc-linaro-6.3.1” 外部エンジニア: RK または Linaro ウェブサイトがリリースしたフル SDK をダウンロードしてください。

17.2 用語集 {#172-terminology}

U-Boot:ユニバーサルブートローダーAOSP:AndroidオープンソースプロジェクトAVB:Android検証ブートDTB:デバイスツリーバイナリDTS:デバイスツリーソースFastboot:もともとAndroid用のファームウェアを更新する方法、それは今、埋め込まれたスペースGPTで広く使用されている:GUIDパーティションテーブルMMC:マルチメディアカード、付属:eMMC、SDカード、など。 SPL:二次プログラムローダーTPL:準プログラムローダーDTB:noun、デバイスツリーbloob DTB:noun、DTCを積み重ねるためのデバイスツリーbob:noun、デバイスツリーコンパイラDTO:noun、デバイスツリースタッキング操作DTS:noun、デバイスツリーソースファイルFDT:noun、フラットテンデッドデバイスツリー

SCMI:システム制御と管理インタフェース

このトピックを詳しく見る → · 学習ガイド →