Hot!SPI flash drivers for Harmony

Author
RUrbas
New Member
  • Total Posts : 9
  • Reward points : 0
  • Joined: 2018/07/03 10:55:47
  • Location: 0
  • Status: offline
2018/08/08 06:47:29 (permalink)
0

SPI flash drivers for Harmony

Hi everyone,
I'm working on a project and I need to use SPI flash memory. However in harmony there are only drivers for SST25 memory chips. Does someone have experience modifying these drivers to work with other chips?
 
I have S25FL128SAGMFI001 chip and PIC32MZ2064DAH176. Harmony version 2.05
 
I need memory to be at least 128 Mbit, so SST25 chips are not suitable, if I'm not mistaken (they are 64 Mbit max?).
Maby you know some other memory chip that would be better/easier to use with SST25 drivers, or maby you have and can share some custom SPI flash drivers.
What SPI flash memory chips have you used with harmony?
 
All suggestions are welcome.
#1

12 Replies Related Threads

    jdeguire
    Super Member
    • Total Posts : 437
    • Reward points : 0
    • Joined: 2012/01/13 07:48:44
    • Location: United States
    • Status: offline
    Re: SPI flash drivers for Harmony 2018/08/08 07:59:08 (permalink)
    0
    Many of those flash chips have a very similar command set as long as you're okay with using SPI mode and not SQI mode (the chips usually differ in how to switch to SQI mode), so porting one of the current drivers to your new device should not be too much of an issue.  The drivers do check for the JEDEC ID on the device to make sure they are talking to the correct device, so you'll need to change that to match your Cypress part.
    #2
    RUrbas
    New Member
    • Total Posts : 9
    • Reward points : 0
    • Joined: 2018/07/03 10:55:47
    • Location: 0
    • Status: offline
    Re: SPI flash drivers for Harmony 2018/08/08 10:01:18 (permalink)
    0
    SPI mode is perfect.
     
    Have you done similar porting? After a quick look I think I will need to change ID, add correct size of memory, sector size, change some opcodes and how some of the commands are sent.
     
    Am I  missing some something things that needs to be changed?
    #3
    RISC
    Super Member
    • Total Posts : 5271
    • Reward points : 0
    • Status: offline
    Re: SPI flash drivers for Harmony 2018/08/08 11:12:18 (permalink)
    0
    Hi,
    In Harmony 2.06 (maybe also 2.05) there are some example projects for SQI Flash :
    c:\microchip\harmony\v2_06\apps\examples\peripheral\sqi\
    c:\microchip\harmony\v2_06\apps\fs\sqi_fat\
    Regards
     
    #4
    Jim Nickerson
    User 452
    • Total Posts : 5263
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: online
    Re: SPI flash drivers for Harmony 2018/08/08 11:13:23 (permalink)
    0
    Maybe use two 64Mbit chips ?
    #5
    NKurzman
    A Guy on the Net
    • Total Posts : 16434
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: SPI flash drivers for Harmony 2018/08/08 11:32:18 (permalink)
    4 (1)
    Harmony Drivers are optional.  You can talk to the Flash chip directly using the PICs SPI Interface.
    #6
    malaugh
    Super Member
    • Total Posts : 341
    • Reward points : 0
    • Joined: 2011/03/31 14:04:42
    • Location: San Diego
    • Status: offline
    Re: SPI flash drivers for Harmony 2018/08/08 12:56:18 (permalink)
    4 (2)
    I have written my own drivers (I refuse to use Harmony) so I know a little bit about these chips and the difference.  
     
    All 25 series SPI flash parts i know of, except for the Microchip 25 series part, have the same "core" functions.  The most important commands are the Read block (08h) and  write block (02h) commands. With these command you can send a start address and a number of bytes to be read or written, and the part automatically increments the address.  The limitation of the command is the start and end address must lie withing the same 256 byte page.  This means you need to write the driver so it writes in blocks that do not cross this 256 byte page boundary.
     
    The "25 series" Microchip part does not support these commands.  They have their own commands (with different hex values ) that write up to 256 bytes with no restriction on the page boundaries for the address.
     
    Weirdly the "26 series" Microchip parts do follow the 25 series core commands, but unlike other
    manufacturer's parts they are locked on power up, so an unlock command must be sent before they can be written.
     
    If you are careful writing the driver you can avoid the unique features of each manufacturers 25 series parts and have a design that will accomodate a wide range of Manufacturers such a Adesto, Spansion, Winbond, etc.
     
     
     
     
    #7
    NKurzman
    A Guy on the Net
    • Total Posts : 16434
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: SPI flash drivers for Harmony 2018/08/08 13:13:22 (permalink)
    4 (1)
    The "25 series" Microchip part  is an SST Part that they got with they bought SST.
    #8
    RUrbas
    New Member
    • Total Posts : 9
    • Reward points : 0
    • Joined: 2018/07/03 10:55:47
    • Location: 0
    • Status: offline
    Re: SPI flash drivers for Harmony 2018/08/08 22:27:48 (permalink)
    3 (1)
    Using two 64 Mbit chips is not really an option, because this memory in part will be accessed as USB MSD to store files for MCU to read them when there is a need.
     
    Right now I'm using sst25_fat example to get an idea how sst25 driver works and what needs to be changed. 
    By adding correct chip ID, code example fails when trying to create a file which is expected, because I didn't yet wrote correct write (and probably read) command.
     
     malaugh thanks for the heads up about address wrapping around in the same page. I didn't notice that at first.
    #9
    RUrbas
    New Member
    • Total Posts : 9
    • Reward points : 0
    • Joined: 2018/07/03 10:55:47
    • Location: 0
    • Status: offline
    Re: SPI flash drivers for Harmony 2018/08/10 05:37:20 (permalink)
    3 (1)
    SST25 64 Mbit chip does wrap around, when you try to write outside page boundry. So it seems that harmony SST25 driver should handle this stuff.
     
    I removed Enable-Write-Status-Register command as my chip do not have this function. changed geometry to match my chip. All other commands look compatible or even identical. 
     
    After making these changes there are no noticeable changes, program doesnt work. I noticed that during formatting mcu programs whole lot of consecutive 0xff. That doesnt look right too.
     
    There is one big difference compared with SST25VF064C. Sector size. SST has uniform 4 KB sectors, while S25FL has hybrid sector sizes (few 4 KB and mostly 64 KB).
     
    I'm not sure what could be wrong. Maby I'm missing something in flash configuration bits. But I'm pretty lost. Any ideas?
    #10
    malaugh
    Super Member
    • Total Posts : 341
    • Reward points : 0
    • Joined: 2011/03/31 14:04:42
    • Location: San Diego
    • Status: offline
    Re: SPI flash drivers for Harmony 2018/08/10 09:32:19 (permalink)
    3 (1)
    I would check the driver code where they write data.  In the Microchip part, command 02 is a single byte write, vs a multi byte write in the generic 25 series parts. Microchip uses command ADh for their multi byte writes, but they restrict the minimum to 2 bytes. 
     
     
    #11
    RUrbas
    New Member
    • Total Posts : 9
    • Reward points : 0
    • Joined: 2018/07/03 10:55:47
    • Location: 0
    • Status: offline
    Re: SPI flash drivers for Harmony 2018/08/10 11:31:16 (permalink)
    0
    Looking into drv_sst25.c file i can see that for all chips driver uses AAI write opcode (ADh or AFh), exept SST25VF064C. For that chip it does use 02h opcode. In that chips datasheet it says that it can write up to 256 bytes.
     
    The page-Program instruction programs up to 256 bytes of data in the memory.

     
    That command in my chip 
    Page Programming allows up to a page size (either 256 or 512 bytes) to be programmed in one operation.
    (256 bytes in my extact chip) So commands look identical.
     
    In driver code if 02h command is used it allows to write whole page at a time, if ADh - then it do limits write to 2 bytes per command.
     
    if (deviceId == 0x4B)
        {
            /* SST25VF064C */
            /* Write block size and number of blocks */
            dObj->mediaGeometryTable[1].blockSize = DRV_SST25_PAGE_SIZE;
            dObj->mediaGeometryTable[1].numBlocks = flashSize >> 8;
            dObj->flashFunctions.write = DRV_SST25_WritePageProgram;
        }
        else
        {
            /* Write block size and number of blocks */
            dObj->mediaGeometryTable[1].blockSize = 2;
            dObj->mediaGeometryTable[1].numBlocks = flashSize >> 1;

            dObj->flashFunctions.write = DRV_SST25_WriteAutoAddressIncrement;
            if (deviceId == 0x49)
            {
                /* SST25VF010A */
                dObj->opCodes.write = DRV_SST25_CMD_AAI_PROGRAM1;
            }
            else
            {
                dObj->opCodes.write = DRV_SST25_CMD_AAI_PROGRAM;
            }
        }

     
    I believe that driver writes only with one or the other opcode. When I edited the driver I made sure that it's using 02h opcode. So it should be alright in that category. 
     
    When I get more time I'll try to manually write/read data, see if chip behaves as expected, there are no mechanical issues. I'll also double check GeometryTable things I did change.
    #12
    malaugh
    Super Member
    • Total Posts : 341
    • Reward points : 0
    • Joined: 2011/03/31 14:04:42
    • Location: San Diego
    • Status: offline
    Re: SPI flash drivers for Harmony 2018/08/10 11:43:27 (permalink)
    3 (1)
    You are correct, when I developed the driver, the Microchip part was SST25VF032B.  It looks like they added the multi byte write feature on the the SST25VF064B. however they have obsoleted that part now, in favor of their 26 series part.  If the write is OK, its likely that the problem is in their write protection features.
    #13
    Jump to:
    © 2018 APG vNext Commercial Version 4.5