write sequence of 512 byte MSC blocks mixed up? writing less than expected? #958
Replies: 6 comments
-
hmm, I have a feeling this may not be TinyUSB bug at all. It probably has something to do with FAT FS. The msc ramdisk example is a quick hack. You probably need to have a better fatfs implementation. TinyUSB work well with elm-chan fatfs on actual flash device and ghostfast (virtual fs) https://github.com/adafruit/tinyuf2/blob/master/src/ghostfat.c. However, lpc1788 isn't used much, It could be lpc1788 specific issue. Can you try to enable the |
Beta Was this translation helpful? Give feedback.
-
Same with me. I suspect it in the msc example source as well. Today I will step throu the code and set some breakpoints in order to see how block number sequence is generated and why not all of them are written. |
Beta Was this translation helpful? Give feedback.
-
Do you happen to have any samd21/51 or nrf52, pico boards to test with. Those are most used and tested mcus, just to rule out lpc1788 specific issue. Note: If you need my help to test this, please attach
Note: I forgot to mention, the ramdisk example have 1 cluser = 1 sector = 512 bytes, you need to keep it in mind when inteprete the fat data, and need to make sure the total data (file payload + overhead) is not exceed the total size. Maybe try to inrease the ramdisk size to 32KB for a quick test.
|
Beta Was this translation helpful? Give feedback.
-
Thanks for picking this up. There is not enough ram to further increase ramdisk. But after some debugging with 512byte sectors I can say:
Because of point 3, I decided to completely change approach. Instead of mirroring flash to ramdisk and vice versa, the LPC will directly read/write 4094 byte flash blocks (size given by lower LPC flash sectors). Unfortunately MSC will not correctly show up in windows. I do see the drive, but name is not visible. Debugger tells me that USB buffer gets loaded from flash boot sector correctly. I certainly increased block size (FAT bytes 11/12 to 0x10/0x00) and moved magic code to bytes 4095 and 4096, but my FAT knowledge might be limited and I do miss something here... |
Beta Was this translation helpful? Give feedback.
-
Drive size is reported 0kb when using 4kB sectors with following FAT12 setting: |
Beta Was this translation helpful? Give feedback.
-
after reading your update, I am absolutely sure that this is purely application issue regarding the Fat filesystem which is not an USB bug. Since it is not within the scope of usb stack, I will move this to discussion, maybe there is other people with more FAT knowledge could help. |
Beta Was this translation helpful? Give feedback.
-
Operating System
Windows 10
Board
custom LPC1788
Firmware
custom firmware
What happened ?
TinyUSB with msc example got configured with 48 msc_disk[] blocks, 512 bytes each. Adding up to 24kB in total.
Writing a 16k file will start on SRAM memory blocks msc_disk[6] to msc_disk[21], then proceeds writing on block msc_disk[3] to msc_disk[5].
First: written blocks are less than 16kB (reading back file shows missing bytes as undefined, see screenshot)
Second: would have expected writing 32 blocks starting at msc_disk[3]
How to reproduce ?
Debug Log
No response
Screenshots
Beta Was this translation helpful? Give feedback.
All reactions