编译

内核可以从以下链接得到:

http://git.phytec.de/

https://stash.phytec.com/

首先用git clone将代码下载到本地(以下以i.MX6为例):

git clone git://git.phytec.de/linux-mainline

然后根据下面的表:

Oops, it seems that you need to place a table or a macro generating a table within the Table Filter macro.

The table is being loaded. Please wait for a bit ...

平台BSP下载最新的meta-phytec tagyoctokernelBootloaderQT
AM65xALPHA4
  •  

3.1 Dunfelllinux-phytec-ti BSP-Yocto-TISDK-AM65xx-ALPHA4uboot-phytec BSP-Yocto-TISDK-AM65xx-ALPHA4
AM57xPD18.1.0
  •  
BSP-Yocto-TISDK-AM57xx-PD18.1.02.2 Mortylinux-phytec-ti v4.9.41-phy1uboot-phytec v2017.01-phy15.7
AM57xPD18.2.0
  •  
BSP-Yocto-TISDK-AM57xx-PD18.2.02.2 Mortylinux-phytec-ti v4.9.41-phy4uboot-phytec v2017.01-phy45.7
AM57xPD19.1.1
  •  
BSP-Yocto-TISDK-AM57xx-PD19.1.12.6 Thudlinux-phytec-ti BSP-Yocto-TISDK-AM57xx-PD19.1.1uboot-phytec BSP-Yocto-TISDK-AM57xx-PD19.1.1
AM57xPD20.1.2
  •  
BSP-Yocto-TISDK-AM57xx-PD20.1.22.6 Thudlinux-phytec-ti BSP-Yocto-TISDK-AM57xx-PD20.1.2uboot-phytec BSP-Yocto-TISDK-AM57xx-PD20.1.25.11
AM335xPD16.2.0
  •  
2.1.2-phy12.1 Krogothlinux-ti v4.4.19-phy2barebox v2016.07.0-phy35.6
AM335xPD17.1.3
  •  
2.2.4-phy42.2 Mortylinux-ti v4.4.141-phy2barebox v2017.06.1-phy45.7
AM335xPD17.2.0
  •  
2.3.2-phy22.3 Pyrolinux-mainline v4.9.47-phy2
5.8
AM335xPD17.2.1
  •  
2.3.3-phy12.3 Pyrolinux-mainline v4.9.47-phy2barebox v2017.10.0-phy25.8
AM335xPD17.2.2
  •  
2.3.3-phy22.3 Pyrolinux-mainline v4.9.98-phy1barebox v2017.10.0-phy35.8
AM335xPD19.1.0
  •  
2.5.2-phy22.5 Sumolinux-mainline v4.14.78-phy4barebox v2018.11.0-phy25.10
AM335xPD19.1.1
  •  
2.5.3-phy72.5 Sumolinux-mainline v4.14.78-phy6barebox v2018.11.0-phy35.10
i.MX6

Mira HTML5 v1.0

  •  
2.2.1-phy1
linux-mainline v4.1.36-phy3barebox v2016.11.0-phy4
i.MX6PD15.3.0
  •  
1.8.1-phy61.8 Fidolinux-mainline v4.1.18-phy4barebox v2015.11.0-phy4
i.MX6PD15.3.1
  •  
1.8.1-phy6-fix11.8 Fidolinux-mainline v4.1.18-phy5barebox v2015.11.0-phy4
i.MX6PD16.1.0
  •  
2.1.2-phy42.1 Krogothlinux-mainline v4.1.36-phy3barebox v2016.11.0-phy75.6
i.MX6PD16.1.1
  •  
2.1.3-phy52.1 Krogothlinux-mainline v4.1.46-phy2barebox v2016.11.0-phy75.6
i.MX6PD16.1.2
  •  
2.1.3-phy82.1 Krogothlinux-mainline v4.1.46-phy4barebox v2016.11.0-phy85.6
i.MX6PD18.1.0
  •  
2.4.3-phy42.4 Rockolinux-mainline v4.14.39-phy4barebox v2017.12.0-phy35.9
i.MX6PD18.1.1
  •  
2.4.4-phy22.4 Rockolinux-mainline v4.14.78-phy2barebox v2017.12.0-phy35.9
i.MX6PD18.1.2
  •  
2.4.4-phy62.4 Rockolinux-mainline v4.14.134-phy2barebox v2017.12.0-phy65.9
i.MX6PD20.1.0
  •  
2.7.4-phy22.7 Warriorlinux-mainline v4.19.100-phy3barebox v2019.11.0-phy25.12
i.MX6PD21.1.0
  •  
3.3.3-phy23.3 Hardknottlinux-mainline v5.10.48-phy2barebox v2021.04.0-phy45.15
i.MX6ulPD17.2.0
  •  
2.2.2-phy52.2 Mortylinux-mainline v4.12.4-phy4barebox v2017.04.0-phy35.7
i.MX6ulPD17.1.2
  •  
2.2.2-phy32.2 Morty

linux-imx v4.1.15-phy3

barebox v2017.04.0-phy35.7
i.MX6ulPD19.1.0
  •  
2.5.3-phy62.5 Sumo

linux-mainline v4.14.93-phy3

barebox v2019.01.0-phy35.10
i.MX6ulPD19.1.1
  •  
2.5.3-phy162.5 Sumolinux-mainline v4.14.184-phy1barebox v2019.01.0-phy75.10
i.MX6ulPD19.1.2
  •  
2.5.3-phy192.5 Sumolinux-mainline v4.14.213-phy1barebox v2019.01.0-phy95.10
i.MX6ulPD21.1.0
  •  
3.1.5-phy13.1 Dunfelllinux-mainline v5.4.91-phy1barebox v2020.09.0-phy35.14
i.MX6ulPD22.1.1
  •  
BSP-Yocto-Ampliphy-i.MX6UL-PD22.1.14.0 Kirkstonelinux-mainline v5.15.102-phy1barebox v2022.02.0-phy15.15
i.MX7PD18.1.1
  •  
v2.2.3-phy3
linux-phytec-fsl v4.9.11

i.MX7PD18.2.0
  •  
v2.2.3-phy52.2 Mortylinux-phytec-fsl v4.9.11-phy3u-boot v2017.03-phy25.8
i.MX7PD19.1.0
  •  
v2.5-phy22.6 Thudlinux-phytec-fsl v4.14.78u-boot v2018.03
i.MX8MPD19.1.0
  •  
2.5.3-phy122.5 Sumolinux-imx v4.14.98-phy4u-boot-imx v2018.03-phy45.10
i.MX8MMPD20.1.0
  •  
2.7.1-phy22.7 Warriorlinux-imx v4.19.35_1.1.0-phy4u-boot-imx v2019.04_1.1.0-phy55.12
i.MX8MMPD22.1.1
  •  
BSP-Yocto-NXP-i.MX8MM-PD22.1.13.3 Hardknottlinux-imx v5.10.72_2.2.0-phy17u-boot-imx v2021.04_2.2.0-phy135.15
i.MX8MPALPHA2
  •  

3.0 Zeuslinux-imx v5.4.70_2.3.0-phy5u-boot-imx v2020.04_2.3.0-phy3
i.MX8MPPD21.1.0
  •  
3.0.4-phy123.0 Zeuslinux-imx v5.4.70_2.3.2-phy3u-boot-imx v2020.04_2.3.2-phy35.15
i.MX8MPPD21.1.1
  •  
v3.0.4-phy153.0 Zeuslinux-imx v5.4.70_2.3.2-phy5u-boot-imx v2020.04_2.3.2-phy35.15
i.MX8MPPD21.1.3
  •  
BSP-Yocto-FSL-i.MX8MP-PD21.1.33.0 Zeuslinux-imx v5.4.70_2.3.2-phy12u-boot-imx v2020.04_2.3.2-phy105.15
i.MX8MPPD22.1.0
  •  
BSP-Yocto-NXP-i.MX8MP-PD22.1.03.3 
Hardknott
linux-imx v5.10.72_2.2.0-phy9u-boot-imx v2021.04_2.2.0-phy75.15
i.MX8MPPD22.1.1
  •  
BSP-Yocto-NXP-i.MX8MP-PD22.1.13.3 Hardknottlinux-imx v5.10.72_2.2.0-phy17u-boot-imx v2021.04_2.2.0-phy135.15
STM32MP1PD20.1.0
  •  
2.6.3-phy42.6 Thudlinux-stm32mp v4.19.94u-boot v2018.115.11
RK3288PD17.1.1
  •  
2.2.1-phy32.2 Mortylinux-mainline v4.9.18-phy1

barebox v2016.07.0-phy5

u-boot-spl v2016.01-phy3

5.7
RK3288PD17.1.3
  •  
2.2.4-phy62.2 Mortylinux-mainline v4.9.98-phy2

barebox v2016.07.0-phy5

u-boot-spl v2016.01-phy3

5.7
RK3288PD-ALPHA2
  •  
2.1.1-phy12.1 Krogothlinux-mainline v4.4.16-phy2

barebox v2016.07.0-phy2

u-boot-spl v2016.01-phy2


checkout到对应的版本(Tag)上:

cd linux-mainline
git checkout v4.1.46-phy4

接下来就可以编译,在编译前,需要

  1. 编译SDK(也可以下载,在我们下载服务器的BSP文件夹中的SDK文件夹中)
  2. 安装SDK

 以上两个都可以在:怎样用yocto生成SDK,以及SDK使用方法 中找到。

接下来source SDK的环境:

. (path to sdk)/environment-setup-cortexa9hf-neon-phytec-linux-gnueabi

此时需要export一个变量,这样告诉后边各种操作是针对arm平台的。

armarm64
export ARCH=arm
export ARCH=arm64

然后准备.config文件,config文件位于内核代码的 arch/arm/configs/

你可以在yocto目录的 sources/meta-phytec/conf/machine/include 中查找

Kernelconfig
phyCORE i.MX6 linux-mainline

imx_v6_v7_defconfig

imx6_phytec_distro.config(PD20+) +

imx6_phytec_machine.config(PD20+) +

imx6_phytec_platform.config(PD20+)

phyCORE i.MX6ul linux-mainline

imx_v6_v7_defconfig

arch/arm/configs/imx_v6_v7_defconfig(PD21+) +

arch/arm/configs/imx6_phytec_*(PD21+)

phyCORE i.MX6ul linux-imximx_v7_defconfig
phyCORE AM335x linux-tiam335x_phytec_defconfig
phyCORE AM335x linux-mainlineam335x_phytec_defconfig
phyCORE i.MX6 Android linux-imxandroid_miraq_defconfig
phyCORE RK3288 linux-mainlinerk3288_phytec_defconfig
phyCORE AM572x linux-phytec-tiam572x_phycore_rdk_defconfig or am57xx_phycore_kit_defconfig
phyCORE i.MX7 linux-phytec-fslimx7_phyboard_zeta_defconfig
phyCORE i.MX8M linux-imx

arch/arm64/configs/defconfig

phyCORE i.MX8MM linux-imx

defconfig

imx8_phytec_distro.config

imx8_phytec_platform.config

phyCORE i.MX8MP linux-imx

defconfig

imx8_phytec_distro.config

imx8_phytec_platform.config

phyCORE AM65xx linux-phytec-tiam65xx_phycore_kit_defconfig

然后

单defconfig的平台config+conf的平台
make imx_v6_v7_defconfig


./scripts/kconfig/merge_config.sh -m arch/arm64/configs/defconfig arch/arm64/configs/imx8_phytec_platform.config arch/arm64/configs/imx8_phytec_distro.config

或者从yocto的deploy中复制zImage.config到源码覆盖.config来使用(不推荐)。

如果需要配置内核的menuconfig,需要注意的是,这个不能在有sdk环境的shell中执行,否则会报ncurses lib的错误。下面这个指令执行前需要export ARCH=arm。

make menuconfig

然后编译内核:

armarm64
make zImage -j?
make Image -j?

j后面的参数是编译使用的线程数,一般为PC的CPU最大线程数。

编译设备树:

dts位于arch/arm(64)/boot/dts/dts位于arch/arm(64)/boot/dts/freescale
make xxxx.dtb
make freescale/xxxx.dtb

然后

make menuconfig

设备树的名称:

你可以在yocto目录的 sources/meta-phytec/conf/machine 中查找对应的machine名称来查找。

machinedts
phycore-am335x-1am335x-phycore-rdk.dtb
phycore-r2-am335x-1am335x-phycore-nand-eeprom-rtc-spi-tmp.dtb
phyboard-wega-am335x-1am335x-wega-rdk.dtb
phyflex-imx6-1/2imx6q-phytec-pbab01.dtb
phyflex-imx6-6imx6dl-phytec-pbab01.dtb
phyboard-mira-imx6-3

imx6q-phytec-mira-ff-rdk-nand.dtb(PD18+)

imx6q-phytec-mira-rdk-nand.dtb(PD16)

phyboard-mira-imx6-4/6

imx6dl-phytec-mira-rdk-nand.dtb(PD16)

phyboard-mira-imx6-5/7imx6q-phytec-mira-rdk-emmc.dtb(PD16)
phyboard-mira-imx6-15imx6dl-phytec-mira-ff-rdk-nand.dtb(PD18+)
phycore androidimx6q-phytec-mira-rdk-nand.dtb
phyCORE RK3288 linuxrk3288-phycore-rdk.dtb
phyboard-segin-imx6ul-2

imx6ul-phytec-phyboard-segin-ff-rdk.dtb(PD17)

imx6ul-phytec-segin-ff-rdk-nand.dtb(PD19+)

phyboard-mira-imx6-13imx6q-phytec-mira-rdk-nand.dtb
phyboard-segin-imx6ul-7imx6ull-phytec-segin-ff-rdk-emmc.dtb
imx7d-phyboard-zeta-001imx7d-phyboard-zeta-001.dtb
phyboard-polaris-imx8m-3

freescale/phytec-imx8mq-phyboard-polaris-rdk-emmc.dtb

freescale/phytec-imx8mq-phyboard-polaris-rdk-emmc-sterling.dtb

(设备树目录:arch/arm64/boot/dts/)

phyboard-polis-imx8mm-3freescale/imx8mm-phyboard-polis-rdk.dtb
phycore-stm32mp1-3

A7:phycore-stm32mp1-3-a7-examples.dtb

M4:phycore-stm32mp1-3-m4-examples.dtb

am65x

k3-am65xx-phycore-kit.dtb

k3-am65xx-phytec-lcd-018.dtso

phyboard-pollux-imx8mp-3

imx8mp-phyboard-pollux-rdk.dtb


defconfig的操作方法

当.config文件有修改后

make savedefconfig

保存当前config为defconfig,然后复制该文件覆盖原文件,如在imx6下

cp defconfig arch/arm/configs/imx_v6_v7_defconfig

此时就可以用git diff看到和之前所做的更改。


编译错误时的解决

问题解决
一般问题

make mrproper

然后再重新编译。

另外用git status检查文件是否有修改。

在编译设备树时,头文件找不到。

fatal error: dt-bindings/gpio/gpio.h: No such file or directory
 #include <dt-bindings/gpio/gpio.h>
          ^~~~~~~~~~~~~~~~~~~~~~~~~

新版本内核,检查下面目录中的链接文件是否正常,不正常删掉后git reset --hard

 % ls -alh scripts/dtc/include-prefixes
total 8.0K
drwxrwxr-x 2 bob bob 4.0K 9月  24 18:53 .
drwxrwxr-x 4 bob bob 4.0K 9月  24 18:47 ..
lrwxrwxrwx 1 bob bob   26 9月  24 18:53 arc -> ../../../arch/arc/boot/dts
lrwxrwxrwx 1 bob bob   26 9月  24 18:53 arm -> ../../../arch/arm/boot/dts
lrwxrwxrwx 1 bob bob   28 9月  24 18:53 arm64 -> ../../../arch/arm64/boot/dts
lrwxrwxrwx 1 bob bob   26 9月  24 18:53 c6x -> ../../../arch/c6x/boot/dts
lrwxrwxrwx 1 bob bob   27 9月  24 18:53 cris -> ../../../arch/cris/boot/dts
lrwxrwxrwx 1 bob bob   28 9月  24 18:53 dt-bindings -> ../../../include/dt-bindings
lrwxrwxrwx 1 bob bob   28 9月  24 18:53 h8300 -> ../../../arch/h8300/boot/dts
lrwxrwxrwx 1 bob bob   28 9月  24 18:53 metag -> ../../../arch/metag/boot/dts
lrwxrwxrwx 1 bob bob   33 9月  24 18:53 microblaze -> ../../../arch/microblaze/boot/dts
lrwxrwxrwx 1 bob bob   27 9月  24 18:53 mips -> ../../../arch/mips/boot/dts
lrwxrwxrwx 1 bob bob   28 9月  24 18:53 nios2 -> ../../../arch/nios2/boot/dts
lrwxrwxrwx 1 bob bob   31 9月  24 18:53 openrisc -> ../../../arch/openrisc/boot/dts
lrwxrwxrwx 1 bob bob   30 9月  24 18:53 powerpc -> ../../../arch/powerpc/boot/dts
lrwxrwxrwx 1 bob bob   25 9月  24 18:53 sh -> ../../../arch/sh/boot/dts
lrwxrwxrwx 1 bob bob   29 9月  24 18:53 xtensa -> ../../../arch/xtensa/boot/dts

旧版本内核,同上,只是文件位置不同。

 % ls ~/kernel/linux-mainline/arch/arm/boot/dts/include/ -l
total 0
lrwxrwxrwx 1 nzhang nzhang 34 10月 19  2018 dt-bindings -> ../../../../../include/dt-bindings
  • No labels