OpenWrt Forum Archive

Topic: Choosing a different kernel release for compiling

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

Hi to all,

I am trying to compile an old trunk release of openwrt because I need a module (tun.ko) compiled for a router that runs an old version of openwrt modded by producer. The linux version is 2.6.30 and it is a Broadcom 6328 platform.

Googling I found out that for compiling with a specific kernel version I have to do the following things:

1) Be sure that the release is one of the supported ones from the release, checking it in include/kernel-version.mk
2) Changing the kernel release in the target folder. My case is target/linux/brcm63xx/Makefile

Now, if I try to compile, the compiling process will fail because now is missing the correct config file in trunk/target/linux/brcm63xx/config-2.6.30. The default config was config-2.6.27 for select platform (bcm63xx).

Then, now I try to find the config-2.6.30 from a newer release and then I copy it in the correct folder. Then, the compiling process goes on but it asks some information about platform and other things (architecture, etc), infact I had to compile with make V=99 so that I have interactive compiling to find out that I have to choose manually the Architecture;but I cannot find BCM63xx, so I choose a generic MIPS MALTA device and then I choose MIPS 32 R1 so that the magic in the module match the one I have in the router.

I don't think that it is the correct way to do these things. Maybe I should be able to choose BCM63xx but it is not avaiable during the interactive compiling.

Maybe I forgot something and I can produce in a different way the config-2.6.30 file?

Infact, I cannot understand: if I choose the target platform (broadcom 63xx) in the main "make menuconfig" is enough to compile, but if I change just the kernel version, then the config file is missing or not complete (if I copy it from another release).

By the way, the compiling now ends correctly and I have my tun.ko that can be inserted (insmod) into the kernel in my router and in dmesg I can see that it is correctly inserted, but something is wrong, infact when I launch openvpn and when it loads tun.ko kernel goes in panic (I suppose) because router restarts its own (!!!) ....

Do you have any suggestion/check I can do? I haven't the RS232 connected then I cannot see what happens in console...

Maybe I need to optimize the process of changing the kernel version in the compiling process? I should do these things in a right/different way?

Thank you for your help.

(Last edited by thecode on 19 Mar 2015, 11:35)

any advice?

(Last edited by thecode on 25 Mar 2015, 13:49)

If you want to compile only some packages for your router you cannot simply use some OpenWrt buildroot and just select/build an older Kernel. Doing it leads to incompatibilities = kernel panic.

Afaik the procedure to generate a single kernel module is : load the GPL tarball of your router and with that you build the Kernel module you are missing by enabling the option there.

You are right but this time I have not the tarball gpl of my router, also I sat that my router have a modified version of openwrt :

root@localhost:~# cat /etc/opkg.conf
src/gz snapshots http://downloads.openwrt.org/snapshots/ … 2/packages
dest root /
dest ram /tmp
dest usb1 /mnt/sda1
lists_dir ext /var/opkg-lists
option overlay_root /overlay
root@localhost:~#

but this trunk (trunk/bcm412l02) doesn't exist in openwrt. Then I thought that I could take a openwrt trunk with the same kernel release and then compile the module.

"bcm412l02" is the old arch name - there was never such arch in official OpenWrt (at least according to a quick look into the commit history)
So it was probably some modified vendor stuff.

So you dont have the same kernel source code (only the vanilla kernel) and you are missing the kernel config that was used to create the image on your router.
Without these it is not possible to create a working kernel module.

The only exception where this does not apply if you have vast knowledge of linux kernel, memory management and the involved subsystems and their ABI/API for that Kernel version (basically you know how to inject custom code without letting the kernel crash).

zloop wrote:

"bcm412l02" is the old arch name - there was never such arch in official OpenWrt (at least according to a quick look into the commit history)
So it was probably some modified vendor stuff.

yes, I suppose so, too

zloop wrote:

So you dont have the same kernel source code (only the vanilla kernel) and you are missing the kernel config that was used to create the image on your router.
Without these it is not possible to create a working kernel module.

I think it is probable, not impossible

zloop wrote:

The only exception where this does not apply if you have vast knowledge of linux kernel, memory management and the involved subsystems and their ABI/API for that Kernel version (basically you know how to inject custom code without letting the kernel crash).

I don't think I have a vast knowledge, however in the past I developed a kernel call to write a firmware into a flash of a router using some primitives already done, then I have some basics about memory structures for passing datas between user space and kernel space; however as I said I have no console output then I have some problem to do a basic troubleshooting, without spending much time...

(Last edited by thecode on 25 Mar 2015, 22:38)

Hi! Sorry for the necroposting...
I have a similar problem. I have to compile a single module (kmod_2800_usb) for my router that runs an old openwrt r32878 with a kernel 3.3.8-1.
I tried to checkout that specific release with
svn co -r 32878 svn://svn.openwrt.org/openwrt/branches/attitude_adjustment
but I get errors when I just try make menuconfig (I think my compiler is too new).

Any advice?
Thank you

post errors

make menuconfig V=s

make[1]: Entering directory '/downloads/aa_r32878/scripts/config'
zconf.tab.o: In function `zconflex':
zconf.tab.c:(.text+0x21c1): undefined reference to `kconf_id_lookup'
zconf.tab.c:(.text+0x2313): undefined reference to `kconf_id_lookup'
collect2: error: ld returned 1 exit status
<builtin>: recipe for target 'conf' failed
make[1]: *** [conf] Error 1
make[1]: Leaving directory '/downloads/aa_r32878/scripts/config'
/downloads/aa_r32878/include/toplevel.mk:73: set di istruzioni per l'obiettivo "scripts/config/mconf" non riuscito
make: *** [scripts/config/mconf] Errore 2

32878 is so old that there was no AA branch, yet. That was created later by 33625.
You should just checkout the trunk of that revision. AA was later branched from that.

Some new compilers generate errors with old code, so one idea for you: download and install an old Ubuntu version (matching your date requirement) to Virtualbox and use that to compile the old firmware. That should have an old gcc compiler.

Other option might be to download the SDK from the AA repo and use that to compile the package.
E.g. for ar71xx: OpenWrt-SDK-ar71xx-for-linux-i486-gcc-4.6-linar... : https://downloads.openwrt.org/attitude_ … .2.tar.bz2 Info at http://wiki.openwrt.org/doc/howto/obtain.firmware.sdk . (I have never used SDK, but that should work.)

Thank you! I had finally been able to compile the module using an old ubuntu virtual machine.
Now I have another problem... I don't know if it is possible to override or if you can help me.
I made all this stuff to have a working wifi usb dongle supporting wireless N, but the rt2800usb in the old 3.8 kernel shows me onlu b/g mode. I think the driver is too old... is it possible to compile a newer version of rt2800usb on this old kernel to support wifi n? I know for sure the newest version has this capability (I tried it myself on chaos calmer).

You are now thinking: "It's easier to reflash an updated openwrt"... it is not so simple, because since some versions after r32878 openwrt has a bug for my HG553 (it is still not solved) that cause the usb devices not to be recognized at startup, they can be used only by disconnect and reconnect manually the device with the router on... it make the router quite unusable for me.

Thank you! smile

Sorry for offtop - but google send users with error like

zconf.tab.c:(.text+0x21c1): undefined reference to `kconf_id_lookup'
zconf.tab.c:(.text+0x2313): undefined reference to `kconf_id_lookup'

on compiling PandoraBox here (me too).

So, comrades - solution for pandora box above is true too - just use older OS and all will ok (Ubuntu12x64)

The discussion might have continued from here.