cancel
Showing results for 
Search instead for 
Did you mean: 

USBX MSC device function USBD_STORAGE_Write() parameters

Kelly3
Associate III

Hi,

I am running firmware for USBX MSC device. The example project  "Ux_Device_MSC" on demo board STM32U575I-EV.  MSC device is enumerated on computer and FATS file system is used. It can transfer file from computer to storage on STM32U575I-EV.  I am trying to figure out the following parameters.

1. how many times the following function in source file "ux_device_msc.c" is called when transfer a large file

UINT USBD_STORAGE_Write(VOID *storage_instance, ULONG lun, UCHAR *data_pointer, ULONG number_blocks, ULONG lba, ULONG *media_status)
{
UINT status = UX_SUCCESS;

/* USER CODE BEGIN USBD_STORAGE_Write */
UX_PARAMETER_NOT_USED(storage_instance);
UX_PARAMETER_NOT_USED(lun);
UX_PARAMETER_NOT_USED(media_status);

ULONG WriteFlags = 0U;

/* Check if the SD card is present */
if (HAL_GPIO_ReadPin(GPIOI, GPIO_PIN_0) == GPIO_PIN_SET)
{

/* Check id SD card is ready */
if(check_sd_status() != HAL_OK)
{
Error_Handler();
}

/* Start the Dma write */
status = HAL_SD_WriteBlocks_DMA(&hsd1, data_pointer, lba, number_blocks);
if(status != HAL_OK)
{
Error_Handler();
}

/* Wait on writeflag until SD card is ready to use for new operation */
if (tx_event_flags_get(&EventFlag, SD_WRITE_FLAG, TX_OR_CLEAR, &WriteFlags, TX_WAIT_FOREVER) != TX_SUCCESS)
{
Error_Handler();
}
}
/* USER CODE END USBD_STORAGE_Write */

return status;
}
 

 

2. What is the parameter *data_pointer, number_blocks and lba are when transfer

a large file from computer to storage.

I run debug mode and set break point at line: status = HAL_SD_WriteBlocks_DMA(&hsd1, data_pointer, lba, number_blocks);

Yet, I am not able to run to this endpoint. May I know the values or how to know the values of parameters

in question 1 and 2?

 

Thank you very much.


Edited to apply source code formatting - please see How to insert source code for future reference.

3 REPLIES 3
Pavel A.
Super User

Do you get to line 17 (check_sd_status) ?

 

how many times the following function in source file "ux_device_msc.c" is called when transfer a large file

At least once.

 

Pavel,

I am not able to pause at line 17 in debugging mode. But I am pretty sure that this function is good since if I download firmware and in run mode, the device functions as MSC properly.

Regards,

Kelly

Then I suspect that something worse is happening there. Like, too much code is optimized out by linker.

Try inserting hardcoded breakpoints ( __BKPT(0) ) to be absolutely sure whether execution arrives to some point or not.