安装依赖
sudo apt install lib32ncurses5 lib32ncurses5-dev lib32ncursesw5 lib32ncursesw5-dev lib32tinfo-dev lib32tinfo5 libcunit1-ncurses libcunit1-ncurses-dev libncurses5 libncurses5-dbg libncurses5-dev libncursesw5 libncursesw5-dbg libncursesw5-dev
sudo apt-get install libncurses5-dev
I 编译不带文件按系统的内核
1.下载交叉编译工具及内核源码
http://ftp.loongnix.cn/embedd/ls3a/toolchain/gcc-4.9.3-64-gnu.tar.gz
http://ftp.loongnix.cn/embedd/ls2k/linux-3.10.tar.gz
2.解压交叉编译工具并加入临时环境变量
export PATH=$PATH:/home/ubuntu/loongson/gcc-4.9.3-64-gnu/opt/gcc-4.9.3-64-gnu/bin
验证 ubuntu@ubuntu:~/loongson/linux-3.10$ mips64el-linux-gcc -v
Using built-in specs.
COLLECT_GCC=mips64el-linux-gcc
COLLECT_LTO_WRAPPER=/home/ubuntu/loongson/gcc-4.9.3-64-gnu/opt/gcc-4.9.3-64-gnu/bin/../libexec/gcc/mips64el-linux/4.9.3/lto-wrapper
Target: mips64el-linux
Configured with: ../gcc-loongson-4.9.3/configure --disable-werror --prefix=/opt/gcc-4.9.3-64-gnu/ --host=x86_64-linux-gnu --build=x86_64-pc-linux-gnu --target=mips64el-linux --host=x86_64-linux-gnu --with-sysroot=/opt/gcc-4.9.3-64-gnu//sysroot --with-abi=64 --enable-static --with-build-sysroot=/opt/gcc-4.9.3-64-gnu//sysroot --enable-poison-system-directories --with-arch=gs464e --with-gmp=/opt/gcc-4.9.3-64-gnu/ --with-mpfr=/opt/gcc-4.9.3-64-gnu/ --with-mpc=/opt/gcc-4.9.3-64-gnu/ -with-cloog=/opt/gcc-4.9.3-64-gnu/ --disable-nls --enable-shared --disable-multilib --enable-__cxa_atexit --enable-c99 --enable-long-long --enable-threads=posix -enable-languages=c,c++,fortran
Thread model: posix
gcc version 4.9.3 20150626 (4.9.3-2) (GCC)
3.解压内核
3.1拷贝.config
cp arch/mips/configs/loongson2k1000_defconfig .config
make menuconfig ARCH=mips
make vmlinuz CROSS_COMPILE=mips64el-linux- ARCH=mips DEBUG=-g -j8
mips64el-linux-strip vmlinuz
4.加载
pmon 开机按'c'
ifaddr syn0 192.168.1.30
tftp load://192.168.1.20/vmlinuz
g
串口打印
5.本文以linux-3.10为例,linux-4.4亲测也可以,方法同上
http://ftp.loongnix.cn/embedd/ls2k/linux-4.4.tar.gz
注意:
II 交叉编译报错 ld: unrecognized option '-Wl,-O1'
例如ld: unrecognized option '-Wl,-O1'
这是由于环境变量中有垃圾,可以通过设置环境变量来解决
例如 LDFLAGS=""
##########################################################################################################################################################
修改下载链接如下
Index of /loongsonpi/pi_2/source (loongnix.cn)
解压后,使用默认.config
配置交叉编译工具,如上
使用如下命令即可,或vi build.sh,加入以下命令,并 chmod 777 -f build.sh更改权限
make ARCH=mips CROSS_COMPILE=mips64el-linux- menuconfig -j8
make ARCH=mips CROSS_COMPILE=mips64el-linux- -j8
III 编译带文件按系统的内核
如果要添加ramdisk文件系统,解压ramdisk.cpio,使用默认文件系统,如下操作,后编译,即可生成带有ram文件系统的内核
编译结果
IV 只显示一个网卡
修改配置文件
# cd /etc/network/
# cat interfaces
# interface file auto-generated by buildroot
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
pre-up /etc/network/nfs_check
wait-delay 15
hostname $(hostname)
hwaddress ether f6:17:c9:f7:68:50
auto eth1
iface eth1 inet dhcp
hwaddress ether f6:17:c9:f7:68:48
#
reboot