Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Buildroot custom kernel under 1MB

I am trying to build minimal kernel under 1 Mb with Buildroot. It is intended for small board with qspi memory and basic functionality, ethernet, usb, spi, and some GPIO's. Basic terminal access via ssh and UART. My first thoughts are if it is even possible to modify kernel .config via linux-menuconfig to reach this size.

Also if it is possible to identify the redundant parts without deep knowledge about kernel architecture and exclude them from compilation.

If someone can direct me to good direction how to solve this problem or even specify some tools and ways how to do it would be very helpful.

Thank you!

like image 260
Michal Gonda Avatar asked Jun 09 '15 12:06

Michal Gonda


People also ask

How long does buildroot take to build?

Thanks to its kernel-like menuconfig, gconfig and xconfig configuration interfaces, building a basic system with Buildroot is easy and typically takes 15-30 minutes.

Is buildroot a Linux distribution?

Buildroot is a tool for automating the creation of Embedded Linux distributions. It builds the code for the architecture of the board so it was set up, all through an overview of Makefiles. In addition to being open-source, it is licensed under GPL-2.0-or-later.


2 Answers

If you have working build root for your board, than, it's better to continue to work with it. Technic for disabling kernel options should be the same. In the article he reached ~0,7MB uImage with lost a lot of functionality (p40). He started with minimal (bare) config (p27) and add blocks of configs. So instead of identify the redundant parts you can build smallest possible uImage you can boot. Than add to it more options: ext2, serial and so on. Actually this work require a lot of testing. And you probably brake dependencies.

Kernel configs (working and new one) could be compared using diff -Naur, so you can see what changed.

Offtopic:

Looks like yocto officially supported by altera. here are instructions how to build altera-image-minimal. If you fine with it size, than use it and don't spend time on minimizing uImage. If you need extra packages installed into it, than you can ease extend it.

And here are instructions about building Angstrom (yocto based distribution). You can create you custom image based on console-image-minimal.

I use Angstrom in production. Must say, it was really hard to use it first time.

like image 140
alexander Avatar answered Sep 28 '22 09:09

alexander


Whether or not you build the kernel with buildroot is not really relevant. The important thing is to configure it so it fits in 1MB. When you build the kernel from buildroot, you can do that with make linux-menuconfig, as you mention.

That said, getting a kernel under 1MB will be quite hard. Biff once did this for an x86-based platform, bifferboard. But that was without networking or USB.

You can refer to the kernel size tuning guide, which has links to some patches to reduce the size. But it's not been updated in a couple of years.

like image 27
Arnout Avatar answered Sep 28 '22 10:09

Arnout