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

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
geatc_3736111
Level 1
Level 1

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 >> 😎 & 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?

0 Likes
1 Solution

Please specify the Winbond SPI Part number.
To confirm the correct the functionality of the SPI part, please try with default bootloader with SPI DMA example firmware (provided with the SDK - C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\firmware\serialif_examples\cyfxusbspidmamode).

View solution in original post

0 Likes
4 Replies
KandlaguntaR_36
Moderator
Moderator
Moderator
25 solutions authored 10 solutions authored 5 solutions authored

Hi,

ROM Bootloader resided in the chip does not handle any vendor requests.

Can you please pass sector number in the vendor command instead of whole address as follows?

(I am not sure how you are sending the vendor command - please provide screen shot of this).

Erase SPI flash sector

      bmRequestType = 0x40

      bRequest      = 0xC4

      wValue        = 0x0001

      wIndex        = 0x0008 - SPI flash sector address (Each sector is assumed to be of 64 KB and the byte address is

                      computed by multiplying wIndex by 65536)

      wLength       = 0x0000

Can you please test the same fucntionality over Cypress reference design, if you have any?

0 Likes
geatc_3736111
Level 1
Level 1

Hello again.

Thank you for your reply. I am sending it as you have instructed(wIndex=0x8) and even checking it through mixed signal osciloscope so I see what I am sending is D8 08 00 00 to the SPI Flash but the erase command seems to be erasing more than one sectors (64KB blocks). I am using the same command on our custom board as well as the Cypress Reference Design. This happens when I use my own bootloader as well as USBFlashProgrammer and feeding sector 8 to the CyFxFlashProgEraseSector() function directly.

On top of that I noticed some other weird activity. I tried using DMA Xfer on the bootloader to DL the firmware image from usb->ram->SPI. It kept writing the bytes but the first one instead of 0x43 it was 0x6 every time. Then I tried transfering without using DMA using writeBytes and it correctly writes the FW image but it repeats the image every few sectors while I only send 1 command. Not to mention this didn't work as Intended considering I would like to store different firmwares at different points in the flash so I can pick which one I want to run on startup depending on parameters.

I suspect something similar is happening for the EraseSector. Later when I get to the office I will also try to provide you with some code as well.

0 Likes

Please specify the Winbond SPI Part number.
To confirm the correct the functionality of the SPI part, please try with default bootloader with SPI DMA example firmware (provided with the SDK - C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\firmware\serialif_examples\cyfxusbspidmamode).

0 Likes

Have you tried with SPI DMA example firmware?

0 Likes