Author Topic: TFTP with uTasker v1.3 SP1  (Read 9319 times)

Offline Jamier

  • Newbie
  • *
  • Posts: 14
    • View Profile
TFTP with uTasker v1.3 SP1
« on: February 12, 2008, 07:11:27 AM »
Hi,

I tried to send and receive a file via TFTP without success. 

I think I am missing something important... I have no problem with FTP.

Perhaps TFTP is not intended for general file transfers - maybe only in a bootloader?

My target board is custom hardware with the NE64 micro.  I have TCP/IP connectivity - FTP, DHCP, HTTP are all working.

Any suggestions?

Thanks.

Jamie.

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: TFTP with uTasker v1.3 SP1
« Reply #1 on: February 12, 2008, 12:00:17 PM »
Hi Jamie

Are you trying the TFTP demo? (defines USE_TFTP in config.h + define TEST_TFTP in application.c).
This demo needs DHCP and, when DHCP is successful, it collects a file from a TFTP server, copies a file to a TFTP server or compares the contents for a local file with that on a TFTP server.

You need to have a TFTP server running and its address must be set in ucTFTP_server_ip[].

Are you recording the Ethernet activity since this will help to see whether it is trying or whether there is a network configuration problem. You can also test with the uTasker simulator in case you think that the target may be the cause of problems (eg. limited resources).

The demo is general purpose and so has nothing to do with a boot loader mode - it should operate the same wherever running.

Regards

Mark


Offline Jamier

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: TFTP with uTasker v1.3 SP1
« Reply #2 on: February 16, 2008, 08:44:38 AM »
Hi Mark,

I was able to get TFTP to transfer a file to the PC when I enabled the TEST_TFTP using the simulator.  Thanks. 

However, I could not send a file to the NE64 until I made two changes in the code:

1. In file tftp.c, function fnGetFileMode(), I had to change !uStrEquiv(cOctet, Data) to uStrEquiv(cOctet, Data).  The code is looking for a match in the TFTP transfer mode and the logic was reversed.  Once I made the change, I could get a bit further so that TFTP transfer could be initiated.

2. In file tftp.c, function fnTFTPListner(), the line:
               else if (!(ucTFTP_state & TFTP_STATE_CLIENT) && (!uMemcpy(ucIP, cucBroadcast, IPV4_LENGTH))) {

         had to be changed to :

               else if (!(ucTFTP_state & TFTP_STATE_CLIENT) && (!uMemcmp(ucIP, cucBroadcast, IPV4_LENGTH))) {

It lookse like the original call to uMemcpy should have been Memcmp.  The comment was "// server not allowed to accept a broadcast address" so it seems you would want to do a mem compare rather than a mem copy.

Once I made those changes I could send a file and verify it was recieved by connecting via FTP and getting a directory listing. Are these correct changes?


Now that I see TFTP working, I am a bit unclear on how one would enable this for application use.  The define for TEST_TFTP suggests that this is only used for testing the TFTP functionality.

For application use, would one simply call fnStartTFTP_client() at start up (or maybe at some user initiated prompt during runtime) to activate the TFTP functionality?

Also, there would probably have to be some way to set and save the TFTP server IP at runtime as hard coding it at compile time would likely impose an unacceptable constraint for most applications.  This should be simple enough for me to do via a webpage.

 Jamie


Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: TFTP with uTasker v1.3 SP1
« Reply #3 on: February 16, 2008, 02:20:36 PM »
Jamie

Many thanks for the valuable feedback. The two corrections that you made do seems to be necessary and I am amazed that these haven't been noticed before - the TFTP has been used in real projects before now so there must have been some luck involved... I have made these corrections in the code ready for future releases.

It is right that the TFTP code is demonstration code - it allows simple checking that it is possible to transfer files or else compare the contents of a file on a server (which is a rather special case but useful for code updates). This can also be simply tested using the uTasker simulatro and a TFTP server (program) locally or somewhere on the network. To use it in a real application requires that the test code be added to a suitable location in the real code. The client can be started either duing initialisation (as in the demo) or on demand by another program.

The IP address of the TFTP server is hard-coded in the demo (quick and dirty but OK - also used in various real projects though). This can however be from a RAM location which can be made configurable (eg. in the parameter system like the local IP address or SMTP settings etc.)

fnStartTFTP_client(tftp_listener, ucTFTP_server_ip, TFTP_PUT, "test1.txt", '0');

ucTFTP_server_ip is passed when starting the client and can be a pointer to the presently valid IP address in RAM or in FLASH and not necessarily a const value in the code. Also the file could be made a parameter.

Regards

Mark