Skip to main content
NikDobro
Associate II
October 24, 2018
Solved

Nucleo-144 STM32F767. Example USB-MSC-Device doesn't connect to PC correctly.

  • October 24, 2018
  • 2 replies
  • 1102 views

Hi, colleges!

I use Nucleo-144 STm32F767 development board to learn USB.

Now - Application example - device USB MSC.

The example uses SD card, with I haven't. I want to use internal instead of SD card. So, I changed the "usbd_storage.c" file. Plugged and not played =) Error - Cann't start this device (code 10).

My STM32 is falling in HardFault_Handler. I've put break point in "Handle Enumeration done Interrupt" and seen the process has stopped. The enumeration process is done. Ok.

What is going then? Which step is next? Where I need to put my break point?

I don't really know how to debug USB transaction and communication process. Wireshark doesn't see my device at all.

/* Private variables ---------------------------------------------------------*/
uint8_t usbMassStorage[0x1000];
....
 
int8_t STORAGE_GetCapacity(uint8_t lun, uint32_t *block_num, uint16_t *block_size)
{
 *block_num = sizeof(usbMassStorage)/512;
 *block_size = 512;
 return 0;
}
 
int8_t STORAGE_IsReady(uint8_t lun)
{
 return 0;
}
 
int8_t STORAGE_IsWriteProtected(uint8_t lun)
{
 return 0;
}
 
int8_t STORAGE_Read(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len)
{
 memcpy(buf,&usbMassStorage[blk_addr],blk_len);
 return 0;
}
 
int8_t STORAGE_Write(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len)
{
 memcpy(&usbMassStorage[blk_addr],buf,blk_len);
 return 0;
}
 
int8_t STORAGE_GetMaxLun(void)
{
 return(STORAGE_LUN_NBR - 1);
}
 

This topic has been closed for replies.
Best answer by NikDobro

One problem is solve. The PC detects my STM32 MCU as MSC.

I've just changed string descriptors index to 0x00 in device descriptor.

How can I write or read smth to/from my MCU? Why it shows 0 kb memory disk?

2 replies

NikDobro
NikDobroAuthorAnswer
Associate II
October 24, 2018

One problem is solve. The PC detects my STM32 MCU as MSC.

I've just changed string descriptors index to 0x00 in device descriptor.

How can I write or read smth to/from my MCU? Why it shows 0 kb memory disk?

Pavel A.
Super User
October 25, 2018

> Why it shows 0 kb memory disk?

Because 0x1000 is 4K bytes. 8 blocks. Too small to create any decent filesystem.

-- pa

NikDobro
NikDobroAuthor
Associate II
October 25, 2018

I'm not sure. I tried with concrete values.

 *block_num = 0x100;
 *block_size = 0x20;

It gave the same result. But MS OS suggested me to format disk. In the window I saw 8 kb. But then was error in format disk process.