不使用yocto搭建 i.MX8QXP Linux 4.14.98_ga 板级开发包编译环境,单步编译

独立编译
1. 编译 SCfirmware
打开一个终端:
pwd
~/imx-yocto-bsp
mkdir standalone
cd standalone
tar -xzvf imx-scfw-porting-kit-1.2.tar.gz (untar scfw tools kit)
|->packages

| |-> imx-scfw-porting-kit-1.2.bin
chmod a+x ./ imx-scfw-porting-kit-1.2.bin
sh ./ imx-scfw-porting-kit-1.2.bin (run the bin file to install scfw tools kit)
cd imx-scfw-porting-kit-1.2/src
tar xzvf scfw_export_mx8qm_b0.tar.gz
tar xzvf scfw_export_mx8qx_b0.tar.gz (untar source codes)
从以下地址 下载编译工具链:

https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads (E.g. Linux 64-bit File:

gcc-arm-none-eabi-6-2017-q2-update-linux.tar.bz2 (95.90 MB) )
注意最新验证过的工具链版本是 2017-q2,不建议使用最新的工具链。
pwd
~/imx-scfw-porting-kit-1.2
mkdir toolchain
mv gcc-arm-none-eabi-6-2017-q2-update-linux.tar.bz2 toolchain/
cd toolchain
tar jxvf gcc-arm-none-eabi-6-2017-q2-update-linux.tar.bz2
pwd
~/imx-scfw-porting-kit-1.2/src/scfw_export_mx8qx_b0
export TOOLS= ../.. /toolchain/
make qx B=mek R=B0 (如果需要看串口调试信息就增加 M=1 参数,U=2 表示使用 SCU 本身串口,注意重新
编译之前要 make clean-qx 一下)
编译结束打印为:

make qx B=mek R=B0 M=1 U=2
Generating platform/board/mx8qx_mek/dcd/imx8qx_dcd_1.2GHz.h
Generating platform/board/mx8qx_mek/dcd/dcd.h from platform/board/mx8qx_mek/dcd/imx8qx_dcd_1.2GHz.h
Generating platform/board/mx8qx_mek/dcd/imx8qx_dcd_1.2GHz_retention.h
Generating platform/board/mx8qx_mek/dcd/dcd_retention.h from
platform/board/mx8qx_mek/dcd/imx8qx_dcd_1.2GHz_retention.h
Compiling platform/drivers/pmic/fsl_pmic.c
Compiling platform/drivers/pmic/pf8100/fsl_pf8100.c
Compiling platform/drivers/pmic/pf100/fsl_pf100.c
Compiling platform/board/mx8qx_mek/board.c
Compiling platform/board/board_common.c
Compiling platform/board/pmic.c
Linking build_mx8qx_b0/scfw_tcm.elf ....
Objcopy build_mx8qx_b0/scfw_tcm.bin ....
done.
2. 编译 uboot:
另打开一个终端
pwd
~/imx-yocto-bsp/standalone
git clone https://source.codeaurora.org/external/imx/uboot-imx
cd uboot-imx
git tag | grep rel_imx_4.14.
....
rel_imx_4.14.98_2.0.0_ga
...
git checkout rel_imx_4.14.98_2.0.0_ga
git status
HEAD detached at rel_imx_4.14.98_2.0.0_ga
nothing to commit, working directory clean
ls configs | grep imx8qxp
…
imx8qxp_mek_defconfig
…
source ~ /imx-yocto-bsp/imx8qxpmek_xwayland/sdk/environment-setup-aarch64-poky-linux
make imx8qxp_mek_defconfig
make
编译 log 如下:

…
LDS u-boot.lds
LD u-boot
OBJCOPY u-boot.srec
OBJCOPY u-boot-nodtb.bin
start=$(aarch64-poky-linux-nm u-boot | grep __rel_dyn_start | cut -f 1 -d ' '); end=$(aarch64-poky-linux-nm u-boot |
grep __rel_dyn_end | cut -f 1 -d ' '); tools/relocate-rela u-boot-nodtb.bin 0x80020000 $start $end
DTC arch/arm/dts/fsl-imx8dx-17x17-val.dtb
DTC arch/arm/dts/fsl-imx8qm-ddr4-arm2.dtb
DTC arch/arm/dts/fsl-imx8qm-lpddr4-arm2.dtb
DTC arch/arm/dts/fsl-imx8qm-mek.dtb
DTC arch/arm/dts/fsl-imx8qm-mek-xen.dtb
DTC arch/arm/dts/fsl-imx8qxp-17x17-val.dtb
DTC arch/arm/dts/fsl-imx8qxp-lpddr4-arm2.dtb
DTC arch/arm/dts/fsl-imx8qxp-mek.dtb
make[2]: 'arch/arm/dts/fsl-imx8qxp-mek.dtb' is up to date.
SHIPPED dts/dt.dtb
FDTGREP dts/dt-spl.dtb
CAT u-boot-dtb.bin
COPY u-boot.bin
SYM u-boot.sym
COPY u-boot.dtb
LD u-boot.elf
CHK include/config.h
CFG u-boot.cfg
CFGCHK u-boot.cfg
编译结束后的输出镜像为:
u-boot.bin
arch/arm/dts/fsl-imx8qxp-mek.dtb
3. 编译 Linux 内核:
pwd
~/imx-yocto-bsp/standalone
git clone https://source.codeaurora.org/external/imx/linux-imx
cd linux-imx
git tag |grep rel_imx_4.14
...
rel_imx_4.14.98_1.0.0_ga
...
git checkout rel_imx_4.14.98_2.0.0_ga
git status
HEAD detached at rel_imx_4.14.98_2.0.0_ga
source ~ /imx-yocto-bsp/imx8qxpmek_wayland/sdk/environment-setup-aarch64-poky-linux
make defconfig
LDFLAGS="" CC="$CC" make 
LDFLAGS="" CC="$CC" make dtbs clean
LDFLAGS="" CC="$CC" make dtbs //just make dtb
编译结束后的输出镜像为:
arch/arm64/boot/dts/freescale/fsl-imx8qxp-mek.dtb
arch/arm64/boot/Image
4. 编译 ATF:
pwd
~/imx-yocto-bsp/standalone
git clone https://source.codeaurora.org/external/imx/imx-atf
cd imx-atf
git tag
...
rel_imx_4.14.98_2.0.0_ga
...
git checkout rel_imx_4.14.98_2.0.0_ga
git status
HEAD detached at rel_imx_4.14.98_2.0.0_ga
source ~/imx-yocto-bsp/imx8qxpmek_wayland/sdk/environment-setup-aarch64-poky-linux
LDFLAGS="" make PLAT=imx8qx
编译 log 为:
…
LD build/imx8qxp/release/bl31/bl31.elf
BIN build/imx8qxp/release/bl31.bin
Built build/imx8qxp/release/bl31.bin successfully
编译结束后的输出镜像为:
./build/imx8qxp/release/bl31.bin
5. 运行 imx-mkimage 脚本生成 flash.bin 镜像:
另打开一个终端,不要与编译 uboot&kernel 同用一个终端:
pwd
~/imx-yocto-bsp/standalone
git clone https://source.codeaurora.org/external/imx/imx-mkimage
cd imx-mkimage
git tag
...
rel_imx_4.14.98_2.0.0_ga
...
git checkout rel_imx_4.14.98_2.0.0_ga
git status
HEAD detached at rel_imx_4.14.98_1.0.0_ga
imx-mkimage 需要调用 host PC 的 GCC 工具,所以需要退出之前的 terminal。重新进入,从而
退出之前 source 的交叉编译变量。
将 mx8qx-ahab-container.img, sc firmware bin, atf 和 uboot 拷贝至对应 iMX8QX 目录:
cp ../../imx8qxpmek_xwayland/tmp/deploy/images/imx8qxpmek/imx-boot-tools/mx8qx-ahab-container.img ./iMX
8QX/
cp ../packages/imx-scfw-porting-kit-1.2/src/scfw_export_mx8qx_b0/build_mx8qx_b0/scfw_tcm.bin ./iMX8QX/
cp ../imx-atf/build/imx8qx/release/bl31.bin ./iMX8QX/
cp ../uboot-imx/u-boot.bin ./iMX8QX/
运行 imx-mkimage 脚本生成 flash.bin 镜像
make SOC=iMX8QX flash_b0
include misc.mak

include m4.mak
include android.mak
include test.mak
include autobuild.mak
include rev_a.mak
include alias.mak
./../mkimage_imx8 -commit > head.hash
630+1 records in
630+1 records out
645154 bytes (645 kB, 630 KiB) copied, 0.00327583 s, 197 MB/s
./../mkimage_imx8 -soc QX -rev B0 -append mx8qx-ahab-container.img -c -scfw scfw_tcm.bin -ap u-boot-atf.bin
a35 0x80000000 -out flash.bin
SOC: QX
REVISION: B0
New Container: 0
SCFW: scfw_tcm.bin
AP: u-boot-atf.bin core: a35 addr: 0x80000000
Output: flash.bin
CONTAINER FUSE VERSION: 0x00
CONTAINER SW VERSION: 0x0000
ivt_offset: 1024
rev: 2
Platform: i.MX8QXP B0
ivt_offset: 1024
container image offset (aligned):a800
flags: 0x10
Hash of the images = sha384
1+0 records in
1+0 records out
150528 bytes (151 kB, 147 KiB) copied, 0.000348217 s, 432 MB/s
292+1 records in
292+1 records out
149568 bytes (150 kB, 146 KiB) copied, 0.000953368 s, 157 MB/s
SCFW file_offset = 0xa800 size = 0x24c00
Hash of the images = sha384
1+0 records in
1+0 records out
777216 bytes (777 kB, 759 KiB) copied, 0.00122179 s, 636 MB/s
1516+1 records in
1516+1 records out
776226 bytes (776 kB, 758 KiB) copied, 0.00426954 s, 182 MB/s
AP file_offset = 0x2f400 size = 0xbdc00
CST: CONTAINER 0 offset: 0x400
CST: CONTAINER 0: Signature Block: offset is at 0x590
DONE.
Note: Please copy image to offset: IVT_OFFSET + IMAGE_OFFSETHash of the images = sha384
1+0 records in
1+0 records out
760832 bytes (761 kB) copied, 0.00102483 s, 742 MB/s
1485+1 records in
1485+1 records out
760702 bytes (761 kB) copied, 0.00259972 s, 293 MB/s
AP file_offset = 0x28c00 size = 0xb9c00
CST: CONTAINER 0 offset: 0x400
CST: CONTAINER 0: Signature Block: offset is at 0x590
DONE.
Note: Please copy image to offset: IVT_OFFSET + IMAGE_OFFSET
结束后生成的 flash.bin 在:
./iMX8QX/flash.bin
6. 烧写镜像到 sdcard
bootloader:
vmuser@ubuntu:~$ cat /proc/partitions
major minor #blocks name
...
8 32 7761920 sdc
8 33 32768 sdc1
8 34 6918144 sdc2
sudo dd if=flash.bin of=/dev/sdc bs=1k seek=32
sync
kernel and btb:

cp Image to Boot imx8qx
cp fsl-imx8qxp.dtb to Boot imx8qx

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值