1、开发环境为ubuntu 18.04-03桌面版。
交叉编译工具下载地址:
wget -c https://releases.linaro.org/components/toolchain/binaries/latest-7/aarch64-linux-gnu/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu.tar.xz -t 0 -T 120
wget -c https://releases.linaro.org/components/toolchain/binaries/latest-7/aarch64-linux-gnu/runtime-gcc-linaro-7.4.1-2019.02-aarch64-linux-gnu.tar.xz -t 0 -T 120
wget -c https://releases.linaro.org/components/toolchain/binaries/latest-7/aarch64-linux-gnu/sysroot-glibc-linaro-2.25-2019.02-aarch64-linux-gnu.tar.xz -t 0 -T 120
如果linux机器在子网中,需要HTTP proxy访问外网, 设置环境变量http_proxy和https_proxy如下:
1. set proxy in /etc/profile.d/proxy.sh or ~/.bashrc, example:
export http_proxy="http://<account>:<password>@<domain>:<port>"
export https_proxy="http://<account>:<password>@<domain>:<port>"
export no_proxy="localhost"
2. set proxy in /etc/apt/apt.conf
Acquire::http::Proxy "http://<account>:<password>@<domain>:<port>";
Acquire::https::Proxy "http://<account>:<password>@<domain>:<port>";
3. set proxy in /etc/wgetrc
http_proxy = http://<account>:<password>@<domain>:<port>
https_proxy = http://<account>:<password>@<domain>:<port>
Download and deploy LSDK images with flex-installer
1.1 下载flex-install来部署LSDK镜像:
wget -c https://www.nxp.com/lgfiles/sdk/lsdk1906/flex-installer && chmod +x flex-installer && sudo mv flex-installer /usr/bin -t 0 -T 120
1.2 自动下载远程LSDK发布版并部署在HOST主机上的目标存储驱动或者Arm板上。
使用方法:
$ flex-installer -i auto -m <machine> -d <device> [-e <dtb|acpi> -f <firmware> -b <bootpartition> -r <rootfs> -R <rootfs2> -u <url>]
The <machine> can be: ls1012ardb, ls1012afrwy, ls1021atwr, ls1028ardb, ls1043ardb, ls1046ardb, ls1046afrwy,ls1088ardb_pb, ls2088ardb, lx2160ardb.
举例:
$ flex-installer -i auto -m ls1043ardb -d /dev/mmcblk0 (deploy default
rootfs_lsdk1906_LS_arm64_main.tgz and bootpartition_LS_arm64_lts_4.19.tgz)
$ flex-installer -i auto -m ls1046ardb -d /dev/sdx -b bootpartition_LS_arm64_lts_4.14.tgz
(specify version bootpartition_LS_arm64_lts_4.14.tgz)
$ flex-installer -i auto -m ls1088ardb -d /dev/sdx -r rootfs_lsdk1906_LS_arm64_edgescale.tgz
(specify RFS for Edgescale instead of the default main)
$ flex-installer -i auto -m ls2088ardb -d /dev/sdx -e dtb ('-e dtb' option is used for UEFI in DTB way, no need for U-Boot case)
1.3 采用flex-builder编译LSDK
1.3.1 Build TF-A with RCW and U-Boot/UEFI in Flexbuild
用法:
Usage:
$ flex-builder -c atf -m <machine> -b <boottype> [-s]
Example:
$ flex-builder -c atf -m ls1043ardb -b sd
# build uboot-based ATF image for SD boot on ls1043ardb
$ flex-builder -c atf -m ls1046ardb -b qspi -s
# build uboot-based ATF image for QSPI-NOR secure boot on ls1046ardb
$ flex-builder -c atf -m lx2160ardb -b xspi
# build uboot-based ATF image for FlexSPI-NOR boot on lx2160ardb
$ flex-builder -c atf -m ls2088ardb -b nor -B uefi
# build uefi-based ATF image for IFC-NOR boot on ls2088ardb
如果想使用不同的RCW代替默认的RCW,可以在<flexbuild>/configs/board/<machine>/manifest中重新配置rcw_<boottype>变量,然后运行flex-builder -c atf -m <machine> -b <boottype>来生成使用特定RCW的新的ATF镜像,如果修改U-Boot, RCW or ATF源码, "flex-builder -c atf " 命令可以自动重新编译相关的U-Boot, RCW and ATF源码。
NOTE
The '-s' option is used for secure boot, OPTEE and FUSE_PROVISIONING are not enabled by default, change CONFIG_BUILD_OPTEE=n to y and/or change CONFIG_FUSE_PROVISIONING=n to y in configs/build_lsdk.cfg to enable it if necessary.
1.3.2 采用flex-builder编译内核
1.3.2.1 使用configs/build_lsdk.cfg中明确的tree/branch/tag来编译内核
$ flex-builder -c linux #针对64-bit mode of ARMv8
$ flex-builder -c linux -a arm32 # for 32-bit mode of ARMv7
1.3.2.2 使用特定的tree/branch/tag和额外的fragment config来编译内核
用法:
$ flex-builder -c linux:<kernel-repo>:<branch|tag> -a arm64 -B fragment:<custom>.config
举例:
$ flex-builder -c linux:dash-lts:linux-4.19 -a arm64 -B fragment:lttng.config
$ flex-builder -c linux:linux:LSDK-19.06-V4.14 -a arm32
$ flex-builder -c linux:linux:LSDK-19.06-V4.19 -a arm64
1.3.2.3 编译LSDK混合固件和boot分区
用法:
$ flex-builder -i mkfw -m <machine> -b <boottype> [-B <bootloader>] [-s]
举例:
$ flex-builder -i mkfw -m ls1043ardb -b sd
firmware_ls1043ardb_uboot_sdboot.img will be generated.
$ flex-builder -i mkfw -m lx2160ardb -b xspi -s
firmware_lx2160ardb_uboot_xspiboot_secure.img will be generated.
$ flex-builder -i mkfw -m ls1046ardb -b qspi -B uefi
firmware_ls1046ardb_uefi_qspiboot.img will be generated.
$ 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.
1.3.2.4 生成LSDK boot分区压缩包,运行如下命令:
$ flex-builder -i mkbootpartition -a arm64
$ flex-builder -i mkbootpartition -a arm32
or
$ flex-builder -i mkbootpartition -a arm64 -s (for secure boot)
$ flex-builder -i mkbootpartition -a arm32 -s (for secure boot)
1.3.3采用Flexbuild编译应用组件
用法:
$ flex-builder -c <component> -a <arch> # build single application component for specified <arch>
举例:
$ flex-builder -c apps # build all arm64 apps components against Ubuntu-based userland by default
$ flex-builder -c edgescale # build EdgeScale client components for arm64 arch
$ flex-builder -c dpdk # build DPDK component for SoCs integrated DPAA1 or DPAA2
$ flex-builder -c ovs-dpdk # build OVS-DPDK 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 ptpd # build ptpd component for IEEE 1588 on arm64 platform
$ flex-builder -c cst # build cst component, needed for secure boot
(arm64 is the default arch if -a <arch> is not specified)
>>>>>>>>>>>>>>>>>>>>>>下面的步骤来在Flexbuild中增加新的应用组件>>>>>>>>>>>>>>>>>>>
Step 1. Add new <component> to apps_repo_list and set CONFIG_BUILD_<component>=y in configs/build_xx.cfg.
Step 2. 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.
Step 3. Add build support of new component in packages/apps/Makefile.
Step 4. Run flex-builder -c <component-name> -a <arch>' to build the new component.
Step 5. Run flex-builder -i merge-component -a <arch> to merge the new component package into target distro userland.
在flexbuild中基于LSDK发布版本添加新的定制机器
假如: Adding a new custom machine named LS1043AXX based on LS1043A SoC
1. Run flex-builder -i repo-fetch to fetch all git repositories of LSDK components for the first time
$ flex-builder -i repo-fetch
2. Add new machine support in U-Boot and ATF, example:
$ cd packages/firmware/u-boot
$ git checkout LSDK-19.06 -b LSDK-19.06-LS1043AXX
Add necessary U-Boot patches in U-boot tree and commit the patches in this branch for new machine. Add necessary ATF patches in ATF tree and commit the patches in this branch for new machine. Assume that you have added packages/firmware/u-boot/configs/ls1043axx_tfa_defconfig and added CONFIG_MACHINE_LS1043AXX=y in configs/build_lsdk.cfg, then run commands below to build TF-A image based on U-Boot for SD boot on LS1043AXX
$ cd packages/firmware/atf
$ git checkout LSDK-19.06 -b LSDK-19.06-LS1043AXX
$ flex-builder -c atf -m ls1043axx -b sd
3. Add new machine support in Linux kernel, take LSDK-19.06 for example:
$ cd packages/linux/linux
$ git checkout LSDK-19.06-V4.19 -b LSDK-19.06-V4.19-LS1043AXX
Now, you can add kernel patches and submit the patches in this branch for the new machine, then make a tag as below.
$ git tag LSDK-19.06-V4.19-LS1043AXX
Assume that you have added a new ls1043axx.dts in packages/linux/linux/arch/arm64/boot/dts directory, run as below to build kernel image for new LS1043AXX
$ flex-builder -c linux:linux:LSDK-19.06-V4.19-LS1043AXX
4. Add configs in flexbuild for new machine.
a. Add ls1043axx node in configs/linux/linux_arm64_LS.its.
b. Add CONFIG_MACHINE_LS1043AXX=y in configs/build_lsdk.cfg.
c. Set linux_repo_tag to LSDK-19.06-V4.19-LS1043AXX and set u_boot_repo_tag to LSDK-19.06-LS1043AXX in configs/build_lsdk.cfg.
d. Set BUILD_DUAL_KERNEL to n in configs/build_lsdk.cfg if user doesn't need the second version of linux.
e. Optionally, user can use different memory layout from default settings by modifying them in configs/board/common/memorylayout.cfg.
f. Add manifest for new machine as below
$ mkdir configs/board/ls1043axx
$ cp configs/board/ls1043ardb/manifest configs/board/ls1043axx.
g. Update the settings in configs/board/ls1043axx/manifest on demand.
h. Generally, user can reuse the settings of rcw/fman/qe/eth-phy used for existing ls1043ardb if those components are same for new ls1043axx, otherwise user needs to add new support in packages/firmware/rcw.
i. Run flex-builder -i mklinux -a arm64 to generate lsdk_linux_arm64_tiny.itb image.
j. Run flex-builder -i mkfw -m ls1043ardb -b sd to generate the shared ppa/rcw/fman/qe/eth-phy images for new ls1043axx.
k. Run flex-builder -i mkfw -m ls1043axx -b sd to generate firmware_ls1043axx_uboot_sdboot.img.
l. User can boot the new lsdk_linux_arm64_tiny.itb from U-Boot prompt duringdebugging stage on LS1043AXX machine.
=> tftp a0000000 lsdk_linux_arm64_tiny.itb
=> bootm a0000000#ls1043axx
5. Build all other images for new custom machine with LSDK userland if required as below:
$ flex-builder -i mkrfs -a arm64
$ flex-builder -c apps -a arm64
$ flex-builder -i mkbootpartition -a arm64
$ flex-builder -i merge-component -a arm64
$ flex-builder -i packrfs -a arm64
Finally, install bootpartition_arm64_lts_<version>.tgz and rootfs_lsdk_<version>_LS_arm64.tgz to SD/USB/SATA storage drive on LS1043AXX machine by flex-installer as below:
$ flex-installer -b bootpartition_LS_arm64_<version>.tgz -r build/rfs/
rootfs_lsdk_<version>_LS_arm64 -d /dev/sdx
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
2、Linux Kernel介绍
应用场景:
PC、服务器、手持设备和不同嵌入式设备比如路由器、交换机、无线访问点、智能电视,DVR及NAS应用领域。
The software is officially released on http://www.kernel.org website through downloadable packages and GIT repositories. A general Linux kernel introduction from kernel.org can also be found at
https://www.kernel.org/doc/html/latest/admin-guide/README.html.
2.1 Kernel Releases and relationship with Layerscape SDK
下面列出与LSDK关联的Linux kernel发行版。
1、Kernel.org official kernel releases
• Mainline
主线树由Linus Torvalds.维护。主线内核每2-3个月发布一次。
• Longterm (LTS)
There are usually several "longterm maintenance" kernel releases provided for the purposes of backporting bugfixes for older kernel trees. Only important bugfixes are applied to such kernels and they don't usually see very frequent releases, especially for older trees.
Refer to https://www.kernel.org/category/releases.html for the current maintained Longterm releases.
2、Linaro LSK kernel release(LSK)
Linaro is an open organization focused on improving Linux on ARM.
They are also providing a Linux kernel release called Linaro Stable Kernel (LSK). It is based on kernel.org Longterm kernel releases and included ARM related features developed by Linaro.
Normally these features are generic kernel features for the ARM architecture. Please refer to https://wiki.linaro.org/LSK for more information about the LSK releases.
3、NXP Layerscape SDK kernel (LSDK)
NXP’s SDK kernel often contains patches that are not upstream yet so essentially the LSDK kernel is an enhanced Linaro LSK which is in turn an enhanced kernel.org LTS. In order to fully utilize the ARM open source eco-system. The kernel versions provided in NXP LSDK will be chosen from the kernel.org Longterm releases to include the important bugfixes backported. It will also include generic ARM kernel features provided by the Linaro LSK release which could be important for some users.
显然,我们采用LSDK是最合适的!!!
2.2 获取LSDK内核源码
源码分支和tag:
sudo apt-get install git
git clone https://source.codeaurora.org/external/qoriq/qoriq-components/linux
cd linux
git branch
git checkout -b linux-4.19 origin/linux-4.19