USB and MSC class sample

Hi everyone,
I've used mass storage code from sample codes of KEIL on AT91SAM7x256.
And it works correctly;
Now I want to change the Memory size show in the My computer (it always show 6 kB!). I'v changed

 MSC_MemorySize

but It still shows 6 KB!
can anyone help me?
thanks for your help!

After that I want to use another type of memory for example SD card instead of SRAM for memory use in this sample. This very important to me. I am so grateful for your help.

Parents
  • > I've used mass storage code from sample codes of KEIL on AT91SAM7x256.

    Do you mean this example on Keil MDK-ARM v4 ?
    C:\Keil\ARM\Boards\Atmel\AT91SAM7X-EK\USB\Memory

    > I'v changed MSC_MemorySize but It still shows 6 KB!

    There are a couple of values you have to touch.

    a) size of ROM DiskImage[] and RAM Memory[] array

    memory.h
    
    /* MSC Disk Image Definitions */
    #define MSC_ImageSize   0x00001000
    

    b) BPB (BIOS Parameter Block) on the ROM DiskImage[] array

    DiskImage[] array holds FAT format (without MBR)

    BPB            1 sector (1 sector = 512 bytes)
    FAT            2
    root directory 1
    file sectors   rest
    

    totalSectors field of BPB shows 0x0010 sectors (in LSB-first format)

    DiskImg.c
    
    const unsigned char DiskImage[MSC_ImageSize] = {
    0xEB,0x3C,0x90,                                           // JmpOpCode
    0x4D,0x53,0x44,0x4F,0x53,0x35,0x2E,0x30,                  // OEMName: MSDOS5.0
    0x00,0x02,                                                // bytesPerSector
    0x01,                                                     // sectorsPerCluster
    0x01,0x00,                                                // reservedSectors
    0x01,                                                     // numberOfFATs
    0x10,0x00,                                                // rootEntries
    0x10,0x00,                                                // totalSectors  <————
    0xF8,                                                     // mediaDescriptor
    0x02,0x00,                                                // sectorsPerFAT
    0x01,0x00,                                                // sectorsPerTrack
    0x01,0x00,                                                // heads
    0x00,0x00,0x00,0x00,                                      // hiddenSectors
    0x00,0x00,0x00,0x00,                                      // bigTotalSectors
    0x00,                                                     // driveNumber
    0x00,                                                     // unused
    0x29,                                                     // extBootSignature
    0x74,0x19,0x02,0x27,                                      // serialNumber
    0x41,0x54,0x53,0x41,0x4D,0x37,0x58,0x5F,0x55,0x53,0x42,   // volumeLabel: ATSAM7X_USB
    0x46,0x41,0x54,0x31,0x32,0x20,0x20,0x20,                  // fileSystemType: FAT12
    

    c) response to SCSI READ_CAPACITY_10 and READ_FORMAT_CAPACITIES

    These SCSI commands returns this volume capacity

    mscuser.h
    
    #define MSC_MemorySize  8192
    

    Assign same number (a multiple of 512) to MSC_ImageSize and MSC_MemorySize
    Divide this number by 512 (number of sectors), and set it to totalSectors field of BPB

    Tsuneo

Reply
  • > I've used mass storage code from sample codes of KEIL on AT91SAM7x256.

    Do you mean this example on Keil MDK-ARM v4 ?
    C:\Keil\ARM\Boards\Atmel\AT91SAM7X-EK\USB\Memory

    > I'v changed MSC_MemorySize but It still shows 6 KB!

    There are a couple of values you have to touch.

    a) size of ROM DiskImage[] and RAM Memory[] array

    memory.h
    
    /* MSC Disk Image Definitions */
    #define MSC_ImageSize   0x00001000
    

    b) BPB (BIOS Parameter Block) on the ROM DiskImage[] array

    DiskImage[] array holds FAT format (without MBR)

    BPB            1 sector (1 sector = 512 bytes)
    FAT            2
    root directory 1
    file sectors   rest
    

    totalSectors field of BPB shows 0x0010 sectors (in LSB-first format)

    DiskImg.c
    
    const unsigned char DiskImage[MSC_ImageSize] = {
    0xEB,0x3C,0x90,                                           // JmpOpCode
    0x4D,0x53,0x44,0x4F,0x53,0x35,0x2E,0x30,                  // OEMName: MSDOS5.0
    0x00,0x02,                                                // bytesPerSector
    0x01,                                                     // sectorsPerCluster
    0x01,0x00,                                                // reservedSectors
    0x01,                                                     // numberOfFATs
    0x10,0x00,                                                // rootEntries
    0x10,0x00,                                                // totalSectors  <————
    0xF8,                                                     // mediaDescriptor
    0x02,0x00,                                                // sectorsPerFAT
    0x01,0x00,                                                // sectorsPerTrack
    0x01,0x00,                                                // heads
    0x00,0x00,0x00,0x00,                                      // hiddenSectors
    0x00,0x00,0x00,0x00,                                      // bigTotalSectors
    0x00,                                                     // driveNumber
    0x00,                                                     // unused
    0x29,                                                     // extBootSignature
    0x74,0x19,0x02,0x27,                                      // serialNumber
    0x41,0x54,0x53,0x41,0x4D,0x37,0x58,0x5F,0x55,0x53,0x42,   // volumeLabel: ATSAM7X_USB
    0x46,0x41,0x54,0x31,0x32,0x20,0x20,0x20,                  // fileSystemType: FAT12
    

    c) response to SCSI READ_CAPACITY_10 and READ_FORMAT_CAPACITIES

    These SCSI commands returns this volume capacity

    mscuser.h
    
    #define MSC_MemorySize  8192
    

    Assign same number (a multiple of 512) to MSC_ImageSize and MSC_MemorySize
    Divide this number by 512 (number of sectors), and set it to totalSectors field of BPB

    Tsuneo

Children
More questions in this forum