cherryUSB + MSC (NOR Flash) + FATFS: How to implement so it can be used as a USB drive and accessed by programs?

cherryUSB + msc (nor-flash) + fatfs: How to implement so it works both as a USB drive and allows program access?

I used the msc program to make it appear as a USB drive.

#ifndef FS_REGION_START_ADDR
    #error "Need to define file system start address!"
#endif

#define FS_ROOT "root"

/**
 * @brief Mount fs.
 */
int mnt_init(void)
{
    register_mtd_device(FS_REGION_START_ADDR, FS_REGION_SIZE, FS_ROOT);
    if (dfs_mount(FS_ROOT, "/", "elm", 0, 0) == 0) // fs exist
    {
        rt_kprintf("mount fs on flash to root success\n");
    }
    else
    {
        // auto mkfs, remove it if you want to mkfs manually
        rt_kprintf("mount fs on flash to root fail\n");
        if (dfs_mkfs("elm", FS_ROOT) == 0) // Format file system
        {
            rt_kprintf("make elm fs on flash success, mount again\n");
            if (dfs_mount(FS_ROOT, "/", "elm", 0, 0) == 0)
                rt_kprintf("mount fs on flash success\n");
            else
                rt_kprintf("mount fs on flash fail\n");
        }
        else
            rt_kprintf("dfs_mkfs elm flash fail\n");
    }
    return RT_EOK;
}
INIT_ENV_EXPORT(mnt_init);

But the two accesses (USB and program) do not point to the same files.
However, I checked and the FLASH addresses are the same:

#define MSC_BLOCK_SIZE           512
#define FLASH_MSC_START_ADDR     (FS_REGION_START_ADDR)
#define FLASH_MSC_TOTAL_SIZE     (FS_REGION_SIZE)

#ifndef SPI_NOR_SECT_SIZE
    #define SPI_NOR_SECT_SIZE    4096
#endif

I didn’t quite understand the requirement. What do you mean by “acting as a USB drive and also being programmatically accessible”?

Mount FS_ROOT onto elm, or connect via USB to turn it into a USB drive. The computer can then access the space of FS_ROOT.

Change the configuration values in these two locations to 4096 so they match the physical sector size of the flash memory, allowing proper recognition.