cancel
Showing results for 
Search instead for 
Did you mean: 

USB Mass Storage with SPI Flash Storage

saimaddy123
Associate II
Posted on May 13, 2011 at 17:28

USB Mass Storage with SPI Flash Storage

13 REPLIES 13
saimaddy123
Associate II
Posted on May 17, 2011 at 14:34

I started porting Mass Storage library and I am hitting with an issue... I am hitting with a hardFault in the library when the data into incoming EP(EP1) is copied into it's FIFO. OTGD_FS_WritePacket is called from ISR. Not sure why i am getting hit with the ASSERT at the step that I have highlighted in the below code. Did any one hit with such an issue? This issue is blocking me. Any one please help with this?

USB_OTG_Status OTGD_FS_WritePacket(uint8_t *src, uint8_t ep_num, uint16_t bytes)

{

  USB_OTG_Status status = USB_OTG_OK;

  uint32_t dword_count = 0 , i = 0;

  __IO uint32_t *fifo;

  /* Find the DWORD length, padded by extra bytes as neccessary if MPS

   * is not a multiple of DWORD */

  dword_count =  (bytes + 3) / 4;

  fifo = USB_OTG_FS_regs.FIFO[ep_num];

  for (i = 0; i < dword_count; i++, src += 4)

  {

    USB_OTG_WRITE_REG32( fifo, *((__packed uint32_t *)src) );

  }

Posted on May 17, 2011 at 14:34

Is src DWORD aligned, what is the address when it fails?

Can you provide the CPU (reg,stack,core) state from your Hard Fault handler?

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
saimaddy123
Associate II
Posted on May 17, 2011 at 14:34

BTW, Virtual COM port application works just fine on the same USB library. Not sure if this is something specific to Mass Storage...

saimaddy123
Associate II
Posted on May 17, 2011 at 14:34

Hi Clive,

when it fails, the address of src appears to be 0x20001000

Please see the attached screen shots...

Posted on May 17, 2011 at 14:34

when it fails, the address of src appears to be 0x20001000

Please see the attached screen shots...

 

No it's 0x20010000, ie at 64K, as I recall the 107 only has 64KB of RAM, so you're touching memory beyond the part's scope and it's hard faulting as a result.

You should also be looking at the code in the disassembled form to see what registers are used, and the actual instruction that faulted. You should also consider a more effective Hard Fault handler, like the one Joseph Yiu has published, that can output the core state. It's helpful when you need to track down a problem, but don't have jtag/debugger access.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
saimaddy123
Associate II
Posted on May 17, 2011 at 14:34

Thanks clive.. I figured this out and now the device is recognized by windows as a mass storage device.

Somehow, I can not create any new posts in this forum... Is there any issue going on with forum?

saimaddy123
Associate II
Posted on May 17, 2011 at 14:34

saimaddy123
Associate II
Posted on May 17, 2011 at 14:34

Folks,

I am working on porting Mass Storage library on STM32F107. I have a Spansion S25FL064K connected to SPI interface

of STM32F107. As the current Mass Storage library does not support SPI Flash interface, I have ported the SPI flash interface and changed the MAL layer(mass_mal.c) in the mass storage library to interface with flash connected to SPI interface. I have declared Max_LUn value to 0. Do I need to make any further changes?

With this, The device is detected by windows properly. But, as soon as device is detected as Removable disk, I am

posed with a message from windows - ''You need to format the disk in F:\ before you can use it'' . I did not expect this to happen. I thought my device will be detected as an 8MB removable hard disk.  Is it an expected behavior even for an SD card or NAND FLASH without any file system or these devices are normally detected? Any one faced with such issue earlier or any pointer to what could be going wrong? 

However, I tried to format the device but i am blessed with an error saying windows can not format the device. I have read mass storage demo documentation as well. As per the documentation, the drive need not have any file system mounted on it as Windows reads the data block by block.

Do I need to make any further changes to the Mass Storage library apart from these for this to work as I expected? Any help would be greatly appreciated. 

Thanks,

Sai

saimaddy123
Associate II
Posted on May 17, 2011 at 14:34

Can any one give pointers on this?? I am really struck.. I expected Mass storage library will expect as documented where as I do not see that...

Thanks