凌云实验室IGKBoard开发板BSP开发相关文件
edit | blame | history | raw

1. 编译系统介绍

从实验室 git 仓库下载相应版本的 BSP(Board Support Package) 文件.

guowenxue@ubuntu22:~$ git clone http://main.iot-yun.club:8088/r/igkboard-bsp.git igkboard-6ull

guowenxue@ubuntu22:~$ cd igkboard-6ull && ls
README.md  bootloader  config.json  images  kernel  tools  yocto

下面是这些文件的说明.

guowenxue@ubuntu22:~/igkboard-6ull$ tree
.
├── bootloader              Bootloader源码编译的工作目录
│   ├── build.sh              Bootloader的一键编译脚本
│   └── patches               Bootloader补丁文件存放目录
│       ├── gen_patch.sh        生成补丁文件的Shell脚本
│       └── igkboard-6ull       IGKBoard-6ULL开发板补丁文件存放目录
├── config.json             编译系统配置文件
├── images                  制作系统镜像的工作目录
│   └── build.sh              系统镜像一键编译脚本
├── kernel                  Linux内核源码编译的工作目录
│   ├── build.sh              Linux内核源码的一键编译脚本
│   └── patches               Linux内核补丁文件存放目录
│       ├── gen_patch.sh        生成补丁文件的Shell脚本
│       └── igkboard-6ull       IGKBoard-6ULL开发板补丁文件存放目录
├── tools                   编译系统工具脚本存放目录
|   ├── imgmnt                挂载系统镜像的工具脚本
|    └── setup_tools.sh        编译环境安装的脚本
├── yocto                   Yocto源码编译的工作目录
    └── build.sh                Yocto源码一键编译脚本

本系统在Ubuntu 22.04上测试通过。

guowenxue@ubuntu22:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.2 LTS
Release:        22.04
Codename:       jammy

2. BSP源码编译

2.1 编译环境安装

进入到 tools 目录下,并以 sudo 权限运行该脚本,它将会自动安装编译BSP源码所需要的系统软件和交叉编译器。

guowenxue@ubuntu22:~/igkboard-6ull$ cd tools/
guowenxue@ubuntu22:~/igkboard-6ull/tools$ sudo ./setup_tools.sh

 --I-- start apt install system tools(commands)
... ...
 --I-- start apt install devlopment tools(commands)
... ...
 --I-- start download AArch32 cross compiler from ARM Developer
... ...
 --I-- AArch32 cross compiler installed to "/opt/gcc-aarch32-10.3-2021.07" successfully
... ...
 --I-- start download buildroot cross compiler from LingYun IoT studio file server
... ...
 --I-- Buildroot cross compiler installed to "/opt/buildroot//gcc-10.4-aarch32-v2023.02/" successfully

2.2 修改配置文件

根据自己的开发板和实际需求,修改下面的开发板、BSP版本以及系统镜像的相关配置。

guowenxue@ubuntu22:~/igkboard-6ull$ vim config.json
{
    "bsp":
    {
        "board":"igkboard-6ull",
        "version":"lf-5.15.71-2.2.0",
        "download":"http://main.iot-yun.club:2211/imx/",
        "crosstool":"/opt/gcc-aarch32-10.3-2021.07/bin/arm-none-linux-gnueabihf-"
    },
    "system":
    {
        "distro":"yocto",
        "version":"kirkstone",
        "imgsize":"2048",
        "bootsize":"100"
    }
}

下面是配置文件中 bsp配置选项 的说明,该选项将影响 BSP 源码的编译:

  • board 指定目标开发板。当前支持 igkboard-6ull 和 igkboard-8mp;
  • version 指定编译的BSP版本。具体支持哪些版本,请查看kernel/patches/文件夹下相应开发板补丁文件;
  • download 指定BSP源码压缩包或其他相关文件的下载服务器;
  • crosstool 指定Bootloader和Linux内核的交叉编译器,前面的编译环境搭建中已安装;

下面是配置文件中 system配置选项 的说明,该选项将影响烧到eMMC/TF卡上的系统镜像文件。

  • distro 指定Linux系统发行版本,当前支持 yoctot、debian 和 buildroot;
  • version 指定相应发行版本的版本,具体支持见下表;
  • imgsize 指定制作生成的系统镜像大小;
  • bootsize 指定生成的系统镜像的BOOT(FAT32)分区大小;

下面是IGKBoard当前支持BSP版本及它与Yocto/Android的对应版本关系:

IMX BSP Version Yocto Version Android Version
lf-6.1.36-2.1.0 Mickledore(4.2) NEW 13.0.0-2.2.0
lf-5.15.71-2.2.0 Kirkstone(4.0) LTS 13.0.0-1.2.0

下面是IGKBoard当前支持的发行版本及相应版本号:

发行版本(distro) 版本号(version)
Yocto kirkstone(4.0)、*mickledore(4.2)*
Debian bullseye(11)、*bookworm(12)*
Buildroot v2023.02

2.3 编译Bootloader

bootloader 文件夹下执行 build.sh 脚本,它将会自动下载源码文件、打补丁、编译,并将编译生成的相关文件拷贝到 install 文件夹下。

guowenxue@ubuntu22:~/igkboard-6ull$ cd bootloader && ls
build.sh  patches

guowenxue@ubuntu22:~/igkboard-6ull/bootloader$ ./build.sh
 start build bootloader for igkboard-6ull
 start fetch uboot-imx source code
 ... ...
bootloader installed to '/home/guowenxue/igkboard-6ull/bootloader/install'
u-boot-igkboard-6ull.imx

2.4 编译Linux内核

kernel 文件夹下执行 build.sh 脚本,它将会自动下载源码文件、打补丁、编译,并将编译生成的相关文件拷贝到 install 文件夹下。

guowenxue@ubuntu22:~/igkboard-6ull$ cd kernel && ls
build.sh  patches

guowenxue@ubuntu22:~/igkboard-6ull/kernel$ ./build.sh
 start build linux kernel for igkboard-6ull
 start fetch linux-imx source code
 ... ...
linux kernel installed to '/home/guowenxue/igkboard-6ull/kernel/install'
igkboard-6ull.dtb  lib  overlays  zImage

2.5 制作系统镜像

images 文件夹下执行 build.sh 脚本,它将会自动下载相应发行版本的根文件系统源码,并将编译生成的镜像文件拷贝到 install 文件夹下。需要注意的是,该脚本必须以 root 权限来执行。

guowenxue@ubuntu22:~/igkboard-6ull$ cd images && ls
build.sh

guowenxue@ubuntu22:~/igkboard-6ull/images$ sudo ./build.sh
 start build yocto-kirkstone for igkboard-6ull
 start fetch rootfs-yocto-kirkstone source code
... ...
system images installed to '/home/guowenxue/igkboard-6ull/images/install'
igkboard-6ull-yocto-kirkstone-lf-5.15.71-2.2.0.img  u-boot-igkboard-6ull.imx
... ...

2.6 编译Yocto源码

如果想要源码编译Yocto系统的话,则Linux主机服务器需满足如下条件:

  • 系统能够代理翻墙访问 github;
  • 推荐使用 8核以上CPU、16GB以上内存;
  • 硬盘空闲空间至少要求 200GB+;
  • 推荐使用 Ubuntu 20.04 系统及以上;

首先运行 proxy 命令使能代理翻墙访问 github,因为编译的过程中会从 github 上下载大量的源代码.

guowenxue@ubuntu22:~$ proxy

注:该命令并不是标准的Linux系统命令,而是我们服务器上翻墙访问 github 的命令.

yocto 文件夹下执行 build.sh 脚本,它将会自动下载Yocto源码并编译生成系统镜像,相关文件将会安装到 install 文件夹下。

guowenxue@ubuntu22:~/igkboard-6ull$ cd yocto && ls
build.sh

guowenxue@ubuntu22:~/igkboard-6ull/yocto$ ./build.sh
 start build Yocto kirkstone for igkboard-6ull
 start fetch Yocto kirkstone source code
 start fetch  source code
... ...
 Yocto(kirkstone) installed to '/home/guowenxue/igkboard-6ull/yocto/install'
rootfs-yocto-kirkstone.tar.zst  u-boot-igkboard-6ull.imx  yocto-image-kirkstone.wic.zst
  • u-boot-igkboard-6ull.imx U-boot镜像文件
  • yocto-image-kirkstone.wic.zst 烧录到 eMMC或TF 卡上的系统镜像压缩文件
  • rootfs-yocto-kirkstone.tar.zst 根文件系统树源码压缩包