LS1043ARDB开发板kernel编译过程

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应用领域。


image.png

image.png

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:
image.png
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
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,937评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,503评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,712评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,668评论 1 276
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,677评论 5 366
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,601评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,975评论 3 396
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,637评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,881评论 1 298
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,621评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,710评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,387评论 4 319
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,971评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,947评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,189评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 44,805评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,449评论 2 342

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,279评论 0 10
  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 9,357评论 0 23
  • mean to add the formatted="false" attribute?.[ 46% 47325/...
    ProZoom阅读 2,689评论 0 3
  • 文/沈拙言 虽已不做财会多年, 仍旧一心想要赚钱! 绞尽脑汁询门路, 莫怵,莫怵, 早日去做富人家属!
    沈_拙言阅读 210评论 0 0
  • 少承诺,多做事: 看着我上次总结时,写的打印时间安排表,没有做。过去的20天浑浑噩噩,晚睡早起变成了晚睡晚起,断舍...
    晴空00阅读 306评论 0 0