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.
> 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
Dear Tsuneo, Yes, I mean that. Thank you so much. Now I got something.Your answers are the most effective and complete ones all over this forum. In my
DiskImg.c
, it just the numbers without the details (descriptions you write).
/* Disk Image */ #include "memory.h" const unsigned char DiskImage[MSC_ImageSize] = { 0xEB,0x3C,0x90,0x4D,0x53,0x44,0x4F,0x53,0x35,0x2E,0x30,0x00,0x02,0x01,0x01,0x00, 0x01,0x10,0x00,0x10,0x00,0xF8,0x02,0x00,0x01,0x00,0x01,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x29,0x74,0x19,0x02,0x27,0x41,0x54,0x53,0x41,0x4D, 0x37,0x58,0x5F,0x55,0x53,0x42,0x46,0x41,0x54,0x31,0x32,0x20,0x20,0x20,0x33,0xC9, 0x8E,0xD1,0xBC,0xF0,0x7B,0x8E,0xD9,0xB8,0x00,0x20,0x8E,0xC0,0xFC,0xBD,0x00,0x7C, 0x38,0x4E,0x24,0x7D,0x24,0x8B,0xC1,0x99,0xE8,0x3C,0x01,0x72,0x1C,0x83,0xEB,0x3A, 0x66,0xA1,0x1C,0x7C,0x26,0x66,0x3B,0x07,0x26,0x8A,0x57,0xFC,0x75,0x06,0x80,0xCA, 0x02,0x88,0x56,0x02,0x80,0xC3,0x10,0x73,0xEB,0x33,0xC9,0x8A,0x46,0x10,0x98,0xF7, 0x66,0x16,0x03,0x46,0x1C,0x13,0x56,0x1E,0x03,0x46,0x0E,0x13,0xD1,0x8B,0x76,0x11, 0x60,0x89,0x46,0xFC,0x89,0x56,0xFE,0xB8,0x20,0x00,0xF7,0xE6,0x8B,0x5E,0x0B,0x03, 0xC3,0x48,0xF7,0xF3,0x01,0x46,0xFC,0x11,0x4E,0xFE,0x61,0xBF,0x00,0x00,0xE8,0xE6, 0x00,0x72,0x39,0x26,0x38,0x2D,0x74,0x17,0x60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xF8,0xC3,0x41,0xBB,0x00,0x00,0x60,0x66,0x6A,0x00,0xEB, 0xB0,0x4E,0x54,0x4C,0x44,0x52,0x20,0x20,0x20,0x20,0x20,0x20,0x0D,0x0A,0x52,0x65, 0x6D,0x6F,0x76,0x65,0x20,0x64,0x69,0x73,0x6B,0x73,0x20,0x6F,0x72,0x20,0x6F,0x74, 0x68,0x65,0x72,0x20,0x6D,0x65,0x64,0x69,0x61,0x2E,0xFF,0x0D,0x0A,0x44,0x69,0x73, 0x6B,0x20,0x65,0x72,0x72,0x6F,0x72,0xFF,0x0D,0x0A,0x50,0x72,0x65,0x73,0x73,0x20, 0x61,0x6E,0x79,0x20,0x6B,0x65,0x79,0x20,0x74,0x6F,0x20,0x72,0x65,0x73,0x74,0x61, 0x72,0x74,0x0D,0x0A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xAC,0xCB,0xD8,0x55,0xAA, 0xF8,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, ....
and I don't know what they are but now I understand and go to change the code according to your help. And can you name a reference to make these numbers clear for me? And what about the another question? Can you help me as clear as your previous answer. I want to use another type of memory for example SD card or internal FLASH. I will be so grateful. Thank you again.
Sometimes, it doesn't hurt to try Google. support.microsoft.com/.../140418 averstak.tripod.com/.../bootsec.htm www.ntfs.com/fat-partition-sector.htm www.dewassoc.com/.../boot_sector.htm ...
Google is full with references.
Dear Per, You are right. But I have no idea about the numbers in DiskImg.c so I don't know what to search. And thank you so much.
I have a another question. How I can change the properties of the file readme.txt that shows in the computer inside the flash memory? I mean that the file would be for example read only and the users in the computer could not change that?
A file is read-only if the directory entry has the read-only flag, or if the file system is mounted read-only.
How to change the read-only flag for a directory entry? Same suggestion as in my previous post. Google can find all information about the structures of a FAT file system. The boot record - which I have already given you multiple references to, allows you to figure out the location of the root directory. And that is where you find the directory entry for your "readme.txt" file, and so can find the attributes flag field.
A directory in a FAT file system is just a file but with an attribute flag saying it's a directory. So the documentation available about the FAT file system allows anyone interested to also figure out how to locate directory entries of files in subdirectories. And how to locate the actual file data for files.
There are even a number of binary editor programs that are able to view information as important structures of FAT file systems - originally intended for people trying to recover data from broken diskettes or hard disks.
But in the end, you'll get better progress if you spend time trying to search for information. Each attempt you learn how to make better and better searches.
View all questions in Keil forum