[RaspPi] How To Compile OpenWRT Trunk with latest Raspberry Pi Kernel 3.6 for the RPi on Ubuntu 12.04

What are we doing here?

As far as I understand the problem, there are two worlds:
Raspberry Pi Foundation on the one hand, the OpenWRT Team on the other one.
OpenWRT does try to patch "Default Kernels" until they work out with the intended Plattform, which does work in most cases very well.
The problem is, RPi is an new target for the latest OpenWRT Release - and does work - but it does not get much love of the devs:
No trunk compiles or nightlys of the Image or the packages - i.e.
And - the "so patched Kernel" does not represent the state of the art of the RPi Kernel Development at all:
I got many errors of the "first days of Pi", like the loved "SDcard error" which corrupted the whole filesystem and such.

User arsiskk of the raspberrypi-openwrt project had the same problem.
The rpi-openwrt project tried to deliever the first OpenWRT Experience to the RPi Users - competing with OpenWRT - and succeeded.
But the problem somehow remained: The old kernel was lingering there and the Team seemed to have given up the project after RPi
became an official target (https://code.google.com/p/raspberrypi-openwrt/).
So arsiskk developed a procedure to compile the raspberrypi-openwrt Code with the latest RPi Kernel - which worked awesome.
But as the project seems to be quite dead now - I tried to convert his idea and use it on the offical OpenWRT Trunk Sourcetree.
And that worked.

So long story short, what are we doing here?
We grab the trunk OpenWRT official source code, load the offical RPi Kernel into it, delete a bunch of files
which would only be needed to supply an standard kernel with a bit of RPi support and compile it.
In the end we will have the latest OpenWRT trunk with the latest RPi Kernel.
The only problem: You would sometimes need to rebuild packages which do not work with the official, but old (3.6.11, compared to OpenWRTs 3.10.4) Kernel.
And - you can't update the OpenWRT trunk that easily.
It is basically an "build and throw away" system.
But it works!
# Dependencies needed
sudo apt-get install build-essential subversion git-core libncurses5-dev zlib1g-dev gawk flex quilt libssl-dev xsltproc libxml-parser-perl mercurial bzr ecj cvs unzip

# Prepare Enviroment (Trunk)
cd ~
mkdir rpi_openwrt
cd rpi_openwrt
git clone git://git.openwrt.org/openwrt.git
cd openwrt
mkdir dl
# Install Packages
./scripts/feeds update -a
./scripts/feeds install -a

# Check Enviroment
make defconfig
make prereq

# Download Kernel and Prepare:
cd /tmp
wget https://github.com/raspberrypi/linux/archive/rpi-3.6.y.tar.gz
tar xfvz rpi-3.6.y.tar.gz
mv linux-rpi-3.6.y linux-3.6.11
tar cvf - linux-3.6.11/ | lzma > linux-3.6.11.tar.xz
mv linux-3.6.11.tar.xz ~/rpi_openwrt/openwrt/dl/

# Prepare Target
cd ~/rpi_openwrt/openwrt/target/linux/brcm2708/
vi Makefile
change LINUX_VERSION to LINUX_VERSION:=3.6.11
mkdir patches-3.6
cp config-3.10 config-3.6
cd ../generic/
cd patches-3.6
#if not exists, dl latest official openwrt, copy files from openwrt/target/linux/generic/patches-3.6 to here
# Normally it should be ok to just remove some of the patches like this:
rm *-mips*
rm *-phy*
rm a*
rm 880-gateworks_system_controller.patch
#But in case there are still errors on the make target/linux/{clean,prepare} V=99 Stage,
#remove all files except these, keep these files: (openwrt specific patches)
200-fix_localversion.patch 621-sched_act_connmark.patch
201-extra_optimization.patch 630-packet_socket_type.patch
202-reduce_module_size.patch 640-bridge_no_eap_forward.patch
210-darwin_scripts_include.patch 641-bridge_always_accept_eap.patch
211-stddef_include.patch 642-bridge_port_isolate.patch
212-byteshift_portability.patch 643-bridge_remove_ipv6_dependency.patch
220-module_exports.patch 644-bridge_optimize_netfilter_hooks.patch
230-openwrt_lzma_options.patch 650-pppoe_header_pad.patch
250-netfilter_depends.patch 651-wireless_mesh_header.patch
251-sound_kconfig.patch 652-atm_header_changes.patch
252-mv_cesa_depends.patch 653-disable_netlink_trim.patch
253-ssb_b43_default_on.patch 655-increase_skb_pad.patch
254-textsearch_kconfig_hacks.patch 900-slab_maxsize.patch
255-lib80211_kconfig_hacks.patch 910-kobject_uevent.patch
256-crypto_add_kconfig_prompts.patch 911-kobject_add_broadcast_uevent.patch
257-wireless_ext_kconfig_hack.patch 920-unable_to_open_console.patch
258-netfilter_netlink_kconfig_hack.patch 921-use_preinit_as_init.patch
260-move_bcm963xx_tag.patch 930-crashlog.patch
600-netfilter_layer7_2.22.patch 940-ocf_kbuild_integration.patch
601-netfilter_layer7_pktmatch.patch 941-ocf_20120127.patch
602-netfilter_layer7_match.patch 950-vm_exports.patch
603-netfilter_layer7_2.6.36_fix.patch 960-decompress_unlzo_fix.patch
604-netfilter_cisco_794x_iphone.patch 970-remove-unsane-filenames-from-deps_initramfs-list.patch
610-netfilter_match_bypass_default_checks.patch 980-arm_openwrt_machtypes.patch
611-netfilter_match_bypass_default_table.patch 992-mpcore_wdt_fix_watchdog_counter_loading.patch
612-netfilter_match_reduce_memory_access.patch 993-mpcore_wdt_fix_wdioc_setoptions_handling.patch
613-netfilter_optional_tcp_window_check.patch 994-mpcore_wdt_fix_timer_mode_setup.patch
620-sched_esfq.patch

#Make
cd ~/rpi_openwrt/openwrt/
make menuconfig # Choose BCM2708 Chipset, Raspberry Pi Board, Exit and Save
make target/linux/{clean,prepare} V=99 # does extract kernel and patch it
make kernel_oldconfig # builds some tools
make kernel_menuconfig # configures kernel
make menuconfig # to change RPi Patterns, i.e.:
# Packages rep:
# Image configuration -> Version configuration options -> Release Repo to:
# http://downloads.openwrt.org/attitude_adjustment/12.09/%T/generic/packages
# Main Partition Size from 48 to 64:
# Target Options -> Root File System Size, change from 48 to 64 MB or more
# Exit and Save
make V=99 -j 3

Files are in ~/rpi_openwrt/openwrt/bin/brcm2708
( i.e. openwrt-brcm2708-sdcard-vfat-ext4.img )
New build:
make kernel_menuconfig
make menuconfig
make V=99 -j 3

Inspiration and Help:
http://wiki.openwrt.org/doc/howto/build
https://code.google.com/p/raspberrypi-openwrt/issues/detail?id=11

11 thoughts on “[RaspPi] How To Compile OpenWRT Trunk with latest Raspberry Pi Kernel 3.6 for the RPi on Ubuntu 12.04

  1. Your command to create a xv file with the kernel source in it gives me a 186K file.

    "tar cvf – linux-3.6.11/ | lzma > linux-3.6.11.tar.xz"

    When I look at the resulting file it is actually a lzma compressed list of files that should be in the archive.
    The actual error from the openwrt buildroot says "This does not look like a tar archive"

    http://pastebin.com/raw.php?i=pZiemEcq

  2. Yeah that is correct. On some part I had to adjust it. That part does basically uncompress the downloaded tar file and creates an xz file from that.

    tar xfvz rpi-3.6.y.tar.gz
    mv linux-rpi-3.6.y linux-3.6.11
    tar -cJvf linux-3.6.11.tar.xz linux-3.6.11
    mv linux-3.6.11.tar.xz ~/rpi_openwrt/openwrt/dl/

    Should be correct - I hope.
    I did change these files by time but haven't published them yet as they are not ready for primetime.

    I would suggest you to download the readily made image from here for the time beeing.

    Please bear in mind that I haven't got any repo and do not plan to make one myself.

  3. I was hoping to build my own openwrt so I could add locale support for owncloud. As openwrt doest have locale support by default. But in this setup, using the openwrt trunk, in Make Menuconfig under busybox no option for adding locale support exists. If I build the standard 12.09 openwrt it is there.
    How can get locale support in the truck and add this step into this tutorial you have put together.

    For the rest your tutorial here has been excellent.
    Thanks

  4. Hello Ronnie,

    Sorry I never integrated locale into OpenWRT.
    Maybe you should try building OpenWRT from the 12.09 and not trunk.
    It should work similar to my example.

    Regards,

    Nico

  5. Thank you for your work around. All the previous steps went smoothly, however it hung during "make kernel_oldconfig", compiling tools/quilt, for more than 5 hours, then I had to kill the process and it showed
    make: *** wait: No child processes. Stop.
    make: *** Waiting for unfinished jobs....
    make: *** wait: No child processes. Stop.
    Anything I can do to fix this?

    Thanks!

  6. Have you ever built OpenWRT Trunk on your system before that?
    Maybe you're missing out on some dependencies
    Check out: http://wiki.openwrt.org/doc/howto/buildroot.exigence
    and try to run make prereq in the openwrt mainfolder.
    Maybe it can help you out.

    That said, OpenWRT as well as Raspberry Pi went to the 3.10 Kernel in the mean time - so this article here (now over 6 months old) can be seen as deprecated.
    I have an about 5 month old image, ready to download here: http://www.nico-maas.de/wordpress/?p=860
    Maybe this could help you out.

  7. Really appreciate your reply! I'm a newb and it's my first time to build OpenWRT. I'm building it on Ubuntu12.04, all tools listed in the first step are successfully installed, and make prereq passed.
    I've tried the compiled image from that link and it works perfectly 🙂 But I think I still need to compile from the source because I intend to integrate OpenFlow into OpenWRT to tune my pi into a OpenFlow switch. Seems I have to add OpenFlow as a package in OpenWRT, as described here http://archive.openflow.org/wk/index.php/Pantou_:_OpenFlow_1.0_for_OpenWRT#Building_from_Sources
    How long does it take to accomplish "make kernel_oldconfig"
    Should I use both the latest version of openwrt and rpi kernel? If so, what modification should I do to make it work?

  8. Well, depending on your hardware I would say that will take about 20-30 minutes or so to build the tools. I would advise to use the latest OpenWRT Trunk Version and the Raspberry Pi 3.10 Kernel. Pantou / OpenFlow however is designed for the 2.6.32 Kernel and an older Version of OpenWRT - so I don't know wheter that will work out this way. However, I found some blog series in the net about OpenFlow and RPi and how to build an OpenFlow Switch with it: http://openflow-sdn.blogspot.co.uk/2013/05/cheapest-openflow-switch-in-world-using.html

    Maybe this would help you. However: Remember that Raspberry Pi is really an low-performance Plattform for Network Switching. Physcially the Ethernet Connection of Modell B and the USB Ports which are all connected to the one and only internal USB Port. So connecting multiple Ethernet USB Devices will decrease Networking Performance with each Device. Same thing applies to the question why using RPi as an NAS could result in bad performance (because the USB HDD and Ethernet Connection are on the same USB Port and need to share their performance...).

    So for testing it would be ok, but using it in an real world enviroment, you would be better suited with using an old OpenWRT enabled Router and OpenFlow enabled in that way as described by your website.

    All the best,

    Nico

  9. Oops.. I didn't know USB ports and ethernet port all use the same internal port, although I just want to build and test openflow network, there will be traffic carrying video streams in local network, now I probably should hunt for another device.

    I also found the link you gave me, haven't tried yet, hoping it could work. Originally, I wanted to use POX as the controller instead of Rye that mentioned in the tutorial, and I also want to take advantage of Luci on OpenWRT to integrate with more user friendly GUI 🙂

    BTW, I'll keep your image and see what I can do with OpenWRT on my Raspberry Pi.
    Thanks a bunch for your help!

  10. Nico that's a really great tutorial!

    Since for already quite a while none of the official brcm2708 images can actually boot on a Raspberry Pi, I decided to build my own image based on rpi-kernel 3.14.6 (this one has patches available in the OpenWRT trunk).

    I could successfully build the image based on your instructions, however just like any other images out there it won't finish booting up - It will hang after the initialisation of eth0 as described in this ticket: https://dev.openwrt.org/ticket/14955

    Have you ever run into this issue?

    Pity the Raspberry isn't getting much love from the OpenWRT devs.

    Thanks a lot for your time!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.