This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

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
  • To make media content Write protect you need to return WP bit set to one in ModeSense response.

    In mscuser.c module change ModeSense6/ModeSense10 functions:

    void MSC_ModeSense6 (void) {
    
      if (!DataInFormat()) return;
    
      BulkBuf[ 0] = 0x03;
      BulkBuf[ 1] = 0x00;
      BulkBuf[ 2] = 0x80;   <---- was 0x00
      BulkBuf[ 3] = 0x00;
      ...
    }
    
    void MSC_ModeSense10 (void) {
    
      if (!DataInFormat()) return;
    
      BulkBuf[ 0] = 0x00;
      BulkBuf[ 1] = 0x06;
      BulkBuf[ 2] = 0x00;
      BulkBuf[ 3] = 0x80;   <---- was 0x00
      BulkBuf[ 4] = 0x00;
      BulkBuf[ 5] = 0x00;
      ...
    }
    

    To retarget media from memory to SD Card you need to retarget read and writes from memory to SD Card.
    So you need to change functions MSC_MemoryRead, MSC_MemoryWrite and MSC_MemoryVerify functions in mscuser.c file to use SD Card write/read instead of memory write/read.

Reply
  • To make media content Write protect you need to return WP bit set to one in ModeSense response.

    In mscuser.c module change ModeSense6/ModeSense10 functions:

    void MSC_ModeSense6 (void) {
    
      if (!DataInFormat()) return;
    
      BulkBuf[ 0] = 0x03;
      BulkBuf[ 1] = 0x00;
      BulkBuf[ 2] = 0x80;   <---- was 0x00
      BulkBuf[ 3] = 0x00;
      ...
    }
    
    void MSC_ModeSense10 (void) {
    
      if (!DataInFormat()) return;
    
      BulkBuf[ 0] = 0x00;
      BulkBuf[ 1] = 0x06;
      BulkBuf[ 2] = 0x00;
      BulkBuf[ 3] = 0x80;   <---- was 0x00
      BulkBuf[ 4] = 0x00;
      BulkBuf[ 5] = 0x00;
      ...
    }
    

    To retarget media from memory to SD Card you need to retarget read and writes from memory to SD Card.
    So you need to change functions MSC_MemoryRead, MSC_MemoryWrite and MSC_MemoryVerify functions in mscuser.c file to use SD Card write/read instead of memory write/read.

Children