1. Environmental introduction
Host environment: ubuntu18.04 64-bit
Target development board: Loongson II (2K1000)
2. Data download
Cross compiler: http://ftp.loongnix.org/loongsonpi/pi_2/toolchain/
Linux kernel: http://ftp.loongnix.org/loongsonpi/pi_2/source/
Three, compile the kernel
3.1 Configure cross compiler
Decompress the cross compiler. In order to facilitate the use of the cross compiler, you can add the path of the cross compiler to the system environment PATH.
3.2 Unzip, configure and compile the kernel
(1). Decompress the kernel
wbyq@wbyq:~/loongson$ tar xvf /mnt/hgfs/linux-share-dir/linux-3.10-loongsonpai.tar.gz
(2). Copy the kernel configuration file
wbyq@wbyq:~/loongson/linux-3.10$ ls
arch fs Makefile ramdisk.cpio tmp
block include Makefile.qlock README tools
config-ls2k init make.sh REPORTING-BUGS usr
COPYING ipc mm samples virt
CREDITS Kbuild modules.builtin scripts vmlinux
crypto Kconfig modules.order security vmlinux.32
Documentation kernel Module.symvers sound vmlinux.o
drivers lib mymake System.map vmlinuz
firmware MAINTAINERS net tags
wbyq@wbyq:~/loongson/linux-3.10$
wbyq@wbyq:~/loongson/linux-3.10$ cp config-ls2k .config
(3). Configure the kernel. If you want to do some personalized configuration of the kernel, you can enter the kernel configuration menu to configure
wbyq@wbyq:~/loongson/linux-3.10$ make ARCH=mips CROSS_COMPILE=mips64el-linux- menuconfig
(4). Compile the kernel: In order to facilitate the compilation, you can first write a compilation script and run the script
wbyq@wbyq:~/loongson/linux-3.10$ touch make.sh
内容如下:
#!/bin/bash
export PATH=/home/wbyq/loongson/gcc-4.9.3-64-gnu/bin:${PATH}
export MAKEFLAGS='CC=mips64el-linux-gcc'
make -j 2 ARCH=mips CROSS_COMPILE=mips64el-linuxmake -j 2 ARCH=mips CROSS_COMPILE=mips64el-linux- INSTALL_MOD_PATH=./tmp modules_install
wbyq@wbyq:~/loongson/linux-3.10$ chmod 777 make.sh
wbyq@wbyq:~/loongson/linux-3.10$ ./make.sh