STM32F105 mass storage device: file system breaks when writing a file larger than 12 KB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2020-10-11 3:41 AM
Hello! If I write less than 12KB #MSD works fine. If I write more than 12KB, Windows7 will ask me to format the drive. If the MSD is not reconnected to the PC, everything works fine. Everything breaks down if Ireconnect the device to the PC. Please tell me what could be wrong?
I am using flash with page size 264 B (2048 pages) [AT45DB041]
The defines looks like this
STORAGE_BLK_NBR 1024
STORAGE_BLK_SIZ 512
The write operation looks like this
int8_t STORAGE_Write_FS(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len)
{
/* USER CODE BEGIN 7 */
AT45dbxx_WritePage(buf, 256, (uint16_t)blk_addr*2);
AT45dbxx_WritePage(buf+256, 256, ((uint16_t)blk_addr*2)+1);
return (USBD_OK);
/* USER CODE END 7 */
}
I write two pages of 256 bytes
W / R memory operations are working properly.
Memory addressing also works correctly. Checked read / write of all 2048 pages
#msd
#AT45DB
Solved! Go to Solution.
- Labels:
-
Flash
-
STM32F1 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2020-10-11 4:15 AM
Do you need to erase the blocks?
Don't seem to handle multiple block writes.
Test the read/write functionality oitside of the USB operation.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2020-10-11 4:15 AM
Do you need to erase the blocks?
Don't seem to handle multiple block writes.
Test the read/write functionality oitside of the USB operation.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2020-10-11 4:34 AM
Thanks for the answer. Yes, I tested it separately. That being said, if I write files less than 12 KB, everything works well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2020-10-13 8:42 AM
The code presented writes a single block, it will clearly fail to do the job if asked to write more than one.
blk_len is a count of 512 byte blocks
Up vote any posts that you find helpful, it shows what's working..
