Category: u-boot解读

  • 关于瑞芯微的一些image

    以下所有的操作基于“
    kernel下面生成的boot.imgRKIMG(RKIMG is a format customized by Rockchip from Android boot image)的镜像,因为u-boot里面用的命令是android_boot(之前不知道这个东西是用安卓启动的方式启动linux内核的,误解成是bootrkp)
    然后FIT镜像是uboot.itb,在uboot目录下的fit,可以用dumpimage -l uboot.itb查看.
    TSPI的原厂固件boot.img,recovery.img也是一个FIT镜像
    所以镜像分两种,一个是uboot FIT一个是android镜像

    分区信息可以在执行完./make.sh orangepi-3b-rk3566后看见fit/u-boot.its

    
    /*
     * Copyright (C) 2020 Rockchip Electronic Co.,Ltd
     *
     * Simple U-boot fit source file containing ATF/OP-TEE/U-Boot/dtb/MCU
     */
    
    /dts-v1/;
    
    / {
        description = "FIT Image with ATF/OP-TEE/U-Boot/MCU";
        #address-cells = <1>;
    
        images {
    
            uboot {
                description = "U-Boot";
                data = /incbin/("u-boot-nodtb.bin");
                type = "standalone";
                arch = "arm64";
                os = "U-Boot";
                compression = "none";
                load = <0x00a00000>;
                hash {
                    algo = "sha256";
                };
            };
            atf-1 {
                description = "ARM Trusted Firmware";
                data = /incbin/("./bl31_0x00040000.bin");
                type = "firmware";
                arch = "arm64";
                os = "arm-trusted-firmware";
                compression = "none";
                load = <0x00040000>;
                hash {
                    algo = "sha256";
                };
            };
            atf-2 {
                description = "ARM Trusted Firmware";
                data = /incbin/("./bl31_0xfdcc1000.bin");
                type = "firmware";
                arch = "arm64";
                os = "arm-trusted-firmware";
                compression = "none";
                load = <0xfdcc1000>;
                hash {
                    algo = "sha256";
                };
            };
            atf-3 {
                description = "ARM Trusted Firmware";
                data = /incbin/("./bl31_0x0006b000.bin");
                type = "firmware";
                arch = "arm64";
                os = "arm-trusted-firmware";
                compression = "none";
                load = <0x0006b000>;
                hash {
                    algo = "sha256";
                };
            };
            atf-4 {
                description = "ARM Trusted Firmware";
                data = /incbin/("./bl31_0xfdcd0000.bin");
                type = "firmware";
                arch = "arm64";
                os = "arm-trusted-firmware";
                compression = "none";
                load = <0xfdcd0000>;
                hash {
                    algo = "sha256";
                };
            };
            atf-5 {
                description = "ARM Trusted Firmware";
                data = /incbin/("./bl31_0xfdcce000.bin");
                type = "firmware";
                arch = "arm64";
                os = "arm-trusted-firmware";
                compression = "none";
                load = <0xfdcce000>;
                hash {
                    algo = "sha256";
                };
            };
            atf-6 {
                description = "ARM Trusted Firmware";
                data = /incbin/("./bl31_0x00069000.bin");
                type = "firmware";
                arch = "arm64";
                os = "arm-trusted-firmware";
                compression = "none";
                load = <0x00069000>;
                hash {
                    algo = "sha256";
                };
            };
            fdt {
                description = "U-Boot dtb";
                data = /incbin/("./u-boot.dtb");
                type = "flat_dt";
                arch = "arm64";
                compression = "none";
                hash {
                    algo = "sha256";
                };
            };
        };
    
        configurations {
            default = "conf";
            conf {
                description = "rk3566-orangepi-3b";
                rollback-index = <0x0>;
                firmware = "atf-1";
                loadables = "uboot", "atf-2", "atf-3", "atf-4", "atf-5", "atf-6";
    
                fdt = "fdt";
                signature {
                    algo = "sha256,rsa2048";
    
                    key-name-hint = "dev";
                    sign-images = "fdt", "firmware", "loadables";
                };
            };
        };
    };
    

    如何pack idblock(idbloader)?

    在u-boot下面进行

    ./make.sh --idblock

    shell源码:

    function pack_idblock()
    {
        INI=${INI_LOADER}
        if [ ! -f ${INI} ]; then
            echo "ERROR: No ${INI}"
            exit 1
        fi
    
        # chip
        COMMON_H=`grep "_common.h:" include/autoconf.mk.dep | awk -F "/" '{ printf $3 }'`
        PLAT=${COMMON_H%_*}
    
        # file
        SPL_BIN=${RKBIN}/`filt_val "FlashBoot" ${INI}`
        TPL_BIN=${RKBIN}/`filt_val "FlashData" ${INI}`
        if [ ! -z "${ARG_SPL_BIN}" ]; then
            SPL_BIN=${ARG_SPL_BIN}
        fi
        if [ ! -z "${ARG_TPL_BIN}" ]; then
            TPL_BIN=${ARG_TPL_BIN}
        fi
    
        # pack
        rm idblock.bin -f
        ./tools/mkimage -n ${PLAT} -T rksd -d ${TPL_BIN}:${SPL_BIN} idblock.bin
        echo "Input:"
        echo "    ${INI}"
        echo "    ${TPL_BIN}"
        echo "    ${SPL_BIN}"
        echo
        echo "Pack ${PLAT} idblock.bin okay!"
        echo
    }

    运行后终端提示:

    (py2) ➜  u-boot-orangepi git:(v2017.09-rk3588) ./make.sh --idblock         
    Image Type:   Rockchip RK35 boot image
    Init Data Size: 55296 bytes
    Boot Data Size: 241664 bytes
    Input:
        /home/ztn/Embedded/RK/rkbin/RKBOOT/RK3566MINIALL.ini
        /home/ztn/Embedded/RK/rkbin/bin/rk35/rk3566_ddr_1056MHz_v1.18.bin
        /home/ztn/Embedded/RK/rkbin/bin/rk35/rk356x_spl_v1.12.bin
    
    Pack rk3568 idblock.bin okay!

    在运行./make.sh xxx时候INI_LOADER如何被选中?

    看源码make.sh, 是从当前目录下的.config中寻找CONFIG_LOADER_INI

    function select_ini_file()
    {
        # default
        INI_LOADER=${RKBIN}/RKBOOT/${RKCHIP_LOADER}MINIALL.ini
        if [ "${ARM64_TRUSTZONE}" == "y" ]; then
            INI_TRUST=${RKBIN}/RKTRUST/${RKCHIP_TRUST}TRUST.ini
        else
            INI_TRUST=${RKBIN}/RKTRUST/${RKCHIP_TRUST}TOS.ini
        fi
    
        # defconfig
        NAME=`filt_val "CONFIG_LOADER_INI" .config`
        if [ ! -z "${NAME}" ]; then
            INI_LOADER=${RKBIN}/RKBOOT/${NAME}
        fi
        NAME=`filt_val "CONFIG_TRUST_INI" .config`
        if [ ! -z "${NAME}" ]; then
            INI_TRUST=${RKBIN}/RKTRUST/${NAME}
        fi
    
        # args
        if [ ! -z "${ARG_INI_TRUST}" ]; then
            INI_TRUST=${ARG_INI_TRUST}
        fi
        if [ ! -z "${ARG_INI_LOADER}" ]; then
            INI_LOADER=${ARG_INI_LOADER}
        fi
    }

    小勘误

    rockchip wiki上面是这样从bin 制作img的(img烧录到sd卡中)

    tools/mkimage -n rkxxxx -T rksd -d rkxx_ddr_vx.xx.bin idbloader.img
    cat rkxx_miniloader_vx.xx.bin >> idbloader.img

    但是这样会有问题(提示文件过大)
    然后用make.sh里面的方法:

    ./tools/mkimage -n ${PLAT} -T rksd -d ${TPL_BIN}:${SPL_BIN} idblock.bin
  • [u-boot解读之基于全志V3s]00序言

    序言

    现在开始我要开一个新坑,也就是对u-boot项目的解读
    一开始初入嵌入式开发,常常会对一些编译操作一知半解,比如

    • 为什么要配置defconfig?
    • xx文件是怎么生成的
    • 最终编译出来的文件包含了哪些源文件(Sc文件)
      等等
      为了提高日后的开发效率,我们需要透过现象看本质
      因此,我会从顶层Makefile入手来剖析整个项目,顺便进行学习

    笔者将基于u-boot仓库主线:2023.10-rc4,git commit hash 为252592214,
    基于Allwinner公司的V3s芯片进行分析,建议读者购买一块v3s开发板,可以从闲鱼购买,只需要二三十块钱

    05:10:28 ztn@ZTN-PC u-boot ±|master ✗|→ git log -a
    252592214f79d8206c3cf0056a8827a0010214e0 (grafted, HEAD -> master, origin/master, origin/HEAD)          ├─────────────────────────────────────────
    Author: Tom Rini <trini@konsulko.com>                                                                          │04:33:37 ztn@ZTN-PC u-boot ±|master ✗|→
    Date:   Sat Sep 9 09:33:02 2023 -0400