Build OpenWrt / LEDE from source codes | [firmware] OpenWrt / LEDE compilation from source codes

Rep: (518)
OpenWrt / LEDE (General theme) | DD-WRT FIRMWARE | Collect bin (dump) for the programmer | Upgraded UBOOT loaders

Build OpenWrt / LEDE from source

Attached Image
The forum decided to post images under the spoilerPicture

Description / What is discussed in the topic, and what is not
OpenWrt is an embedded Linux kernel-based operating system designed primarily for home routers. Core components include the Linux kernel, util-linux, uClibc or musl, and BusyBox. The source code is open. Distributed under licenseGNU GPL

The LEDE project is developed on the basis of Linux, an embedded meta-distribution based on OpenWRT, focused on a wide range of SOHO wireless routers and non-network devices. “Linux Embedded Development Environment”.
LEDE turned away from the parent project in May 2016, with the goal of continuing to develop better software in an open management model and encouraging new developers to contribute and development efforts.

  • This topic is intended to discuss the build process, discuss the components of the firmware for inclusion in the finished file for the firmware of your router and everything that is not related to the compilation of the firmware.
  • In this topicdon't discuss OpenWrt / LEDE settings, installation process of ready-made assemblies on your router. Questions like: "I installed OpenWrt and now I don’t know what to do, how to set up the Internet" is offtopic and will be deleted without any warnings. There is a general theme for such questions. OpenWrt / LEDE - alternative firmware

Initial instruction with pictures. Buildroot Build Method
All manipulations are done on a computer with linux (in our example it will be for Debian / Ubuntu)
First, install everything you need.

Open the console and copy the commands there.
sudo apt-get install subversion git

sudo apt-get install g ++ libncurses5-dev zlib1g-dev gawk libssl-dev unzip make

Is done.
For convenience, create a directory, for example, with the name 1 and go into it
mkdir 1 && cd ~ / 1

Next you need to download the source of the firmware (see spoilerGit-repositories of OpenWrt and LEDE projects )

Download the branch we need (in this example, it is OpenWrt v17.01.4)

git clone git: // -b v17.01.4

Next, go to the directory so that we have downloaded. Our initial path was ~ / 1 and we ran the command above along this path, we created the openwrt directory, we need to go to it to continue
cd ~ / 1 / openwrt /

In Ubuntu, you can:
Attached Image

Now you need to run
./scripts/feeds update -a

After the update process is completed, we perform
./scripts/feeds install -a

Almost everything is ready, then we perform
make prereq

If everything is ok, then there will be this message: Collecting package info: done
Starting the interface for selecting the firmware components (in the latest versions it appears automatically after the previous step)
make menuconfig

Moving through the points is done with the keyboard keys: up-down, space and esc.
Target system
Attached Image

Target Profile can be selected for the desired model, if you leave the default profile then a lot of compiled firmware will be created for all devices at once from the Target System profile
Attached Image

Now a few simple explanations:
We put the web-interface
Attached Image

Attached Image

Attached Image

and Russian language to him
Attached Image

Attached Image

Attached Image

To support L2TP, you need to select the xl2tpd package.
Attached Image

Attached Image

Attached Image

Also the necessary protocols pptp and so on are selected here:
Network --->
Attached Image

Add busybox components:
Attached Image

Attached Image

Attached Image

Well, then be guided by your needs, remember that the place in the router is not rubber and you often need to keep within 4 mb., So do not overdo it.
When everything is finished, save our configuration with the button<Save>
We proceed to the assembly:

And for a 4-core processor, to include all cores, the command will be as follows:
make -j5 V = -1

Attached Image

We are waiting, in half an hour or an hour we find our firmware in the directory ~ / 1 / openwrt /bin

If the correct target is selected before the build, but the firmware is obtained in a size larger than the size allowed for the flash of your router - the files * sysupgrade.bin and * factory.bin will not be created.

make clean

Removes the contents of the bin and build_dir directories.

make dirclean

Removes the contents of the / bin and / build_dir directories, as well as the addition of / staging_dir and / toolchain (cross-compilation tools). 'Dirclean' is the main command for a thorough cleanup.

make distclean

Removes everything that you have collected or configured, and also removes everything downloaded from the repository and the source codes of the packages.
ATTENTION: Among other things, your build configuration (.config), your toolchain, and all other source codes will be erased. Use with caution!

Addresses of the repositories used are in the file feeds.conf.default

Git-repositories of OpenWrt and LEDE projects

git clone git: // -b v18.06.4

git clone git: // -b v18.06.3

git clone git: // -b v18.06.2

git clone git: // -b v18.06.1

git clone git: // -b v18.06.0

git clone git: // -b v17.01.6

git clone git: // -b v17.01.5

git clone git: // -b v17.01.4

git clone git: // -b v17.01.3

git clone git: // -b v17.01.2

git clone git: // -b v17.01.1

git clone git: // -b v17.01.0

git clone git: // -b v15.05.1

git clone git: // -b v15.05

git clone git: // -b v14.07

git clone git: // -b v12.09

Useful programs
WinSCPgraphical client SFTP and SCP
Settings for connecting to a router with LEDE (dropbear must be enabled)
Attached Image

TFTP for Linux using Ubuntu as an example
Configure tftpd-hpa TFTP server

Install the tftpd-hpa package:
sudo apt-get install tftpd-hpa

After installation, edit the file
sudo nano / etc / default / tftpd-hpa
containing server settings. Let's bring it to the following form:

TFTP_DIRECTORY = "/ var / tftp"
TFTP_OPTIONS = "- ipv4 --secure --create --umask 027 --permissive"

In the settings are additional options:
create allows the server to create new files,
ipv4 instructs it to wait for connections only on IPv4 addresses,
umask instructs to reset the write bit for the group and all access bits for other users,
permissive instructs not to carry out any file permissions checks in excess of the operating system.
Create a directory for the tftp server, give the server access to the directory:

sudo mkdir / var / tftp

sudo chown tftp: tftp / var / tftp

You can also change the home directory of the tftp user in the / etc / passwd file to / var / tftp.

Now we just write the ip addresses we need through the gnome network manager and that's it.

It remains to restart the daemon to start working with the new directory:
sudo /etc/init.d/tftpd-hpa restart

Useful topics
OpenWrt project news

Post has been editedstp101 - 16.07.19, 00:40
Reason for editing: OpenWrt release 06/18/04

Rep: (11)
stp101 @ 01.15.18, 03:03*
Next download branch 17.04
git clone git: // -b v17.01.4

Maybe all the same -b v17.01? She even updated ...
Correct if I'm wrong.

Rep: (66)
* parallelno, All cross-compilation and assembly should correctly pass from under a user with limited rights. Sudo may only be needed during the installation of the cross-compilation toolkit. Starting with the "git clone" command and further, superuser rights are not needed and, moreover, harmful.

Rep: (518)
She even updated ...

Building OpenWrt / LEDE from source codes - discussion (Post ttb # 68784724)
turnips are replaced by ice
So yes, 17.01.4 the last one, well, apart from the trunk (reboot), or as it is called now, you can get confused: D
UPD understood what was the point, I had a typo, yes, of course, 01/17, sealed from 04/17: D sorry

Post has been editedstp101 - 14.01.18, 23:17

Rep: (0)
If you don’t want to update your Ubuntu 12.04 (which is by the way not supported anymore, well, more precisely only paid extended support, but that’s the way)
It will be easier to take a virtual machine, roll something easy on it, for example Xubuntu 16.04

I'm not a proud guy. put everything you need. By the way, I wrote all the messages when building on Ubuntu14 (which, by the way, I indicated in one of the messages). And the choice was very practical. Catching compilation errors are the same as
FCSM19LeXeR @ 13.11.17, 14:55*
A123l @ 09.11.17, 13:28 *
Take ubuntu over, type 12.04

On version 14, everything was collected: lol:
Originally on tplink 941nd v6 no Luci
removing nothing collected with luci: happy:

Thanks for the advice guys. I'll try again but with Xubuntu 16.04.3 LTS (Xenial Xerus)

Posted on 1/14/2018, 23:29:

Yellow Horror @ 01/14/18, 11:10*
parallelno, all cross-compilation and assembly should correctly pass from under a user with limited rights. Sudo may only be needed during the installation of the cross-compilation toolkit. Starting with the "git clone" command and further, superuser rights are not needed and, moreover, harmful.

I'd love to, but you read my previous posts. when compiling an error that no access rights. (

Rep: (518)
wrote all the messages when building on Ubuntu14

Well, that means I'm already a little distracted in the evening. In any case, everything is fine going if you put all the pridendals that I described and use that branch, I myself have recently checked, everything is fine. Here is the result on the old man dir 300
Attached Image

The topic is terrible looking and funny that it is still called LEDE.
By the way here I looked, the old versions moved to the archive
Support for older releases of OpenWrt (until May 15th) will be discontinued, and for OpenWrt May 15th updates will be provided to fix vulnerabilities and serious problems. LEDE 17.01 support will be provided in full. In the next few months is expected to form a new significant release, which will be released under the name OpenWrt.

Rep: (0)
Everything is going fine, so think for yourself what the problem is, in turnips or in your version of the distribution

Maybe I found the root of evil. By default, virtual boxing offers to make the hard disk dynamic. those. allocates memory for it at once as much as needed, but as needed. And during the installation of packages and other things, Ubuntu reported that the place ends. At some point, I stopped paying attention to it. And the place on a disk came to an end absolutely. Allocated 10 gigov on boot partishen and 1.7GB on swap. Now I have allocated 15 gigs for boot and lo and behold, the first and second compilation stages were successful! Now I compile the firmware. I'm waiting for what the end of it is. )

Post has been editedparallelno - 14.01.18, 23:51

Rep: (0)
I do not believe my eyes. All gathered without problems.
firmware lede-ramips-rt305x-mpr-a1-squashfs-sysupgrade.bin
size 3.1MB
so here. because of some nonsense so much trouble ...))
Thank you all guys for the tips!

But this firmware without LUCI and anything else you need. I hope everything fits. But if not, tell me pliz what the maximum size should be for the firmware, if I have 4MB flash and Uboot.

Rep: (0)
Rebuilt with what you need, I got 3.6 megabytes. The last one downloaded from the openwrt site for my router and which is now flooded into the router, weighed 3.4MB and it still seemed to have 240 kilobytes of free space on the flash.
those. firmware in the butt Pliz tell me what is the maximum size for a 4MB flash drive.

Rep: (518)
parallelno @ 01/15/18, 00:05*
Pliz tell me what is the maximum size for a 4MB flash drive.

Well, if you collected for a specific profile of the router, then if you exceed the size of the firmware relative to the flash drive, the file squashfs-sysupgrade.bin does not create as far as I remember. : unsure:
What I collected today turned out to be 3.7 for a 4 meter flash drive and free space 84.00 KB shows. running make last sentence does not yield images for one ... as it probably is.

Post has been editedstp101 - 15.01.18, 00:22

Rep: (0)
Thank you. Was sewed. I did everything as it was

and got the result! Hooray!
Attached Image

True, at 640 * 480 fps it feels like only 1-2 and the processor load is 70%. We need to further understand.

Post has been editedstp101 - 15.01.18, 01:36
Reason for editing: Under the spoiler pictures

Rep: (11)
parallelno @ 01/15/18 04:05*
Pliz tell me what is the maximum size for a 4MB flash drive.

If I am not mistaken, then, someone in this thread wrote:

in case of using a router with 4 MB of flash memory, the size of the firmware file with the marking of squashfs factory should not exceed 3.8 MB or3932160 bye t; check it twice before proceeding with the firmware of the router

If I am mistaken, I apologize, the flu, lazy and hard to look for :)


I do not believe my eyes. everything gathered without problems
But this firmware without LUCI and anything else you need.

From the firmware, you can throw a lot of things, as an example:
Compilation options

Turn on the Strip
Disable Debug
Disable support for Mesh networks
Disable IPv6 support
Change the size of the block SquashFS
Remove information about installed packages

Further, with care, as needed:
What packages can be removed

OPKG Package Manager
Dropbear - SSH Server
WPAd - Wi-Fi Daemon
iwinfo - wifi command line information
USB 1.x aka OHCI

INFA taken from this article:

OPKG, by definition, is not needed, since you are assembling the firmware yourself, you will be able to include the necessary package in it during assembly.
About serverSshI would argue, especially if, without LuCi, everything depends on the danger of the environment, there is a usual telnet offered for replacement, so it’s your choice.
WPAd is replaced by WPAd-mini, but the author suggests replacing it with packages, the development of which leaves much to be desired. I am certainly not an expert, but, all the same, security holes should be closed, and who closes them, if the packages are not updated, is a rhetorical question.
Well, USB, if not in the router, is uniquely deleted, if there is, then decide for what purposes and select only the necessary packages.

Further,STRIPandDEBUGit cleans up normally, and you are struggling for size ... However, please note that without debugging, some glitches, if any, you may not catch.
To summarize: It helped me, the place remained decent.

Post has been editedCrestFallen_Soul - 15.01.18, 12:47

Rep: (66)
The maximum size of the firmware depends on the specific device. If the correct target is selected before the build, the firmware with a size larger than the allowed one will not be assembled, the files * sysupgrade.bin and * factory.bin will not be created.

Rep: (2)
CrestFallen_Soul @ 01/15/18, 12:10*
WPAd is replaced by WPAd-mini, but the author suggests replacing it with packages, the development of which leaves much to be desired. I am certainly not an expert, but, all the same, security holes should be closed, and who closes them, if the packages are not updated, is a rhetorical question.

All these wpa * and hostapd * are built from the same source code by enabling / disabling dependencies, so if the latest version of the source code is, then there will be no holes in all derived packages.
On the pages of the official wiki
https: //wiki.openwrt.o...wto/wireless.utilities
https: //
what packages are needed for this or that functionality.

Posted on 1/16/2018 21:30:

If there is someone who understands porting OpenWRT / Lede, I suggest creating a topic for the relevant discussion and exchange of experience.
IMHO, the build process from source and using imagebuilder is well described in the official project wiki, but with porting, even there everything is completely deaf.

Rep: (23)
* iplate , I'm trying to port the device myself ... For almost a year already .. Successes have been .. But very minor

Rep: (518)
Automatic reboot by Cron in OpenWrt / LEDE (example of Cron jobs)

The crontab table consists of 6 columns, separated by spaces or tabs. The first five columns set the execution time (Minute, Hour, Day, Month, Day of the Week).
In each of the five time fields you can put:
meaning any value
5 single value
15.25,40 comma-separated list of values
9-18 range of values
* / 5 period of values ​​(in the minute field it means every 5 minutes)
All other characters in the string are interpreted as an executable command with its parameters.
| | | | |
| | | | ----- Day of the week (0 - 7) (Sunday = 0)
| | | ------- Month (1 - 12)
| | --------- Day (1 - 31)
| ----------- Hour (0 - 23)
------------- Minute (0 - 59)
/ 10 5,7,11 root command1 the command will be launched every 10 minutes in July and July
0 9-18 1-5 root command2 command will be run once per hour during the workday (from 9 to 18) from Monday to Friday
We write everything here
Attached Image

Example command: 53 6 * * 2 reboot - reboot at 6.53 every Tuesday
Naturally, by this principle it is possible not only to reboot the router, but also a lot more to do.

Post has been editedstp101 - 18.01.18, 20:06
Reason for editing: Instructions for caps, if that.

Rep: (125)
D-Link DIR-615 - Discussion (Post inak # 59387380)

Something on backup vrt.

Rep: (26)
Good morning!
Does someone run kernel_menuconfig? I do not, chews, chews something and falls out with an error that the terminal is skewing. I tried this:
make kernel_menuconfig CONFIG_TARGET = ar71xx
My device is TP-LINK TL-WDR3600. According to the documentation
make kernel_menuconfig CONFIG_TARGET = subtarget
CONFIG_TARGET allows you to select which config you want to edit. possible options: target, subtarget, env.
What is the subtarget & env?

Rep: (19)
Good day!
Please help.

I got a routerYouku YK-L1 MT7620A

Characteristics are as follows:
CPU MediaTek MT7620A ver 2, eco 6
Macronix Flash MX25L25635E @ 24MHz (32MB)

The seller gives 2 firmware, one OpenWrt, the second LEDE.
In the first one, it sees half of the memory and does not see the SD card, in the second, everything connected with USB does not work and does not install packages from the repository.

I collected the firmware on the infe from this topic, but it does not work the constant reboot of the router.

Post has been editedshalunh - 24.01.18, 08:20
Reason for editing: editing data

Rep: (23)
* shalunh
and dts on the device is? or the log of your download, taken off uart "oh, well, as an information, after which it drops and how

Rep: (304)
shalunh @ 01/23/18, 10:36*
I purchased a router Youku YK-L1 MT7620A

Two twins Youku YK-L1, Youku YK-L1c
shalunh @ 01/23/18, 10:36*
In the first one sees half the memory and does not see the SD card.

Firmware for Youku YK-L1c
shalunh @ 01/23/18, 10:36*
In the second, everything connected with USB does not work

Firmware for Youku YK-L1

They have a different amount of memory.
To build the firmware for your router you need to edit
multiple files and create a dtc file of your device,hereYou can see how to do it.
Just noticed that there is a link to the corrected files.

Post has been editedvadim1963333 - 24.01.18, 01:05

Full version    

Help     rules

Now: 07.22.19, 13:02