一、OS
ubuntu 16.04.6 x64
不能使用ubuntu 18.04 否则 一堆错误让你怀疑人生, 不要问为什么!!!
二、 配置软件源
打开 software & updates , 从Download from 中选择 other ,在 弹出的对话框中选择 china --> mirrors.aliyun.com
三、 安装基础软件包
-
32位程序运行库
apt-get install lib32ncurses5 lib32z1
-
编译工具库
apt-get install gcc g++ cmake git gitk vim
apt-get install libreadline-dev libncurses5-dev
-
安装apt-file(用于搜索头文件在哪个包中)
apt-get install apt-file
apt-file update
apt-file 使用例子
apt-file search openssl/bio.h
libssl-dev: /usr/include/openssl/bio.h
libwolfssl-dev: /usr/include/cyassl/openssl/bio.h
libwolfssl-dev: /usr/include/wolfssl/openssl/bio.h
nodejs-mozilla: /usr/lib/nodejs-mozilla/include/node/openssl/bio.h
四、安装交叉工具链
下载工具链:http://ftp.loongnix.org/toolchain/gcc/release/cross-gcc-4.9.3-n64-loongson-rc6.1.tar.bz2
#chmod 777 /opt
$ tar xf cross-gcc-4.9.3-n64-loongson-rc6.1.tar.bz2 -C /opt/
增加环境变量(此步骤可以略过)
$ echo "source /opt/cross-gcc-4.9.3-n64-loongson-rc6.1/setenv.sh" >> ~/.bashrc
五、编译内核
-
编译ls2k内核(3.10)
下载内核:http://ftp.loongnix.org/embedd/ls2k/linux-3.10.tar.gz 或者从 git clone git://cgit.loongnix.org/kernel/linux-3.10.git
设置工具链 source /opt/cross-gcc-4.9.3-n64-loongson-rc6.1/setenv.sh tar xf linux-3.10.tar.gz cd linux-3.10 make ARCH=mips CROSS_COMPILE=mips64el-loongson-linux- 安装模块文件到 /lib/modules/ make ARCH=mips CROSS_COMPILE=mips64el-linux- modules_install
-
编译ls1b 内核(3.18)
下载工具链:[http://ftp.loongnix.org/toolchain/gcc/release/gcc-4.3-ls232.tar.gz](http://ftp.loongnix.org/toolchain/gcc/release/gcc-4.3-ls232.tar.gz) tar xf gcc-4.3-ls232.tar.bz2 -C /opt/ 仿照ls2k 的工具链组织目录,重新组织目录复制ls2k 工具链中setenv.sh 修改下目录, 然后运行使工具链生效。 source /opt/gcc-4.3-ls232/setenv.sh cp arch/mips/configs/ls1b_core_defconfig .config make ARCH=mips CROSS_COMPILE=mipsel-linux- menuconfig (退出保存) make ARCH=mips CROSS_COMPILE=mipsel-linux-
-
编译ls3a内核(4.19)
使用与ls2k 编译一样的工具链 apt-get install bison apt-get install flex apt-get install libssl-dev 下载内核:[https://github.com/loongson-community/linux-stable] cp arch/mips/configs/loongson3_defconfig .config make ARCH=mips CROSS_COMPILE=mips64el-loongson-linux- menuconfig make ARCH=mips CROSS_COMPILE=mips64el-loongson-linux- 安装内核到/boot make ARCH=mips CROSS_COMPILE=mips64el-loongson-linux- install 安装模块文件到 /lib/modules/ make ARCH=mips CROSS_COMPILE=mips64el-loongson-linux- modules_install 制作initrd.img(需要在龙芯电脑环境制作) 解压modules文件到/lib/modules cd / mkinitramfs 4.19.26 -o /boot/initrd.img-4.19.26