8,367
edits
Changes
→Source Code Compilation of Android and Linux
<div>[[File:Orange-pi-2g-iot-img61.png|600px|]]</div>
<br>
== '''Source Code Compilation of Android and Linux''' ==
<br>
Hardware: Orange Pi development board*1, Card reader*1, TF card*1, power supply*1
<div style="padding-left:200px;">[[File:Orange-pi-2g-iot-img5.png|500px]]</div>
<br>
Software: Linux host computer, which hard disk space at least 50G (to meet a fully compiled need)<br>
Linux host computer needs:<br>
Version 2.7.3 of Python;<br>
Version 3.81-3.82 of GNU Make;<br>
JDK1.6;<br>
Version 1.7 or higher version of Git.<br>
<br>
'''Install JDK'''<br>
<br>
* Download and unzip JDK, you will get jdk-6u31-linux-x64.bin, copy it to the directory of /opt
* Modify the permission of jdk-6u31-linux-x64.bin with following command:<br>
sudo chmod 755 jdk-6u31-linux-x64.bin
* Install jdk1.6<br>
/jdk-6u31-linux-x64.bin
* Configuration multi Java version coexistence mode with the following command:<br>
sudo update-alternatives --install /user/bin/java java /opt/jdk1.6.0_31/bin/java 300 <br>
sudo update-alternatives --install /user/bin/javap javap /opt/jdk1.6.0_31/bin/javap 300<br>
sudo update-alternatives --install /user/bin/javac javac /opt/jdk1.6.0_31/bin/javac 300<br>
sudo update-alternatives --install /user/bin/jar jar /opt/jdk1.6.0_31/bin/jar 300<br>
sudo update-alternatives --install /user/bin/javaws javaws /opt/jdk1.6.0_31/bin/javaws 300<br>
sudo update-alternatives --install /user/bin/javapdoc javadoc /opt/jdk1.6.0_31/bin/javadoc 300<br>
<br>
* Switch to java version and select version 1.6, use the following command:<br>
sudo update-alternatives --config java<br>
sudo update-alternatives --config javac<br>
sudo update-alternatives --config jar<br>
sudo update-alternatives --config javap<br>
sudo update-alternatives --config javaws<br>
sudo update-alternatives --config javadoc<br>
* After confirmed it is version 1.6, you could use the following command:
java -version
<div style="padding-left:200px;">[[File:Orange-pi-i96-img36.png|800px]]</div>
<br>
=== '''Install Platform Supported Software''' ===
<br>
$ sudo apt-get install git gnupg flex bison gperf build-essential \<br>
zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \<br>
libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \<br>
libgl1-mesa-dev g++-multilib mingw32 tofrodos \<br>
python-markdown libxml2-utils xsltproc zlib1g-dev:i386<br>
$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1/usr/lib/i386-linux-gnu/libGL.so<br>
<br>
=== '''Download the Source Package and Unzip it''' ===
<br>
Download website: http://www.orangepi.online/downloadresources/<br>
Downloaded source package and use the following command:<br>
$cat OrangePi_2G-IOT* > tar.tar.gz<br>
$ tar –xvzf tar.tar.gz<br>
<br>
Unzip the file you will get the trunk directory, enter it via the terminal.<br>
<br>
=== '''Android source code compiler''' ===
<br>
Before compiling Android source code, please make sure you have already installed JAVA 1.6 version, if not, please refer to previous charter to install first. After you install jave 1.6 successfully, you could begin to compile Android source code.<br>
Before compile Android source code, you need to first compile modem kernel for both Tcard Startup and Nand Startup. modem kernel is misp framework, you need to use corresponding cross compilation tool.Youo could use the following command to unzip the cross compilation tool file:<br>
<br>
$ tar -xvjf OrangePi_Doc.tar.bz2<br>
$ cd Platform/RDA/modem-cross<br>
$ tar -xvzf modem-cross-compiler-linux.tar.gz<br>
$ cd cross-compiler<br>
<br>
After you get the corresponding tool, install the cross compilation tool of modem as the following steps:<br>
Step 1: Cross-Compiler Installation<br>
$ sudo tar -xzf ~/modem-cross-compiler-linux.tar.gz -C /opt<br>
$ ls /opt/cross-compiler<br>
$ sudo chown -R root:root /opt/cross-compiler<br>
$ sudo chmod +x /opt/cross-compiler/bin/*<br>
<br>
Step 2: Environment Configuration<br>
$ sudo sh -c 'echo export PATH=$PATH:/opt/cross-compiler/bin > /etc/profile.d/cross-compiler.sh'<br>
$ sudo sh -c 'echo /opt/cross-compiler/lib > /etc/ld.so.conf.d/cross-compiler.conf'<br>
$ sudo ldconfig -v<br>
$ sudo ldconfig -v | grep '/opt/cross-compiler/lib'<br>
$ mips-elf-gcc -v<br>
<br>
* Select source code:
Use command to switch to Android source code:<br>
cd */trunk/<br>
* Import development variables
$ source build/envsetup.sh
* Select project
$ lunch<br>
If boot from TF card, select slt-userdebug, then select NollecA9V2VV8810P_ext4<br>
If boot from Nand, select etu-userdebug, then select NollecA9V2VV8810P<br>
<br>
* Compile system
$ make –j
* Update image if boot from TF card
After compile Android source code for booting from TF card, you will get a new image on the directory of:<br>
*/trunk/out/target/product/slt**/<br>
And use the following commands to update it:<br>
sudo dd if=bootloader.img of=/dev/sdc bs=512 seek=256 count=4096 && sync <br>
sudo dd if=modem.img of=/dev/sdc bs=512 seek=12544 count=8192 && sync<br>
sudo dd if=boot.img of=/dev/sdc bs=512 seek=20736 count=16384 && sync<br>
sudo dd if=recovery.img of=/dev/sdc bs=512 seek=37120 count=20480 && sync<br>
sudo dd if=system.ext4.img of=/dev/sdc bs=512 seek=57600 count=512000 && sync<br>
sudo dd if=vendor.ext4.img of=/dev/sdc bs=512 seek=569600 count=512000 && sync<br>
/dev/sdc is the mounted number on system of SD card.
* Nand update
There will be corespondent image on the directory of */trunk/out/target/product/etu**/ after compilation. Update the image into system with NAND update tool. About the details steps you could refer to How to update Android Nand in the manual.<br>
<br>
=== '''Compile Linux source Code''' ===
<br>
Linux source code of Orange Pi i96 has been updated to github, you could download from github. Compile Linux would require you work under Linux environment. We would recommend you use Ubuntu 16.04 of Linux PC.<br>
* Download Linux source code
You could download Linux source code from github:<br>
[https://github.com/OrangePiLibra/OrangePi <span style="color:#42a0e5;">https://github.com/OrangePiLibra/OrangePi</span>]
<br>
You could also use git command to update:<br>
git clone https://github.com/OrangePiLibra/OrangePi.git
* Compile source code
Use the following command to enter into source code directory:<br>
cd */OrangePi<br>
Execute the following script:<br>
./Build_OrangePi.sh<br>
Input root password:
<div style="padding-left:200px;">[[File:Orange-pi-i96-img37.png|600px]]</div>
<br>
After root password recognize successful, enter inter main interface and use Enter key.
<div style="padding-left:200px;">[[File:Orange-pi-i96-img38.png|600px]]</div>
<br>
Select “Build system with kernel/uboot/rootfs” on main functional interface and use Enter key.
<div style="padding-left:200px;">[[File:Orange-pi-i96-img39.png|600px]]</div>
<br>
And then select “OrangePi I96” with Enter key to update source code.
<div style="padding-left:200px;">[[File:Orange-pi-i96-img40.png|600px]]</div>
<br>
It would take around 40minutes to update source code and corresponding scripts. After updated the source code, there will be generated a directory of OrangePi_i96. This directory contains both Linux source code and scripts:
<div style="padding-left:200px;">[[File:Orange-pi-i96-img41.png|600px]]</div>
<br>
* Compile Linux
<br>
Execute the following command after enter into directory of OrangePiRDA: ./build.sh<br>
The script is is an automatic script, you could select a corresponding board which you want to compile, here is “OrangePi I96”.
<div style="padding-left:200px;">[[File:Orange-pi-i96-img42.png|600px]]</div>
<br>
If it is the first time you run the script, the system would install development tool automatic to make sure the network is connecting.
<div style="padding-left:200px;">[[File:Orange-pi-i96-img43.png|600px]]</div>
<br>
After installed tool, enter root password and use Enter key.
<div style="padding-left:200px;">[[File:Orange-pi-i96-img44.png|600px]]</div>
<br>
You will enter into the main interface after entering password, select what you are going to do:
<div style="padding-left:200px;">[[File:Orange-pi-i96-img45.png|600px]]</div>
<br>
This version is only support the above three options. After selecting the corresponding option, the system would compile automatically.
<div style="padding-left:200px;">[[File:Orange-pi-i96-img46.png|600px]]</div>
<br>
There will be prompt the location of kernel image and module after compilation.
<div style="padding-left:200px;">[[File:Orange-pi-i96-img47.png|600px]]</div>
<br>
* Update Linux Kernel and module
After finished the above compilation steps, you could update the new kernel and module into the board to run it. Before this, you could refer to the charter about Linux image writing section to write a Linux distro into SD card. After written image, insert SD card into PC and till now it would recognize there are two partitions, one is boot partition with file of uboot, kernel and Ramdisk. The other partition is rootfs partion which contains root file system.<br>
There is already marked the location of generated kernel, you only need to copy the generated zImage into first partition of SD card and replace zImage inside. Till now the kernel has been updated.<br>
And there is already marked the location of new generated module, the second SD card partition is Rootfs partition, you need to have root permission to delete the directory of rootfs/lib/modules/3.xxx with following command:<br>
sudo rm -rf */rootfs/lib/modules/3.xxx<br>
Copy the new generated module into rootfs partition you need to use the following command:<br>
sudo cp -rf */OrangePiRDA/output/lib/modules/3.xxx */rootfs/lib/modules/ sync<br>
After all above steps, kernel and module update have been finished.<br>
You could insert SD card into Orange pi, and make the jumper like the following, after booting, it would enter into Linux.
<div style="padding-left:200px;">[[File:Orange-pi-i96-img48.png|600px]]</div>
<br>