This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SDK16 USB MSC - Understanding working buffers

Hi everyone,

I am working on USB MSC example. I have two questions.

1. What is the MSC_WORKBUFFER_SIZE defines in the example? Is the last parameter of APP_USBD_MSC_GLOBAL_DEF function. The documentation says that is the " Work buffer size (need to fit into all block devices from block device list)", What does it mean?

    a.  What's the purpose? I understand that this is somehow related to the number of block devices?

    b. How does it calculated for each specific project? For instance, why the example defines MSC_WORKBUFFER_SIZE (1024)?

#define MSC_WORKBUFFER_SIZE (1024)

/*lint -save -e26 -e64 -e123 -e505 -e651*/
/**
 * @brief Mass storage class instance
 */
APP_USBD_MSC_GLOBAL_DEF(m_app_msc,
    0,
    msc_user_ev_handler,
    ENDPOINT_LIST(),
    BLOCKDEV_LIST(),
    MSC_WORKBUFFER_SIZE);


2. The second question is related to the f_mkfs() function. 

    a. What is the purpose of the 4th parameter

    b. How does it calculated for each specific project? For instance, why the example sets the working buffer to 512bytes?

static uint8_t buf[512];
ff_result = f_mkfs("", FM_FAT, 1024, buf, sizeof(buf)); 

Thanks in advance

Nick

Parents
  • I think I will need to look into question 1, I assume it related to the work buffer size for the mass storage drive, larger should typically be faster.

    Regarding 2. From (http://elm-chan.org/fsw/ff/doc/mkfs.html):

    work
    Pointer to the working buffer used for the format process. When a null pointer is given with FF_USE_LFN == 3, the function obtains a memory block in this function for the working buffer.
    len
    Size of the working buffer in unit of byte. It needs to be FF_MAX_SS at least. Plenty of working buffer reduces number of write transactions to the drive and the format process will finish quickly.
Reply
  • I think I will need to look into question 1, I assume it related to the work buffer size for the mass storage drive, larger should typically be faster.

    Regarding 2. From (http://elm-chan.org/fsw/ff/doc/mkfs.html):

    work
    Pointer to the working buffer used for the format process. When a null pointer is given with FF_USE_LFN == 3, the function obtains a memory block in this function for the working buffer.
    len
    Size of the working buffer in unit of byte. It needs to be FF_MAX_SS at least. Plenty of working buffer reduces number of write transactions to the drive and the format process will finish quickly.
Children
Related