Thursday, April 08, 2010

port GNU/Linux kernel-2.6.28 to ixp4xx(420)

Copyright (c) Shawn the R0ck.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation;with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.A copy of the license is included in the section entitled "GNU Free Documentation License".

I have been doing some porting on ixp4xx(420) for weeks.the boring one is that port the network adapter to kernel-2.6.28.Perhaps there's many ways could be done this job.I tried compile the ixp4xx drivers into kernel-2.6.28.And needed to change a lot in driver code which for fit in the data structures of kernel high-speed changes.in the end,you still need the intel full of shits(accessLib and something else) to provided a link library for complete the compiliation of kernel.Because of Intel as big corporation would never like to accept spirit of GPL and they made a abstraction layer is called accessLib which is followed BSD-license.Intel wants to copping out GPL license and that was the way.The wrost thing is my cross-compiler cant not gernerate these libs.dont laugh on me,I have try more than 4 verions of cross-compilers that all failed.That's why I have to pick a easy way to done this job.That way is port the shit used by snapgear...Hope this roughly document could give you help!

1.Download snapgear-4.0 and extract the files into a folder of snapgear.Download GNU/Linux kernel 2.6.28,you need to move the kernel(after extracted) into directory of snapgear and changes the named of "linux-2.6.28" to "linux-2.6.x"(bash:mv linux-2.6.28 linux-2.6.x).

2.download snapgear-modules-20090807.sh,then move it to snapgear.you will get 4 files after execution(bash: ./snapgear-modules-20090807).And follow the "sexy" README files steps to patching your snapgear distro.

3.because of you wanna get npe modules that you have to add something to linux-2.6.x/Makefile.Find where vmlinux-dirs and vmlinux-alldirs are,and looks like this after correct edited:
vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
$(core-y) $(core-m) $(drivers-y) $(drivers-m) \
$(net-y) $(net-m) $(libs-y) $(libs-m) $(EXTRA_MODULE_DIRS)))

vmlinux-alldirs := $(sort $(vmlinux-dirs) $(patsubst %/,%,$(filter %/, \
$(init-n) $(init-) \
$(core-n) $(core-) $(drivers-n) $(drivers-) \
$(net-n) $(net-) $(libs-n) $(libs-) $(EXTRA_MODULE_DIRS))))

4.if you dont wanna get a error like "/home/snapgear/modules/ixp425/net-2.4/ixp400_eth.c: In function 'port_disable': /home/snapgear/modules/ixp425/net-2.4/ixp400_eth.c:2836: error: implicit declaration of function 'kill_proc'",you need to edit the file of ixp400_eth.c.

before edited:
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)

#include "linux..."

#define kill_proc(p,s,v) send_sig(s,find_task_by_vpid(p),0)

#endif

after edited:

#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)

#include "linux..."

#define kill_proc(p,s,v) send_sig(s,find_task_by_vpid(p),0)

#endif

5.continue to editing a right $(AWK) execution path.add vmlinux-only-dirs = $(filter-out /%,$(vmlinux-dirs)) into linux2.6.x/Makefile for a proper place and replace vmlinux-dirs with vmlinux-only-dirs.Only the second "vmlinux-dirs" need to be replaced that looks like this:

PHONY += modules
modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux)
$(Q)$(AWK) '!x[$$0]++' $(vmlinux-only-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order

6.snapgear wouldnt gernerate a right path for ixp400_eth.ko.so you still need to change the linux-2.6.x/scripts/Makefile.modinst like this:

modinst_dir = $(subst $(dir $(TOPDIR))modules/,,$(if $(KBUILD_EXTMOD),$(ext-mod-dir),kernel/$(@D)))

7.edit snapgear\modules\ixp425\ixp400-2.4\ixp400_xscale_sw\src\ethMii\IxEthMii_p.h.add "#define IX_ETH_MII_IP175C_PHY_ID 0x02430d80" near by behind the "/* supported PHYs */"

And,turn to the 172th line of snapgear\modules\ixp425\ixp400-2.4\ixp400_xscale_sw\src\ethMii\IxEthMii.c.Add "|| (ixEthMiiPhyId[i] == IX_ETH_MII_IP175C_PHY_ID)" to where behind the "|| (ixEthMiiPhyId[i] == IX_ETH_MII_RTL8305SC_PHY_ID)"

I tested a version of which doesnt made the changes and snapgear pop up some error.But the network adapter is still works.I dont know what exactly effect on it.

8.you will get a compile error "/home/snapgear/modules/ixp425/net-2.4/ixp400_eth.c:2025: error: implicit declaration of function '_netif_rx_schedule_prep'" when you select the NAPI option.

The solution is edit ixp400_eth.c,before edited:

#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)

priv_data_t *priv = netdev_priv(ndev);

if(napi_schedule_prep(&priv->napi))

{

ixEthAccQMgrRxNotificationDisableQueue(i);

ixQMgrNotificationDisable(i);

__napi_schedule(&priv->napi);

}

#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)

priv_data_t *priv = netdev_priv(ndev);

if(netif_rx_schedule_prep(&priv->napi))

{

ixEthAccQMgrRxNotificationDisableQueue(i);

ixQMgrNotificationDisable(i);

__netif_rx_schedule(&priv->napi);

}

done the edit:

#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)

priv_data_t *priv = netdev_priv(ndev);

if(napi_schedule_prep(&priv->napi))

{

ixEthAccQMgrRxNotificationDisableQueue(i);

ixQMgrNotificationDisable(i);

__napi_schedule(&priv->napi);

}

#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)

priv_data_t *priv = netdev_priv(ndev);

if(netif_rx_schedule_prep(&priv->napi))

{

ixEthAccQMgrRxNotificationDisableQueue(i);

ixQMgrNotificationDisable(i);

__netif_rx_schedule(&priv->napi);

}

finnlay,you need to type a few command lines after booting the ixp4xx-board:

# insmod ixp400.ko
# cat /etc/IxNpeMicrocode.dat > /dev/ixNpe
# insmod ixp400_eth.ko

ixp400_eth: Initializing IXP400 NPE Ethernet driver software v. 1.7SG
ixp400_eth: CPU clock speed (approx) = 266 MHz
[warning] ixNpeDlNpeMgrInit - Warning:NPEA is not present.
ixp400_eth: ixp0 is using NPEB and the PHY at address 0
ixp400_eth: ixp1 is using NPEC and the PHY at address 1
ixp400_eth: Use default MAC address 00:02:b3:01:01:01 for port 0
ixp400_eth: Use default MAC address 00:02:b3:02:02:02 for port 1

dont even think that you have done all works of port.of course no~your ixp420 needed 2 network cables plug into 2 RJ-45 interfaces which one for TX and another for RX.I dont figure it out yet.Im still hacking on it.I found out that some functions which writing datas into registers of ip175c net chip got something wrong.Now the ixp4xx can writing the data correctly but still cant send or receive the datas from network within one network adapter.

port is a muscular work,definitely:-)

1 comment:

Anonymous said...

Quite right! I like this idea, I completely with you agree.