cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F767ZI FreeRTOS + USB_OTG MSC after update CubeIDE don't work!?

DK.7
Senior

I have a very simple code and it is works wery well in Cubeide V1.8.0 and the same code does not work at all in Cubeide v1.11.2.

file main.c

void Start_USB_Task(void const *argument) {
	/* USER CODE BEGIN Start_USB_Task */
	uint8_t sflag = 1;
	uint8_t rflag = 1;
	uint8_t dflag = 1;
	uint8_t iflag = 1;
	/* Infinite loop */
	for (;;) {
 
//		      MX_USB_HOST_Process();
 
		switch (Appli_state) {
		case APPLICATION_IDLE:
			HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, RESET);  // Blue
			HAL_GPIO_TogglePin(LD1_GPIO_Port, LD1_Pin); // Green
			if (iflag == 1) {
				printf("Removed a USB from STM32. \r\n");
				iflag = 0;
			}
			osDelay(100);
			break;
		case APPLICATION_START:
			dflag = 1;
			rflag = 1;
			iflag = 1;
			if (f_mount(&USBHFatFS, (const TCHAR*) USBHPath, 0) == FR_OK) {
				HAL_GPIO_WritePin(LD1_GPIO_Port, LD1_Pin, RESET);
				HAL_GPIO_WritePin(LD3_GPIO_Port, LD3_Pin, RESET);
				if (sflag == 1) {
					printf("APPLICATION is START. \r\n");
					sflag = 0;
				}
			}
			break;
		case APPLICATION_READY:
			dflag = 1;
			sflag = 1;
			iflag = 1;
			if (rflag == 1) {
				printf("APPLICATION is READY. \r\n");
				rflag = 0;
				HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, SET);  // Blue
				if (f_mount(&USBHFatFS, (const TCHAR*) USBHPath, 0) == FR_OK) {
					printf("USB is mounted success! \r\n");
				}
				if (f_mkdir((const TCHAR*) "ADC") == FR_OK) {
//				if (f_chdir("ADC") == FR_OK) {
					printf("Falder 'ADC' is CREATED! \r\n");
//				}
				}else{
					printf("Falder 'ADC' is NOT created! \r\n");
				}
				if (f_open(&USBHFile, (const TCHAR*) "ADC.TXT",
				FA_WRITE | FA_OPEN_APPEND) == FR_OK) {
					sprintf(hold, "%s", "ADC VALUES NOT PRESENT! \r\n");
					RES = f_write(&USBHFile, (const void*) hold, strlen(hold),
							&Byteswritten);
					if (RES != FR_OK || Byteswritten == 0) {
//					return 0;
					} else {
						for (int n = 0; n < 3; n++) {
							HAL_GPIO_TogglePin(LD3_GPIO_Port, LD3_Pin); // Red
							osDelay(250);
						}
					}
				}else{
					printf("File is NOT created! \r\n");
				}
				f_close(&USBHFile);
			}
			break;
		case APPLICATION_DISCONNECT:
			sflag = 1;
			rflag = 1;
			iflag = 1;
			if (dflag == 1) {
				f_mount(NULL, (TCHAR const*) "", 0); // Then flash is removed
				printf("APPLICATION is DISCONNECT. \r\n");
				dflag = 0;
			}
			HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, RESET);  // Blue
			HAL_GPIO_TogglePin(LD3_GPIO_Port, LD3_Pin); // Red
			osDelay(100);
			break;
		default:
			printf("Error! operator is not correct \r\n");
		}
 
	}
	/* USER CODE END Start_USB_Task */
}

The reason: function "USBH_USERPROCESS" never gets state

"Case host_user_class_active:
  Appli_state = Application_Rready;

If you insert a USB flash drive, it gets state

  case HOST_USER_CONNECTION:
  Appli_state = APPLICATION_START;
  break;

If you take out the USB flash drive, it gets state

CASE HOST_USER_DISCONNECTION:
  Appli_state = Application_disConnect;
  Break;

But, as I wrote above, the function "USBH_USERPROCESS" never gets gets state

"Case host_user_class_active:
Appli_state = Application_Rriedy;
Break;

Could someone tell me what was changed and how to fix it?

1 REPLY 1
DK.7
Senior

I turned on the debag for the USB to compare in the working version in CubeIDE v1.8.0 with a non -working CubeIDE v1.11.2

Could someone tell me how to fix initialisation of USB?

And below comparison

0693W00000aHep7QAC.png