Mini2440: Bug in DM9000 Driver for CE ?

Max Penth
Hello,

i'm experiencing problems similar to those:
http://www.friendlyarm.net/forum/topic/9

When downloading a file via FTP or sending packets (TCP or UDP) from the
device it doesn't take long for the driver to crash. Crashing means the
device loses its IP address (at least its not possible to ping it anymore).

What seems to be strange is when sending UDP Packets after the crash (TCP
not possible because it cant handshake anymore) packets will be send to the
network (can be sniffed with Ethereal or Wireshark), but it doesn't send
UDP packets, it sends out raw Ethernet-II-Frames. So it appears that the
device driver has problems to communicate with the upper layers after the
crash.

When limiting transmit speed to about 20 kb/s it seems to run a long time
without a crash. However, when increasing the number of parallel send
threads the crash occurs pretty quickly, even with limited transfer rate
per thread.

Obviously limiting the speed to 20 kb/s and just one thread can't be the
solution to this. 

After finding the solved bug in the linux driver I suspect the CE bug to be
similar.

I hope someone with more experience in driver developing could look into
this.

To reproduce the problem just set up a mini2440-Board with CE 5.0 and an
FTP-Server and try to download a bunch of files (e.g. \windows), it should
crash pretty quickly. The problem isn't caused by the FTP-Server because I
have the same issues with a custom socket application.

Baldwin
Hello,

I have exactly the same problem. It seems that there's really a bug in that
driver.

Any ideas ?
Thank you

Max
After having to rebuild a new OS for the new 128MB-Boards this error seems
to be gone, at least I can't get it to crash anymore, stable FTP
downloading with ~600 kb/s.

I used this BSP to build my OS:
http://www.andahammer.com/Downloads/mini2440-en.rar

Baldwin
Hello again,

Currently I'm using the BSP indicated as mini2440-bsp-en-090901 (last
version). 
This driver is crashing sometimes using FTP. Please note that crashing is
not inmediate... it needs about 5-6 ftp downloads of 1Mb file and about 5-6
dirs in windows directory.

Examining the BSP DM9000 driver code I encountered a problem that can cause
this driver to crash. I'm not an expert in WCE driver development, but I
think that there's a possible workarond to solve this:

As I understand, the DM9000 has memory to alloc up to 2 IP TX packets (I
and II), but the driver is using these 2 packets incorrectly. In fact, the
driver is sending these two packets without any check. The DM9000 datasheet
indicates "... The D9000 starts to trasmit the index I packet. BEFORE the
trasmission of the index I packet ends, the data of the next (index II)
packet can be moved to TX RAM.", but also "AFTER the index I packet ends
trasmission, write the byte count data of the index II to BYTE_COUNT
registed an then set the bit 0 of TX control register to trasmit the index
II packet". The driver is NOT checking if pack I is trasmitted before
setting length and send packet II. This timing can cause, in some
conditions, the driver to fail to a non recoverable status (the m_nTx
variable has a wrong value and can't be recovered).

As a workaround I modified the driver to send only one packet at a time:
In file "dm9000.cpp", function C_DM9000:DeviceSend (..), replace the line
"for (;m_nTx < 2;)" by line "for (;m_nTx < 1;)".

In my case this is solving the crash, but in theory is also slowing the
transfers (I didn't notice any slowdown).

I hope this post helps to modify the driver in a more elegant way.

matt_Damon
Hello,

Did the above fix solve the problem?  I am using the build-in web server
and randomly the web server hangs and does not even respond to ping.  I
tried to built my own web server, but with it I am not able to send data
more than 16KB, I don't know why?

Thanks,
Jagan.

Baldwin
Hello matt,

The above dm9000.cpp fix solved completely the bug (at least in my case).

Regards
Baldwin

matt_Damon
Hello,

It solved hte problem! thanks for the tip!

I was also able to change the Web Server Port using the regedit tool.

There is a software known as mobile registery editor which connects through
Sync to MINI2440 and then under services you can chnage the port from
default 80 to 75 for example.  Remember the value under services is in HEX,
so we will have to input the new value in HEX.

The port itself is little bit confusing , it is someting like 00 00 50
00...,
we will have to only change 50 to 4B to have the new port 75 instead of 80.

Hope this helps...

luyaotang
Thanks ,it fix my problem too..

Stranet
Hi to all.
I hope you still reading this post.

I need to use a mini2440 WinCE board for a school project, may you share a
WinCE5-Os image so I can directly use the fix?

Really thank you.