OpenWRT on Ebox3300 (IV): Adding patches
04 Oct 2014 | CommentsIn this part, we will deal with enabling not functioning parts of our device. We’ve already noticed, that there are no disks seen and ethernet controller is also not visible. The second is quite easily resolved by selecting appropriate options in the OpenWRT menuconfig. However the first thing is going to be more interesting, as we will be creating patch to the OpenWRT build tree itself. The solution to these hardware problems I’ve found on this blog.
The ethernet controller
First, we deal with ethernet controller. The controller on board is based on
the RDC R6040
device. So we will need r6040 kernel module. It’s location
in OpenWRT’s menuconfig is Kernel modules > Network Devices > kmod-r6040
.
We simply select it to build and that’s all. When we rebuild our image we will
hopefully get our working ethernet device in ifconfig
and in dmesg
we will
get something like this:
There is a slight problem with this device (it sometimes fails to enumerate - at least in my case), but I will get back to it later on.
The IDE controller
As far as disks are concerned, it’s going to be more complicated. According to blog, which I provided link above, the needed driver is in kernel. However, driver is not assigned to the specific hardware ID our device uses. So we have to add this ID to the driver headers in order to correctly identify it.
The correct way to add a patch to OpenWRT build tree is using the tool named
quilt
(which is great tool to work with patches - used by Linux kernel
maintainers). The procedure is described on
official OpenWRT wiki.
We are going to use the procedure described in Adding or editing kernel
patches section.
Adding the kernel patch
Procedure looks like this (of course we need quilt
, so install it ;)):
- First we need to prepare our kernel tree in order to add changes:
- Then we go to build directory and prepare our patch:
- The
build_dir
is for version of OpenWRT I use. On different version, however, it should be similar. - Patch name (for kernel patches) must be constructed that way:
{platform,generic}/[number]-[name_of_patch].patch
. Our patch is ofplatform
type.
- The
-
Next we edit the files:
Note:
quilt edit
uses editor, which can be set in~/.quiltrc
asEDITOR=
variable.
- We make our changes visible in patch by using
quilt refresh
command. - We may see what changes are being applied to the patch using
quilt diff
:
As we can see, only those two lines are needed in order to enable our device in the driver.
- To add our patch to the main OpenWRT buildroot we need to run this command from root directory:
- After that we can run again
make target/linux/{clean,prepare} V=s QUILT=1
and see if our changes are added. We may also check, if the patch is in the patch dir, in this case:target/linux/x86/patches-3.10
.
Adding the device to OpenWRT menuconfig
After the necessary modification we have to enable correct kernel module in OpenWRT menuconfig, but there is no appropriate option. So we must add one.
It is quite straightforward. The necessary change must be done in the
package/kernel/linux/modules/block.mk
file. It will add kernel module
in Kernel modules > Block Devices > kmod-ata-core > kmod-ata-pata-821x
.
This piece of code should be added under this submenu:
Here is the lines we should add:
After those changes, we should have necessary option available and also
we should have visible disks (as sda
, sdb
, etc.) when we rebuild image
with correct module selected.
Let’s check with dmesg
:
Disks should be visible under /dev
. My µSD card is seen as sda
and CF card
as sdb
. So far, so good.
Summary
After those changes, we should be able to use the ethernet device, as well as memory cards as IDE drives. In the next part we deal with adding Ebox3300 target to OpenWRT build tree and we will look into networking facilities.
Comments
comments powered by Disqus