Loongson Kernel Compilation and use

Source: Internet
Author: User
Tags git clone
Loongson kernel compilation and use

Original: Http://wiki.loongnix.org/index.php/Loongson_Kernel%E7%BC%96%E8%AF%91%E4%B8%8E%E4%BD%BF%E7%94%A8




The Godson processor uses the open source Linux operating system, simultaneously unifies the godson processor the characteristic to carry on the transplant optimization. Kernel source code is compiled using a cross compilation, research and development Center for the current BIOS and kernel development of the server is http://www.loongnix.org/gitweb/.
The current godson kernel all based on git management, download kernel need to familiarize yourself with the use of GIT version management tools, commonly used commands for Git-clone, Git-diff, Git-status, Git-format-patch, Git-apply and so on.

Note: the current godson's compiler is divided into two types:
1. Old compiler:2012-11-26 Meng xiaofu loongson3 serial set baudrate would clear ier register ... (Does not contain the secondary patch) before the user and compiles the godson 2HSOC kernel user to use. Compiler download Address: http://ftp.loongnix.org/toolchain/gcc/release/CROSS_COMPILE/loongson-clean-gcc-4.4.0.tar.gz
2. New compiler:2012-11-26 Meng xiaofu loongson3 serial set baudrate would clear ier register ... Users after this patch are using:
Compiler download Address http://ftp.loongnix.org/toolchain/gcc/release/CROSS_COMPILE/loongson3-gcc4.4.tar.gz

Kernel's download site is: http://www.loongnix.org/gitweb, view the git version of the library source information.
Kernel source Download way: Git clone http://www.loongnix.org/gitweb/linux-loongson-all

New compiler configuration: Extract the compiler into the/opt/directory, execute the path script under loongson3-gcc4.4 to set the corresponding environment variable (path set path and LD_LIBRARY_PATH environment variable)

Export Path=/opt/loongson3-gcc4.4/install/bin: $PATH 

Export ld_library_path=/opt/loongson3-gcc4.4/library/ Mpfr/lib:/opt/loongson3-gcc4.4/library/ppl/lib:
/opt/loongson3-gcc4.4/library/gmp-5.0.1/lib:/opt/ Loongson3-gcc4.4/library/cloog/lib:
/opt/loongson3-gcc4.4/install/i686-linux/mips64el-linux/lib:/opt/ loongson3-gcc4.4/source/gmpmpfr/lib/: $LD _library_path


To test how to use the compiler:
1) Download Test applet: http://ftp.loongnix.org/toolchain/gcc/release/test/gcc-test.tar.gz

Compile the A.S into A.O, and then disassemble it to see if there is sync in front of you, if there is sync, is the new compiler to use

    mips64el-linux-objdump-d A.O 

2) direct checksum compiled kernel binary

  Mips64el-linux-objdump-d vmlinux >. /v.s in the cross-compilation environment with this command

 with awk-f Count_sync_ll_pair.awk V.S Checksum will have been added to the sync, the correct results are as follows

9400 ll number of

9400 sync number

The two numbers that appear should be the same.
Count_sync_ll_pair.awk contents are as follows:

#check if every ll has one SYNC that exactly placing before LL.

#countsync must equal to Countll

begin{

before=0;

countll=0;

countsync=0;

}

{

       if ($3~/^ll/)

       {

       countll++;

       if (before~/^sync$/)

       {

               countsync++

       }

       }}

       Before= $

}

end{

       Print (countll);

       Print (Countsync);

}


Note: You need to use the new downloaded compiler objdump
old Compiler compilation method (For 2012-11-26, before the godson 3 series source code and the latest godson 2HSOC source)
GCC Download Address: http://ftp.loongnix.org/toolchain/gcc/release/CROSS_COMPILE/loongson-clean-gcc-4.4.0.tar.gz
Extract the compiler into the/opt/directory, and execute the path script under loongson-clean-gcc-4.4.0 to set the appropriate environment variables. Download source after configuration complete git clone http://www.loongnix.org/gitweb/linux-loongson-all
After downloading the source code, enter the Linux-loongson-all, followed by the following command:
CD Linux-loongson-all
Enter Linux-loongson-all Directory
Compile godson 3 Series Board kernel copy the configuration file in the following manner

CP arch/mips/configs/loongson3_defconfig. config  

Build godson 2HSOC Board kernel Copy the configuration file in the following manner

CP arch/mips/configs/loongson2h_defconfig. config make 


 menuconfig arch=mips cross_compile=mips64el-linux-


Read the configuration information in. config and generate the following interface, which can be manually cropped to the kernel. For example, you can choose whether to compile an option into kernel, or to compile it into a module, or to crop the option.

Make Arch=mips cross_compile=mips64el-linux--j8


new Compiler compilation Method (for the latest Godson 3 series source)

GCC Download Address: http://ftp.loongnix.org/toolchain/gcc/release/CROSS_COMPILE/loongson3-gcc4.4.tar.gz to extract the compiler into the/opt/directory, Execute the path script under loongson3-gcc4.4 to set the appropriate environment variable. After the configuration is complete download the source git clone http://www.loongnix.org/gitweb/linux-loongson-all source code download, enter the Linux-loongson-all, sequentially execute the following command:
CD Linux-loongson-all
Enter Linux-loongson-all Directory

CP arch/mips/configs/loongson3_defconfig. config  

The Godson 3 Series board the default configuration file is copied to. config

Make Menuconfig arch=mips cross_compile=mips64el-linux-


Read the configuration information in. config and generate the following interface, which can be manually cropped to the kernel. For example, you can choose whether to compile an option into kernel, or to compile it into a module, or to crop the option.

Make Arch=mips cross_compile=mips64el-linux--j8


After the compilation succeeds, the vmlinux.32 (32-bit), Vmlinux (64-bit) is generated in the current directory, then the vmlinux.32 is copied to the hard disk, or the/tftpboot directory of the server can be tested.
Make Modules_install
Executing this command will install the compiled module to/lib/modules/, because we are in the x86 server cross compilation godson kernel source code, so do not execute the command. You can create a directory and then execute the following command to install the compiled module into the directory you specify.
mkdir ~/mymodules
Make Modules_install Install_mod_path=~/mymodules
gcc compiler download Address: http://ftp.loongnix.org/toolchain/gcc/release/CROSS_COMPILE/loongson3-gcc4.4.tar.gz

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.