Hi guys,
I have been playing (almost wanting to strangle) with your port of uip
to the avr. I'm using a atmega128 with an additional 32kb of external
sram and a spi flash chip for data (ie. web page) storage and using a
prebuilt enc28j60 ethernet modules from
www.modtronix.com.au.
I am working on a project that requires a webserver and as such have
been trying to get the code to work well for me. I am using efsl to
store/retrieve webpages from a flash chip. I have found that the
psock code is particularly buggy. I have rewritten parts of it, but
it is still in an untidy state so I'm not going to share it quite yet.
I have also found 2 bugs in the enc28j60.c file. According to the
erratas for the chip the delay after a reset should be at least 1ms
(1000us). So the code that read:
void enc28j60Init(void)
{
// perform system reset
enc28j60WriteOp(ENC28J60_SOFT_RESET, 0, ENC28J60_SOFT_RESET);
// check CLKRDY bit to see if reset is complete
_delay_us(50);
while(!(enc28j60Read(ESTAT) & ESTAT_CLKRDY));
should be changed to be a delay of 1000 (ie. _delay_us(1000);). I was
having issues where after a reset the device would not respond. This
appears to have fixed it.
I have also been having problems with packets not actually getting
sent (using wireshark to monitor the network). This i have tracked
down to trying to send a packet before the sending of the previous one
was completed. Changing the start of the enc28j60PacketSend function
to read as:
void enc28j60PacketSend(unsigned int len1, unsigned char* packet1,
unsigned int len2, unsigned char* packet2)
{
//srr - wait until ready to send
while(enc28j60Read(ECON1) & ECON1_TXRTS);
//Errata: Transmit Logic reset
enc28j60WriteOp(ENC28J60_BIT_FIELD_SET, ECON1, ECON1_TXRST);
enc28j60WriteOp(ENC28J60_BIT_FIELD_CLR, ECON1, ECON1_TXRST);
has fixed this. This simply adds a check to make sure that the
previous packet has finished sending before continuing. This is
probably only a problem if the avr is running at 16Mhz or more. I
discovered this as I was removing debug printf's to the uart that made
the code run more efficiently.
Some other things that should be done in an avr port is to ensure that
all the static strings are stored in flash and not copied to sram
(progmem stuff).
It would also be nice to figure out how to clean up all the
compilation warnings. There were some other things that I can't
remember at the moment.
Hope this input is useful.
Cheers
Simon.