交叉編譯龍芯內核

一、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
    
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章