Author Topic: Simulator problems with utFAT and FTP.  (Read 17389 times)

Offline aloft

  • Newbie
  • *
  • Posts: 18
    • View Profile
Simulator problems with utFAT and FTP.
« on: July 12, 2010, 03:31:42 AM »
Hi Mark,

I'm using a stock V1.4 with utFAT enabled (which I think is enabled by default in this LM3S project).  While following the steps in the utFAT document, I'm running into a problem with FTP.  I'm having problems connecting via Telnet but that is a different issue.  After I do successfully connect with Telnet and format the SD card, I try to upload the html pages in the WebPages directory.

After loading these pages to the FTP server using the copy_all.bat file, if I look at the FTP server with FileZilla, the pages all have January 00 1980 prepended on each file.  I'm able to successfully load these files without the utFAT enabled (if I delete the SD_CARD.bin file) and see them correctly on the browser.  Is there something else I'm missing?  Attached is the screen capture of the uTasker FTP server after I've uploaded the files.

Thanks,

TW

Offline aloft

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Simulator problems with utFAT and FTP.
« Reply #1 on: July 12, 2010, 03:47:41 AM »
Hi Mark,

Maybe I'm doing something wrong because with a Telnet DIR command, the files look OK (except for weird time/data stamps).  See the attachment.

However, something isn't working right because the http://192.168.0.3/0Menu.htm shows the uTasker Error 404 orange background page so I'm not looking in the right place for this file..  I'll start looking at this but I'm hoping you can direct me to where I need to focus.

If I put a breakpoint in fnDoWebPage(), it looks as if the utOpenFile() function fails.  It looks like uTasker isn't finding the file in the root directory.  It is also interesting seeing the ptr_utDirectory->ptrDirectoryPath is NULL.

Thanks,

TW
« Last Edit: July 12, 2010, 04:22:24 AM by aloft »

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3238
    • View Profile
    • uTasker
Re: Simulator problems with utFAT and FTP.
« Reply #2 on: July 12, 2010, 10:45:42 AM »
Hi

I am not sure exactly what is going on but here are few tips:

1) For HTTP to work with the SD card the define HTTP_UTFAT must be active.
2) The HTTP server doesn't have access to the complete SD card but uses a root directory defined by #define HTTP_ROOT              "dir1". In this case all web content needs to be in this directory (dir1) or else it will not exist. This protects SD card content because the web server then only has access to this restricted directory (and sub-directories). You need to have this directory on the SD card and the web pages need to be in it.
3) When connecting to the web server without specifying a file name, the file to be accessed is defined by #define DEFAULT_HTTP_FILE      "index.htm". Therefore a start page with this name is required.


4) When files are coped by FTP there is a default time stamp set. See fnSetTimeDate() in mass_storage.c. This assumes that the board has no RTC with time and data information. Note that no time/date info is passed in the FTP communication and so it is up to the FTP server to add such time stamps. If there is a local RTC a time stamp can be added in this function. In my latest development version there is support for this from some local RTCs. The data that you are seeing isn't correct because it should be a fixed from the 3.1.2010 - this I can't explain at the moment but this shouldn't be that serious for first tests.

5) FTP accesses the SD card at the root of the SD card (top level) and so can access all of the card.

6) Check that you have patches from http://www.utasker.com/forum/index.php?topic=792.0 (you won't need then for first testing but there are some required when working with larger file structures).

Regards

Mark

Offline aloft

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Simulator problems with utFAT and FTP.
« Reply #3 on: July 12, 2010, 02:17:01 PM »
Thanks Mark. 

I completely missed the dir1 directory setup.  Now it works on the simulator but I can't get the LM3S6965 EV board to work yet.  I've probably missed something there.

Thanks,

TW

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3238
    • View Profile
    • uTasker
Re: Simulator problems with utFAT and FTP.
« Reply #4 on: July 12, 2010, 05:28:05 PM »
Hi

I found that I needed to add a pull-up resistor (4k7 for example) on the SDI line on this board to get it to work.
Just recently I managed to get an it to work without a pull-up on the LM3S1958, whereby the configuration is below:

        // Configure to suit SD card SPI mode at between 100k and 400k
        //
        #define SPI_CS1_1                  PORTE_BIT1
        #define INITIALISE_SPI_SD_INTERFACE() RCGC2 |= CGC_GPIOE; GPIOAFSEL_E = 0; \
                                           _CONFIG_PERIPHERAL(E, SSI1, 1, (PORTE_BIT0 | PORTE_BIT3), (PE0_SSI1Clk | PE3_SSI1Tx)); \
                                           _CONFIG_DRIVE_PORT_OUTPUT_VALUE(E, PORTA_BIT2, PORTA_BIT2); \
                                           _CONFIG_DRIVE_PORT_OUTPUT_VALUE(E, SPI_CS1_1, SPI_CS1_1); \
                                           SSICR1_1 = 0; SSICPSR_1 = 2; \
                                           SSICR0_1 = (FRS_FREESCALE_SPI | SSI_SPH | SSI_SPO | DSS_8_BIT | ((((MASTER_CLOCK/2 + 300000/2)/300000) - 1) << SSI_SCR_SHIFT));

        #define ENABLE_SPI_SD_OPERATION()  SSICR1_1 = SSI_SSE
        #define SET_SD_CARD_MODE()         _CONFIG_PORT_PULLUP(E, PORTE_BIT2); _CONFIG_PERIPHERAL(E, SSI1, 1, (PORTE_BIT2), (PE2_SSI1Rx))
        // Set maximum speed
        //
        #define SET_SPI_SD_INTERFACE_FULL_SPEED() SSICR0_1 = (FRS_FREESCALE_SPI | SSI_SPH | SSI_SPO | DSS_8_BIT | ((((MASTER_CLOCK/2 + 12000000/2)/12000000) - 1) << SSI_SCR_SHIFT))
        #ifdef _WINDOWS
            #define WRITE_SPI_CMD(byte)    SSIDR_1 = (unsigned char)byte; SSIDR_1 = _fnSimSD_write((unsigned char)byte)
            #define WAIT_TRANSMISSON_END() while (SSISR_1 & SSI_BSY) { SSISR_1 &= ~SSI_BSY; }
        #else
            #define WRITE_SPI_CMD(byte)    SSIDR_1 = (unsigned char)byte
            #define WAIT_TRANSMISSON_END() while (SSISR_1 & SSI_BSY) {}
        #endif
        #define READ_SPI_DATA()            (unsigned char)SSIDR_1

        #define POWER_UP_SD_CARD()                                       // apply power to the SD card if appropriate
        #define POWER_DOWN_SD_CARD()                                     // remove power from SD card interface
        #define SET_SD_DI_CS_HIGH()        _SETBITS(E, SPI_CS1_1)        // force DI and CS lines high ready for the initialisation sequence
        #define SET_SD_CS_LOW()            _CLEARBITS(E, SPI_CS1_1)      // assert the CS line of the SD card to be read
        #define SET_SD_CS_HIGH()           _SETBITS(E, SPI_CS1_1)        // negate the CS line of the SD card to be read

Note that during the initial configuration is SDI line is configured as a port input with pull-up resistor. Only when the SPI mode has commanded is it reconfigured as SPI input.

You may be able to solve it be changing the EK_LM3S6965 configuration to do the same; if not add a pull-up should solve it.

I also noticed that the loss of time and date when writing files is known and there is a patch for it in the patch list: http://www.utasker.com/forum/index.php?topic=792.0(point 3).

Regards

Mark

Offline aloft

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Simulator problems with utFAT and FTP.
« Reply #5 on: July 13, 2010, 11:43:18 AM »
Hi Mark,

I'm still having problems but I just realized that maybe I'm not initializing the SPI interface.   Right now, I'm just defining SDCARD_SUPPORT.  Do I also need to define SSC_INTERFACE or SPI_INTERFACE?  It looks to me like these are just for SPI EEPROM chips, but maybe I'm missing something else.

It also might be the SD cards I'm using.  The 2GB card doesn't work at all and the 1GB card has a message saying V1 and MMC are not supported which you state in the documentation.  I added a pullup to the SSTX line which connects to the DI line but I'm still seeing issues.  I was able to read the 1GB card using the Luminary Micro sd_card project so I know the interface works.  Unfortunatley, the 2GB card did not work with the sd_card project.

I'm also going to try adding a pullup to the CS line.  That may help.

Thank you for all your help,

TW

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3238
    • View Profile
    • uTasker
Re: Simulator problems with utFAT and FTP.
« Reply #6 on: July 13, 2010, 01:23:58 PM »
HI

Only SDCARD_SUPPORT is required. Thsi automatically uses the corresponding SPI interface.

If you are getting messages from the 1G card it sounds as though it can basically communicate. The pull-up that I used was on the SSRX line.

When the other card is inserted try the "info" command. This will show whether a card has been detected or no - it may be that it is detected but is not formatted, or that it has a different FAT formatted on it. In this case it can be formatted with the appropriate command.

Regards

Mark

P.S. Note that the size of the SD card should be a problem since the utFAT supports HCSD from 2G and also smaller ones.

« Last Edit: July 13, 2010, 01:25:53 PM by mark »