Helpful ReplyHot!How to enable SST25 to store web pages ?

Author
Emcy
Super Member
  • Total Posts : 473
  • Reward points : 0
  • Joined: 2008/01/09 03:37:06
  • Location: 0
  • Status: offline
2018/01/04 09:06:49 (permalink)
0

How to enable SST25 to store web pages ?

Hello,
 
How must I configure Harmony configurator to store web pages in an external flash (SST25) for HTTP NET Server ?
 
I use PIC32MZ
 
Thanks
 
post edited by Emcy - 2018/01/04 09:09:28
#1
bblessing
Super Member
  • Total Posts : 540
  • Reward points : 0
  • Joined: 2008/12/04 06:44:21
  • Location: Cincinnati, OH
  • Status: online
Re: How to enable SST25 to store web pages ? 2018/01/04 09:55:01 (permalink)
0
Before you go too much further, it will most assuredly be pointed out that SST25 chips are deprecated and not recommended for new designs. You'll find that the SST26 chips are MUCH easier to work with, and faster, since they use page writing as opposed to the auto-increment address (word) writing.
 
Also, is this SPI or SQI? Bear in mind that you have a metric crapton of flash in a PIC32MZ. Why not just use internal flash as your storage medium?
#2
Emcy
Super Member
  • Total Posts : 473
  • Reward points : 0
  • Joined: 2008/01/09 03:37:06
  • Location: 0
  • Status: offline
Re: How to enable SST25 to store web pages ? 2018/01/05 01:09:42 (permalink)
0
I want use SST26 but in SPI mode (not SQI).
SST25 is managed by SPI driver but but not for SST26 : It isn't a problem because it is easy to adapt SPI driver source code to manage SST26 (I bought SST25 to test source code before to try to implement SST26).
 
I can't use SQI mode because with 64-pin PIC32, it is impossible to use SPI and Ethernet peripherials (SPI peripherial use same pins that Ethernet peripherial).
 
I want to use external flash because I need all memory of internal flash to store my program.
 
Where can I find a exemple to use Harmony with SST25 ?
 
 What is volume name that I must use ?
 
 
post edited by Emcy - 2018/01/05 02:25:28
#3
bblessing
Super Member
  • Total Posts : 540
  • Reward points : 0
  • Joined: 2008/12/04 06:44:21
  • Location: Cincinnati, OH
  • Status: online
Re: How to enable SST25 to store web pages ? 2018/01/05 09:52:07 (permalink)
4 (1)
For now, try and get the web server up and running with internal flash. It's tried, true, and tested. Therefore, the people on these fora will be able to help you get that up and running. It's best to be systematic: if you know that your web server runs internally then anything that screws up attempting to run it out of flash is probably due to your SST25, SPI, or file system service setup.
 
Under your SST25 driver, you'll need to register it with the file system; there is an option available to do this in 2.05. The file system will need to be setup for MPFS, which is the filesystem that Microchip uses for these webpages. You will also need to include a call to mount somewhere in your code to ensure that the file system is mounted properly.
 
This is going to add some blocking to your code, though I'm not sure how much. The MPFS driver sits in a loop with the tasks function for the SST25 driver. You may need to make your SPI tasks driver run in interrupt mode for this to work.
#4
Emcy
Super Member
  • Total Posts : 473
  • Reward points : 0
  • Joined: 2008/01/09 03:37:06
  • Location: 0
  • Status: offline
Re: How to enable SST25 to store web pages ? 2018/01/08 01:03:12 (permalink)
0
My code operate with internal flash but not with external flash.
 
In app.c, I do :

 
       #define SYS_FS_DRIVE                        "SST25"
       #define SYS_FS_SST25_VOL                    "/dev/mtda1"
 
 
 
        case APP_MOUNT_DISK:
            if(SYS_FS_Mount(SYS_FS_SST25_VOL, LOCAL_WEBSITE_PATH_FS, MPFS2, 0, NULL) == 0)
 
            {
                SYS_CONSOLE_PRINT("SYS_Initialize: The %s File System is mounted\r\n", SYS_FS_MPFS_STRING);
                appData.state = APP_TCPIP_WAIT_INIT;
            }
            break;
 
           ...
 

 
Flash ID check is passed in SPI driver.
 
When I try to open a webpage, HTTP connection is reseted
DHCP and discover operate.
 
 
 
post edited by Emcy - 2018/01/08 01:04:41
#5
bblessing
Super Member
  • Total Posts : 540
  • Reward points : 0
  • Joined: 2008/12/04 06:44:21
  • Location: Cincinnati, OH
  • Status: online
Re: How to enable SST25 to store web pages ? 2018/01/08 08:21:01 (permalink)
0
Do you have anything else on the SPI bus?
#6
friesen
Super Member
  • Total Posts : 1823
  • Reward points : 0
  • Joined: 2008/05/08 05:23:35
  • Location: Indiana, USA
  • Status: offline
Re: How to enable SST25 to store web pages ? 2018/01/08 15:20:52 (permalink)
0
Are you using DMA?  If so mpfs may require some modification.

Erik Friesen
#7
friesen
Super Member
  • Total Posts : 1823
  • Reward points : 0
  • Joined: 2008/05/08 05:23:35
  • Location: Indiana, USA
  • Status: offline
Re: How to enable SST25 to store web pages ? 2018/01/08 15:27:21 (permalink) ☄ Helpfulby Emcy 2018/01/09 02:40:59
5 (1)
http://www.microchip.com/forums/m1029579.aspx  I'm not sure what it will take for your driver, just know it took some fiddling for sqi.

Erik Friesen
#8
Emcy
Super Member
  • Total Posts : 473
  • Reward points : 0
  • Joined: 2008/01/09 03:37:06
  • Location: 0
  • Status: offline
Re: How to enable SST25 to store web pages ? 2018/01/09 02:40:20 (permalink)
0
I don't use anything else on SPI.
I don't use DMA.
@friesen : there is same problem on mpfs.c for SPI flash (I fixed while loop and now, Harmony initialization operate... now I must modify HTTP Net server to upload MPFS file : mpfsupload page doesn't operate).
 
 
SYS_DEVCON_DataCacheInvalidate() is usefull only if I use DMA on SPI peripheral ?


 
post edited by Emcy - 2018/01/09 06:55:26
#9
Emcy
Super Member
  • Total Posts : 473
  • Reward points : 0
  • Joined: 2008/01/09 03:37:06
  • Location: 0
  • Status: offline
Re: How to enable SST25 to store web pages ? 2018/01/09 07:01:56 (permalink)
0
The best way to manage SST26 in SPI mode is to upgrade SST25 SPI driver or SST26 SQI driver ?
#10
friesen
Super Member
  • Total Posts : 1823
  • Reward points : 0
  • Joined: 2008/05/08 05:23:35
  • Location: Indiana, USA
  • Status: offline
Re: How to enable SST25 to store web pages ? 2018/01/09 07:42:58 (permalink)
0
I'm not sure what you are asking.  However, I will say that the SST26 SQI driver isn't without some headache.  I think you could get it to work in SPI mode with some fiddling with the mode bits in the sqi driver, but its not documented.

Erik Friesen
#11
Emcy
Super Member
  • Total Posts : 473
  • Reward points : 0
  • Joined: 2008/01/09 03:37:06
  • Location: 0
  • Status: offline
Re: How to enable SST25 to store web pages ? 2018/01/10 02:15:57 (permalink)
0
I will modify SST25 SPI driver to integrate SST26 : it will be easier.
 
Now I can upload MPFS file in SST25 (32MB) and display web pages :)
 
Harmony 2.05 update...
 
system_config.h

 
#define USE_FS_SST25
#define SYS_FS_DRIVE                        "SST25"
#define SYS_FS_SST25_VOL                    "/dev/mtda1"
 

 
 
app.c -> APP_Tasks()

 
    switch(appData.state)
    {
        case APP_MOUNT_DISK:
            #if defined(USE_FS_SST25)
            if(SYS_FS_Mount(SYS_FS_SST25_VOL, LOCAL_WEBSITE_PATH_FS, MPFS2, 0, NULL) == 0)
            #elif defined(SYS_FS_SD_VOL)
            if(SYS_FS_Mount(SYS_FS_SD_VOL, LOCAL_WEBSITE_PATH_FS, MPFS2, 0, NULL) == 0)
            #elif defined(SYS_FS_NVM_VOL)
            if(SYS_FS_Mount(SYS_FS_NVM_VOL, LOCAL_WEBSITE_PATH_FS, MPFS2, 0, NULL) == 0)
            #endif
            {
                appData.state = APP_TCPIP_WAIT_INIT;
            }
            break
 

 
 
drv_sst25_local.h

 
#define DRV_SST25_NUM_DEVICE_SUPPORTED  (7)
 

 
 
drv_sst25.c

 
const uint32_t gSstFlashIdSizeTable [DRV_SST25_NUM_DEVICE_SUPPORTED][2] = {
    {0x49, 0x20000},  /* SST25VF010A - 1 MBit */
    {0x8C, 0x40000},  /* SST25VF020B - 2 MBit */
    {0x8D, 0x80000},  /* SST25VF040B - 4 MBit */
    {0x8E, 0x100000}, /* SST25VF080B - 8 MBit */
    {0x41, 0x200000}, /* SST25VF016B - 16 MBit */
    {0x4A, 0x400000}, /* SST25VF032B - 32 MBit */
    {0x4B, 0x800000}  /* SST25VF064C - 64 MBit */
};
 

 
 
mpfs.c -> MPFSDiskRead()

 
    do
    {
        SYS_FS_MEDIA_MANAGER_TransferTask (diskNum);
        commandStatus = SYS_FS_MEDIA_MANAGER_CommandStatusGet(diskNum, commandHandle);
    } while (commandStatus != SYS_FS_MEDIA_COMMAND_COMPLETED);
 

 
mpfs.c -> MPFS_Mount()

 
    if (memcmp((void*)&gSysMpfsFileRecord, (const void*)"MPFS\x02\x01", 6) != 0)
    {
        diskNo = 0;
    } else {
        if (MPFSGetArray(diskNo, 6, 2, (uint8_t*)&gSysMpfsObj.numFiles) == false)
        {
            return MPFS_DISK_ERR;
        }
    }
 

 
 
http_net.c -> TCPIP_HTTP_NET_FSUpload()

 
                #ifdef USE_FS_SST25
                if(SYS_FS_Mount(SYS_FS_SST25_VOL, LOCAL_WEBSITE_PATH_FS, MPFS2, 0, NULL)  != SYS_FS_RES_FAILURE)
                #else
                if(SYS_FS_Mount(SYS_FS_NVM_VOL, LOCAL_WEBSITE_PATH_FS, MPFS2, 0, NULL)  != SYS_FS_RES_FAILURE)
                #endif
 

 
I don't integrate friesen cache management functions and it operates.
post edited by Emcy - 2018/01/10 02:59:10
#12
Emcy
Super Member
  • Total Posts : 473
  • Reward points : 0
  • Joined: 2008/01/09 03:37:06
  • Location: 0
  • Status: offline
Re: How to enable SST25 to store web pages ? 2018/01/12 08:58:01 (permalink)
0
Hello,
 
I made a debug function to see data in SST25 Flash. This function is called in  APP_Tasks() :

 
void DEBUG_SYS_FS_MEDIA_MANAGER_TASK(void){
    
    typedef enum {
        DEBUG_SYS_FS_MEDIA_MANAGER_SM__INIT = 0,
        DEBUG_SYS_FS_MEDIA_MANAGER_SM__READ_CMD,
        DEBUG_SYS_FS_MEDIA_MANAGER_SM__READ_STATUS,
        DEBUG_SYS_FS_MEDIA_MANAGER_SM__END
    } DEBUG_SYS_FS_MEDIA_MANAGER_SM;    
    static DEBUG_SYS_FS_MEDIA_MANAGER_SM sm = DEBUG_SYS_FS_MEDIA_MANAGER_SM__INIT;
    
    static SYS_FS_MEDIA_BLOCK_COMMAND_HANDLE sysFsMedia_handle;
    static uint8_t data[4096];
    static uint32_t sector_num = 0;
    
    switch(sm){
        default:
        case DEBUG_SYS_FS_MEDIA_MANAGER_SM__INIT :
            sm = DEBUG_SYS_FS_MEDIA_MANAGER_SM__READ_CMD;
            break;
        
        case DEBUG_SYS_FS_MEDIA_MANAGER_SM__READ_CMD:
            {
                sysFsMedia_handle = SYS_FS_MEDIA_MANAGER_SectorRead(0, data, sector_num, 1);
                if(sysFsMedia_handle == SYS_FS_MEDIA_BLOCK_COMMAND_HANDLE_INVALID){
                    printf("[ERR] DEBUG_SYS_FS_MEDIA_MANAGER_TASK %p\r\n", sysFsMedia_handle);
                    return;
                }
                sm = DEBUG_SYS_FS_MEDIA_MANAGER_SM__READ_CMD;
                break;
            }
                        
        case DEBUG_SYS_FS_MEDIA_MANAGER_SM__READ_STATUS:
            {
                SYS_FS_MEDIA_COMMAND_STATUS status = SYS_FS_MEDIA_MANAGER_CommandStatusGet(0, sysFsMedia_handle);
                if(status != SYS_FS_MEDIA_COMMAND_COMPLETED){
                    return;
                }
                
                int i,j;
                for(j=0; j<16; j++){
                    for(i=0; i<16; i++){
                        printf("%02X ", data[(j*16)+i]);
                    }                    
                    printf("   ");                    
                    for(i=0; i<16; i++){
                        printf("%c", data[(j*16)+i]);
                    }                    
                    printf("\r\n");
                }
                
                
                sm = DEBUG_SYS_FS_MEDIA_MANAGER_SM__END;
                break;
            }
        
        case DEBUG_SYS_FS_MEDIA_MANAGER_SM__END:
            break;            
    }
    
}
 

This code doesn't operate : printf error message is displayed always (printf("[ERR] DEBUG_SYS_FS_MEDIA_MANAGER_TASK %p\r\n", sysFsMedia_handle);)
 
When I comment my code code I can display web pages but when I enable my function, I can't dusplay web pages.
 
What is the problem ?
 
Thanks
 
 
 
 
 
 
#13
friesen
Super Member
  • Total Posts : 1823
  • Reward points : 0
  • Joined: 2008/05/08 05:23:35
  • Location: Indiana, USA
  • Status: offline
Re: How to enable SST25 to store web pages ? 2018/01/12 10:15:57 (permalink)
0
I'm not sure right off, but that is real heavy right there.  If you want it to maybe work, lower your word count to minimum and baud rate to maximum.

Erik Friesen
#14
Emcy
Super Member
  • Total Posts : 473
  • Reward points : 0
  • Joined: 2008/01/09 03:37:06
  • Location: 0
  • Status: offline
Re: How to enable SST25 to store web pages ? 2018/01/16 03:21:04 (permalink)
0
Hello,
 
I think, It isn't the problem because program block before the DEBUG_SYS_FS_MEDIA_MANAGER_SM__READ_STATUS step
 
I think there is a problem for SYS_FS_MEDIA_MANAGER_SectorRead() parameters ... or perhaps this function is bugged ?
#15
Emcy
Super Member
  • Total Posts : 473
  • Reward points : 0
  • Joined: 2008/01/09 03:37:06
  • Location: 0
  • Status: offline
Re: How to enable SST25 to store web pages ? 2018/01/16 06:46:59 (permalink)
0
I found problem : all SST25 buffers are used, it must incremente value of #define DRV_SST25_BUFFER_OBJ_NUMBER
 

void DEBUG_SYS_FS_MEDIA_MANAGER_TASK(void){
    // You must incremente +1 DRV_SST25_BUFFER_OBJ_NUMBER to use this function
    
    typedef enum {
        DEBUG_SYS_FS_MEDIA_MANAGER_SM__INIT = 0,
        DEBUG_SYS_FS_MEDIA_MANAGER_SM__READ_CMD,
        DEBUG_SYS_FS_MEDIA_MANAGER_SM__READ_STATUS,
        DEBUG_SYS_FS_MEDIA_MANAGER_SM__END
    } DEBUG_SYS_FS_MEDIA_MANAGER_SM;    
    static DEBUG_SYS_FS_MEDIA_MANAGER_SM sm = DEBUG_SYS_FS_MEDIA_MANAGER_SM__INIT;
    
    static SYS_FS_MEDIA_BLOCK_COMMAND_HANDLE sysFsMedia_handle;
    static uint8_t data[4096];
    static uint32_t sector_num = 0;
    
    switch(sm){
        default:
        case DEBUG_SYS_FS_MEDIA_MANAGER_SM__INIT :
            //DRV_SST25_RegisterWithSysFs(x, y, z)
            sm = DEBUG_SYS_FS_MEDIA_MANAGER_SM__READ_CMD;
            break;
        
        case DEBUG_SYS_FS_MEDIA_MANAGER_SM__READ_CMD:
            {
                sysFsMedia_handle = SYS_FS_MEDIA_MANAGER_SectorRead(0, data, sector_num, 1);
                if(sysFsMedia_handle == SYS_FS_MEDIA_BLOCK_COMMAND_HANDLE_INVALID){
                    printf("[ERR] DEBUG_SYS_FS_MEDIA_MANAGER_TASK %p\r\n", sysFsMedia_handle);
                    return;
                }
                sm = DEBUG_SYS_FS_MEDIA_MANAGER_SM__READ_STATUS;
                break;
            }
                        
        case DEBUG_SYS_FS_MEDIA_MANAGER_SM__READ_STATUS:
            {
                SYS_FS_MEDIA_COMMAND_STATUS status = SYS_FS_MEDIA_MANAGER_CommandStatusGet(0, sysFsMedia_handle);
                if(status != SYS_FS_MEDIA_COMMAND_COMPLETED){
                    return;
                }
                
                int i,j;
                for(j=0; j<16; j++){
                    for(i=0; i<16; i++){
                        printf("%02X ", data[(j*16)+i]);
                    }                    
                    printf("   ");                    
                    for(i=0; i<16; i++){
                        printf("%c", data[(j*16)+i]);
                    }                    
                    printf("\r\n");
                }
               
                //sm = DEBUG_SYS_FS_MEDIA_MANAGER_SM__END;
                sm = DEBUG_SYS_FS_MEDIA_MANAGER_SM__READ_CMD;
                break;
            }
        
        case DEBUG_SYS_FS_MEDIA_MANAGER_SM__END:
             // How to do to free the buffer ?
            break;            
    }
    
}

 
SYS_FS_MEDIA_MANAGER_SectorRead() reserve a buffer but I don't know how to do to free this buffer when my read operation is finished...
#16
friesen
Super Member
  • Total Posts : 1823
  • Reward points : 0
  • Joined: 2008/05/08 05:23:35
  • Location: Indiana, USA
  • Status: offline
Re: How to enable SST25 to store web pages ? 2018/01/16 07:40:40 (permalink)
0
I have my sst26 at 5 objects.

Erik Friesen
#17
Emcy
Super Member
  • Total Posts : 473
  • Reward points : 0
  • Joined: 2008/01/09 03:37:06
  • Location: 0
  • Status: offline
Re: How to enable SST25 to store web pages ? 2018/01/16 07:44:30 (permalink)
0
And this code operate for you ?
In demo project, value of DRV_SST25_BUFFER_OBJ_NUMBER is 5 and must be increment to 6 to excute my debug code.
 
#18
Emcy
Super Member
  • Total Posts : 473
  • Reward points : 0
  • Joined: 2008/01/09 03:37:06
  • Location: 0
  • Status: offline
Re: How to enable SST25 to store web pages ? 2018/01/18 01:21:14 (permalink)
0
I found a bug in drv_sst25_local.h : in DRV_SST25_OBJ structure, cmdParamsLen must be a uint16_t (not a uint8_t).
Problem is in page program write function : uint8_t is too small to store the value of 256+4 for 64Mb memories.
 
Now I can upload web pages on SST25 and SST26 and I can display web pages.
 
I would like to limit size of web pages to store custom data (config file, log files, temporary firmware, ...) : is it possible to do it without change source code of Harmony ?
 => is it possible to use MPFS2 and FAT at the same time on a Flash ?
 
post edited by Emcy - 2018/01/18 04:18:24
#19
Jump to:
© 2018 APG vNext Commercial Version 4.5