OpenWRT compilation tutorial and openwrt compilation tutorial

Source: Internet
Author: User

OpenWRT compilation tutorial and openwrt compilation tutorial

1. Install Ubuntu

Download To http://www.ubuntu.org.cn/desktop/get-ubuntu/download/, version casually, I chose 10.10 32-bit version. The installation process will not be mentioned. graphical installation and the Chinese version are not supported. You can close this page. It can be installed in a virtual machine or on a physical machine. It is recommended that you install it on a physical machine if necessary. It may be said that virtual machines may be unpredictable sometimes, but there are many people in virtual machines. Question: When I set the user name and password in one step of the installation process, I chose to log on automatically because I am too lazy to enter the password every time. It is just a compilation system and there is no secret.

2. disable screen saver

After installation, select "Screen Saver" in the "System" menu "Preferences" in the upper left corner, and then remove "Activate screen saver when the computer is idle" in the lower left corner ", then press "close". The window does not contain "application" or "OK". Close it and save it. I am used to the attention of WINDOWS users. Why do we need to do this? This is because some steps will take some time to complete during the compilation process. It is also troublesome to automatically enable the screen saver and re-enter the password to exit.

3. Switch to the root user

Select "application"-"attachment"-"terminal" in the upper-left corner to enter the command line, enter sudo-sH, pay attention to Case sensitivity, and enter the user password set when installing the system, you can switch to the root node. (The prompt is that * is not displayed when you enter the password. It is not displayed at all, and some people do not need to be alarmed ). Switching to root is to install or upgrade some necessary components. Some components require the root permission.

4. install components required for compilation

 

apt-get install g++apt-get install libncurses5-devapt-get install zlib1g-devapt-get install bisonapt-get install flexapt-get install unzipapt-get install autoconfapt-get install gawkapt-get install makeapt-get install gettextapt-get install gccapt-get install binutilsapt-get install patchapt-get install bzip2apt-get install libz-devapt-get install asciidocapt-get install subversion


After each line of carriage return, the system immediately checks whether to install or upgrade the component. The official WIKI uses a single command. I separated it because it is easier to check whether the installation of each component is successful. If a command line is run, a lot of things are coming out consecutively, so I am too lazy to drag the scroll bar and look back. Separate the steps one by one to facilitate reading. I like it. The final asciidoc component in the middle needs to download more than 400 MB of things and wait. Before downloading an object, you will be prompted about how many MB objects to download. If you want to download the object, Press y and press enter to download the object. Tip: If it prompts that the software package cannot be found, you may need to check the software name in the command again, because sometimes there is a number 1 in the middle of the letter, and it is easy to think of it as the letter L.

5. Exit root.

After the above installation is complete, this step is very important, that is, execute the Exit command to Exit the root. If you do not exit the root account, the system will be dizzy later. The next step is to download the source code. After downloading the source code as root, some will prompt that the root account cannot be used as the root account, however, the source code has been downloaded as root, and the "owner" of all files is root. After exiting the root account, the system will prompt you that you do not have the permission because the file is root, normal users cannot access the file, and only commands can be used to modify the file owner. Therefore, You need to exit root and execute the following download source code command as a normal user. In fact, when installing components at the beginning, you can add sudo in front of the command to achieve the temporary root identity, and then return to the general permission after the execution, but for the novice, you don't have to pursue this too much. If you have a feasible method, just try it out first.

6. Download the source code

There are two types: the latest version, but not the most stable version, namely the trunk version, and the backfire version. The source code download commands are:
Create a folder first:
Mkdir openwrt
Cd openwrt

Download command for Trunk: svn co svn: // svn.openwrt.org/openwrt/trunk/
Backfire download command: svn co svn: // svn.openwrt.org/openwrt/branches/backfire/
Select the desired version. And then wait for the download...

7. Start preparing for compilation
Cd Trunk or Cd backfire
If it is not the code you just downloaded, you should regularly run Svn up to update the code to keep the code updated. You do not know when it will change.
Then update the software package:
./Scripts/feeds update-
./Scripts/feeds install-
If you do not update the software package, you will find that you cannot see many software packages later, and you will not be able to integrate those unseen packages. Next, make defconfig, and then make menuconfig to enter the customization interface. You can choose to compile only the firmware of the specified device. Be sure to select your own device type, then you can specify the specific type. I don't know much about the configuration, but I don't know much about it. I just hit it a few times. If you don't understand some software packages, it means you don't need it, some software packages need to be installed separately after you install the official website version. If you see them, you can choose to integrate them. To make it appear in brackets, * Indicates integration. After the configuration is complete, exit and remember to save it. If you want to modify the source code, you should do so at this time. For example, you can modify large-capacity Flash files and find the modified files on the Internet. Then, you can find the files on the Ubuntu graphic interface, double-click to open the text editor and save the changes. If you want to integrate a Chinese package or other unofficial packages, I will not help you, because I will not.

8. Execute Compilation

Finally, execute make to start compilation. The first compilation is a long wait. If it is a dual-core CPU, the use of the Make-j 2 command can speed up, but some people do not recommend this, the official WIKI did not say this, I do not know whether it is good. However, I am a 4-core CPU. I used the Make-j 4 command and found that the CPU usage has not improved significantly. After reading help, I found that no number can be added, by default, no number is used to limit the number of tasks simultaneously. After I use Make-j to limit the number of tasks at the same time, the CPU usage is 100%, but the entire compilation process will fluctuate, at the beginning, it was 100%, followed by around 25% in a period of time (that is, only a single core), and sometimes 40% to 50% (almost using a dual-core), sometimes even almost no operation, CPU usage is low. However, the first compilation is particularly slow, and the first compilation is much faster. The tragedy is that the first time I use Make-j to compile the result is a failure, and then Make will succeed without parameters. Maybe this is why some people do not recommend it, however, because of the previous compilation, the second time is very fast. That is to say, if the j parameter can be used for acceleration, although it may fail, but because the second time does not take a long time, it may be possible to add the j parameter for acceleration in the first compilation. However, I did not compare the time difference between adding or not adding the-j parameter. If you are interested, compare them yourself.

9. After compilation is complete, the bin folder will appear. Go to the BIN folder and find the desired bin.


Where can I buy books that start OpenWrt firmware compilation and development, or what is its name?

Compiling openwrt firmware is not as complicated as I think. I am also a little bit confused. The following content is a little integration of compilation tutorials on the network. I found that many compilation tutorials did not explain how to change flash-related configurations.

Install ubuntu.
Note that after the installation is complete, the root user cannot log on directly. You need to set a password and set the method.

For Virtual Machine installation, set the NIC of the virtual machine to the bridging mode;
****************** ******
Edit interfaces in the/etc/networt/option folder, and configure iface eth0 inet dhcp to dhcp mode,
Then execute/etc/init. d/networking restar to automatically obtain the IP address (this method is applicable when dhcp is used to obtain the IP address in the home or organization. If it is a fixed address, study it on your own ). After Internet connectivity, perform the following:

Sudo apt-get update
Install components required for compilation:
Sudo apt-get install gcc
Sudo apt-get install g ++
Sudo apt-get install binutils
Sudo apt-get install patch
Sudo apt-get install bzip2
Sudo apt-get install flex
Sudo apt-get install bison
Sudo apt-get install make
Sudo apt-get install autoconf
Sudo apt-get install gettext
Sudo apt-get install texinfo
Sudo apt-get install unzip
Sudo apt-get install sharutils
Sudo apt-get install subversion
Sudo apt-get install libncurses5-dev
Sudo apt-get install ncurses-term
Sudo apt-get install zlib1g-dev
Sudo apt-get install gawk
Sudo apt-get install asciidoc
Sudo apt-get install libz-dev
If a component is missing during compilation, use sudo apt-get install to install it.
Build the compiling environment
* ************* Note: the following operations must be performed under the user you have created ************************
Mkdir openwrt: Create an openwrt folder
Cd openwrt: Enter the openwrt folder
Svn co svn: // svn.openwrt.org/openwrt/branches/backfire
Or svn co svn: // svn.openwrt.org/openwrt/trunkto download the official website source code.
Note: backfire and trunk are the openwrt source code of two different branches. backfire is said to be relatively stable, but there are not many trunk routers. trunk is more called a test version, however, it is okay to use it after compilation. You only need to execute the preceding command during compilation. After the execution is complete, a directory is generated under openwrt, And the backfire directory is generated using the backfire source code. The trunk is the same as ...... the remaining full text>

Teaches OpenWrt compilation. For Opkg, ImageBuilder, and Package

I also encountered the first problem, but it cannot be used normally after forced installation of KMOD ......
 

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.