CX3 PMODE boot option

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

cross mob
NoAr_1540581
Level 5
Level 5
Distributor - Macnica (Japan)
5 solutions authored 250 sign-ins 100 replies posted

Hello

Normally, when writing FW and booting, I think that Dip-switch will be used to switch PMODE. At the customer's request, the PMODE setting is "fixed" without using Dip-switch.
Q) Is there a way to write FW from the HOST (Control Center) to SPI Flash and then boot from SPI Flash? Please let me know if there is a method in which PMODE is fixed and both(USB and SPI) boot options can be set.

Best Regards

Arai

0 Likes
1 Solution

Hello Arai san,


I understand the customer requirement as pointed by you.
I verified this on the FX3S FPGA DVK by PACTRON and since there was some image in the FLASH already, i had to change the PMODE to USB first to make it enumerate and then change it back to PMODE: 0Z1.

In customer's use case, during first boot up, the device will "fail" loading of the image from FLASH into RAM since the FLASH will be empty or won't have the first 2 bytes as 'CY' and will fallback to USB boot and enumerate as Cypress USB Bootloader Device.

Once the device enumerates as Cypress USB Bootloader Device, you can program the SPI FLASH using the control center and once it succeeded, reboot (or power cycle) the device.

The device will again try to load the data from FLASH to RAM and since the image has CY initials as the first 2 bytes, the device will successfully enumerate as the customer's firmware device (Cypress Bulkloop Example Device, in my case).

Once the device enumerates as the expected device, the customer can use the above implementation when they want to program the device again, to make the enumeration fallback to USB.

Regards,
Yashwant

View solution in original post

0 Likes
8 Replies
YashwantK_46
Moderator
Moderator
Moderator
100 solutions authored 50 solutions authored 50 likes received

Hello Arai-san,

Please confirm the fixed PMODE settings that the customer is using now.
Is it 0Z1 : SPI fallback to USB ?

If the PMODE[2:0] is set to 0Z1, the bootloader will try to load the firmware from SPI FLASH to RAM and if that fails, the device will fall back to USB as Cypress USB Bootloader Device and you can use Control Center to program the RAM or SPI FLASH from it.


Regards,
Yashwant

0 Likes
NoAr_1540581
Level 5
Level 5
Distributor - Macnica (Japan)
5 solutions authored 250 sign-ins 100 replies posted

Hello Yashwant san

>Please confirm the fixed PMODE settings that the customer is using now.
>Is it 0Z1: SPI fallback to USB?
>
➡ They haven't decided it.They plan to make both settings feasible.However, there is no good way to set it.

I understand the above, but what should be done when switching between USB and SPI with fixed PMODE if the  PMODE[2:0] is set to 0Z1? DIPSW is not used. In details question,
How can they switch between "fail" and "non-fail" states below?

>If the PMODE [2: 0] is set to 0Z1, the bootloader will try to load the firmware from SPI FLASH to RAM and if that """fails""", the device will fall >back to USB as Cypress USB Bootloader Device and you can use Control Center to program the RAM or SPI FLASH from it.

>

Best Regards

Arai

0 Likes

Hello Arai san,

You can suggest the customer to use the PMODE[2:0] = 0Z1 : SPI fallback to USB.

How can they switch between "fail" and "non-fail" states below?

=> The customer can implement a vendor command which will have to access the first 2 bytes of FLASH and overwrite it with something else. The first 2 bytes in the .img file are 'CY' and the bootloader checks for this signature to be present in the flash before loading the firmware to RAM.

If this is overwritten by any data, the device will fall back to USB boot mode and enumerate as Cypress USB Bootloader Device and you can re-program the flash with any other image file.

i have tested the same using the UsbSpiRegMode example project available in the EZ-USB Suite as follows:

1.) Used USB boot mode in starting to program the SPI FLASH using the control center.

2.) Changed PMODE to 0Z1 and the device booted from FLASH as bulkloop example device.

3.) Used the vendor command to SPI FLASH WRITE (0xC2) and over-write the first two bytes in the FLASH.

4.) Didn't change the PMODE and is still set in 0Z1.

5.) Reset the device.

6.) The device fails to get the 'CY' signature and falls back as Cypress USB Bootloader Device in the control center.

7.) The re-programming of FLASH got succeeded when tried with a different image and booted successfully when resetting the device.


Regards,
Yashwant

0 Likes
NoAr_1540581
Level 5
Level 5
Distributor - Macnica (Japan)
5 solutions authored 250 sign-ins 100 replies posted

Hello Yashwant san

Thank you for your reply.

>3.) Used the vendor command to SPI FLASH WRITE (0xC2) and over-write the first two bytes in the FLASH.

>

➡ Please tell me about the detailed procedure above? If the above can be over-write in Control Center, could you please share the screen copy for setting?

Bets Regards

Arai

0 Likes

Hello Arai san,

Consider the device is being booted for the first time, the device will come up as Cypress Bootloader Device since there is no valid image in the SPI FLASH.

You can just program the device with the firmware UsbSpiRegMode example project (or use a similar implementation of firmware that has SPI implemented) available in the SDK from the path: C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\firmware\serialif_examples\cyfxusbspiregmode

NOTE: The default path may change based on the installation directory.

The above-mentioned example initializes the SPI block of FX3/CX3/FX3S and can be used to read or write data to the FLASH using vendor commands as shown in Figure 1 (highlighted in yellow):
pastedImage_2.png

                                                Figure 1: firmware snippet

Here's what i did to get the expected behaviour:
1.) Plugged the device with PMODE set to Z11(USB boot) for now to simulate the first enumeration of device or fallback scenario because of the invalid firmware image.

2.) Programmed the UsbSpiRegMode.img from the project mentioned above to the SPI FLASH and programming succeeds as shown (highlight in yellow):
pastedImage_3.png

3.) Changed PMODE to 0Z1: SPI fallback to USB.

4.) Reset the device.

5.) Device enumerates as Cypress FX3 BulkloopExample Device with the control endpoint and a set of bulk endpoints as shown:

pastedImage_0.png

4.) After this, based on the Figure 1, firstly sending the command 0xC3 (READ) gives the first 512 bytes in the FLASH as below:

pastedImage_1.png

The First Two Bytes, i.e., 43 59 translates to CY in AnsiChar as shown when you open a .img file with HxD Editor as below:

pastedImage_2.png

5.) When the firmware is loaded from FLASH, the bootloader checks for the first two bytes, i.e., CY or (43 59) and if it’s not the same, the device will fall back to USB boot.

6.) To force this, we will need to change the first two bytes of the image stored in FLASH using the vendor command 0xC2 (WRITE) as shown below:

pastedImage_3.png

7.) Reading the contents from FLASH again using 0xC3 gives the following data, i.e., AB (41 42) highlighted in RED:

pastedImage_4.png

Since the first 2 bytes are not CY or 43 59, and PMODE is 0Z1, the device will automatically fallback to USB and enumerate as Cypress USB Bootloader Device on the next reboot.

8.) Reset the device (PMODE is 0Z1 -- unchanged).

9.) Device enumerates as shown below (PMODE is still set to 0Z1):

pastedImage_32.png

10.) You can program the FLASH again using the control center with the updated image.

NOTE: The customer will have to use SPI write to change the first two bytes as shown and they can use UsbSpiRegMode example in the SDK as reference.


Regards,
Yashwant

0 Likes
NoAr_1540581
Level 5
Level 5
Distributor - Macnica (Japan)
5 solutions authored 250 sign-ins 100 replies posted

Hello Yashwant san

Thank you so much for your reply. I understand about your answer. However, customer does not want to use plural PMODE settings for their board design.So, they do not want to use DIP-Switch for changing PMODE. They want to use fixed( only one ) PMODE setting to their design board.

According to your answer , PMODE must be switched in "1)" and "3)" below.

>1.) Plugged the device with PMODE set to Z11(USB boot) for now to simulate the first enumeration of device or fallback scenario because of >the invalid firmware image.

>3.) Changed PMODE to 0Z1: SPI fallback to USB.

Is there any way to work without switched PMODE mentioned above?

Best Regards

Arai

0 Likes

Hello Arai san,


I understand the customer requirement as pointed by you.
I verified this on the FX3S FPGA DVK by PACTRON and since there was some image in the FLASH already, i had to change the PMODE to USB first to make it enumerate and then change it back to PMODE: 0Z1.

In customer's use case, during first boot up, the device will "fail" loading of the image from FLASH into RAM since the FLASH will be empty or won't have the first 2 bytes as 'CY' and will fallback to USB boot and enumerate as Cypress USB Bootloader Device.

Once the device enumerates as Cypress USB Bootloader Device, you can program the SPI FLASH using the control center and once it succeeded, reboot (or power cycle) the device.

The device will again try to load the data from FLASH to RAM and since the image has CY initials as the first 2 bytes, the device will successfully enumerate as the customer's firmware device (Cypress Bulkloop Example Device, in my case).

Once the device enumerates as the expected device, the customer can use the above implementation when they want to program the device again, to make the enumeration fallback to USB.

Regards,
Yashwant

0 Likes
NoAr_1540581
Level 5
Level 5
Distributor - Macnica (Japan)
5 solutions authored 250 sign-ins 100 replies posted

Hello Yashwant san

I understood. Thank you for your explanation.

Best Regards

Arai

0 Likes