Author Topic: Missing defines in tftp.c  (Read 6122 times)

Offline Mostafa

  • Newbie
  • *
  • Posts: 7
    • View Profile
Missing defines in tftp.c
« on: November 03, 2010, 03:41:20 PM »
Hi Mark,

I added tftp support to my project and when I tried to build, I got a compile error at line 433.

uFileWrite(tftp_file_pointer, ucData, usDataLen SUBFILE_WRITE); // save the received data to file. Existing files will automatically be deleted

I traced the problem and found that the tftp.c file is missing the following lines (as seen in the ftp.c file):

#ifdef SUB_FILE_SIZE
    #define SUBFILE_WRITE  , ucSubFileInProgress
    #define SUB_FILE_ON    ,SUB_FILE_TYPE
#else
    #define SUBFILE_WRITE
    #define SUB_FILE_ON
#endif


When I added them, the project built successfully. Please confirm that these lines should be added to the tftp.c file.


On a different note, is there an ftp client? I can't seem to find any mention of an ftp client in utasker. I found the tftp client demo but no ftp client.

Best regards,

Mostafa

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2962
    • View Profile
    • uTasker
Re: Missing defines in tftp.c
« Reply #1 on: November 03, 2010, 07:37:00 PM »
Hi Mostafa

Yes, it does indeed look as though the sub-file support has not been added completely to the TFTP code.
If you are not using sub-files then adding the defines is adequate.

If however sub-files are use also an additional variable is needed, which is set when the file is opened.

#ifdef SUB_FILE_SIZE
    static unsigned char ucSubFileInProgress = 0;
#endif


#ifdef SUB_FILE_SIZE
        ucSubFileInProgress = fnGetFileType(cFile);                      // get file characteristics so that it is later handled correctly
#endif


The project includes an FTP server but not a client.

Regards

Mark

Offline Mostafa

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Missing defines in tftp.c
« Reply #2 on: November 03, 2010, 09:11:45 PM »
OK, thanks for this, Mark.

Best regards,

Mostafa

Offline Mostafa

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Missing defines in tftp.c
« Reply #3 on: November 03, 2010, 11:05:13 PM »
I am trying to uploand a new SW load to the board. Here are the particulars:

1- No serial eeprom, downloading to flash.
2- The z_Upload.bin file size is about 36K.
3- using tftp for download as I am behined a firewall, can't use servers. My board has to be a client.
4- Download seems succesful as reported by Tftpd32.
5 When inspecting the flash memory, I do see the file there starting at 0x19000 and ending at 0x216FD which jives with the exact file size.

However, when I manually reset the board no software upgrade takes place. What am I doing wrong here?  I can't use the HTTP or ftp as described in the documentation.

Any bright ideas?

Thanks,

Mostafa

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2962
    • View Profile
    • uTasker
Re: Missing defines in tftp.c
« Reply #4 on: November 04, 2010, 01:36:03 AM »
Hi Mostafa

It sounds as though the TFTP part is working correctly (that is, if the file is in memory at the correct location and the content is correct the TFTP part has done its job).

If the SW is not loaded by the boot loader after a reset this is normally due to the fact that there is a mismatch between the boot loader settings and the stored file. This is discussed here, with details for debugging it in the simulator: http://www.utasker.com/forum/index.php?topic=902.0

1) Check that the SW in in the correct format for the boot loader (with a header containing the correct reference keys)
2) Check that it is saved as a uFileSystem file (the boot loader looks for it as a file with header)
3) The conversion settings must match the boot loader settings (magic number, key, encryption settings if used) - related to point 1
4) The boot loader must be looking for the file at the correct location in memory.

Remember that it doesn't matter to the boot loader how the data gets there (it is used with FTP, HTTP port, USB and serial - plus TFTP in your case). The only important thing is that its format is correct and its location also matches.

Regards

Mark



Offline Mostafa

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Missing defines in tftp.c
« Reply #5 on: November 05, 2010, 02:41:29 PM »
Hi Mark,

Thanks for your prompt reply and responsiveness. I followed the instructions mentiond in the provided link on how to use the simulator to find out upload problems and was able to determine that the culprit was UPLOAD_FILE_LOCATION. There was a mismatch between the difintion in the application (0x19000) and the the bootloader (0x28400). Once that was resolved, things went smoothly and the firmware was upgraded.

Thanks again for your help,

Mostafa



Offline mont23spears

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Missing defines in tftp.c
« Reply #6 on: February 28, 2011, 07:54:47 AM »
Got some of my doubts cleared about how to use simulators...This was helpful!!