Using USB MSC with internal flash in MK64

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using USB MSC with internal flash in MK64

657 Views
letitfly
Contributor I

Hello,

I want my Hexiwear (MK64) act as USB mass storage when connected with PC.

But in this USB msc driver, the data partition was hardcoded as below. And I can't use internal flash with this driver.

How can I link msc with internal flash?

In addition, how can I set my flash memory map?

Header 1

static const mbr_t mbr = {
    .boot_sector = {
        0xEB,0x3C, // x86 Jump
        0x90,      // NOP
        'M','S','W','I','N','4','.','1' // OEM Name in text
    },

    .bytes_per_sector         = MBR_BYTES_PER_SECTOR,
    .sectors_per_cluster      = WANTED_SECTORS_PER_CLUSTER,
    .reserved_logical_sectors = 1,
    .num_fats                 = 2,
    .max_root_dir_entries     = 32,
    .total_logical_sectors    = ((MBR_NUM_NEEDED_SECTORS > 32768) ? 0 : MBR_NUM_NEEDED_SECTORS),
    .media_descriptor         = MEDIA_DESCRIPTOR,
    .logical_sectors_per_fat  = MBR_SECTORS_PER_FAT, /* Need 3 sectors/FAT for every 1024 clusters */

    .physical_sectors_per_track = 1,
    .heads = 1,
    .hidden_sectors = 0,
    .big_sectors_on_drive = ((MBR_NUM_NEEDED_SECTORS > 32768) ? MBR_NUM_NEEDED_SECTORS : 0),

    .physical_drive_number = 0,
    .not_used = 0,
    .boot_record_signature = 0x29,
    .volume_id = 0x27021974,
    .volume_label = {'M','b','e','d',' ','U','S','B',' ',' ',' '},
    .file_system_type = {'F','A','T','1','2',' ',' ',' '},

    /* Executable boot code that starts the operating system */
    .bootstrap = {
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
    },
    .signature = 0xAA55,
};

.....................................................

  

SECTOR sectors[] = {
    /* Reserved Sectors: Master Boot Record */
    {(const uint8_t *)&mbr , 512},

    /* FAT Region: FAT1 */
    {fat1, sizeof(fat1)},   // fat1, sect1
    EMPTY_FAT_SECTORS

    /* FAT Region: FAT2 */
    {fat2, 0},              // fat2, sect1
    EMPTY_FAT_SECTORS

    /* Root Directory Region */
    {root_dir1, sizeof(root_dir1)}, // first 16 of the max 32 (mbr.max_root_dir_entries) root dir entries
    {root_dir2, sizeof(root_dir2)}, // last 16 of the max 32 (mbr.max_root_dir_entries) root dir entries

    /* Data Region */

    // Section for mac compatibility
    {sect5, sizeof(sect5)},

    // contains mbed.htm
    {(const uint8_t *)BlockBuf, 512},
};

Labels (2)
2 Replies

473 Views
mjbcswitzerland
Specialist V

Hi

You can get USB-MSD device for K64 with internal Flash or FAT emulation http://www.utasker.com/docs/uTasker/uTaskerEmulatedFAT.pdf
form the uTasker project: http://www.utasker.com/kinetis/FRDM-K64F.html

Regards

Mark

473 Views
letitfly
Contributor I

Hi, Mark.

I can not see the source code yet. But the document that you linked, is exactly I want.

I will try with uTasker source code

Thank you for your answer.

Regrads

Jee

0 Kudos