Detailed Steps to Compile OpenWrt Firmware with Luci Interface

Detailed Steps to Compile OpenWrt Firmware with Luci Interface

If you want to master the OpenWrt system, you should learn to compile OpenWrt firmware yourself, and even learn to add your own small features to the OpenWrt system.

Many people have encountered situations where the OpenWrt firmware they compiled does not have a web interface, so they start trying various methods to find the problem.

For beginners, they might just restart to try, while for experts, it may require a series of operations, such as pinging the LAN port, clearing the cache, SSH into the backend, etc. An experienced person can tell from the browser response status that this is due to the missing Luci management page. Below, I will introduce how to compile OpenWrt firmware with Luci, focusing on downloading, installing, and configuring Luci, provided that you master the basic compilation knowledge.

1 Source Code Acquisition

We use the native OpenWrt source code, with the branch being openwrt-18.06.

Git download address:

https://github.com/openwrt/openwrt.git

Download using the git command.

Detailed Steps to Compile OpenWrt Firmware with Luci Interface

After downloading, you will have the code for the OpenWrt main branch, and we also need to switch to the specified branch.

View the branch list (git branch -a).

Detailed Steps to Compile OpenWrt Firmware with Luci Interface

Switch to the openwrt-18.06 branch.

Detailed Steps to Compile OpenWrt Firmware with Luci Interface

The original directory structure is as follows.

Detailed Steps to Compile OpenWrt Firmware with Luci Interface

As can be seen from the above image, the code directory just downloaded is very small, only containing the basic system framework, mainly including the package configuration. Many directories are generated during the compilation process.

Many people start executing make to compile directly after downloading the basic source code, resulting in firmware that is the default profile firmware and does not include the Luci interface. Therefore, before compiling, we also need to download and configure the Luci package.

2 Integrate Third-Party Packages (Luci)

The basic OpenWrt framework only contains the basic packages, and many third-party packages need to be added to the system, such as Luci.

OpenWrt uses the feeds script to download third-party packages.

The default configuration is in feeds.conf.default, which contains the download addresses of the packages, similar to the source files in the Ubuntu system.

Configuration is as follows:

Detailed Steps to Compile OpenWrt Firmware with Luci Interface

Now we start executing the command to download and install third-party packages.

Download

./scripts/feeds update -a

The downloaded files are in the feeds directory in the root directory.

Install

./scripts/feeds install -a

After installation, the packages in the feeds directory are integrated into the OpenWrt system. The integration process is done through symbolic links,

for example, the Luci package directory is package/feeds/luci/.

Various packages of Luci are all linked to the corresponding directory in the root directory.

Detailed Steps to Compile OpenWrt Firmware with Luci Interface

Of course, in addition to the above two commands, there is another way to update feeds, which is

make package/symlinks

Many people may not understand the role of symlinks.

Symlinks are a target defined in the makefile, located in include/toplevel.mk.

Detailed Steps to Compile OpenWrt Firmware with Luci Interface

From the code in the above image, we can see thatmake package/symlinksultimately executes the update and install commands, so the effects of the two methods are the same.

Of course, you can also executemake package/symlinks-cleanto uninstall feeds packages.

3 Use make menuconfig to Select Luci

After we have completed the installation of the Luci package, we also need to select Luci for compilation. The make menuconfig command is used to select packages for compilation and can be used to control which packages need to be integrated into the OpenWrt firmware.

After executing make menuconfig, we can see the Luci configuration options.

Detailed Steps to Compile OpenWrt Firmware with Luci Interface

Selecting Luci will bring you to the following interface.

Detailed Steps to Compile OpenWrt Firmware with Luci Interface

Select Collections and then enable Luci, thus selecting the Luci module, which will be integrated into the system during compilation.

Detailed Steps to Compile OpenWrt Firmware with Luci Interface

In addition to selecting the Luci module, you can also configure other aspects of Luci, such as multilingual support, menu configuration, interface themes, etc.

Selecting multilingual support.

Detailed Steps to Compile OpenWrt Firmware with Luci Interface

Selecting the Luci module.

Luci supports interface customization, allowing dynamic page generation based on configuration.

Detailed Steps to Compile OpenWrt Firmware with Luci Interface

Once configured, simply select yes to save and exit.

Detailed Steps to Compile OpenWrt Firmware with Luci Interface

4 Compile Firmware

Notes

  • Ensure you are a non-root user while compiling, otherwise an error will occur.

  • During compilation, necessary compressed packages will be downloaded to the dl directory, which may be slow, and some packages may require a proxy.

After compilation, the firmware will be in the corresponding bin directory, for example, for the 7621 platform, the firmware directory will be

bin/targets/ramips/mt7621/

▼ Long press the QR code to get more OpenWrt development technical articles ▼
Detailed Steps to Compile OpenWrt Firmware with Luci Interface

Detailed Steps to Compile OpenWrt Firmware with Luci Interface

If you like it, please click [Like] ~

Leave a Comment