FX3 SPI boot fails when S25FS128S flash is used – KBA231163

Version 1

    Version: **

     

    By default, the S25FS128S flash device comes with hybrid sectors (the first sector of 64KB divided into 9 sectors (8 sectors of 4KB and one 32KB sector).  All remaining sectors are uniform (64KB each).

     

    When you use the Control Center application from the FX3 SDK, the internal programming utility (CyBootProgrammer.img) assumes uniform sector size for the flash device; this leads to corrupted data in the first sector, which is a hybrid sector.

     

    To prevent this, configure the flash device to use uniform sectors of 64KB each by modifying the Configuration Register 3 (CR3NV) – see Figure 1.

     

    Figure 1. Configuration Register 3 (CR3NV): Address = 0x00000004

         

     

    To configure the flash with uniform 64KB sectors, write ‘1’ to CR3NV[3] and ‘0’ to CR3NV[1] using the  WRAR 71h command (write 0x08 into the CR3NV register). After updating this register, use the default Control Center application to load the firmware image to the flash.

     

    An alternative approach is to modify the default programmer tool in the Control Center utility (CyBootProgrammer.img). However, note that this may cause errors if other types of flash are used. Therefore, create a backup of CyBootProgrammer.img for use with other flash devices.

     

    Do the following to modify CyBootProgrammer.img:

     

    1. Import the SDK example project cyfxflashprog from the following location into EZ-USB Suite:

    C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\firmware\basic_examples\cyfxflashprog

     

    2. Open the cyfxflashprog.c source file, and locate the CyFxFlashProgSpiInit function.

     

    3. Add the following lines of code to the end of this function:

    uint32_t reg_adr = 0x000004;

    uint32_t temp;

    uint8_t  location[5], rdBuf[2];

        location[0] = 0x06;  /* Write enable. */

        CyU3PSpiSetSsnLine (CyFalse);

        status = CyU3PSpiTransferWords (location, 1, 0, 0);

        CyU3PSpiSetSsnLine (CyTrue);

        rdBuf[0] = 0x8;

        location[0] = 0x71; /* Sector erase. */

        temp  = reg_adr;

        location[1] = (temp >> 16) & 0xFF;

        location[2] = (temp >> 8) & 0xFF;

        location[3] = temp & 0xFF;

        location[4] = 0x08;

        CyU3PSpiSetSsnLine (CyFalse);

        status = CyU3PSpiTransferWords (location, 5, 0, 0);

        CyU3PSpiSetSsnLine (CyTrue);

     

    4. Build the project.

     

    5. Rename the .img file generated to CyBootProgrammer.img.

     

    6. Copy and paste this file to the following location:

    C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\bin.

     

    7. Create a backup of the existing CyBootProgrammer.img in this location so that it can be used with other SPI flash devices.

     

    8. Use the Control Center utility (CyControl.exe) to program the flash.

     

    The attached cyfxflashprog SDK example project has the required firmware modification.

     

    See Control Center user guide:C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\application\c_sharp