Author Topic: tftp tests  (Read 13699 times)

Offline twoerner

  • Newbie
  • *
  • Posts: 16
    • View Profile
tftp tests
« on: July 09, 2007, 11:21:39 PM »
app: uTasker sample app V1.3.0 with SP1-4

I don't mean to nit-pick, but in order to play around with the TFTP demo/test software, it was necessary to add the file 'stack\tftp.c' to the project, otherwise the link would fail.

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: tftp tests
« Reply #1 on: July 10, 2007, 12:02:18 AM »
Hi

Yes, this is correct. The tftp support was added in a service pack and the service packs update the code but not the project (I will look at the feasibility of including an upgraded project file in future service packs to automate this).

For example, if you look at the service pack release notes for the M5223X you will see that tftp was added with SP3 and the upgrade guide states:
"TFTP.c will have to be added to the simulation or target project if TFTP is used."

However you are correct that it would be neater if this were automated. The only risk is that it needs to be updated in all project files (VS, GNU, Eclipe, Codewarrior, IAR, and any others which are supported) and so it is difficult to shut out all chances of a mistake when adding services to an existing project.

Thanks for the tip though and I will see what can be done.

Regards

Mark

« Last Edit: July 20, 2007, 08:26:23 PM by mark »

Offline fabio

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • bandaspilamberto
Re: tftp tests
« Reply #2 on: July 27, 2007, 04:53:44 PM »
I'm not able to test the tftp bootloader.
These are the steps I have done:

1- add to target tasker project the tftp.c
2- enable in config.h of tasker and boot project the line  #define USE_TFTP   
3- enable in application.c  #define TEST_TFTP
4- set the IP of the tftp-server in application.c    ucTFTP_server_ip[IPV4_LENGTH] = {192, 168, 25, 83};
   that is the ip of my PC connected to the target with a cross cable

5- I have started filezilla server on my PC (with "anonymous" user and port 21)
6- then I have started the Ethereal to view the IP traffic

7- then start the debug. I espected the execution in application.c
    fnStartTFTP_client(tftp_listener, ucTFTP_server_ip, TFTP_PUT, "test1.txt", '0');
   to transfer local file ('0') to TFTP server and save it there as (test1.txt)

   but program never arrive to this code line, infact I have nothing in Ethereal log

   I have also some problem in debugging with codewarrior...many times an error windows compare like this
   "error occured while tryng for single step" and I cannot debug with simulator because the boot loader isn't
   implemented.

   can you help me?

   best regards
   Fabio

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: tftp tests
« Reply #3 on: July 29, 2007, 09:32:43 AM »
Hi Fabio

The first 4 steps that you have performed seem to be correct.
Step 5 seems strange because when testing TFTP you will need a TFTP server. Firezilla is an FTP (not TFTP) client and so will not be suitable (as far as I know - in any case the TFTP port number is generally 69 and there is no log-in). There are a number of free TFTP servers available on the internet. I don't have on on my PC at the moment but I think that I use something from "Wierd Solutions".

If fnStartTFTP_client(tftp_listener, ucTFTP_server_ip, TFTP_PUT, "test1.txt", '0'); is never called it is of course normal that there will be no Ethereal data collected so I have looked at possible reasons for this:
- fnStartTFTP_client() is called from fnTransferTFTP().
- fnTransferTFTP() is called after successful DHCP

This imples that USE_DHCP must be active in the project, the network parameters must have ACTIVE_DHCP set (DHCP rather than pre-defined IP settings) and it must be able to obtain its IP settings from a DHCL server.
Once the IP settings have been successfully received (usually takes about 8s after power up) then the TFTP transfer should begin.

Now I don't remember exactly why the TFTP test has been combined with the DHCP process; it was obviously a requirement when the demo was built into the project.

If you would like to test TFTF without having to also go through the HDCP process, add the following code to application.c:

Code: [Select]
    if (!iAppState) {
....
....
#ifdef TEST_TFTP
        if (!(parameters->ucServers & ACTIVE_DHCP)) {  // If we are not using DHCP
            fnTransferTFTP();                          // start test TFTP transfer
        }
#endif
    }

The only thing which is not optimum here is that the process will be started before the network link is up on the target (the simulator will immediately try to send). However this should still work because once the destination IP address has been resolved by ARP (will be successful once the link is up) the local TFTP lister will then receive the event TFTP_ARP_RESOLVED. It will then call fnTransferTFTP() again which will then start immediately.

WARNING: If the file '0' is empty, the process will also be terminated without any data being sent. In this case ensure that you have the file "0Menu.html" loaded in FLASH (or simulated FLASH) so that it can transfer something. You are correct that this file will be saved on the TFTP server with the name "test1.txt".

As you have probable already seen, there are two other test cases which can be set:
fnStartTFTP_client(tftp_listener, ucTFTP_server_ip, TFTP_GET, "test.txt", '0'); // get a file (text.txt) from TFTP server and save it locally (to file '0')
or
fnStartTFTP_client(tftp_listener, ucTFTP_server_ip, TFTP_GET_COMPARE, "test.txt", '0'); // get a file (text.txt) from TFTP server and compare it to local file ('0')
The second (TFTP_GET_COMPARE) is rather special because it collects a file from the TFTP server and compares it with the contents of the local file. It doesn't actually save anything locally. This can be useful for a boot loader since it can compare the reference software on the server with a local program (or file). If these match the callback function receives the event TFTP_TRANSFER_READ_COMPLETE.
If these don't match the callback function receives the event TFTP_FILE_NOT_EQUAL: in this case the more standard call using TFTP_GET can be executed to fetch the file but this time save it locally so that the software can be updated.
WARNING: For the compare function to work, SUPPORT_FILE_COMPARE should be activated in config.h.



Note that when debugging on the target (I assume that you are working with the M5223X) you need to ensure that the watchdog has been disabled. It is not possible to step in code with an active watchdog since it will fire and cause such an error message. Make sure that you have the laterst version of the tutorial (get it from the documents page on the uTasker web server) because there is a section addressing this, including how to avoid the problem (basically compile with watchdog disabled, force the watchdog disable after setting a break point at the appropriate location or holding the IRQ4 line to ground at reset - this is used by the demo project code to decide whether to activate the watchdog or not).

The uTasker "Bare-minimum" project doesn't have a simulator project (usually it doesn't need to be simulated because to use it only configuration parameters need changing and it should immediately run on the target).

If you are writing your own boot loader (the "BM"-Bootloader doesn't include TFTP support) then it is possible to copy the demo project and then use its simulator.

Regards

Mark

Offline fabio

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • bandaspilamberto
Re: tftp tests
« Reply #4 on: July 30, 2007, 04:35:48 PM »
Thank you Mark.
Now it is ok! I have disabled the   //#define USE_DHCP,
installed a free TFTP server called TFTPD32.exe and the demo go well, it has transferred the file text1.txt to the server.

Now I'd like transfer a file to the target and make with this a TFTP bootloader...
If you have any suggestion it will be very appreciate, sorry if it is out-of-topic...

best regards
Fabio

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: tftp tests
« Reply #5 on: July 30, 2007, 11:14:14 PM »
Hi Fabio

To implement a TFTP based boot loader it will be necessary to make a minimum project with the TFTP transfer support (code size as small as possible).

When the board starts it can check whether there is new SW available at the server (some solutions require a command to be sent first via serial port but others could include setting a port to '0' on power up to enter the mode, etc...).

Once new code has been loaded (using the check and load methods) to the correct location, the boot loader must be able to jump to this location and then run this code rather than the boot loder code. It is best that the boot loader can also verify that the application SW is valid and not corrupted, etc.

There is a thread including some discussions about starting application code from a boot loader code which may also be helpful.

Hope this helps to maybe get a first attempt started.

Regards

Mark