What is the difference between make nconfig & make linux-nconfig? - linux-kernel

I am using buildroot and did not see a difference between:
make nconfig
and
make linux-nconfig
Is there a difference?

make nconfig runs the configuration of Buildroot itself (i.e. selecting which packages to build, which architecture, which toolchain, etc). make linux-nconfig runs the configuration of the Linux kernel. It will first download and extract the kernel, and then run the kernel Kconfig infrastructure. It allows you to select CPU, drivers, filesystems etc.

Related

In what circumstances 'Openwrt ' is preferred over 'Buildroot' frame work?

I'm confused between Buildroot and OpenWrt. I mean in which scenario one will choose OpenWrt over Buildroot.
As per my understanding, there are only 2 differences between Buildroot and OpenWrt
OpenWrt provides package manager(opkg) which is not available for buildroot.
OpenWrt provides the good number of packages support for most networking related devices (routers, switches etc).
If I don’t need any package manager for a project and yet I want network support then I can choose Build root over OpenWrt, right? Is it not possible to build networking related packages in Buildroot itself?
I mean if package manager is not a concern we can go ahead with buildroot itself right? there is no need to opt OpenWrt?
If I'm wrong can anyone address the scenarios where buildroot fails and Openwrt wins?
I mean is it possible to achieve what OpenWrt is doing(Building Firmware images for networking related hardware) with Buildroot itself. I observed that the init process (early userspace) behaviour is different for Buildroot and OpenWrt.
In Buildroot init script will be read etc/inittab and the scripts under init.d will be executed.
In Openwrt procd is the init script (rc.common)and will run the scripts listed under init.d as well as scripts under rc.d.
Will this affect any way if I try to use Buildroot to generate an Image for the firmware which is supported by OpenWrt?
OpenWRT is based on Buildroot, just as Ubuntu is based on Debian. While the two projects share code, OpenWRT focuses on routers and the like, whereas buildroot is just a general purpose toolchain for embedded linux. What you should be asking yourself is, "Which of these two projects contain what I need to accomplish my task?"
OpenWRT can be compiled without opkg, in fact, many packages can be ripped out and it will work just fine. This is useful for devices with less resources.
Also, OpenWRT can be made to use regular init scripts; you don't have to use procd if you don't want to. The abstractions offered by it do make it easier to configure an existing package, however, if you are looking to port a new package, advanced knowledge of procd is needed to create those from scratch.

cross-compilation terminologies --- build, host and target

I'm seeing a lot of conflict information and would like some clarification.
build, host and target
There are three system names that the build knows about: the machine you are building on (build), the machine that you are building for (host), and the machine that GCC will produce code for (target). When you configure GCC, you specify these with --build=, --host=, and --target=.
Actually, I don't understand what the difference between host and target in the above definition.
Some other page says
‘host’ is the machine (or architecture, or platform) that you are using to compile the code;
‘target’ is the machine (or architecture, or platform) that is intended to run the code.
This makes sense to me, but in this explanation, is the host always the same as the build ?? I'm pretty confused.
In my case, I am configuring such that
the compiler (GCC) runs on x86_64 machine and the binary executable runs on ARM. The program is written in C, so the compiler is GCC.
./configure --build=x86_64 --host=x86_64 --target=arm-linux-gnueabihf
make
make install
It sounds like
build, host are both x86_64 and target is arm. Is that correct?
I am compiling my own embedded program that runs on Jenkins machine (x86_64). And the embedded program runs on ARM based machine.
Lets say I have a PowerPC machine making a compiler that you will use (run) on an x86 machine that will make binaries that run on an ARM.
That makes the PPC the build, the x86 the host, and the target is the ARM. As Basile commented, this is a Canadian-cross.
It's less common to have a build and host that are different, but it certainly does happen. Sometimes the build and host are even the same architecture, but there's something different about the environments that cause this. Making a custom toolchain on my x86 will mean that build and host are x86, but the host may have different libraries, or versions of dependencies, than the build. This is the case when building sand-boxed toolchains for embedded development that run on a build server, for example.
"There are three system names that the build knows about: the machine you are building on (build), the machine that you are building for (host), and the machine that GCC will produce code for (target). When you configure GCC, you specify these with --build=, --host=, and --target="
...
If build, host, and target are all the same, this is called a native.
If build and host are the same but target is different, this is called a cross.
If build, host, and target are all different this is called a canadian (for obscure reasons dealing with Canada’s political party and the background of the person working on the build at that time).
If host and target are the same, but build is different, you are using a cross-compiler to build a native for a different system.
Some people call this a host-x-host, crossed native, or cross-built native.
If build and target are the same, but host is different, you are using a cross compiler to build a cross compiler that produces code for the machine you’re building on.
This is rare, so there is no common way of describing it. There is a proposal to call this a crossback.
Source: https://gcc.gnu.org/onlinedocs/gccint/Configure-Terms.html
Someone already gave an example of the 'Canadian'.
An example of a cross-compilation is that when building sox from source (the Linux sound library) you need to provide 32-bit binaries for the codecs etc. I just came across this situation on a 64-bit machine, and I want to build it for my own use, which means in this case:
The build is the host (my machine)
The target is a 32-bit system
This is my understanding anyway, I agree this can be a bit confusingly explained, hope this helps :-)

How to install a bare Linux kernel without any distribution to study it?

I want to study the kernel of Linux without any distribution.
I found the LoadLin boatloader of Ms-dos, but i think it works only in older version of windows (windows 95,98, ME).
So i need to install the kernel only in my PC if Possible.
How I can install it?
The kernel only is not that much useful to you; you'll probably need some shell and a working compiler if you want to test things first-hand, and these are not part of the kernel.
There's a distribution called Linux From Scratch which basically allows you to install the kernel and then whatever other stuff you want, literally from scratch (as in, by compiling stuff yourself and only adding what YOU want)
I am wondering though, what is it exactly you want to study and how does having a distribution affect your studying of the kernel? (Yes, some distributions ship custom kernels but the major features are almost always the same)
Minimal Linux Live is a small script that:
downloads the source for the kernel and busybox
compiles them
generates a bootable 8Mb ISO with them
The ISO then leaves you in a minimal shell with busybox.
With QEMU you can then easily boot into the system, which might be a more convenient way to study the kernel.
Or you can just use the Live ISO as a regular distribution and install it on metal.
Usage:
git clone https://github.com/ivandavidov/minimal
cd minimal/src
./build_minimal_linux_live.sh
# Wait.
# Install QEMU.
# minimal_linux_live.iso was generated
./qemu64.sh
and you will be left inside a QEMU Window with you new minimal system. Awesome.
See also:
https://unix.stackexchange.com/questions/17122/is-it-possible-to-install-the-linux-kernel-alone
https://superuser.com/questions/307087/linux-distro-with-just-busybox-and-bash
Why not use a distribution? Just get some free VM (eg. virtualbox) and install an arbitrary Linux distribution. You have all the build tools there you need to compile the kernel, without actually touching your system.

How can I generate kernel headers for an "unknown" embedded ARM system?

I have an (old) embedded system for which I want to compile programs. I don't have the toolchain, so I want to create one.
The embedded system has an "ARM926EJ-S rev 5 (v5l)" CPU and "cat /proc/version" says that it runs "Linux version 2.6.20.7" with GCC 4.0.2.
I have heard that I have to include the kernel headers in the build process. I download the Linux kernel version 2.6.20 from kernel.org, extract all files and run "make headers_install ARCH=arm INSTALL_HDR_PATH=~/headers". Is this the correct way or do I need the header files of the specific kernel?
untar the kernel.
make mrproper
make ARCH=${arch} headers_check
e.g make ARCH=arm headers_check
make ARCH=${CLFS_ARCH} INSTALL_HDR_PATH=dest headers_install
This are the steps to get headers from kernel.
The purpose of kernel headers is -->C library and compiled programs needs to interact with the kernel
i.e for Available system calls and their numbers, Constant definitions, Data structures, etc.
Therefore, compiling the C library requires kernel headers, and many applications also require them.
do I need the header files of the specific kernel?
The kernel-to-userspace ABI is backward compatible
--> 1)Binaries generated with a toolchain using kernel headers older
than the running kernel will work without problem, but won't
be able to use the new system calls, data structures, etc.
-->2)Binaries generated with a toolchain using kernel headers newer
than the running kernel might work on if they don't use the
recent features, otherwise they will break.
--->3)Using the latest kernel headers is not necessary, unless access
to the new kernel features is needed
So in your case kernel version is "Linux version 2.6.20.7"
You can use kernel headers of Linux kernel version 2.6.20 or 2.6.21 from kernel.org.
does not create any problem in this case.
That should be fine if you're using the headers to build a libc
You should probably run make ARCH=arm headers_check beforehand too.

Linux l2TPv3 support

I use CentOS and it does not have support for L2TPv3 which was introduced in 2.6.35.
CentOS is at 2.6.32. How do I selectively patch just the L2TPv3 changes to my kernel?
Also, these are kernel modules. Would I need to run the modified kernel to be able to insmod these KOs?
Back porting features is a very non trivial task, not something that can easily be done casually. Thus, your best option is to look around whether somebody created the necessary patches for your kernel version.
Also, Linux kernel has no strict interface definitions when modules are concerned, thus it is very desirable that kernel and modules are compiled from the same source. Sometimes it is possible to successfully use "mismatched" modules with a given kernel, but rather frequently an attempt to do so results in various problems.
But if you will adventurous, try using modprobe -f. This will disable the module version checking and modprobe will try to squeeze the module in (even at a cost of crashing the system on spot).

Resources