2022-05-11 08:12 AM
Here are details about my project:
My USB device is using FAT32 format. I AM SORRY if I made some dumb mistake; I am newbie
2022-05-14 11:30 PM
@Community member @Javier Muñoz
Sorry for bothering you guys again. I have tried to solve DISKIO error but everything is working fine. There are no errors. Can low heap size cause FR_DISK_ERR??
I am posting the code I wrote in "USB_host.c" and my settings which I am using:
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "usb_host.h"
#include "usbh_core.h"
#include "usbh_msc.h"
/* USER CODE BEGIN Includes */
#include "ff.h"
/* USER CODE END Includes */
/* USER CODE BEGIN PV */
/* Private variables ----------------------------
* -----------------------------*/
FATFS USBH_fatfs;
FIL MyFile;
FRESULT res;
uint8_t oktext = "USB mounted !";
uint8_t text = "USB not mounted !";
extern char USBHpath[];
extern UART_HandleTypeDef huart3;
/* USER CODE END PV */
/* USER CODE BEGIN PFP */
/* Private function prototypes -----------------------------------------------*/
/* USER CODE END PFP */
/* USB Host core handle declaration */
USBH_HandleTypeDef hUsbHostFS;
ApplicationTypeDef Appli_state = APPLICATION_IDLE;
/*
* -- Insert your variables declaration here --
*/
/* USER CODE BEGIN 0 */
void UserPr(void)
{
if(f_mount(&USBH_fatfs, USBHpath, 1) != FR_OK)
{
HAL_UART_Transmit(&huart3, text, sizeof(text), 100);
}
else
{
HAL_UART_Transmit(&huart3, oktext, sizeof(oktext), 100);
}
}
/* USER CODE END 0 */
2022-05-15 05:12 PM
>>Can low heap size cause FR_DISK_ERR??
Generally speaking GNU/GCC hides a lot of potential size issues with heap/stack
Some of the USB Driver Stack for devices used the heap.
FATFS can use the heap for things like long filenames, etc, check ff_conf.h
It can also use the stack for auto/local variables, I'd typical look for at least 1 or 2 KB
Suggest the following syntax for the output
uint8_t text[] = "USB not mounted !";
HAL_UART_Transmit(&huart3, text, sizeof(text)-1, 100); // or strlen(text)
2022-05-16 08:33 AM
Thank you so much, I have tried everything by fat but I am still not able to mount my USB device, I am using 32GB pendrive; Is that a problem?
I am still getting FR_DISK_ERR. Can you guys post your settings and code?? So I cam identify problem