推荐在 Ubuntu 18.04 系统环境下进行开发

环境部署

  • 检查软件源列表

    sudo apt update
  • 安装依赖包

    sudo apt install -y repo git ssh make gcc libssl-dev liblz4-tool expect g++ patchelf gawk texinfo chrpath diffstat binfmt-support qemu-user-static live-build bison flex fakeroot cmake gcc-multilib g++-multilib unzip python-pip ncurses-dev python-pyelftools  android-tools-adb vim net-tools tree minicom libssl-dev device-tree-compiler gcc-aarch64-linux-gnu mtools libusb-1.0-0-dev autoconf autotools-dev libsigsegv2 m4 intltool libdrm-dev curl sed binutils build-essential g+bash patch gzip bzip2 perl tar cpio python rsync file bc wget libncurses5 u-boot-tools cvs mercurial rsync openssh-client subversion expect liblz4-tool libtool keychain libncurses-dev parted libudev-dev

时间可能很久需要耐心等待,安装依赖这一步时间还算比较短,后续下载其他包会更慢。

下载及解压SDK包

  • 下载及校验SDK
    SDK包比较大,下载后(或者从其他本地设备传入)需要校验MD5

    md5sum RV1126_RV1109_LINUX_SDK_V2.2.4_20211019.tar.xz
  • SDK 解压

    gzip -d RV1126_RV1109_LINUX_SDK_V2.2.4_20211019.tar.xz

开始编译

  • 进入SDK路径

    cd RV1126_RV1109_LINUX_SDK_V2.2.4_20211019/
  • 选择ENV

    source envsetup.sh
  • 指定编译版型

    这里有两种方式可以,一种是直接指定,一种是可以选择

    ./build.sh BoardConfig-38x38-spi-nand.mk
    
    or
    
    ./build.sh lunch
  • 屏蔽repo的更新
    这一步的原本作用是从ROCKCHIP更新最新的源码,当然这需要官方git的权限,个人开发者不太可能有,就算是有也不一定需要更新代码。具体操作,在build.sh文件的905行左右范围内,修改如下:

    #Generate patches
    #.repo/repo/repo forall -c \
    #  "$TOP_DIR/device/rockchip/common/gen_patches_body.sh"
    
    #Copy stubs
    #.repo/repo/repo manifest -r -o $STUB_PATH/manifest_${DATE}.xml
  • 开始编译

    export FORCE_UNSAFE_CONFIGRUE=1
    ./build.sh
  • 编译过程

    这一步其实等待就行了,但是鉴于网络情况的问题,可能需要代理软件,具体内容不详细介绍,可以自行搜索,过程也很简单。下面介绍一下代理服务搭建完成后如何配置代理:

    echo -e "export http_proxy=http://127.0.0.1:7890\nexport https_proxy=http://127.0.0.1:7890" >> ~/.bashrc

    然后重新打开一个终端

    env | grep proxy

    然后还是提示有下载失败的报错,可以手动在报错信息里面找到下载的地址,然后手动下载,放在 buildroot/root目录下面,参考报错如下:

    2023-04-08T12:26:09 install -m 644 fcgiwrap.8 /root/RV1126_RV1109_LINUX_SDK_V2.2.4_20211019/buildroot/output/rockchip_rv1126_rv1109_spi_nand/target/usr/man/man8
    
    2023-04-08T12:26:09 >>> libpng 1.6.37 Downloading
    
    2023-04-08T12:26:09 --2023-04-08 12:26:09--  [http://downloads.sourceforge.net/project/libpng/libpng16/1.6.37/libpng-1.6.37.tar.xz](http://downloads.sourceforge.net/project/libpng/libpng16/1.6.37/libpng-1.6.37.tar.xz)
    
    2023-04-08T12:26:19 Resolving [downloads.sourceforge.net](http://downloads.sourceforge.net) ([downloads.sourceforge.net](http://downloads.sourceforge.net))... failed: Temporary failure in name resolution.
    
    2023-04-08T12:26:19 wget: unable to resolve host address '[downloads.sourceforge.net](http://downloads.sourceforge.net)'
    
    2023-04-08T12:26:19 --2023-04-08 12:26:19--  [http://sources.buildroot.net/libpng-1.6.37.tar.xz](http://sources.buildroot.net/libpng-1.6.37.tar.xz)
    
    2023-04-08T12:26:19 Resolving [sources.buildroot.net](http://sources.buildroot.net) ([sources.buildroot.net](http://sources.buildroot.net))... 2606:4700:20::ac43:4838, 2606:4700:20::681a:25, 2606:4700:20::681a:125, ...
    
    2023-04-08T12:28:30 Connecting to [sources.buildroot.net](http://sources.buildroot.net) ([sources.buildroot.net](http://sources.buildroot.net))|2606:4700:20::ac43:4838|:80... failed: Connection timed out.
    
    2023-04-08T12:30:41 Connecting to [sources.buildroot.net](http://sources.buildroot.net) ([sources.buildroot.net](http://sources.buildroot.net))|2606:4700:20::681a:25|:80... failed: Connection timed out.
    
    2023-04-08T12:32:52 Connecting to [sources.buildroot.net](http://sources.buildroot.net) ([sources.buildroot.net](http://sources.buildroot.net))|2606:4700:20::681a:125|:80... failed: Connection timed out.
    
    2023-04-08T12:32:52 Connecting to [sources.buildroot.net](http://sources.buildroot.net) ([sources.buildroot.net](http://sources.buildroot.net))|104.26.1.37|:80... connected.
    
    2023-04-08T12:32:53 HTTP request sent, awaiting response... 404 Not Found
    
    2023-04-08T12:32:53 2023-04-08 12:32:53 ERROR 404: Not Found.
    
    2023-04-08T12:32:53
    
    2023-04-08T12:32:53 package/pkg-generic.mk:138: recipe for target '/root/RV1126_RV1109_LINUX_SDK_V2.2.4_20211019/buildroot/output/rockchip_rv1126_rv1109_spi_nand/build/libpng-1.6.37/.stamp_downloaded' failed
    
    2023-04-08T12:32:53 make[1]: *** [/root/RV1126_RV1109_LINUX_SDK_V2.2.4_20211019/buildroot/output/rockchip_rv1126_rv1109_spi_nand/build/libpng-1.6.37/.stamp_downloaded] Error 1
    
    2023-04-08T12:32:53 /root/RV1126_RV1109_LINUX_SDK_V2.2.4_20211019/buildroot/output/rockchip_rv1126_rv1109_spi_nand/Makefile:16: recipe for target '_all' failed
    
    2023-04-08T12:32:53 make: *** [_all] Error 2
    
    Command exited with non-zero status 1
    
    you take 1:54:42 to build builroot
    
    ERROR: Running build_buildroot failed!
    
    ERROR: exit code 1 from line 556:
    
      /usr/bin/time -f "you take %E to build builroot" $COMMON_DIR/mk-buildroot.sh $BOARD_CONFIG

然后重新开始编译即可。./build.sh

编译完成后的内容

  • 编译输出的镜像和固件在 SDK包path/IMAGE/xxxxxx/
  • 编译后需要再次检查各电源域电压(版型选择与电源方案),编译后输出如下,在最后有各个电源域电压,需要和硬件原理图互相校验

    ====Build rockchip_rv1126_rv1109_spi_nand_recovery ok!====
    pack recovery.img...fdt {
    kernel {
    ramdisk {
    resource {
    FIT description: U-Boot FIT source file for arm
    Created:         Sat Apr  8 07:28:11 2023
      Image 0 (fdt)
        Description:  unavailable
        Created:      Sat Apr  8 07:28:11 2023
        Type:         Flat Device Tree
        Compression:  uncompressed
        Data Size:    87116 Bytes = 85.07 KiB = 0.08 MiB
        Architecture: ARM
        Load Address: 0xffffff00
        Hash algo:    sha256
        Hash value:   ac645a4aab328ccd693a8d47f497cc44d93894dbbcda20980a8f79aef8511040
      Image 1 (kernel)
        Description:  unavailable
        Created:      Sat Apr  8 07:28:11 2023
        Type:         Kernel Image
        Compression:  uncompressed
        Data Size:    6063104 Bytes = 5921.00 KiB = 5.78 MiB
        Architecture: ARM
        OS:           Linux
        Load Address: 0xffffff01
        Entry Point:  0xffffff01
        Hash algo:    sha256
        Hash value:   a131ceaefe3ff4b34ee1d103a745bd8f92624b985352821640493644feef38d3
      Image 2 (ramdisk)
        Description:  unavailable
        Created:      Sat Apr  8 07:28:11 2023
        Type:         RAMDisk Image
        Compression:  uncompressed
        Data Size:    7122341 Bytes = 6955.41 KiB = 6.79 MiB
        Architecture: ARM
        OS:           Linux
        Load Address: 0xffffff02
        Entry Point:  unavailable
        Hash algo:    sha256
        Hash value:   a64ef176083c7e5330b22a1a83de7985568df55da27e7d861ecba41ecedc508a
      Image 3 (resource)
        Description:  unavailable
        Created:      Sat Apr  8 07:28:11 2023
        Type:         Multi-File Image
        Compression:  uncompressed
        Data Size:    125440 Bytes = 122.50 KiB = 0.12 MiB
        Hash algo:    sha256
        Hash value:   e3cf14636f21f78252c6069dfe0c714b6f3d5d16f2ff2b1de77712e984a48b85
      Default Configuration: 'conf'
      Configuration 0 (conf)
        Description:  unavailable
        Kernel:       kernel
        Init Ramdisk: ramdisk
        FDT:          fdt
    done.
    you take 0:11.98 to build recovery
    Running build_recovery succeeded.
    Skipping build_ramboot for missing configs:  RK_CFG_RAMBOOT.
    Running build_all succeeded.
    /usr/bin/fakeroot
    create rootfs.img...done.
    create parameter...done.
    /home/hulk/RV1126_RV1109_LINUX_SDK_V2.2.4_20211019/device/rockchip/rv1126_rv1109/parameter-fit-nand-256M.txt
    0x00000800@0x00001000(vnvm),0x00002800@0x00001800(uboot),0x00004000@0x00004000(boot),0x0002A800@0x00008000(rootfs),0x00000400@0x00032800(misc),0x00008000@0x00032C00(recovery),-@0x0003AC00(userdata:grow)
    create recovery.img...done.
    create misc.img...done.
    create uboot.img...done.
    uboot fotmat type is fit, so ignore trust.img...
    create loader...done.
    create boot.img...done.
      Image: image in rockdev is ready 
    Running build_firmware succeeded.
    Make update.img
    start to make update.img...
    Android Firmware Package Tool v1.66
    ------ PACKAGE ------
    Add file: ./package-file
    Add file: ./package-file done,offset=0x800,size=0x2fe,userspace=0x1
    Add file: ./Image/MiniLoaderAll.bin
    Add file: ./Image/MiniLoaderAll.bin done,offset=0x1000,size=0x4294e,userspace=0x86
    Add file: ./Image/parameter.txt
    Add file: ./Image/parameter.txt done,offset=0x44000,size=0x1d7,userspace=0x1
    Add file: ./Image/uboot.img
    Add file: ./Image/uboot.img done,offset=0x44800,size=0x400000,userspace=0x800
    Add file: ./Image/misc.img
    Add file: ./Image/misc.img done,offset=0x444800,size=0xc000,userspace=0x18
    Add file: ./Image/boot.img
    Add file: ./Image/boot.img done,offset=0x450800,size=0x5fd000,userspace=0xbfa
    Add file: ./Image/recovery.img
    Add file: ./Image/recovery.img done,offset=0xa4d800,size=0xcc7e00,userspace=0x1990
    Add file: ./Image/rootfs.img
    Add file: ./Image/rootfs.img done,offset=0x1715800,size=0x4d20000,userspace=0x9a40
    Add CRC...
    Make firmware OK!
    ------ OK ------
    **RKImageMaker ver 1.66**
    Generating new image, please wait...
    Writing head info...
    Writing boot file...
    Writing firmware...
    Generating MD5 data...
    MD5 data generated successfully!
    New image generated successfully!
    Making -RK1126 update.img OK.
    Running build_updateimg succeeded.
    Running build_save succeeded.
      PLEASE CHECK BOARD GPIO POWER DOMAIN CONFIGURATION !!!!!
      <<< ESPECIALLY Wi-Fi/Flash/Ethernet IO power domain >>> !!!!!
      Check Node [pmu_io_domains] in the file: /home/hulk/RV1126_RV1109_LINUX_SDK_V2.2.4_20211019/kernel/arch/arm/boot/dts/rv1109-38-v10-spi-nand.dts 
      请再次确认板级的电源域配置!!!!!!
      <<< 特别是Wi-Fi,FLASH,以太网这几路IO电源的配置 >>> !!!!!
      检查内核文件 /home/hulk/RV1126_RV1109_LINUX_SDK_V2.2.4_20211019/kernel/arch/arm/boot/dts/rv1109-38-v10-spi-nand.dts 的节点 [pmu_io_domains] 
    pmuio0-supply 
    regulator-min-microvolt =  3300mV
    regulator-max-microvolt =  3300mV
    pmuio1-supply 
    regulator-min-microvolt =  3300mV
    regulator-max-microvolt =  3300mV
    vccio2-supply 
    regulator-min-microvolt =  3300mV
    regulator-max-microvolt =  3300mV
    vccio4-supply 
    regulator-min-microvolt =  1800mV
    regulator-max-microvolt =  1800mV
    vccio5-supply 
    regulator-min-microvolt =  3300mV
    regulator-max-microvolt =  3300mV
    vccio6-supply 
    regulator-min-microvolt =  3300mV
    regulator-max-microvolt =  3300mV
    vccio7-supply 
    regulator-min-microvolt =  3300mV
    regulator-max-microvolt =  3300mV
    Running build_allsave succeeded.
  • 固件烧录

    如果您编译出来的固件只为烧录uboot或者Boot等部分,可以选择单独烧录,也可以选择 update.img烧录完整部分,可以在Windows下使用瑞芯微开发工具烧录也可以在Linux下使用 sudo ./rkflash.sh烧录。还需要注意需要板子连接后处于MASKROM模式。

附录

参考资料:

最后修改:2023 年 04 月 10 日
如果觉得我的文章对你有用,请随意赞赏