如果您有一台龙芯的电脑,那么可以直接进行内核的编译。
git clone git://cgit.loongnix.org/kernel/linux-2.6.32-el6.git cd linux-2.6.32-el6
如果编译龙芯3系列板卡,kernel则按照下面方式拷贝配置文件: cp arch/mips/configs/loongson3_defconfig .config
如果龙芯最新的3A2000系列板卡,kernel则按照下面方式拷贝配置文件: cp arch/mips/configs/loongson3a2000_defconfig .config
如果龙芯2Hsoc板卡,kernel则按照下面方式拷贝配置文件: cp arch/mips/configs/loongson2h_defconfig .config
选择完毕,可以执行下面命令进行内核配置:
make menuconfig //如果执行出错,请根据出错提示,yum update最新的包
可能会有的错误提示:
*** Unable to find the ncurses libraries or the *** required header files. *** 'make menuconfig' requires the ncurses libraries. *** *** Install ncurses (ncurses-devel) and try again. *** make[1]: *** [scripts/kconfig/dochecklxdialog] 错误 1
错误提示: 系统缺少ncurses libraries。解决办法:
yum install ncurses-devel 或者 yum update ncurses-devel
make -j4 //执行make命令进行编译,-j4表示使用系统4个核进行编译,如果系统多核可以指定这个参数
make modules_install
注:编译3.10内核和编译2.6.32内核步骤相同,只是使用配置文件不同,3.10内核在3a1000板卡和3a2000板卡使用如下通用配置文件:
cp arch/mips/configs/loongson3_defconfig .config
http://ftp.loongnix.org/toolchain/gcc/release/gcc-4.4.7-7215-n64-loongson.tar.gz
$ source setenv.sh
(针对不同的开发板使用交叉编译器不相同,参考前面提到的根据时间段和开发板进行选择):
git clone git://cgit.loongnix.org/kernel/linux-2.6.32-el6.git cd linux-2.6.32-el6
如果编译龙芯3系列板卡,kernel则按照下面方式拷贝配置文件: cp arch/mips/configs/loongson3_defconfig .config
如果龙芯最新的3A2000系列板卡,kernel则按照下面方式拷贝配置文件: cp arch/mips/configs/loongson3a2000_defconfig .config
如果龙芯2Hsoc板卡,kernel则按照下面方式拷贝配置文件: cp arch/mips/configs/loongson2h_defconfig .config
选择完毕,可以执行下面命令进行内核配置:
make menuconfig ARCH=mips CROSS_COMPILE=mips64el-redhat-linux- //如果执行出错,请根据出错提示,yum update最新的包
可能会有的错误提示:
*** Unable to find the ncurses libraries or the *** required header files. *** 'make menuconfig' requires the ncurses libraries. *** *** Install ncurses (ncurses-devel) and try again. *** make[1]: *** [scripts/kconfig/dochecklxdialog] 错误 1
错误提示: 系统缺少ncurses libraries。解决办法:
yum install ncurses-devel 或者 yum update ncurses-devel
make ARCH=mips CROSS_COMPILE=mips64el-redhat-linux- -j 16
提示:在服务器上,-j参数可以大幅度提高编译速度
mkdir ~/mymodules make modules_install INSTALL_MOD_PATH=~/mymodules ARCH=mips CROSS_COMPILE=mips64el-redhat-linux-
注:编译3.10内核和2.6.32内核步骤相同,只是使用配置文件不同。3.10内核在3a1000板卡和3a2000板卡使用如下通用配置文件:
cp arch/mips/configs/loongson3_defconfig .config
对于编译出来的内核,需要使用下面的3个文件:
vmlinuz(或者vmlinux) mymodules 目录 System.map
把这些文件都上传到龙芯机器上。
把/dev/sda1挂载到 /mnt 下,
# mount /dev/sda1 /mnt
把内核文件放置到相应目录下:
# cp vmlinuz /mnt # cp System.map /mnt/System.map-3.10.0+ # cp mymodules/lib/* /lib -rf
这一步非常容易出错,注意:
这样即使新加的title写的不正确,仍然可以选择原来的title正常进入系统。
boot.cfg的典型内容(只改kernel一行):
title Loongnix kernel (wd0,0)/vmlinuz initrd (wd0,0)/initramfs-3.10.84-17.fc21.loongson.mips64el.img args root=UUID=f8cc9919-415f-427d-8cdd-1feae1fdf55e ro rhgb quiet loglevel=0 LANG=zh_CN.UTF-8
grub.cfg也是只改linux一行。
# uname -a
看内核的编译时间,应该是最新的时间。