4 Replies Latest reply on Dec 26, 2018 11:17 PM by KandlaguntaR_36

    Cx3 SPI Flash eraseBlock and Cypress Onboard Cx3 bootloader supported USB Vendor Requests.

    georgios.athanasopoulos_3736111

      Greetings.

       

      In my work I am using a CX3 reference device kit board and I am trying to develop a bootloader for it. Since I want the bootloader to have more features than either the bulkLoop Example Bootloader Firmware offers or the USBFlashProgrammer I took as base the first one and added some functions and vendor requests. I am encountering some weird behaviors when I try to erase Blocks in the SPI Flash through 0xEB custom vendor request and then send to the SPI the command 0xD8 0x08 0x00 0x00  verified through checking the bus. As far as I read in the winbond datasheet it is  supposed to be Erase Block of 64KB(0xD8) followed by MSB first and ending with LSB where the last 3 bytes are used to store the address of the specified sector. 0x80000 = 0x8 * 0x10000 so it's a multiple of 64KBs. I would also like to point out that the memory sectors are not locked but even if they were it would ignore the command not erase a different one.

       

       

      The function that follows shows the function I am using in order to erase the block which is very similar to the one used by USBFlashProgrammer.

       

      CyFx3BootErrorCode_t

      blockErase ( uint32_t address )

      {

      CyFx3BootErrorCode_t status = CY_FX3_BOOT_SUCCESS;

      uint8_t addr[4];

       

       

      addr[0] = 0xD8; /* Sector erase. */

      addr[1] = (address >> 16) & 0xFF;

       

       

      /* */

      addr[2] = (address >> 8) & 0xFF;

      addr[3] = (address) & 0xFF;

       

       

      status = spiWriteEnable();/* Write enable. */

      if (status != CY_FX3_BOOT_SUCCESS)

      {

          return status;

      }

       

       

      Cx3BootSpiSetSsnLine(CyFalse); /* Sector erase. */

      status = Cx3BootSpiTransmitWords(addr, 4);

      if (status != CY_FX3_BOOT_SUCCESS)

      {

      Cx3BootSpiSetSsnLine(CyTrue);

      return status;

      }

       

       

      Cx3BootSpiSetSsnLine(CyTrue);

       

       

      status = waitForSpiStatus();

      return status;

      }

       

      And then the custom vendor request added follows:

       

      case 0xEB:

                 UartTransmit ("Erase Block", sizeof("Erase Block"));

                     UartTransmit ("\n\r", 2);

                 status =  blockErase(bl);

                 break;

       

       

      When I send the command I see the message of UartTraasmit() and the blockErase() gets executed as well.

       

      The behavior I receive is that even though I pass 0x80000 as address it still erases from sector 0 regardless of the address.

       

       

      First of all I would like to ask what Vendor Requests are supported by the OnBoard Bootloader. I would also like to say that the functionality of automatic USBFlashProgrammer img download to RAM for Control Center has been put out of order right now so I know I receive the right requests while having the bootloader working.behavior happens ?

       

      Also do u have ideas why this is happening?