Author Topic: Telnet server on M52259DEMO board seems hanging  (Read 7995 times)

Offline marcelo_

  • Newbie
  • *
  • Posts: 25
    • View Profile
Telnet server on M52259DEMO board seems hanging
« on: October 11, 2010, 09:29:48 PM »
Hi Mark
Some weeks ago I asked you a related question. In these days, I could not establish a telnet connection to the board.
You adviced me to grow the heap, and I did it. Additionally, I limited the http sessions to one.
Now the connection is established ( as shown by Wireshark ), but nothing more happens: the client machine send the SYN, and the board answers SYN, ACK. But from that point nothing happens.
My heap is now 27 kb, from which some 4 kb are free; and I have 0 unused stack.
May be this stack depletion the reason the telnet server dont send the menu to the client?
Other TCP and IP funcionality is working OK: http, ftp, ping, and my own protocol.
Could you tell me what to do next?
TIA
Regards
Marcelo

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: Telnet server on M52259DEMO board seems hanging
« Reply #1 on: October 11, 2010, 10:19:52 PM »
Hi Marcelo

You need to be careful when using only 1 HTTP session since it mean that the web content needs to be kept simple. When serving pages with images the web browser will try to establish several connections at the same time (therefore enough sessions should be reserved - sessions don't require much memory  - about 70 bytes or so each). If there are not enough the images may be slow or sometimes not show and need to be refreshed.

A stack size of 0 on the target is an indication of problems (the simulator will always show zero and this doesn't have any relevance).
I would disable some other protocols (FTP etc.) until you get normal readings for heap and stack use. If TELNET then works there is a memory issue. I don't know of any other reasons why the connection works but then nothing else. To be sure also monitor the heap use before and after the TELNET connection. It should increase on first connection when its buffered TCP buffer is allocated. If there is no increase it means that the allocation failed - it then can't send anything.

Regards

Mark


Offline marcelo_

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Telnet server on M52259DEMO board seems hanging
« Reply #2 on: October 12, 2010, 05:37:12 PM »
Hi Mark
Thank you.
The whole thing seems strange.
Beforehand, I must to tell that my application specific TCP/IP communication is done using fnSendBufTCP() to relieve my code from NACKs treatment. And I would like to get Telnet as a mean of debugging and logging.
I incremented again the heap size, this time to 28262 bytes.
When the board starts, and cannot connect with the server ( because it's down ) my readings are
Heap free: 7750 bytes
Stack unused: 0 bytes
After that, I can
1) Start the application server. When the connection is up and the board sends its first "handshake" frame, the values are
Heap free: 4906 byte
Stack unused: 0 bytes ( of course )
In this stage, if I try to connect the telnet server, the board resets ( under watchdog command, I suppose ).
2) Alternatively, on board reset with no app server up, I can connect the telnet server, and get the telnet menu.
Of course, the heap and stack figures are equal.
Once the telnet session is established, if I start my app server, when the board tries to send the handshake, again the watchdog detects an anomaly and resets the board.
After the first TCP buffer allocation, the heap is reduced by 2844 bytes, which matches sizeof(tcp-buffer), and remains 4906, which would suffice to allocate a second TCP buffer, but it's clear that it does not happens.
Could you give me a tip regarding this? I was diving the code to find a way to increment the stack size but at no luck.

Another strange thing is when the telnet connection is established. After the board sends the menu, a few seconds later two debugging messages starts to appear, one after the other, once and again:
TIMEOUT!!!
No valid SD-card
I traced both to mass_storage.c, but cannot find why the app is trying to access an SD card.

Thank you in advance, Mark.

Best regards

Marcelo





Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: Telnet server on M52259DEMO board seems hanging
« Reply #3 on: October 12, 2010, 07:42:38 PM »
Hi Marcelo

I still have the feeling that the fact that you don't have a positive stack value is the real issue here.

Check the linker script file that you are using since they are usually set up for the smaller processors with less internal SRAM - this is because the demo project will normally be able to run on the smaller ones. Since the M52259 has 64k of SRAM make sure that it is using all of it (check the following settings in the script file - eg. M52235EVB_FLASH.lcf in \Applications\uTaskerV1.4\CodeWarrior_M5223X\cfg):
Code: [Select]
    sram    (RWX)  : ORIGIN = 0x20000400, LENGTH = 0x0000fC00

___SRAM = 0x20000000;
___SRAM_SIZE = 0x00010000;

If you find that 32k is being used instead increase it accordingly since you should in fact have a large amount of stack available when using 28k heap size.

If you have SD card support active, the mass-storage task will be regularly trying to mount a card. The error error message that you are seeing is the result of the test, which is repeated every 5s or so (define SD_CARD_RETRY_INTERVAL). The M52259DEMO doesn't have an SD card socket so you can disable SD card support unless you want to connect an external socket. [Note that the M52259 Tower Kit does have an SD card socket when the LCD extension card is used - see http://www.youtube.com/watch?v=AdtRyQ-2IrE]

Regards

Mark

Offline marcelo_

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Telnet server on M52259DEMO board seems hanging
« Reply #4 on: October 12, 2010, 08:08:48 PM »
Hi Mark
That was the problem: a too little stack. I followed your hints and all is working now.
Thank you again.
Best regards
Marcelo

PS Regarding the SDCARD_SUPPORT manifest, I commented it and the errors disappeared. But on another thread I asked you how to enable utFat on an USB device.