Error trying to compile our own OpenWrt image

I’m trying to compile a custom openwrt image following the wiki’s guide http://wiki.mikrotik.com/wiki/Manual:Metarouter
But at end i receved this error:
Applying patch platform/099-mips_module_reloc_fix.patch
patching file arch/mips/kernel/module.c
Hunk #1 FAILED at 191.
1 out of 1 hunk FAILED – rejects in file arch/mips/kernel/module.c
Patch platform/099-mips_module_reloc_fix.patch does not apply (enforce with -f)
make[4]: *** [/home/maxxo/openwrt-mk/trunk/build_dir/linux-mr-mips/linux-2.6.31.10/.quilt_checked] Error 1
make[4]: Leaving directory /home/maxxo/openwrt-mk/trunk/target/linux/mr-mips' make[3]: *** [compile] Error 2 make[3]: Leaving directory /home/maxxo/openwrt-mk/trunk/target/linux’
make[2]: *** [target/linux/compile] Error 2
make[2]: Leaving directory /home/maxxo/openwrt-mk/trunk' make[1]: *** [/home/maxxo/openwrt-mk/trunk/staging_dir/target-mips_uClibc-0.9.33.2/stamp/.target_compile] Error 2 make[1]: Leaving directory /home/maxxo/openwrt-mk/trunk’
make: *** [world] Errore 2

I tried with:
S.O.:Ubuntu 10.10,11.10,12.40,Centos 6.0
Openwrt:Any version Backfire,kamikaze
I tried with openwrt-metarouter-1.2.patch and openwrt-metarouter-1.1.patch
But Nothing changes…

Any Idea

Did you see this thread?

As I said there, the patch has not been updated by MT in a while (over 2 years!), and that Wiki page is quite old. Many changes have been made to OpenWRT since then.

In fact, I can see now what is causing your problem, and the other poster’s problem: the latest version of the patch MikroTik wrote is against Linux kernel version 2.6.31. At the time they wrote the patch, 2.6.31 was supported in ‘trunk’. It was never supported in the official Kamikaze (which only supported 2.6.23-2.6.26), or in Backfire (only 2.6.30 and 2.6.32). The current version of ‘trunk’ only supports kernels 3.1, 3.2, and 3.3…all support of 2.6.x has been removed from ‘trunk’ by OpenWRT devs as of a couple of weeks ago.

So, again, either you are going to have to study MikroTik’s patch and port it forward to a more recent kernel, or grab a copy of OpenWRT that has 2.6.31 support, or introduce support for 2.6.31 into whatever OpenWRT version you want to build.

In my case, I backported kernel 2.6.31 to Kamikaze 8.09.2 (SVN r18961), and I can share those patches with you. I have been planning on working on a build of Backfire 10.03.1, but have not had the time recently.

If you want to try building a version of ‘trunk’ with 2.6.31 support, it looks like r31411 is the last revision of ‘trunk’ before OpenWRT devs ripped support for that kernel out. You will have to check 31411 out of SVN and try patching and building against that.

If you want to try building against Kamikaze with my patches that introduce 2.6.31 support, I have them for download here:

[u]http://www.nconx.com/~nathan/openwrt-metarouter/mr1p2_owrt_18961.patch.gz[/u]

Kamikaze 8.09.2 buildroot source is available straight from OpenWRT:

[u]http://downloads.openwrt.org/kamikaze/8.09.2/kamikaze_8.09.2_source.tar.bz2[/u]

First apply MikroTik’s 1.2 patch as instructed on the Wiki. Then apply my patches with ‘zcat mr1p2_owrt_18961.patch.gz | patch -p1’ from within the root of the Kamikaze source tree directory. Finally, ‘make menuconfig’, make sure to select either MetaROUTER MIPS or PPC, and then select ‘tgz’ from “Target Images”. Save, and then ‘make’. Final tgz image file will be located under ‘bin/’.

If you elect to try to grab an older revision of ‘trunk’ to build against that supports kernel 2.6.31, you should be able to simply follow the instructions on the Wiki as-is and all should be well (in theory).

– Nathan

Thank you very much for your response with kamikaze and your patch i’ve resolved

I receveid a patch from Mikrotik for kernel 2.6.35 and in this patch there are changes for RouterBoards and changes for Metarouter. So I thinks there is only one patch for linux kernel

can you share us with your mr patch for linux kernel 2.6.35 ?
thank you.

I resolved by checking-out openwrt revision 20828 as
svn co -r 20828 svn://svn.openwrt.org/openwrt/trunk

Is there are way, how to compile trunk for METAROUTER MIPS?

please read the posts at the beginning of the thread, there is an answer.

nothing dosn’t work for me for trunk

I tried the NathanA suggestion but it fails even in the revision it was supposed to work.

make[1]: Entering directory `/home/ubuntu/trunk'
make[2]: Entering directory `/home/ubuntu/trunk'
make[3]: Entering directory `/home/ubuntu/trunk/target/linux'
make[4]: Entering directory `/home/ubuntu/trunk/target/linux/mr-mips'
if [ -s "/home/ubuntu/trunk/build_dir/linux-mr-mips/linux-2.6.31.10/patches/series" ]; then (cd "/home/ubuntu/trunk/build_dir/linux-mr-mips/linux-2.6.31.10"; if quilt --quiltrc=- next >/dev/null 2>&1; then quilt --quiltrc=- push -a; else quilt --quiltrc=- top >/dev/null 2>&1; fi ); fi
Applying patch platform/099-mips_module_reloc_fix.patch
patching file arch/mips/kernel/module.c
Hunk #1 FAILED at 191.
1 out of 1 hunk FAILED -- rejects in file arch/mips/kernel/module.c
Patch platform/099-mips_module_reloc_fix.patch does not apply (enforce with -f)
make[4]: *** [/home/ubuntu/trunk/build_dir/linux-mr-mips/linux-2.6.31.10/.quilt_checked] Error 1
make[4]: Leaving directory `/home/ubuntu/trunk/target/linux/mr-mips'
make[3]: *** [compile] Error 2
make[3]: Leaving directory `/home/ubuntu/trunk/target/linux'
make[2]: *** [target/linux/compile] Error 2
make[2]: Leaving directory `/home/ubuntu/trunk'
make[1]: *** [/home/ubuntu/trunk/staging_dir/target-mips_uClibc-0.9.33.2/stamp/.target_compile] Error 2
make[1]: Leaving directory `/home/ubuntu/trunk'
make: *** [world] Error 2

I used this to build:

sudo apt-get update
sudo apt-get install gcc g++ patch binutils bzip2 flex make gettext pkg-config unzip libz-dev libc6 ncurses-base ncurses-bin libncurses5-dev subversion git
 
svn checkout -r 33081 svn://svn.openwrt.org/openwrt/trunk/
cd trunk/
wget http://www.mikrotik.com/download/metarouter/openwrt-metarouter-1.2.patch
patch -p0 <openwrt-metarouter-1.2.patch
make menuconfig

maybe try older revision as you get the error while applying the patch. most probably NathanA managed to apply patch to this revision.

Following the suggestion of the Wiki I tried with an even older version but with the same results.

Note: Patch 1.2 was made against older kernel then in current trunk and some extra steps should be taken to apply it to OpenWRT. For example r29684 can be used without modifications

I tried with r29684

I think you should modify the documentation to state that at this moment compiling OpenWRT images to Metarouter is not supported.

Well apparently you didn’t, or you didn’t do it correctly, 'cause just a few minutes ago I tried it (compiling r29684 with MikroTik’s MR v1.2 patches applied), and it went smooth as silk. I’ve never even tried to build that version before, and I did it on a brand new install of Ubuntu (10.04 LTS) that I’d never before used to do any other build of OpenWRT. So I can definitely tell you that it does work.

In this very thread, I specifically called out r31411 as the last version that had support for kernel 2.6.31.10. So what are you doing checking out 33081?

I don’t know exactly what you’re doing wrong, but you are doing something wrong.

– Nathan

wrong revision is my error as this was set in the wiki. Corrected that with the revision number you are mentioning here. So wiki will have last revision OpenWRT kamikaze that works with the metarouter patch 1.2

Ah, got it. I didn’t realize 33081 had been mentioned on the wiki page.

FYI, I just tried building 31411, which I had never actually tried building before. I just noticed that in 31412, all kernel 2.6.31 patches were ripped out. 31411 does not actually build correctly, but this has nothing to do with the MikroTik patches. The problem is a bug in 31411 when trying to build a MIPS kernel, related to the GCC compiler version being used for the MIPS toolchain in this particular revision of OpenWRT ‘trunk’.

I fixed it by taking the file target/linux/generic/patches-2.6.32/032-mips_unused_variables.patch, copying it to target/linux/generic/patches-2.6.31, renaming it to 033-mips_unused_variables.patch, and finally editing this new file (target/linux/generic/patches-2.6.31/033-mips_unused_variables.patch) and deleting lines 12 through 22 (everything related to the syscall.c patch). With this modification, building r31411 for the MIPS architecture proceeded without fault.

In summary:

r29684 builds without any modification
r31411 builds with the changes I described above (there’s a bug in r31411 for MIPS with kernel 2.6.31, not the MikroTik patches)
r33081 is not compatible with the MikroTik patches

– Nathan

adjusted wiki to version that can be built without problems.

Not quite. r29689 fails in the following points:

  • bison and m4 fails with newer gcc for using gets
  • elf.cpp needs an additional “#include <unistd.h>” - bug is exposed by newer gcc versions.

Aaaaand these are MikroTik’s problems…how, exactly?

Also, should I assume that r2968**9** is just a typo on your part?

– Nathan

Because the patch no longer works with the current version of gcc. And yes it was a typo.