OpenWrt Forum Archive

Topic: kernel development

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

i want to make some changes to the kernel, especially the net/ipv4 directory. currently i work with the attitude adjustment release (having a modified 3.3 kernel as far as i know).

as i am new to that i have several questions, that hopefully arent too odd and someone of you can answer to me ;D!

1.) can i download the 3.3 kernel from the link given (http://lxr.free-electrons.com/source/net/ipv4/?v=3.3), change it and then compile and somehow add it to my next openwrt build? if yes, whats the easiest way?
2.) how about the sources that have been ported from kernel 3.5 into the 3.3 being used with the attitude adjustment release? if i download the kernel from  the above link those changes wont be included i guess?
3.) is it possible to from somewhere download the kernel source used in the official attitude adjustment release and if yes, where can i get it, because for me that of course would be the preferable way... =P
4.) any tutorials to recommend, because i was unable to find more than a few articles or blog posts sad?

thank you folks!

(Last edited by triskelian on 18 Jan 2014, 23:09)

Assuming you already have the OpenWRT source code root directory. At your local OpenWRT source root directory, execute make kernel_menuconfig and you will be prompted with the Linux kernel menu configuration.

1.) I think that site uses the official sources. Downloadable via FTP from: ftp://ftp.kernel.org/pub/linux/kernel/v3.x/

2.) No. Every Patch of OpenWrt to official software sources is included if you download the Buildroot environment for Attitude Adjustment.
see source download: https://dev.openwrt.org/wiki/GetSource
example of patches: https://dev.openwrt.org/browser/branche … atches-3.3

3.) look in the wiki / link posted above ... It was 2 clicks away from www.openwrt.org and you did not find it? big_smile
(its https://dev.openwrt.org/wiki/GetSource )
All software sources are downloaded when you build OpenWrt.

4.) Look at some wiki pages like:
- wiki.openwrt.org/doc/howto/buildroot.exigence
- http://wiki.openwrt.org/doc/howto/build
- http://wiki.openwrt.org/doc/devel/patches

To add to the advice given be previous posters, a few comments:

Openwrt uses the official kernel. The build system downloads and extracts the sources.
Then "generic" openwrt config & patches common to all architectures are applied to it.
Finally platform-specific config & patches are applied it.
Then the kernel is compiled.

In the buildhost, the extracted & patched kernel source can be found in "build_dir", e.g. /Openwrt/attitude/build_dir/linux-ar71xx_generic/linux-3.3.8

These links show the items used for ar71xx architecture:
Version: https://dev.openwrt.org/browser/branche … version.mk

Generic config & patches: https://dev.openwrt.org/browser/branche … ux/generic
https://dev.openwrt.org/browser/branche … config-3.3
https://dev.openwrt.org/browser/branche … atches-3.3

ar71xx config & patches: https://dev.openwrt.org/browser/branche … nux/ar71xx
https://dev.openwrt.org/browser/branche … config-3.3
https://dev.openwrt.org/browser/branche … atches-3.3

I am not quite sure if you are looking kernel config changes (see kernel_menuconfig like already said), or actually modifying kernel sources. If modifying sources, read the already mentioned wiki article on Openwrt patches, as the right way is to make your changes as new patches added to the end of the platform patches directory.

first of all, thank you all for the constructive information given within only a few hours.

@mazilo: thank you for telling me the kernel_menuconfig command, that actually was a new one for me, i only came across the standard menuconfig one as i created my own build a few weeks ago

@zloop: actually i was "not only two clicks away", because i already downloaded attitude_adjustment via svn and modified the image to properly work on my alix2 boards (x86) with the additional packages i need. of course i also understand that this means that the kernel has to be included in my buildroot, otherwise a hardware specific building process wouldnt be possible at all. the problem is, i was unable to locate the kernels sourcecode within my buildroot environment to 1) be sure to have the appropriate .c files that are used by the openwrt release, and 2) be able to modify the .c sources.

This leads me to hnyman's reply:
@hnyman: like you wrote in your messages last paragraph i actually want to make changes to the kernel sourcecode itself. i want to change some functionality and add a few new things for a custom development. therefore need to have an option to get the .c files and not some precompiled ones.

two days ago i came across those, from you mentioned "patches" that can be used to add new elements to the kernel. even tough currently i didnt get the whole concept of how they work i will find a way as it seems to me that this would be the optimum and cleanest way of doing the changes im planning to.

still the question arises: how to retrieve the kernel source from the openwrt buildroot (or cant i find it within the buildroot and it is stored online and downloaded during build process!?) to work with, do some changes and compile them as a kernel patch?

concerning the patches: do these patches overwrite the existing .c libraries if i inclue a new library with the same name than an existing one? how will the kernel react, because its not only about adding new things, but also make changes to some already existing methods within the kernel.

hope that all of you got the point what i am looking for,
thx

Kernel sources are not included initially. They are downloaded in the make process.
The kernel sources get expanded to <buildroot>/build_dir/.... when you do the first make.
For AA that would be <buildroot>/build_dir/linux-<your_architecture>/linux-3.3.8

read that patches wiki article already mentioned:
http://wiki.openwrt.org/doc/devel/patch … el.patches

If you add new patches at the end of other architecture patches, they will be applied along the old patches modifying the source before compilation.

And please note that the "imagebuilder" is not enough. You need to check out the whole sources.

(Last edited by hnyman on 19 Jan 2014, 16:53)

alright hnyman!

thank you for your last reply, you helped me a lot as i finally was able to locate the kernel sourcecodes and combind with the other information given, i guess am now ready to start right off big_smile

Please also understand that the sources will get deleted away from build_dir with every "make clean", so all your changes there will get blown away. So, no changes there are not permanent.

The correct way is to make sure that the changes get defined as patches in the patch queues.

You can also try "Use external kernel tree" (EXTERNAL_KERNEL_TREE). Remember to apply all OpenWrt patches to your external kernel tree, so you make sure OpenWrt will boot.

@hnyman: that makes sense, thank you for that explaination
@ zajec: for the beginning i guess this will be the easiest way for me as i also want to work using svn repositories while developing the kernel

guys you really helped me a lot!

The discussion might have continued from here.