OpenWrt Forum Archive

Topic: Just how hard is it to update the Linux kernel?

The content of this topic has been archived on 14 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi I just wanted to know just how hard is it to update the kernel? When I used Lubuntu on a shity laptop some one gave to me I had Intel GPU issues and read on a forum how to update the Kernel to fix them. It was a kace of using the update software to tell it to download the new Kernel and install and reboot. Why can't that be dun with Openwrt? I have herd about packages having Kernel dependences but i don't really know what that miens. I have herd devs say it is a lot of work to update the Kernel for Openwrt but just what does that entail? Pleas go easy on me i am not a programmer. All sow I have seen a lot of questions along similar lines in other threads so it's not just me who would like to know. Thanks.

Yes, its not very easy to update openwrt kernel preserving everything else.
Its simplier on devices where kernel is stored in a file but on most routers its compressed and programmed to flash.
+ in any case you have to copy new kernel modules.
If kernel version is significantly differs from the old one then modules can change, some modules disapper and new modules appear. All of this must be reflected in /etc/modules.d, so in common case its not enough to change kernel and module files, some other stuff must be corrected. On devices with low flash space (most routers) part of rootfs is read-only compressed squashfs and it also must be changed because it has kernel modules and its own /etc/modules.d. No procedures are developed for separate kernel and rootfs update, just total reflash that wipes everything - kernel, rootfs, settings.

Thats why its much simplier to save configuration, reflash and restore configuration back. Openwrt is designed for embedded systems with limited resources - this is the reason for not having desktop-like management.

(Last edited by bolvan on 7 Oct 2016, 12:14)

From pure "is it possible to update in a live router" view: like bolvan said, the kernel is stored in a compressed format on flash. You need to change whole kernel at once. Most routers have very limited amount of flash memory. It is pretty hard to update the ~1,3 MB kernel when you only have a few hundred kB free flash space. On desktop computers you usually have rather unlimited disk space, so you first write the new kernel components to the disk and then switch over.

Additionally, from programming angle: Updating the kernel in Openwrt sources is indeed a rather large task, as there are over 100 generic Openwrt-specific patches for kernel plus 10-50 additional patches for each of the ~40 platforms (ar71xx, x86, mvebu, ...). At each version bump you should evaluate how to change the patches and if some patches are now unnecessary due to upstream changes.

An example: a minor bump of 4.4 from 4.4.13 to 4.4.14 required changes to 47 files.
https://github.com/openwrt/openwrt/comm … 946dfcfd21

When support for 4.4 was originally added, it took 181 files just for the "generic" parts. Plus later several fixes.
https://github.com/openwrt/openwrt/comm … 6fa68408b2
Platform-specific changes were done separately, platform by platform. E.g. ar71xx platform's initial 4.4 commit, which required about 20-30 later fixes to fully work... https://github.com/openwrt/openwrt/comm … 5f8835f0ba

Openwrt supports so many devices/architectures, that kernel updates are a large task.

(Last edited by hnyman on 7 Oct 2016, 12:26)

Thanks both for your good explanations. Yes it is a bit mad, all the CPUS and radios that Openwrt will work with. When you stop to think about it when you run Linux on a laptop or desktop it's just x86 or x64 for the greatest part. So is it rite to say that even when in the fewcher most routers come with bigger roms like the wrt1900ac which has 128 meg of nand it would still be better to flash a hole rom like we do now and not switch to the desktop way?

Wrt1900ac is very expensive. It doesnt cost so much. For that price better to buy mini-itx quad-core celeron with dual gbit ethernet + wifi access point. It will cost the same or less.
Most today's cheap routers still have 8-16 mb of flash because they are designed for fixed functionality provided by stock firmware. No need for additional expensive components. That's how vendor think.
But openwrt also runs on x86 as well, on ARM that boots from SD card and where kernel is in the file and no squash fs is used.
Do we need 2 different deployment systems ? May be it would be good but developer's resources are low. Better they focus on key functionality such as new device support.
If we need desktop-like system on ARM or x86 we just install ubuntu and have fun with it

bolvan wrote:

Yes, its not very easy to update openwrt kernel preserving everything else.
Its simplier on devices where kernel is stored in a file but on most routers its compressed and programmed to flash.
+ in any case you have to copy new kernel modules.
If kernel version is significantly differs from the old one then modules can change, some modules disapper and new modules appear. All of this must be reflected in /etc/modules.d, so in common case its not enough to change kernel and module files, some other stuff must be corrected. On devices with low flash space (most routers) part of rootfs is read-only compressed squashfs and it also must be changed because it has kernel modules and its own /etc/modules.d. No procedures are developed for separate kernel and rootfs update, just total reflash that wipes everything - kernel, rootfs, settings.

Thats why its much simplier to save configuration, reflash and restore configuration back. Openwrt is designed for embedded systems with limited resources - this is the reason for not having desktop-like management.

I have one OutOfTopic question. Could be the directory /etc/modules.d replaced with depmod (with additional kernel config changes) for autoloading modules (They are loaded as soon as they are needed)? I've manage this in AA OpenWRT version. In BB or CC and DD are'nt modules loaded correctly (bad talking to the kernel over "new" hotplug?)

The discussion might have continued from here.