I am facing error handling problem with FX3-based camera which leads to significant frame loss after an error occurs.
Camera configuration: 640 x 512, 16-bit, 50fps, ~262MBit/s = 32.7MB / s
FX3 configuration: USB 2.0 only, AN75779 based firmware, SDK version 1.3.4 and 1.3.5 (unofficial release)
After the host detects an error -71 it initiates a restart of the video stream, which results in a pause of about 1000 milliseconds between issuing CY_U3P_USB_SC_CLEAR_FEATURE and CY_FX_UVC_STREAM_EVENT which leads to a loss of 50 frames. Most likely, such a pause in case of an error -71 is set by the software on the host side, which, unfortunately, I cannot influence.
Some FX3 UVC device debug UART logs ( timestamp format: seconds.milliseconds )
9390.335 - UVC: Completed 5149 frames and 2 buffers, DMA(Watermark) = 2
9391.335 - UVC: Completed 5199 frames and 2 buffers, DMA(Watermark) = 3
9391.644 - Clear feature request detected..., DMA(WM) = 2
9391.645 - Application Stopped
9391.645 - UVC: Completed 0 frames and 0 buffers, DMA(Watermark) = 2
9392.645 - UVC: Completed 0 frames and 0 buffers, DMA(Watermark) = 0
9392.648 - Application Started
9392.648 - UVC: Completed 0 frames and 0 buffers, DMA(Watermark) = 0
9393.648 - UVC: Completed 49 frames and 29 buffers, DMA(Watermark) = 2
9394.648 - UVC: Completed 99 frames and 30 buffers, DMA(Watermark) = 2
9395.648 - UVC: Completed 149 frames and 30 buffers, DMA(Watermark) = 2
9396.648 - UVC: Completed 199 frames and 30 buffers, DMA(Watermark) = 2
9397.648 - UVC: Completed 249 frames and 30 buffers, DMA(Watermark) = 2
9398.648 - UVC: Completed 299 frames and 30 buffers, DMA(Watermark) = 3
The goal is to reduce this pause as much as possible. I am thinking about strategy described in KBA231382 article with monitoring difference between commited but not consumed DMA buffers to avoid this error at all, but it looks like I didn't quite get the idea.
The first thing I would like to get is a number of DMA buffers already sent by FX3 but not yet received by host as a threshold criteria to temporarely stop producing more data from GPIF state machine:
static uint8_t DMABufferWatermark = 0;
static uint8_t DMABufferWatermark_Max = 0
void CyFxUvcApplnDmaCallback (
CyU3PDmaMultiChannel *chHandle,
CyU3PDmaCbType_t type,
CyU3PDmaCBInput_t *input
)
{
CyU3PDmaBuffer_t dmaBuffer;
CyU3PReturnStatus_t status = CY_U3P_SUCCESS;
if (type == CY_U3P_DMA_CB_PROD_EVENT)
{
#ifdef FRAME_TIMER_ENABLE
/* Received data from the sensor so stop the frame timer */
CyU3PTimerStop(&UvcTimer);
/* Restart the frame timer so that we receive the next buffer before timer overflows */
CyU3PTimerModify(&UvcTimer, glFrameTimerPeriod, 0);
CyU3PTimerStart(&UvcTimer);
#endif
/* There is a possibility that CyU3PDmaMultiChannelGetBuffer will return CY_U3P_ERROR_INVALID_SEQUENCE here.
* In such a case, do nothing. We make up for this missed produce event by making repeated commit actions
* in subsequent produce event callbacks.
*/
status = CyU3PDmaMultiChannelGetBuffer (chHandle, &dmaBuffer, CYU3P_NO_WAIT);
while (status == CY_U3P_SUCCESS)
{
/* Add Headers*/
if (dmaBuffer.count == CY_FX_UVC_BUF_FULL_SIZE)
{
/* A full buffer indicates there is more data to go in this video frame. */
CyFxUVCAddHeader (dmaBuffer.buffer - CY_FX_UVC_MAX_HEADER, CY_FX_UVC_HEADER_FRAME);
}
else
{
/* A partially filled buffer indicates the end of the ongoing video frame. */
CyFxUVCAddHeader (dmaBuffer.buffer - CY_FX_UVC_MAX_HEADER, CY_FX_UVC_HEADER_EOF);
#ifdef DEBUG_PRINT_FRAME_COUNT
glFrameCount++;
glDmaDone = 0;
#endif
}
/* Commit Buffer to USB*/
status = CyU3PDmaMultiChannelCommitBuffer (chHandle, (dmaBuffer.count + CY_FX_UVC_MAX_HEADER), 0);
if (status == CY_U3P_SUCCESS)
{
DMABufferWatermark++;
#ifdef DEBUG_PRINT_FRAME_COUNT
glDmaDone++;
#endif
}
else
{
if(glDmaResetFlag == CY_FX_UVC_DMA_RESET_EVENT_NOT_ACTIVE)
{
glDmaResetFlag = CY_FX_UVC_DMA_RESET_COMMIT_BUFFER_FAILURE;
CyU3PEventSet(&glFxUVCEvent, CY_FX_UVC_DMA_RESET_EVENT, CYU3P_EVENT_OR);
}
break;
}
/* Check if any more buffers are ready to go, and commit them here. */
status = CyU3PDmaMultiChannelGetBuffer (chHandle, &dmaBuffer, CYU3P_NO_WAIT);
}
}
else if (type == CY_U3P_DMA_CB_CONS_EVENT)
{
if (DMABufferWatermark > 0)
DMABufferWatermark--;
streamingStarted = CyTrue;
glCommitBufferFailureCount = 0; /* Reset the counter after data is consumed by USB */
}
DMABufferWatermark_Max = max(DMABufferWatermark_Max, DMABufferWatermark);
}
void UVCAppThread_Entry (uint32_t input)
{
for (;;)
{
apiRetStatus = CyU3PEventGet (&glFxUVCEvent, CY_FX_UVC_STREAM_ABORT_EVENT | CY_FX_UVC_STREAM_EVENT | CY_FX_UVC_DMA_RESET_EVENT | CY_FX_USB_SUSPEND_EVENT_HANDLER, CYU3P_EVENT_OR_CLEAR, &flag, LOOP_TIMEOUT);
...
CyFxUVCAppDebugPrint(4, "UVC: Completed %d frames and %d buffers, DMA(Watermark) = %d", glFrameCount, (glDmaDone != 0) ? (glDmaDone - 1) : 0, DMABufferWatermark_Max);
DMABufferWatermark_Max = 0;
}
}
It seems like DMABufferWatermark_Max is around pretty normal 2..3 even in case of -71 error and never comes close to all 8 available DMA Buffers which I expect as a pre-error criterion.
How to correctly implement the recommendations given in the article KBA231382 in the software code?
Regards,
Sergiy
Show LessHello,
For the last few days, I'm trying failsafe firmware update as explained here , I'm using the same code and followed the same steps as mentioned, first I merged 2nd stage boot loader and UsbBulkSrcSink and then flashed to my Denebola Kit, and It successfully shows itself as a device in the control center, but later when I try to update new firmware(USBBulkloopAutoEnum from examples) with given Firmware Updater, I flashed new firmware with given Firmware updater, but It didn't execute in Denebola Kit. Even in the control center, I didn't get anything to see.
Show LessHello forum,
I am looking for some clarification concerning the use of bridged external devices such as IMU sensor, capacitive touch sensor, and PWM LED controller peripherals that would be connected via I2C, UART, SPI, or GPIO to the CYUSB3065.
The intended end use is a two in one design, meaning that we want to use a single design/schematic that will ultimately be used for two separate products.
- One product would make use of the MIPI camera along with the above mentioned peripheral sensors and would make full use of USB3.0 provided via 1/2 of a USB type-C w/DP. A re-driver is used to split the Type-C into USB3.0 and DP and since that design only requires 1080p resolution to the display, only two of the four USB channels are required leaving the remaining two for the USB3.0 and the camera interface.
- The second product would not use the MIPI camera portion of the CYUSB3065, but still needs to access the bridge function for communications with the peripheral sensors. This second product requires all four USB channels to be used for the display since it will be 4k resolution and therefore no USB3.0 split will be available to the CYUSB3065 leaving only the USB2.0 for all bridge functions.
My question is, am I correct to assume that we can indeed use the USB2.0 D+/D- lines to handle all communications between the host PC and the peripheral sensors (excluding the camera/image sensor)?
In the long run, at least for us, designing for a single board that can accommodate both products will make much more sense than two separate designs.
I'd also like to ask if there is anyone here that we could contract with to help on the software development side of things concerning EZ-USB and the CYUSB3065 interface, or at least help get us going in the right direction? I hope this question is allowed here, if not I apologize.
I have spent a great deal of time scouring through the documentation and app notes, but several things are still unclear on how to retrieve sensor data from peripherals through the CYUSB3065 and EZ-USB.
Thank you for any help you're willing to lend.
-Dan Gates
Hello,
I want to send vendor-specific commands from the Control center to the Denebola kit, How to do that?
and In the control center, I found the load script icon, for what it is used? is that one to send vendor commands?
Show LessHi FX3 team,
From the example code in slavefifo_example\slfifosync, the UART in CyFxSlFifoApplnDebugInit (void) in the example code is pointing to CY_U3P_LPP_SOCKET_UART_CONS. meaning the UART message will be send to the physical UART port in cypress FX3 IC.
Can i reuse back the same code with minor change on :
and direct the UART message via USB to the host-PC and read it with teraterm terminal?
the example code i am refering to with the minor change is as in the picture attached.minor change in line 40
Show Less
Hi I am using FX3 USB superspeed hardware. I am trying to do file transfer from Master to Slave using cyusb_linux application. I have downloaded the latest application from your website. My OS is Ubuntu. I am getting the below errors LIBUSB_ERROR_TIMEOUT , LIBUSB_ERROR_OTHER and unable to clear halt data pipe. I want to transfer bulk files from master to slave. Kindly help me out in this. I have attached the screen shot. Thanks in advance.
Show LessHello, I'm using the Denebola kit, I'm trying to write data to SPI flash, I don't get any error while writing data, but when trying to read back I get a value as 0, one more thing to notice is, at some locations values is same as what I have I written.
Let me explain the whole thing clearly, present I'm using a failsafe firmware update, this is the source:https://community.infineon.com/t5/Resource-Library/FX3-Fail-Safe-Firmware-Update/ta-p/246074
but as explained there I'm not using I2C, instead, I'm using SPI, and I'm using the merger provided in the source to combine Images, so my partition is the same as explained in the source.
i.e, bootLoader Partition starts at 0x0000
Primary Firmware starts at 0x6000
Secondary Firmware starts at 0x23000
I'm able to boot to primary Firmware and Secondary Firmware,
I'm using the USBBulkSrcSink example provided in the source, in there I tried to write data to the 0x6000 location and read the data,
the values which are written is stored perfectly, but using the same process I tried to access 0x3FFFF values are not reflecting while reading, even I don't get any error while writing.
screen shot is shared :
Red bix shows code and green box shows output
Show Less
I'm trying to run FX3 for compliance testing. But It can't enter test mode. Are there any conditions to enter test mode?
Also, is there a way to tell if FX3 has entered test mode?
Thanks,
Tetsuo
Is it possible to change DMA configuration while running and restart DMA?
Below is a source that runs in 2-socket GPIF mode and runs fine.
and I want to stop GPIF and run it in loopback mode .
but it stop running.
The red source seems to be wrong.
Please give me guide line. Thank you.
dmaCfg.size = (usbSpeed == CY_U3P_SUPER_SPEED) ?(size * CY_FX_EP_BURST_LENGTH ) : (size);
dmaCfg.count = 4;
dmaCfg.validSckCount = 2;
dmaCfg.dmaMode = CY_U3P_DMA_MODE_BYTE;
dmaCfg.cb = NULL;
dmaCfg.notification = 0;
dmaCfg.prodSckId[0] = CY_U3P_PIB_SOCKET_0;
dmaCfg.prodSckId[1] = CY_U3P_PIB_SOCKET_1;
dmaCfg.consSckId[0] = CY_FX_EP_CONSUMER_SOCKET;
apiRetStatus = CyU3PDmaMultiChannelCreate (&glChHandleBulkSrc, CY_U3P_DMA_TYPE_AUTO_MANY_TO_ONE, &dmaCfg);
apiRetStatus = CyU3PDmaChannelSetXfer (&glChHandleBulkSrc, CY_FX_BULKSRCSINK_DMA_TX_SIZE);
( Runnig Well)
(change to loop back mode)
dmaCfg.prodSckId[0] = CY_U3P_CPU_SOCKET_PROD;
dmaCfg.prodSckId[1] = CY_U3P_CPU_SOCKET_PROD;// duplicate ?
dmaCfg.consSckId[0] = CY_FX_EP_CONSUMER_SOCKET;
dmaCfg.cb = CyFxBulkSrcSinkDmaCallback;
dmaCfg.notification = CY_U3P_DMA_CB_CONS_EVENT;
CyU3PGpifDisable(CyTrue);
CyU3PDmaMultiChannelAbort(&glChHandleBulkSrc);
apiRetStatus = CyU3PDmaMultiChannelCreate (&glChHandleBulkSrc, CY_U3P_DMA_TYPE_AUTO_MANY_TO_ONE, &dmaCfg);
apiRetStatus = CyU3PDmaChannelSetXfer (&glChHandleBulkSrc, CY_FX_BULKSRCSINK_DMA_TX_SIZE);
( running is stop)
我使用的开发板是CYUSB3KIT-003。开发板在StreamerExample模式下正常启动后,PC端通过EP0端口给开发板发送一个字节,开发板响应代码如下所示:
if(itype == 64 && itarget == 2 && ireq_type==66 && irequest == 11)
{
CyU3PDebugPrint(6, "switch to bootloader\r\n");
CyU3PUsbAckSetup ();
CyU3PThreadSleep (10);
app_stop();
CyU3PDebugDeInit ();
CyU3PUartDeInit ();
//CyU3PConnectState(CyFalse, CyFalse);
CyU3PUsbSetBooterSwitch (CyTrue);
CyU3PUsbJumpBackToBooter (0x40078000);
//CyU3PDeviceReset(CyTrue);
while (1)
CyU3PThreadSleep (100);
bis_handled = CyTrue;
}
我希望它切换到bootloader模式,结果设备不见了,如下图所示:
怎样用代码从StreamerExample模式切换到bootloader模式呢?如下图所示:
Show Less