We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi,
I'm trying the RL-ARM tcp/ip stack on a arm7 LPC2368 from ETT (futurlec). I succeed setting up a TCP listen socket with the EasyWeb API. But when I try to use the TCP stack from RL-ARM 4.12 I don't succeed.
When the controller goes online, it send one packet (ARP notify) and it is filled with 'U' (55) the whole frame/packet, 1392 bytes long.
If I try to setup a TCP connection from my controller to the PC. several packets as described above appear.
Any idea?
Kind Regards.
This is the code I used: On flashmagic I have set Osc. freq to 48.0 Mhz
#include <stdio.h> #include <RTL.h> #include <LPC23xx.H> /* LPC23xx definitions */ #define MCLK 48000000 /* Master Clock 48 MHz */ #define TCLK 10 /* Timer Clock rate 10/s */ #define TCNT (MCLK/TCLK/4) /* Timer Counts */ void delay(unsigned long int); void init(void); U16 tcp_callback (U8 soc, U8 evt, U8 *ptr, U16 par); void procrec (U8 *buf); static void timer_poll (void); U8 socket_tcp; U8 rem_ip[4] = {192,168,3,68}; int main() { init(); init_TcpNet (); socket_tcp = tcp_get_socket (TCP_TYPE_CLIENT, 0, 30, tcp_callback); /* Initialize TCP Socket and start listening */ // tcp_listen (socket_tcp, 300) ; tcp_connect (socket_tcp, rem_ip, 300, 0); while(1) { timer_poll (); main_TcpNet (); } } void delay(unsigned long int count1) { count1 = count1 * 11000; while(count1-- > 0){ } } static void timer_poll () { // System tick timer running in poll mode if (T1IR & 1) { T1IR = 1; // Timer tick every 100 ms timer_tick (); } } void init() { /* Timer 1 as interval timer, reload to 100ms. */ T1TCR = 1; // Timer[1] = 100mS Trigger T1MCR = 3; T1MR0 = TCNT - 1; } U16 tcp_callback (U8 soc, U8 evt, U8 *ptr, U16 par) { if (soc != socket_tcp) { return (0); } switch (evt) { case TCP_EVT_DATA: /* TCP data frame has arrived, data is located at *par1, */ procrec(ptr); /* data length is par2. Allocate buffer to send reply. */ break; case TCP_EVT_CONREQ: /* Remote peer requested connect, accept it */ return (1); case TCP_EVT_CONNECT: /* The TCP socket is connected */ return (1); } return (0); } /*--------------------------- Process received data ------------------------*/ void procrec (U8 *buf) { switch (buf[0]) { case 49: break; } }
Do you have enough heap memory allocated?
All the default settings. Nothing I have changed. (nor in the startup file: LPC3200.c)
Net_Config.c : only TCP & UDP enabled. (and ethernet ofcourse) dhcp & netbios disabled. Arp notify disabled. #define MEM_SIZE 2000 (== Default: 8000 bytes )
Startup file: there is a setting: Heap Size: 0x0000 0000
I have added this files to one Group:
.\main.c (code above) .\LPC2300.s (uVision added this file) C:\Keil\ARM\RL\TCPnet\Drivers\LPC23_EMAC.c C:\Keil\ARM\RV31\LIB\TCP_ARM_L.lib C:\Keil\ARM\RL\TCPnet\SRC\Net_Config.c
And I used the default compiler options. Check output create Hex, and use that Hex to flash with flashmagic.
Add heap memory - at least 0x400 bytes.
I have set: Heap_Size EQU 0x00000400 also: Heap_Size EQU 0x00000800
Still the same.
I don't think TCPnet requires any heap (as specified in the startup) for 'basic' operation. The Keil example that I originally ran had it set for zero (and the current version of that demo still does).
It does, however, require a memory pool to operate. This is specified in Net_Config.C, which will be included in your project. You should check it's value.
In Net_Config.c That should be the default 8K -> #define MEM_SIZE 2000 ( * 4 = the default setting -> 8000 bytes )
I think you are right! I mixed up FlashFS with TCPNet. Ouch.
Sorry, my bad - I now see you mentioned that before.
"When the controller goes online, it send one packet (ARP notify) and it is filled with 'U' (55) the whole frame/packet, 1392 bytes long."
I'm confused about that one though. Are you saying that the packet is being sent from your board is completely filled with 'U'? or does it have the ARP message but is padded with 'U'? or something else?
Completly (the whole packet/frame) filled with 'U' (0x55) from the first byte to the last byte.
A buffer overrun somewhere? Far fetched, but worth a try...
"Completly (the whole packet/frame) filled with 'U' (0x55)..."
As a first step, I would say you need to determine whether it is a bad packet that is being generated/corrupted or the MAC that is sending rubbish.
So ... put a breakpoint in the transmit routine of LPC3200.c and see what is being passed to that.
Tomorrow I will try to printf to the terminal COM console (don't have a debugger)
LPC23_EMAC.c -> void send_frame (OS_FRAME *frame) I suppose this is located in Tx_Desc[idx].Packet ? something like:
for( i ; i<30 ; i++) { printf("%d " , Tx_Desc[idx].Packet[i]); }
Should that do it ?
thank you all for the input.
"I suppose this is located in Tx_Desc[idx].Packet ?"
That would be the destination for the data. You might want to check it.
Firstly, you need to look at the parameter 'frame' - It contains the packet length (frame->length) and actual data (frame->data).
It's defined in Net_Config.H