AN84868 - Slave Fifo does not longer work after USB disconnection and reconnection

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

cross mob
wowi
Level 2
Level 2
First solution authored 10 replies posted 10 sign-ins

We have the same problem with our own hardware design and I could not solve it, so I tested it with the original AN84868 hardware and software, the SP601 evaluation kit and the EZ-USB FX3 Development Kit. When the FPGA is configured, it should be possible to disconnect and reconnect the USB on a self-powered design and the Slave FIFO interface should still work, but it does not.

It is rather obvious the the source file cyfxslfifosync.c must be changed. The CyFxSlFifoApplnStop function must contain code like CyU3PGpifDisable(CyTrue); to disable the Gpif, and the CyU3PGpifLoad must be moved from the CyFxSlFifoApplnInit into the  CyFxSlFifoApplnStart, but I was not able to get a firmware that did work after USB reconnection. Could anybody help?

 

0 Likes
1 Solution
JayakrishnaT_76
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hello Wowi,

I think the issue is caused by the difference in sequence numbers when you disconnect and reconnect the device from the USB host. Based on the current implementation, the same data endpoint is used for sending the firmware image and also for the slave fifo operation. So, when you switch from FPGA configurator to Slave FIFO, the sequence number is queried by using the API CyU3PUsbGetEpSeqNum (). You can find this API called in the source file cyfxconfigfpga.c.

The same sequence number is set for the data endpoint before it is configured for Slave FIFO operation. This is done by the API CyU3PUsbSetEpSeqNum (). This could be the reason for you to see the data transfer when you use Slave FIFO after configuring the FPGA and before disconnecting the device from the host. But, once you disconnect and reconnect the device from the host, the data endpoint is again configured with the last obtained sequence number (i.e that returned by the API CyU3PUsbGetEpSeqNum () from the source file cyfxconfigfpga.c. This will cause a difference between the sequence number sent by the host and the sequence number the device expects.

So, please try the following modifications in the project and let me know if it helps:

1. Inside the function SlFifoAppThread_Entry (), just before calling CyFxSlFifoApplnDebugInit (), store the data pointed by seqnum_p as 0 i.e, use the following line of code:

*seqnum_p = 0;

2. Inside disconnect event, set a global flag i.e

gl_disconnect_flag = CyTrue; 

The above flag should be declared as a global flag and should be initialized as follows:

bool gl_disconnect_flag = CyFalse;

3. When the SETCONF event is received, check if the flag is set. If the flag is set, then reset *seqnum_p to 0 and clear the flag i.e:

case CY_U3P_USB_EVENT_SETCONF:

.....

if (gl_disconnect_flag)

{

           *seqnum_p = 0;

            gl_disconnect_flag  = CyFalse;

}

Please note that these lines of code should be added before the function CyFxSlFifoApplnStart () is called inside the CY_U3P_USB_EVENT_SETCONF event.

Please test the project after making the above modifications and let me know if you still face any issues.

Best Regards,
Jayakrishna

View solution in original post

0 Likes
19 Replies
JayakrishnaT_76
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hello,

From my understanding, you are trying to configure the FPGA using AN84868. After the configuration is done, you are switching to slave fifo mode by using the vendor command 0xB1. After this, the device is disconnected and reconnected. This will make the slave FIFO interface to stop working. Please correct me if my understanding is wrong.

If my understanding is correct, then please let us know what exactly is the failure seen when you say "Slave FIFO interface stops working"? Are you seeing failures in data transfers? If not, then can you elaborate the failure seen so that we can debug the issue faster.

Also, please share the source code of the project with us so that we can understand the changes made. In addition to this, please share the UART debug logs.

Best Regards,
Jayakrishna
0 Likes

Hello Jayakrishna,

you are right. When I say "Slave FIFO interface stops working", I mean, I cannot longer make data transfers after a USB disconnection and reconnection. When I try to send the test.txt file over the Bulk out endpoint 0x01 using the control center, I get a message: BULK OUT transfer failed with Error code: 997.

The source code of the project is the AN84868 example, the code can be downloaded from the inineon website

https://www.infineon.com/dgdl/Infineon-AN84868_Configuring_an_FPGA_over_USB_Using_Infineon_EZ-USB_FX...

I changed only the file cyfxslfifosync.c, I attach this changed file here. I just extracted the code to load the GPIF into a new function that I called before calling CyFxSlFifoApplnStart, and inserted a CyU3PGpifDisable into the The CyFxSlFifoApplnStop . The behaviour is the same as with the original version. I use the release version and have no UART debug logs.

Best regards,

Wowi

0 Likes
JayakrishnaT_76
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hello Wowi,

Can you please let me know the reason for the non availability of UART debug logs from your end? Is it because the UART lines are not routed on your PCB?

For a test, can you please try sending a vendor command (0xB1 or 0xB2) and check if you are able to get the DATA IN on the host side? This will help us to understand if the issue is just related to the slave fifo application or not.

Best Regards,
Jayakrishna
0 Likes

Hello Jayakrishna,

my PCB is the the SP601 evaluation kit and the EZ-USB FX3 Development Kit.

What info do you expect from UART ? there are only UART outputs when a call to a Cypress function results a no success error, but there are no such failed calls, otherwise the firmware would go into an endless loop defined in the error handler and not longer respond.

DATA In transfer results also into a message "BULK IN transfer failed with Error Code: 997" shown in the control center.

I hope you can contact the developers of the AN84868 and ask them to provide a fixed version?

Best regards,

Wowi

0 Likes
JayakrishnaT_76
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hello,

I wanted to check about the UART debug logs to see if we can trace the different events that occur in the firmware (especially the USB related events).

DATA In transfer results also into a message "BULK IN transfer failed with Error Code: 997" shown in the control center.

>> I wanted to check control IN transfer and not BULK IN transfer. Can you try issuing a  vendor command (0xB1) to the device after reconnection and check if the device is responding back with the 1 byte data?

Best Regards,
Jayakrishna
0 Likes

Hello Jayakrishna,

When I try a 0xB1 vendor request on the Control endpoint 00 to read one byte using the control center, I get a message

CONTROL IN transfer
0000 01
CONTROL IN transfer completed

So such requests still work also after USB disconnection and reconnection, but the Slave fifo does not.

Best regards, Wowi

0 Likes
JayakrishnaT_76
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hello Wowi,

It looks like the call to CyFxSlFifoApplnStop () in the event CY_U3P_USB_EVENT_DISCONNECT results in the BULK transactions to fail.

Can you please try restarting the application when the event CY_U3P_USB_EVENT_CONNECT is received?

Best Regards,
Jayakrishna
0 Likes

Hello Jayakrishna,

good idea. I tried it but if I try to handle the CY_U3P_USB_EVENT_CONNECT the firmware does not work at all.  The actions after reconnection are done at an CY_U3P_USB_EVENT_SETCONF event.

To check the status of the firmware, I introduced a new vendor command B0 that outputs a 8 byte firmware ID. Initially it is  "FX3 V10 ".

After the FPGA is configured, it is "FC-FW 1 ". And after USB disconnection and reconnection it is "FC-FW 1K". I can clearly seen that the ID is changed after reconnection, so the application was stopped and restarted. I attach this version of my changed source and firmware files.

Best regards, Wowi

0 Likes
JayakrishnaT_76
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hello Wowi,

Please find my questions/comments for further debug below:

1. Is the Slave FIFO interface working fine before disconnection and reconnection? That is, is it working correctly after the FPGA is configured and before you disconnect and reconnect the device to the host?


2. Can you manually trigger CyFxSlFifoApplnStop () and restart by using vendor commands? Please check if the data transfer is successful or not after this test. This is to check if the handling of stop/restart sequence is actually causing the issue or not.

3. After restart, do you see at least one successful transfer or is it like all the transfers fail with timeout error? This is to check if the problem is related to the GPIF II interface or not.

4. Previously, you mentioned that BULK IN transfers also failed after disconnection and reconnection. Can you please confirm that the FPGA was sending data when the BULK IN transfer failed?

Best Regards,
Jayakrishna
0 Likes

Hello Jayakrishna ,

1. yes, the Slave FIFO interface is working fine before disconnection and reconnection after the FPGA is configured.

2. I made a new vendor IN command 0xB3 that stops, reloads GPIF and starts, and sends the 8 byte firmware ID that is changed to "FC-FW 1L". It has the same effect as disconnect/reconnecting the USB, i.e. BULK IN and OUT transfers fail, only control commands still work.

3. After restart all the BULK transfers fail with timeout error.

4. After the FPGA is normally configured, I can send the test.txt file on endpoint 0x01 and can receive the data on endpoint 0x81. When I do a restart before requesting the data and try then to do the BULK IN, it fails also. I don't know if the FPGA is really sending data or not in this case.

Best regards, Wowi

0 Likes
JayakrishnaT_76
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hello,

I tested the attachment ver220331.zip using FX3 DVK at my end without connecting the FPGA. I was not able to see the timeout errors for 2 BULK OUT transfers. The 3rd BULK OUT transfer will obviously fail as the FPGA was not connected. The steps that I did at my end are given below:

1. Sent the vendor command 0xB0. I got "FX3 V10" as response.

2. Issued the vendor command 0xB1. I was able to get the 1 byte return data from the device.

3. Issued the vendor command 0xB0 and got FC-FW 1 as return data.

4. Tried BULK OUT of 1024 bytes twice. I did not see any failure at this point. I also did the tests without performing this step.

5. Unplugged the USB cable from the host and then re-connected the cable back to the host again.

6. Issued the vendor command 0xB0 again and got FC-FW 1K as return data. This means that the device was stopped and restarted after the reconnection.

7. I was able to see successful BULK OUT transfers of 1024 bytes twice after the above steps. The 3rd BULK OUT transfer failed as the FPGA was not connected.

I tried the same multiple times and was not able to reproduce the issue at my end. Please let me know if there are any changes in any of the steps that I mentioned above.

Best Regards,
Jayakrishna
0 Likes

Hello Jayakrishna,

I can verify these steps, by letting the SP601 FPGA board unpowered and not configured. So it means it has to do with the FPGA?

But what can be done to let the Slave Fifo working?

Best regards, Wowi

0 Likes
JayakrishnaT_76
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hello Wowi,

I don't think the FPGA will interfere here. Please let me know if there is anything different in your test procedure (other than using the FPGA) after comparing with the procedure shared in my previous response. You can also test the same at your end and check if you are also finding the same result or not. As mentioned in my previous response, I was not able to reproduce the issue at my end with the firmware that you shared.

I also tried using the project in the attachment ver220401.zip and tried the following:

1. Sent the vendor command 0xB0. I got "FX3 V10" as response.

2. Issued the vendor command 0xB1. I was able to get the 1 byte return data from the device.

3. Issued the vendor command 0xB0 and got FC-FW 1 as return data.

4. Issued the vendor command 0xB3 and got the response as FC-FW 1L

5. Issued 2 bulk OUT transfers. 

I did not find any failures. The 3rd BULK OUT transfer failed as the FPGA was not connected. Please let me know if there is any difference in this test procedure compared to the procedure that you followed.

Best Regards,
Jayakrishna
0 Likes

Hello Jayakrishna,

thankyou for your efforts to help us. Without the fpga board I can observe the same as you describe. But the important point of the AN84868 is to load a firmware into an fpga using USB from the PC and then switch to Slave Fifo mode and communicate with the fpga through gpif. This works fine as long as the PC remains powered and the USB is not disconnected. But after a disconnection it is not longer possible to communicate with the fpga without a complete shutdown. 

I use the same fpga board SP601 as described in the appnote. All the hardware and software is the same as in this appnote. This is a serious problem. I still hope that the developers of the AN84868 make an update to fix this issue. Can you contact them?

Best regards,

Wowi

0 Likes
JayakrishnaT_76
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hello Wowi,

I think the issue is caused by the difference in sequence numbers when you disconnect and reconnect the device from the USB host. Based on the current implementation, the same data endpoint is used for sending the firmware image and also for the slave fifo operation. So, when you switch from FPGA configurator to Slave FIFO, the sequence number is queried by using the API CyU3PUsbGetEpSeqNum (). You can find this API called in the source file cyfxconfigfpga.c.

The same sequence number is set for the data endpoint before it is configured for Slave FIFO operation. This is done by the API CyU3PUsbSetEpSeqNum (). This could be the reason for you to see the data transfer when you use Slave FIFO after configuring the FPGA and before disconnecting the device from the host. But, once you disconnect and reconnect the device from the host, the data endpoint is again configured with the last obtained sequence number (i.e that returned by the API CyU3PUsbGetEpSeqNum () from the source file cyfxconfigfpga.c. This will cause a difference between the sequence number sent by the host and the sequence number the device expects.

So, please try the following modifications in the project and let me know if it helps:

1. Inside the function SlFifoAppThread_Entry (), just before calling CyFxSlFifoApplnDebugInit (), store the data pointed by seqnum_p as 0 i.e, use the following line of code:

*seqnum_p = 0;

2. Inside disconnect event, set a global flag i.e

gl_disconnect_flag = CyTrue; 

The above flag should be declared as a global flag and should be initialized as follows:

bool gl_disconnect_flag = CyFalse;

3. When the SETCONF event is received, check if the flag is set. If the flag is set, then reset *seqnum_p to 0 and clear the flag i.e:

case CY_U3P_USB_EVENT_SETCONF:

.....

if (gl_disconnect_flag)

{

           *seqnum_p = 0;

            gl_disconnect_flag  = CyFalse;

}

Please note that these lines of code should be added before the function CyFxSlFifoApplnStart () is called inside the CY_U3P_USB_EVENT_SETCONF event.

Please test the project after making the above modifications and let me know if you still face any issues.

Best Regards,
Jayakrishna
0 Likes

Hello Jayakrishna,

congratulations! this solved the problem!

There is only a slightly change, the sequence number must be defined as value, not as pointer. After a disconnection / reconnection now the bulk data transfers still work. What is not yet working, is the vendor command B3 that should do the same as the physical disconnection / reconnection. May be you find the point what is wrong , so I attach the last version here. But it is not important.

Best regards and many thanks,

Wowi

0 Likes
JayakrishnaT_76
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hello Wowi,

Im glad to hear that my suggestion helped to solve your issue.

As for the vendor command 0xB3, you can try the following:

1. As soon as the vendor command 0xB3 is received, obtain the sequence number using the API CyU3PUsbGetEpSeqNum () to get the last sequence number.

2. While you restart the application, use the sequence number obtained above to configure the endpoint. You can use similar logic that was used before to implement this requirement.

Please test this and let me know if you still face any issues.

Best Regards,
Jayakrishna
0 Likes

Hello Jayakrishna,

thankyou, this works, but I have to do the same also with the consumer endpoint. Otherwise I can only send data, but not receive after a reload via vendor command B3. Thankyou very much, everything is solved now.

Best regards,

Wowi

0 Likes
JayakrishnaT_76
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hello Wowi,

We are glad to hear that the issue is solved.

Best Regards,
Jayakrishna
0 Likes