AMiLDA FORUM

You are not logged in.

Announcement

### Our Homepage is down at the moment...work in progress !! ###

#1 2006-06-09 00:36:21

HH
Developer
Registered: 2006-02-15
Last visit: 2007-03-12
Posts: 103

Ethernet driver question

Sergio, you did a great job back-porting the adm5120 ethernet drivers to AMiLDA.  Did you ever look closely at the drivers for the 2.4.18 kernel?

Offline

 

#2 2006-06-09 03:17:16

sergioag
Developer
Peru
From: Lima
Registered: 2006-02-16
Last visit: 2011-08-15
Posts: 166
Website

Re: Ethernet driver question

Hi HH

Not really, i couldn't understand that code very much. At first i wanted to add support for configuring the ethernet switch. But i found the code too messy so i prefered backporting Jeroe Vreeken's driver instead. If you want to modify the ethernet driver, i would recommend you to try with the current AMiLDA driver. It will be easier and it already includes more functionality.

Regards,

Sergio

Offline

 

#3 2006-06-09 09:47:18

HH
Developer
Registered: 2006-02-15
Last visit: 2007-03-12
Posts: 103

Re: Ethernet driver question

Thanks, I'll have a look.  The unmodified switch driver from Edimax creates an "ethx" port for every vlan.  Does your code do that the same?

Offline

 

#4 2006-06-09 14:14:39

sergioag
Developer
Peru
From: Lima
Registered: 2006-02-16
Last visit: 2011-08-15
Posts: 166
Website

Re: Ethernet driver question

Nope, it doesn't do the same. It creates 5 (or 6 if you're using the BGA version) interfaces which stand for each of the ethernet ports the CPU has. They can be optionally connected to a physical port. You can say "connect ports 1 to 3 to CPU port 1, then ports 4-6 to CPU port 2" and so on. The original driver just hardcodes the number of interfaces to 2 and the switch configuration is also hardcoded. Nothing much to do there.

Sergio

Offline

 

#5 2006-06-09 20:38:57

HH
Developer
Registered: 2006-02-15
Last visit: 2007-03-12
Posts: 103

Re: Ethernet driver question

I think I understand.  Now I am doing some classic reverse-engineering.  I disassembled the entire Hawking vmlinux.bin kernel.  I compiled the 2.4.18 Edimax file drivers/net/am5120sw/swdrv.c and disassembled it.  Comparing the two listings shows some interesting things.

The Hawking firmware turns on the Bridge Testing Mode (BTM bit 2) in the CPUp_conf register (sw offset 0x24).  That seems very strange.  Any idea what that bit does?  I will have to run a test to see if they leave it on after the router is initialized.

Another interesting thing: in swdriv_init() the Hawking code sets the GFP_DMA flag in calls to kmalloc, but the Edimax source code does not!  I think I'm getting closer.  smile

Offline

 

#6 2006-06-09 21:17:06

sergioag
Developer
Peru
From: Lima
Registered: 2006-02-16
Last visit: 2011-08-15
Posts: 166
Website

Re: Ethernet driver question

Maybe this has something to do with the 16MB DMA limit someone mentioned in another post...

Sergio

Offline

 

#7 2006-06-10 10:13:06

HH
Developer
Registered: 2006-02-15
Last visit: 2007-03-12
Posts: 103

Re: Ethernet driver question

That was me  smile  I made the kmalloc changes and now I can ping outside the router, but only if I do an "ifconfig" after the eth1 interface is up.  Weird.  Not "down" and "up" again, just plain "ifconfig".  Then ping starts to work.  It seems random.  One thing that still happens is a kernel oops right after I type in "reboot".  Seeing a live ping response is encouraging, however, because it wasn't working at all before the change.

Offline

 

#8 2006-06-10 15:49:03

sergioag
Developer
Peru
From: Lima
Registered: 2006-02-16
Last visit: 2011-08-15
Posts: 166
Website

Re: Ethernet driver question

Very good! Probably you're having a memory corruption problem, which causes the oops. What kmalloc change have you done? Don't forget to send a diff!

Sergio

Offline

 

#9 2006-06-12 23:04:35

HH
Developer
Registered: 2006-02-15
Last visit: 2007-03-12
Posts: 103

Re: Ethernet driver question

Finally I fixed the problem in the 2.4.18 Edimax code.  In drivers/net/am5120sw/if5120.h the constant BUF_ADDR_MASK needed to be changed from 0x00FFFFFF to 0x01FFFFFF.  This value should essentially be (ramsize - 1).  I found this by doing a painstaking comparison of the object code I compiled from the Edimax source with the binary vmlinux.bin kernel from the actual Hawking vendor firmware.  The code itself was fine but this constant was wrong for 32 MB of RAM.

It's amazing what you can find by reverse engineering binary code smile

Changing MAX_DMA_ADDRESS in include/asm-mips/dma.h, or adding the GFP_DMA flag to the kmalloc calls in drivers/net/am5120sw/swdrv.c did not help because the adm5120 drivers were obtaining memory from kmalloc above the 16 MB line anyway, and when an address above 16 MB is masked with 0x00FFFFFF then the address is broken.  That explains the random nature of the failures I was seeing.  If a page was obtained below the 16 MB line it would work, but if a page was obtained above the 16 MB line then it was lost forever after the address was masked with the incorrect value.

In the AMiLDA code I tried changing ADM5120_DMA_MASK (in drivers/net/adm5120sw.h) from 0x00FFFFFF to 0x01FFFFFF but the network still doesn't work when 32 MB of RAM is defined.  sad  I'm not sure where else to look in the AMiLDA code but I think the cause of the problem is similar to the Edimax driver problem.

Last edited by HH (2006-06-12 23:13:51)

Offline

 

#10 2006-06-13 17:21:07

sergioag
Developer
Peru
From: Lima
Registered: 2006-02-16
Last visit: 2011-08-15
Posts: 166
Website

Re: Ethernet driver question

I'll try to check for obvious places where this may occur.

Sergio

Offline

 

#11 2006-06-15 03:50:03

TRC1109
New member
Japan
Registered: 2006-06-14
Last visit: 2006-06-22
Posts: 6

Re: Ethernet driver question

HH wrote:

Finally I fixed the problem in the 2.4.18 Edimax code.  In drivers/net/am5120sw/if5120.h the constant BUF_ADDR_MASK needed to be changed from 0x00FFFFFF to 0x01FFFFFF.  This value should essentially be (ramsize - 1).  I found this by doing a painstaking comparison of the object code I compiled from the Edimax source with the binary vmlinux.bin kernel from the actual Hawking vendor firmware.  The code itself was fine but this constant was wrong for 32 MB of RAM.

It's amazing what you can find by reverse engineering binary code :)

Changing MAX_DMA_ADDRESS in include/asm-mips/dma.h, or adding the GFP_DMA flag to the kmalloc calls in drivers/net/am5120sw/swdrv.c did not help because the adm5120 drivers were obtaining memory from kmalloc above the 16 MB line anyway, and when an address above 16 MB is masked with 0x00FFFFFF then the address is broken.  That explains the random nature of the failures I was seeing.  If a page was obtained below the 16 MB line it would work, but if a page was obtained above the 16 MB line then it was lost forever after the address was masked with the incorrect value.

In the AMiLDA code I tried changing ADM5120_DMA_MASK (in drivers/net/adm5120sw.h) from 0x00FFFFFF to 0x01FFFFFF but the network still doesn't work when 32 MB of RAM is defined.  :(  I'm not sure where else to look in the AMiLDA code but I think the cause of the problem is similar to the Edimax driver problem.

Hi,
I modified drivers/net/adm5120sw.h as you said and it works! (from 0x00FFFFFF to 0x01FFFFFF and memsize of prom.c)
My kernel was patched by linux-2.4.32-adm.patch.


ADM5120 Boot:


Copyright 2002-2004  Infineon-ADMtek, Inc.
CPU: ADM5120-175MHz
SDRAM: 32MB
Flash: NOR-4MB
Boot System: Linux-5120
Loader Version: 1.00.03
Creation Date: 2004.06.04

Press <space> key tree times to enter boot menu..
0
Booting Linux...
Kernel decompress ... PASS
LINUX started...
ADM5120 Demo board
GETENV: envname is memsize
GETENV: returning 0x002000000
CPU revision is: 0001800b
Primary instruction cache 8kB, physically tagged, 2-way, linesize 16 bytes.
Primary data cache 8kB, 2-way, linesize 16 bytes.
Linux version 2.4.32-MIPS-01.00 (root@root) (gcc version 2.96 20000731 (Red Hat L
inux 7.3 2.96-110.1)) #6 四 6月 15 09:24:20 CST 2006
adm5120_setup() starts.
System has PCI BIOS
Determined physical RAM map:
memory: 01ddb000 @ 00225000 (usable)
Initial ramdisk at: 0x801a6000 (368640 bytes)
On node 0 totalpages: 8192
zone(0): 8192 pages.
zone(1): 0 pages.
zone(2): 0 pages.
Kernel command line: load_ramdisk=/dev/ram0 root=/dev/ram0 rw console=ttyS0
CPU clock: 175MHz
Using 87.50 MHz high precision timer.
Calibrating delay loop... 174.47 BogoMIPS
Memory: 30208k/30572k available (1477k kernel code, 364k reserved, 456k data, 88
k init, 0k highmem)
Dentry cache hash table entries: 4096 (order: 3, 32768 bytes)
Inode cache hash table entries: 2048 (order: 2, 16384 bytes)
Mount cache hash table entries: 512 (order: 0, 4096 bytes)
Buffer cache hash table entries: 1024 (order: 0, 4096 bytes)
Page-cache hash table entries: 8192 (order: 3, 32768 bytes)
Checking for 'wait' instruction...  available.
POSIX conformance testing by UNIFIX
Autoconfig PCI channel 0x801a5478
Scanning bus 00, I/O 0x11500000:0x115ffff0, Mem 0x11400000:0x11500000
00:00.0 Class 0600: 1317:5120
        Mem unavailable -- skipping
        I/O unavailable -- skipping
fixup resource
fixup host controller
adm5120 fix up
pcibios_fixup
fixup IRQ
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket
Starting kswapd
pty: 256 Unix98 ptys configured
HDLC line discipline: version $Revision: 3.7 $, maxframe=4096
N_HDLC line discipline registered.
adm5120gpio: ADM5120 GPIO driver initialized.
RAMDISK driver initialized: 16 RAM disks of 5120K size 1024 blocksize
loop: loaded (max 8 devices)
adm5120sw: initialized with 6 ports.
PPP generic driver version 2.4.2
SCSI subsystem driver Revision: 1.00
MX29LV320B flash device: 200000 at 1fc00000
Amd/Fujitsu Extended Query Table v1.1 at 0x0040
number of CFI chips: 1
cfi_cmdset_0002: Disabling fast programming due to code brokenness.
Creating 3 MTD partitions on "MX29LV320B flash device":
0x00000000-0x00200000 : "Flash Disk 1"
0x00000000-0x00008000 : "Boot Partition"
0x00008000-0x00010000 : "Config Partition"
MX29LV320B flash device initialized
ftl_cs: FTL header not found.
ftl_cs: FTL header not found.
ftl_cs: FTL header not found.
usb.c: registered new driver hub
Start Init AHCI_INIT
usb.c: new USB bus registered, assigned bus number 1
hub.c: USB hub found
hub.c: 2 ports detected
Initializing USB Mass Storage driver...
usb.c: registered new driver usb-storage
USB Mass Storage support registered.
NET4: Linux TCP/IP 1.0 for NET4.0
IP Protocols: ICMP, UDP, TCP
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 2048 bind 4096)
ip_conntrack version 2.1 (256 buckets, 2048 max) - 288 bytes per conntrack
ip_tables: (C) 2000-2002 Netfilter core team
ipt_recent v0.3.1: Stephen Frost <sfrost@snowman.net>.  http://snowman.net/proje
cts/ipt_recent/
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
NET4: Ethernet Bridge 008 for NET4.0
RAMDISK: bzip2 compressed image found at block 0
Freeing initrd memory: 360k freed
VFS: Mounted root (ext2 filesystem).
Freeing prom memory: 0kb freed
Freeing unused kernel memory: 88k freed

Please press Enter to activate this console.


BusyBox v1.00-pre7 (2005.08.06-03:38+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.

# ifconfig eth0 192.168.2.115
# ping 192.168.2.102
PING 192.168.2.102 (192.168.2.102): 56 data bytes
64 bytes from 192.168.2.102: icmp_seq=0 ttl=64 time=1.3 ms
64 bytes from 192.168.2.102: icmp_seq=1 ttl=64 time=0.7 ms
64 bytes from 192.168.2.102: icmp_seq=2 ttl=64 time=0.7 ms

--- 192.168.2.102 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 0.7/0.9/1.3 ms
# ping 192.168.2.104
PING 192.168.2.104 (192.168.2.104): 56 data bytes
64 bytes from 192.168.2.104: icmp_seq=0 ttl=128 time=1.3 ms
64 bytes from 192.168.2.104: icmp_seq=1 ttl=128 time=0.7 ms
64 bytes from 192.168.2.104: icmp_seq=2 ttl=128 time=0.7 ms
64 bytes from 192.168.2.104: icmp_seq=3 ttl=128 time=0.7 ms

--- 192.168.2.104 ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 0.7/0.8/1.3 ms
#
# free
              total         used         free       shared      buffers
  Mem:        30656         6060        24596            0           52
Swap:            0            0            0
Total:        30656         6060        24596

Offline

 

#12 2006-06-15 06:35:00

HH
Developer
Registered: 2006-02-15
Last visit: 2007-03-12
Posts: 103

Re: Ethernet driver question

Glad to hear it  big_smile

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2008 PunBB