OpenWrt Forum Archive

Topic: Compiling openwrt with a newer Kernel.

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

Hi,

I would like to try to compile openwrt with kernel 4.7. Is it possible to change easily Kernel version when compiling openwrt trunk?

(I want to change kernel version because with current trunk version I get Kernel panics and random reboots: https://dev.openwrt.org/ticket/24785#ticket )

Thank's in advance!
Pierre.

(Last edited by pparent on 7 Sep 2016, 09:12)

Not easy. Search for previous discussions on the topic.

But in brief, you need to
* define the new kernel major version and its patchver in kernel-version.mk
* adjust generic kernel patches (~100 files) and config to the changes in kernel between a supported version and your target version, e.g. 4.4-4.7
* adjust platform patches (~100 files) and config to the changes in kernel between 4.4-4.7
* adjust platform Makefile to use kernel 4.x

Example ar71xx and kernel 4.4 support:
https://github.com/openwrt/openwrt/blob … version.mk
https://github.com/openwrt/openwrt/blob … config-4.4
https://github.com/openwrt/openwrt/tree … atches-4.4
https://github.com/openwrt/openwrt/blob … config-4.4
https://github.com/openwrt/openwrt/tree … atches-4.4
https://github.com/openwrt/openwrt/blob … x/Makefile

Unless you are really familiar with the kernel, your platform and Openwrt details, the task is pretty difficult.

Thanks for your answer.

Well yes I had noticed that the hard point seemed to be the patches, who do not remain compatible between kernel version.

Pierre.

(Last edited by pparent on 7 Sep 2016, 11:09)

If you update the kernel to a higher level within the same version for example Chaos Calmer has version 3.18.36 and the latest version is 3.18.41 at this moment.

Do you need to refresh (update) the patches or is it possible just to update by changing the kernel-version.mk?

(Last edited by bladeoner on 12 Sep 2016, 08:21)

hnyman wrote:

Not easy. Search for previous discussions on the topic.

But in brief, you need to
* define the new kernel major version and its patchver in kernel-version.mk
* adjust generic kernel patches (~100 files) and config to the changes in kernel between a supported version and your target version, e.g. 4.4-4.7
* adjust platform patches (~100 files) and config to the changes in kernel between 4.4-4.7
* adjust platform Makefile to use kernel 4.x

Example ar71xx and kernel 4.4 support:
https://github.com/openwrt/openwrt/blob … version.mk
https://github.com/openwrt/openwrt/blob … config-4.4
https://github.com/openwrt/openwrt/tree … atches-4.4
https://github.com/openwrt/openwrt/blob … config-4.4
https://github.com/openwrt/openwrt/tree … atches-4.4
https://github.com/openwrt/openwrt/blob … x/Makefile

Unless you are really familiar with the kernel, your platform and Openwrt details, the task is pretty difficult.

Hnyman, thank you for pointing in the right direction.
With this post and the following post I was able to update build Chaos Calmer 15.05.1 r49404 to kernel 3.18.41:
https://forum.openwrt.org/viewtopic.php?id=67420

If someone wants to upgrade their own build, I figured out that in kernel 3.18.41 a lot of things changed with  netfilter and that patch "610-netfilter_match_bypass_default_checks.patch" in the /target/linux/generic/patches-3.18 folder needed to be changed.

I changed: include/kernel-version.mk
Increased the version number and changed the md5sum.

And in the "610-netfilter_match_bypass_default_checks.patch" in the /target/linux/generic/patches-3.18 folder I removed the following because the IP_TABLE.C file changed in the 3.18.41 Kernel and is not used anymore:

@@ -565,7 +591,7 @@ static void cleanup_match(struct xt_entr
}

static int
-check_entry(const struct ipt_entry *e, const char *name)
+check_entry(struct ipt_entry *e, const char *name)
{
    const struct xt_entry_target *t;

@@ -574,6 +600,8 @@ check_entry(const struct ipt_entry *e, c
        return -EINVAL;
    }

+    ip_checkdefault(&e->ip);
+
    if (e->target_offset + sizeof(struct xt_entry_target) >
        e->next_offset)
        return -EINVAL;

(Last edited by bladeoner on 18 Sep 2016, 16:53)

I will to test the same steps with the today released 3.18.42 and will let know the outcome.

I am testing this for a Netgear WNDR4300.

Did a test creating a firmware with 3.18.42 but the system didn't boot.

I tried with both Sysupgrade and the normal firmware.

I created the firmware with 3.18.43 and it works.

(Last edited by bladeoner on 15 Oct 2016, 13:56)

The discussion might have continued from here.