Flexbuild主要功能介绍
Automatically build Linux, bootloader, miscellaneous user-space components and various Root File Systems (based on Ubuntu, Debian, CentOS, Yocto, Buildroot, etc).
自动构建Linux、bootloader、其他用户空间组件和各种根文件系统(基于Ubuntu、Debian、CentOS、Yocto、Buildroot等)。
Generate machine-specific composite firmware for various boot types: SD/QSPI/XSPI/NOR/NAND normal boot and secure boot based on U-Boot or UEFI as bootloader.
为各种引导类型生成特定于机器的复合固件:SD/QSPI/XSPI/NOR/NAND正常引导和基于U-boot或UEFI作为引导加载程序的安全引导。
Support repo integrated management with commands of repo-fetch, repo-branch, repo-commit, repo-tag, repo-update for all components.
支持repo集成管理,支持所有组件的repo-fetch, repo-branch, repo-commit, repo-tag, repo-update等命令。
Support cross build on x86 Ubuntu 18.04 host machine for aarch64/armhf target.
为aarch64/armhf目标在x86 ubuntu18.04主机上支持交叉编译环境。
Support native build on aarch64/armhf machine for Arm arch target.
支持在aarch64/armhf机器上为Arm arch目标进行本地编译。
Support creating an Ubuntu docker container and building LSDK inside it when the host machine is using CentOS, RHEL, Fedora, SUSE, Debian, non-18.04 Ubuntu, etc.
支持在主机使用CentOS、RHEL、Fedora、SUSE、Debian、non-18.04 Ubuntu等时创建Ubuntu docker容器并在其中编译LSDK。
Scalability of integrating various components of both system firmware and user space applications.
系统固件和用户空间应用程序的各种组件的可伸缩性。
Capability of generating custom aarch64/armhf NXP LSDK userland integrated configurable packages and proprietary components.
能够生成用户空间集成了可配置包和专有组件的定制的 aarch64/armhf NXP LSDK 。
Flexbuild可以单独构建每个组件或自动构建所有组件,它生成复合固件(包含RCW、U-Boot/UEFI、PHY固件、内核映像、dtb、initrd)和NXP LSDK userland(包含指定的包和应用组件)。
以LSDK20为例,设备使用LS1028ARDB
链接:https://pan.baidu.com/s/1PDquK6RMChxVE-bsj7Pvkw 提取码:uxzr 单击此处下载
$ tar xvzf flexbuild_<version>.tgz
$ cd flexbuild_<verison>
$ source setup.env
$ flex-builder -h
flex-builder -m ls1028ardb
Tips:用户可以在 <flexbuild dir>/configs/build 中更改默认构建选项_lsdk.cfg公司启用/禁用某些生成功能。 例如,您可以通过按需设置CONFIG_app_<component_name>=y/n来启用/禁用某些应用程序组件。
标题How to generate LSDK composite firmware如何生成复合固件
前面介绍的自动编译方式生成的固件包含了所有必要的组件,比如:一个完整的固件包含RCW、U-Boot/UEFI、PHY固件、内核映像、dtb、initrd和NXP LSDK userland(包含指定的包和应用组件),也可以通过手工的方式自己来单独编译、打包所有固件。 LSDK composite firmware consists of RCW/PBL, ATF, Bootloader(U-Boot or UEFI), secure headers, Ethernet MAC/PHY firmware, dtb, kernel and tiny initrd RFS. The composite firmware can be programmed at offset 0x0 in flash device or at offset block# 8 in SD/eMMC card. 复合固件可以直接烧写在flash的0X00处,也可以烧写在SD/EMMC的block# 8处,也就是该固件包含了所有的引导功能,可以直接启动设备。
$ flex-builder -i mkfw -m <machine> -b <boottype> [-B <bootloader>] [-s]
-m <machine>:指的是开发板名称
-b boottype:指的是存储介质类型 SD XPSI QSPI NOR
-B bootloader:指的是BootLoader类型,支持ubooot和uefi
-i mkfw:flex-builder的编译固件命令
Examples:
$ flex-builder -i mkfw -m ls1028ardb -b sd
firmware_ls1028ardb_uboot_sdboot.img will be generated.
指定固件启动介质是SD卡
$ flex-builder -i mkfw -m lx2160ardb -b xspi -s
firmware_lx2160ardb_uboot_xspiboot_secure.img will be generated.
指定固件启动介质是XSPI
$ flex-builder -i mkfw -m ls1046ardb -b qspi -B uefi
firmware_ls1046ardb_uefi_qspiboot.img will be generated.
指定固件启动介质是QSPI
$ flex-builder -i mkfw -m ls2088ardb -b nor
firmware_ls2088ardb_uboot_norboot.img will be generated.
$ flex-builder -i mkfw -m ls2088ardb -b nor -s
firmware_ls2088ardb_uboot_norboot_secure.img will be generated for secure boot.
$ flex-builder -i mkfw -m lx2160ardb_rev2 -b xspi
firmware_lx2160ardb_rev2_uboot_xspiboot.img will be generated.
如何单独编译内核
configs/build_lsdk.cfg是内核编译配置文件 关于LS1028A是多少位的处理器:64位,单击查看
$ flex-builder -c linux -a arm64 (for all Layerscale arm64 platforms)
这里使用arm64编译
$ flex-builder -c linux -a arm32 (for arm32 platform, e.g. ls1021atwr)
tips:如果不想使用默认配置编译内核,可以使用如下命令指定内核版本和配置文件
Usage: flex-builder -c linux:<kernel-repo>:<branch|tag> [ -a arm64 -B fragment:<custom>.config ]
Example:
$ flex-builder -c linux:dash-lts:linux-5.4 -a arm64 -B fragment:lttng.config
$ flex-builder -c linux:linux:LSDK-20.04-V4.14 -a arm32
$ flex-builder -c linux:linux:LSDK-20.04-V5.4 -a arm64
用户自己可以添加特殊的配置文件,在以下路径创建一个配置文件test.config flexbuild/packages/linux/<kernel-repo>/arch/arm64/configs 使用以下命令编译 $ flex-builder -c linux -a arm64 -B fragment:test.config
裁剪内核
To build kernel with custom kernel options in interactive menu:
Step1: Use 'custom' option to customize kernel .config in interactive menu
$ flex-builder -c linux:custom -a arm64
先使用此命令通过图形交互界面生成定制的配置文件
Step2: Continue to build kernel with the customized .config generated in Step1
$ flex-builder -c linux -a arm64
重新编译内核
如何构建基于自定义内核和各种发行版的linux-itb
(u-boot推出了全新的image格式-----FIT uImage,就是itb)
你可以在<flexbuild_dir>/packages/linux/linux下面修改内核源码,也可以修改默认的内核源branch/tag,修改结束后编译内核即可 $ flex-builder -c linux -a arm64
Optionally, the prebuilt rootfs_<lsdk_version>_yocto_tiny_arm64.cpio.gz is used for generating itb image by default, 另外,预编译好的RootFS默认被用于编译itb镜像文件rootfs_<lsdk_version>_yocto_tiny_arm64.cpio.gz
你可以参考LSDK说明手册的 "How to build LSDK with Flexbuild"章节下的"How to build various userland with custom packages"来定制用户空间代码。
运行以下命令来生成linux-uboot-itb镜像文件
$ flex-builder -i mkitb -r <distro_type>:<distro_scale> -a <arch>
For example:
$ flex-builder -i mkitb -r yocto:tiny -a arm64
$ flex-builder -i mkitb -r yocto:devel -a arm32
$ flex-builder -i mkitb -r ubuntu:lite -a arm64
$ flex-builder -i mkitb -r ubuntu:main -a arm64 (使用这个)
运行以下命令在RAM中载入itb
=> tftp $load_addr <itb_img>
=> bootm $load_addr#<board_name>
如何生成LSDK的 启动分区压缩包 boot partition tarball
tips:引导分区包括kernel image, DTB, distro boot script, secure boot headers, tiny initrd等。flex builder会在您自己修改内核源或配置后,自动构建不存在的依赖映像,您可以运行以下命令来生成用于LSDK部署的bootpartition_LS_arm64_lts.tgz 压缩文件。
$ flex-builder -i mkbootpartition -a arm64 (for normal boot)(选这个)
or
$ flex-builder -i mkbootpartition -a arm32 (for normal boot)
or
$ flex-builder -i mkbootpartition -a arm64 -s (for secure boot)
or
$ flex-builder -i mkbootpartition -a arm32 -s (for secure boot)
or
$ flex-builder -i mkbootpartition -a arm64 -s -t (for secure boot with IMA-EVM)
or
$ flex-builder -i mkbootpartition -a arm32 -s -t (for secure boot with IMA-EVM)
如何构建应用组件
Usage: flex-builder -c <component-name> -a <arch>
Example:
$ flex-builder -c apps # build all arm64 apps components against Ubuntu-based main userland by default
$ flex-builder -c apps -r yocto:devel # build all arm64 apps components against Yocto-based devel userland
$ flex-builder -c edgescale # build EdgeScale client components for arm64 arch
$ flex-builder -c dpdk # build DPDK component for Layerscape platforms
$ flex-builder -c ovs_dpdk # build OVS-DPDK component
$ flex-builder -c pktgen_dpdk # build PKTGEN-DPDK component
$ flex-builder -c vpp # build VPP component
$ flex-builder -c fmc -a arm32 # build FMC component for arm32 arch
$ flex-builder -c fmc -a arm64 # build FMC component for arm64 arch
$ flex-builder -c restool # build RESTOOL component for arm64 arch,
$ flex-builder -c tsntool # build tsntool component
(arm64 is the default arch if -a <arch> is not specified)
如何添加自己的应用组件
Add new <component> to apps_repo_list and set CONFIG_BUILD_<component>=y in configs/build_xx.cfg.
Configure url/branch/tag/commit info for new <component_name>in configs/build_xx.cfg, default remote. Component git repository is specified by GIT_REPOSITORY_URL by default if <component>_url is not specified, user also can directly create the new component git repository in packages/apps directory.
Add build support of new component in packages/apps/Makefile..
Run flex-builder -c <component-name> -a <arch>' to build the new component.
Run flex-builder -i merge-component -a <arch> to merge the new component package into target distro userland.
如何用定制的内核替换目标板上的默认内核(前提是没有使用 secure boot )
Step1: Optionally, run 'flex-builder -i repo-fetch -B linux' to download linux source, then modify Linux kernel source code in <flexbuild_dir>/packages/linux/<kernel-repo>
Step2: Optionaly, customize kernel options in interactive menu by command "flex-builder -c linux:custom -a arm64"
Step3: Build new kernel by command "flex-builder -c linux -a arm64"
Step4: Generate new linux tarball by command "flex-builder -i mkbootpartition -a arm64"
The new kernel tarball <flexbuild-dir>/build/images/linux_5.4_LS_arm64_<timestamp>.tgz will be generated.
Step5: Login LSDK Linux system on target board and replace the existing kernel as below:
root@localhost:/# dhclient -i <port_name>
root@localhost:/# wget <webserver_path>/linux_5.4_LS_arm64_<timestamp>.tgz (or by scp command)
root@localhost:/# tar xfmv linux_5.4_LS_arm64_<timestamp>.tgz -C /
root@localhost:/# reboot
如何在本地修改NXP组件源代码后,部署新镜像
Step1: Clean the old apps images as below
$ flex-builder -i clean-apps -a arm64
$ make clean -C packages/apps/<component_name>
Step2: Modify component source code in directory packages/apps/<component-name> on demand
Step3: Build the component and generate the compressed app component tarball
$ flex_builder -c <component-name> -a arm64 (or run 'flex_builder -c apps' for building all components)
$ flex-builder -i packapps -a arm64
Step4: Login LSDK Linux system on target board, download app_components_LS_arm64.tgz and replace the existing app component as below
root@localhost:/# wget <webserver_path>/app_components_LS_arm64.tgz (or by scp command)
root@localhost:~# tar xfm app_components_LS_arm64.tgz -C /
root@localhost:~# reboot
How to add new app component in Flexbuild
Add a new CONFIG_APP_<component>=y and configure <component>_repo_url and <component>_repo_branch in configs/build_lsdk.cfg. Or, you can directly create the new component git repository in packages/apps/<category>/<component>.
Add make object in packages/apps/<category>/<category>.mk, this is applicable to component, which uses either Make build system or non Make build system (For example, cmake, meson, ninja).
Run flex-builder -c <component> -a <arch> to build new component.
Run flex-builder -i merge-component -a <arch> to merge new component package into distro userland.
Run flex-builder -i packrfs -a <arch> to pack the target distro userland for deployment.
Note: -r <distro_type>:<distro_scale> can be specified if needed, -r ubuntu:main, by default. In case you just need to integrate a few simple source files which are not in a git repository, you can put them under packages/apps/generic directory and add make object in packages/apps/generic/generic.mk.
LSDK CentOS-based Userland (optional)
The LSDK CentOS-based userland consists of CentOS packages and some NXP’s packages, which can be generated by the following steps:
a. Optionally, clean obsolete image build/rfs/rootfs_lsdk2004_centos_7.7.1908_arm64 $ flex-builder -i clean-rfs -r centos
b. Run the following commands to build target CentOS userland $ flex-builder -i mkrfs -r centos -a arm64 (generate rootfs_lsdk2004_centos_7.7.1908_arm64 target userland) $ flex-builder -i mkbootpartition -a arm64 (generate bootpartition_LS_arm64_lts_5.4.tgz) $ flex-builder -i merge-component -r centos (merge app components to CentOS userland) $ flex-builder -i packrfs -r centos -a arm64 (pack userland as rootfs_lsdk2004_centos_7.7.1908_arm64.tgz,~970M)
c. Plug an SD card or USB/SATA disk onto your host machine or ARM reference board, then install target userland as below: $ flex-installer -b bootpartition_LS_arm64_lts_5.4.tgz -r rootfs_lsdk2004_centos_7.7.1908_arm64.tgz -d /dev/sdx