USBSERIAL Reliability Issues with qf_ssi_ai_app
Posted: Sun Feb 21, 2021 10:19 pm
Hello,
One of the things I'd like to add to my project is the ability to perform diagnostics over the USB serial port, and keep the hard UART reserved for use with a different peripheral. My project is based off of
qorc-sdk/qf_apps/qf_ssi_ai_app/ in qorc-sdk as I felt this would be appropriate starting point to interface with the I2C sensors I needed.
One difference with this project from the helloworldsw project is that it uses a different clock rate 72MHz, but it looks like the code is configured to account for this when configuring the USB SERIAL, so I think it is intended to be a usable feature. It is also mentioned in the SensiML documentation as something that can be enabled in this project (at least for viewing debug output).
I have made the following modifications to enable the USB serial port.
In Fw_global_config.h
1. Set FEATURE_USBSERIAL to 1
2. Set DEBUG_UART to UART_ID_USBSERIAL
In main.c
1. Set the "int" in the delay loop to "volatile int", as I found it was getting optimized out. Without this, my Windows machine failed to recognize the device.
2. Before starting the scheduler, start the CLI task.
With just these changes, it seems that only part of what is expected will be printed to the terminal. After this, it seems that the USB SERIAL enters into a state where no more data is being printed to the screen.
While playing around with this, one interesting thing I found that is if I commented out this delay in cli_platform.c, that the CLI seems to run OK and I'm able to interact with the board over the USBSERIAL... except after a few minutes it seems to go into a hanging state again and I'm not able to interact with it anymore. Also, this is library code so I would prefer not to have to edit this file at all, but this was discovered while troubleshooting.
Based on the note here, one more idea I had was to also insert a busy wait in the HAL layer, waiting for the USB SERIAL to become empty again. But again, after some time it seems to just enter some kind of hanging state and never empties, and will fail to exit this while loop.
--
Wondering if anybody has any success with using the USB SERIAL with this qf_ssi_ai_app project? As I said this would be a nice feature to use for my project to do some diagnostics and keep the hard UART for one of my peripherals.
Would appreciate ideas or advice on troubleshooting this or thoughts on whether using this feature should be possible like this.
One of the things I'd like to add to my project is the ability to perform diagnostics over the USB serial port, and keep the hard UART reserved for use with a different peripheral. My project is based off of
qorc-sdk/qf_apps/qf_ssi_ai_app/ in qorc-sdk as I felt this would be appropriate starting point to interface with the I2C sensors I needed.
One difference with this project from the helloworldsw project is that it uses a different clock rate 72MHz, but it looks like the code is configured to account for this when configuring the USB SERIAL, so I think it is intended to be a usable feature. It is also mentioned in the SensiML documentation as something that can be enabled in this project (at least for viewing debug output).
I have made the following modifications to enable the USB serial port.
In Fw_global_config.h
1. Set FEATURE_USBSERIAL to 1
2. Set DEBUG_UART to UART_ID_USBSERIAL
Code: Select all
// In Fw_global_config.c
#define FEATURE_USBSERIAL 1 // USBSERIAL port is present
#define DEBUG_UART UART_ID_USBSERIAL // Write data to USB serial port
1. Set the "int" in the delay loop to "volatile int", as I found it was getting optimized out. Without this, my Windows machine failed to recognize the device.
Code: Select all
// In main.c
load_fpga(axFPGABitStream_length,axFPGABitStream); // Note that I'm quite confident the correct version of the USB FPGA IP is loaded (i.e. I can see it is the correct revision 0x200 in the debugger).
// Use 0x6141 as USB serial product ID (USB PID)
HAL_usbserial_init2(false, true, 0x6141); // Start USB serial not using interrupts
for (volatile int i = 0; i != 4000000; i++) ; // Give it time to enumerate <---- CHANGED
Code: Select all
#if (FEATURE_USBSERIAL == 1)
CLI_start_task( my_main_menu );
#endif
While playing around with this, one interesting thing I found that is if I commented out this delay in cli_platform.c, that the CLI seems to run OK and I'm able to interact with the board over the USBSERIAL... except after a few minutes it seems to go into a hanging state again and I'm not able to interact with it anymore. Also, this is library code so I would prefer not to have to edit this file at all, but this was discovered while troubleshooting.
Code: Select all
// In cli_platform.c
void CLI_task( void *pParameter )
{
(void)(pParameter);
int k;
//wait_ffe_fpga_load();
/* set to 1 to have a timestamp on the side */
// vTaskDelay(100); // <---- CHANGED
Code: Select all
// In eoss3_hal_fpga_serial.c
void HAL_usbserial_putc(char c) {
// Wait for room in Tx FIFO
while(pusbserial_regs->m2u_fifo_flags == 0)
;
pusbserial_regs->wdata = c;
// Wait until Tx FIFO is empty
while(pusbserial_regs->m2u_fifo_flags != 1)
;
}
Wondering if anybody has any success with using the USB SERIAL with this qf_ssi_ai_app project? As I said this would be a nice feature to use for my project to do some diagnostics and keep the hard UART for one of my peripherals.
Would appreciate ideas or advice on troubleshooting this or thoughts on whether using this feature should be possible like this.