编译环境搭建
下面以ubuntu16.04 x86环境为例,搭建交叉编译环境如下:
1.龙芯开源社区下载交叉编译器(最右边的二进制下载)
http://www.loongnix.cn/zh/toolchain/GNU/
2.系统相关库升级
apt-get update
apt-get upgrade
apt install bison flex
3.交叉编译loongarch架构的pmon
cd zloader.ls2k
make cfg &&make tgt=rom CROSS_COMPILE=/opt/loongarch64-linux-gnu-2021-08-09-vector/bin/loongarch64-linux-gnu-
make dtb
注意:因为有些二进制和系统文件有执行权限,需要在root执行;
4.交叉编译loongarch架构的内核
make menuconfig ARCH=loongarch
make ARCH=loongarch CROSS_COMPILE=/opt/loongarch64-linux-gnu-2021-08-09-vector/bin/loongarch64-linux-gnu- vmlinuz -j4
编译成功后,会有如下打印信息:
AR drivers/built-in.a
GEN .version
CHK include/generated/compile.h
AR built-in.a
LD vmlinux.o
MODPOST vmlinux.o
WARNING: modpost: Found 1 section mismatch(es).
To see full details build your kernel with:
'make CONFIG_DEBUG_SECTION_MISMATCH=y'
KSYM .tmp_kallsyms1.o
KSYM .tmp_kallsyms2.o
LD vmlinux
SORTEX vmlinux
SYSMAP System.map
AS arch/loongarch/boot/compressed/head.o
CC arch/loongarch/boot/compressed/decompress.o
CC arch/loongarch/boot/compressed/string.o
CC arch/loongarch/boot/compressed/dummy.o
OBJCOPY arch/loongarch/boot/compressed/vmlinux.bin
HOSTCC arch/loongarch/boot/compressed/calc_vmlinuz_load_addr
LZMA arch/loongarch/boot/compressed/vmlinux.bin.z
OBJCOPY arch/loongarch/boot/compressed/piggy.o
LD vmlinuz
STRIP vmlinuz