Buildroot linux kernel clean build - embedded-linux

I am using buildroot to build linux firmware. How can I do a clean rebuild the linux kernel only (without having to build the whole thing which take an hour)?
I tried -
make linux-rebuild
but that does not do a clean.
I have also tried
make linux-reconfigure && make linux-rebuild
but that does not work either.

If you want to remove all of the changes in sources of the linux kernel be in buildroot directory (cd buildroot) and do following:
make linux-dirclean
make linux-rebuild
The first command will remove output/build/linux* directory and the second one will fetch and rebuild from scratch the kernel.

I've found in the buildroot /dl folder a copy of the kernel repo is stored in there as a tar.gz file. If you do not delete that file, buildroot will not pull any kernel updates.

after reading a lot through buildroot manual and trail and error - this is what you need to do for cleaning of linux only -
make clean linux

Related

Modifications not taken into account when recompiling linux kernel sources

I want to use the writeprotect mode of the userfaultfd feature, but it is implemented only from Linux 5.11.
I have ubuntu 20 with kernel 5.4 so I installed version 5.11 of Linux from sources, but when I reboot on the installed version, and try to use the writeprotect mode in a c user program the macros (e.g., UFFDIO_WRITEPROTECT) still appear not to be defined. And I verified that userfaultfd is not a module (doing lsmod).
In the other hand, if I make a modification for example in the scheduler just for a test (let's say in kernel/sched/core.c:context_switch) the modification are taken into account because this is in-core, but modifications for user space are not, I'm confused.
The userfaultfd.c file is in the fs/ directory of the kernel.
So please is it something that I'm missing in the compilation process (make menuconfig, make, make modules_install, make) ?
I was wrongly interpreting the error I had.
The modifications are indeed taken into account when I boot on the newly compiled kernel.
But while searching an understanding of what happens when booting on a compiled kernel, I got this:
When booting on a kernel compiled from sources, the libraries in /usr/include are not modified on the disk
If you want to overwrite them by the one modified, you should do this:
make deb-pkg //from the kernel sources directory
cd ..
sudo dpkg -i *.deb
This will install the new kernel and overwrite the headers

Adding only one driver to linux kernel

I know that on the internet I can find same information about "adding one driver to linux kernel" but I can not get it working.
I need to compile an ADV7800driver. It is based on adv7180 driver code.
I put my driver file (adv7800.c) into /linux_source_folder/drivers/media/platform/mxc/capture folder. I also add
adv7800_converter-objs := adv7800.o
obj-$(CONFIG_MXC_ADV7800_CONVERTER)+=adv7800_converter.o
in makefile in the same folder and add information in Kconfigfile.
Then I go back to /linux_source_folder and do sudo make menuconfig and set adv7800 as a module and save config. Then sudo make defconfig, then sudo make -j4 modules (now waiting about 2 hours) and then sudo make modules install.
As a result I can see every module which I configure in menuconfig but I can not see my own module (only .c file exists).
How can I do this correctly and how can I build only this one module without building others (to same much time) ?
I do not remember exactly what happens in terms of instructions executed, but the idea of defconfig is to set a default configuration for a given architecture/platform.
If, as you said, you run sudo make defconfig after you configure your module to be compiled, most likely you loose your configuration. The defconfig should be executed first (once) and then you customize the configuration.
Regarding the compilation of a single module, I point you to an old answer
How to "make" existing Linux kernel module driver after modifying the driver source code.
One note: you should not use sudo to compile

Reliable build of the Linux Kernel for the BeagleBone Black

Is there a reliable build of the Linux kernel for the BeagleBone Black platform anywhere ? I've followed the instructions here, as well as numerous other places, and none of them work. Either the modules don't build (the .ko files just don't get built and can't be found in the case of the link above), or there's missing build targets for the kernel. I'm using the Linaro ARM compiler (arm-linux-gnueabihf-gcc) cross compiling on 32-bit x86 Ubuntu 14.04.
Specifically, I've checked out the source at the BeagleBone Git repository, branches 3.8, 3.11, 3.12, 3.13 and 3.14. I've also checked out a 3rd party git clone here. The problems I've encountered are as follows:
3.8: Kernel will compile (with numerous warnings), but the modules fail to compile due to errors in the patching process from running patch.sh in the branch.
3.11: Kernel will compile (with numerous warnings), but the uImage-dtb.am335x-boneblack Make target will not. Compiling modules fails due to at least one file having an incorrect patch that yields incorrect C syntax.
3.12: Kernel will compile (with numerous warnings), along with the modules. Copying kernel and modules to the board succeeds. Booting the kernel fails, and freezes as soon as the bootup begins right out of the boot command in U-Boot.
3.13, 3.14: The kernel compilation fails with numerous syntax errors.
3.8.13+ from TowerTech: The kernel compilation succeeds (with numerous warnings), the module compilation fails, again due to incorrect patching from patch.sh.
In the cases where I could compile a kernel, I copied it to a fresh, vanilla board in memory using a TFTP boot server from U-Boot, and booted the kernel in memory. However, none of the successfully compiled kernels could work properly because they were missing their modules / firmware / dtbs. What could be causing the incorrect patching ? Surely, the developers who've written the code and patches must have tested it, so there may be something wrong with my workspace, though I can't imagine what at this point. The commands I used were the same as those at link 1.
I also followed the link you have mentioned and I am able to boot the BBB. I am using the mainline kernel from https://www.kernel.org/. The following are the steps I followed
Download the latest kernel. My version is 3.18-rc4
Use "omap2plus_defconfig" which is the default config for beaglebone black
Make commands are
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- omap2plus_defconfig -j4
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- uImage dtbs LOADADDR=0x80008000 -j4.
The image produced is present in the following path.
arch/arm/boot/uImage uImage
arch/arm/boot/dts/am335x-boneblack.dtb
After this compile the modules.
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- modules -j4
I was using busybox and NFS server as root
Compiler used is arm-linux-gnueabi-gcc. With this I am able to boot successfully and run modules. It has the advantage that we are using the latest kernel available.
I was finally able to boot the BBB with a new kernel 3.14
I am on a beagleboneblack rev C with debian pre-installed.
I basically followed steps here
http://dev.ardupilot.com/wiki/building-for-beaglebone-black-on-linux/
Kernel download: (I didn't use git, limited bandwidth...)
https://github.com/beagleboard/linux/archive/3.14.tar.gz
Build (done on a Ubuntu 14.04) : (I am not sure if some steps are not relevant or redundant)
Install mkimage
sudo apt-get install libssl-dev
wget ftp://ftp.denx.de/pub/u-boot/u-boot-latest.tar.bz2
tar -xjf u-boot-latest.tar.bz2
cd u-boot-2014.10/
make sandbox_defconfig tools-only
sudo install tools/mkimage /usr/local/bin
Download am335x-pm-firmware.bin from http://arago-project.org/git/projects/?p=am33x-cm3.git;a=tree;f=bin;h=75a5de7aa94ff6ccbfb1b3b9dc80bc2fe5b423bf;hb=refs/heads/master and copy to kernel directory
Build the kernel
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- bb.org_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- menuconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- uImage dtbs LOADADDR=0x80008000 -j4
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- modules -j4
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- am335x-boneblack.dtb -j4
Install Modules
mkdir -p ../export/rootfs
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- INSTALL_MOD_PATH=../export/rootfs/ modules_install
Now copy modules to /lib/modules/ directory in your beaglebone black (create a new directory for the modules)
cd ../export/rootfs/lib/modules/
rsync -avz 3.14.25/ root#192.168.1.3:/lib/modules/3.14.25/
Next is to copy the zImage and am335x-boneblack.dtb to the BBB
copy zImage from arch/arm/boot to /boot/uboot/ of BBB
copy am335x-boneblack.dtb from arch/arm/boot/dts to /boot/uboot/dtbs
If you replace the existing zImage and am335x-boneblack.dtb with new ones directly and they don't work, you will be in trouble. I stored the new images in a folder in /boot/uboot and manipulated environment variables in uboot to pick the one i wanted.
I know, I could have used tftpserver..
I hope it helps someone. I spent a lot of time on this which should have been very straightforward :(
Yeah, the documentation is really out of date (circa 2011 or early 2012) and very confusing. First, the github/beagleboard/kernel area says it is deprecated and to use beagleboard/linux for the kernel. BUT, it is still be actively used 1) to add patches that have not been accepted to the kernel tree yet and 2) to add kernel configs specifically for the beaglebone devel builds. The bb.org_defconfig in the kernel tree does not turn on some debug stuff.
So.. both github/beagleboard/linux AND github/beagleboard/kernel work for me (3.14) on a BBB. If you want a standard image, use "linux"; if you want a bells-and-whistles image use "kernel".
Also, a more recent cross-compiler is in APT at gcc-arm-linux-gnueabihf. Make sure you have the "hf" (hard floating point unit) version. No need to depend on linaro.
I'll update the docs after I get the project rolling....

Kernel recompiled with same config but: cpufreq: no nforce2 chipset error

I need to compile an old kernel 2.6.23 (downloaded from linuxkernels.com) in order to use it with a real time patch (it's a long story...), I installed ubuntu 10.04 which has a kernel 2.6.32-43-generic-pae.
I decided to simple copy ubuntu configuration:
cp cp /boot/config-2.6.32-43-generic-pae /usr/src/linux-2.6.23/.config
I recompile the kernel:
make menuconfig
make
make install
make modules_install
mkinitramfs -o /boot/initrd.img-2.6.23-MYVER 2.6.23-MYVER
note that in the config I make this edit: I remove the module versioning support under loadable modules section. (this step is required by the patch).
At start, I get the title error:
cpufreq: no nforce2 chipset error
how it possible, since I copied a working configuration? Maybe is because of that only flag I disable?
Not sure, but when I copy an existing .config, I run "make oldconfig" first to make sure I'm all sync'd up. Then I run make menuconfig if I want to interactively review/change any settings.

Installing Linux Kernel Modules

I usually only work on the FreeBSD kernel and it is a bit different. I get up to the stage of making and installing the modules, but how do you actually boot the kernel that you just built?
Take a look here. Essentially it's something along the lines of make menuconfig, make all, make install, make install_modules, make install_firmware, and then tweaks in grub or lilo config.
Depends on how your system is configured, but you want to copy the bzImage file somewhere your boot loader can see it, then update configs (if necessary). On my gentoo box:
#pwd is /usr/src/linux
cp arch/i386/boot/bzImage /boot/default-kernel

Resources