cancel
Showing results for 
Search instead for 
Did you mean: 

MASS Storage DATA flow

jogerh
Associate II
Posted on January 24, 2016 at 19:04

Dear Community,

while experimenting with CLIVES SDcard to USB example [1] I checked the dataflow inside the function: int8_t STORAGE_Read to understand what data are necessary to make a mass storage device (e.g. from a paper tape reader). However my investigation stopped since I cannot figure out how e.g. an ASCII text- file is read – I just see that the first symbol is read while the notepad (WIN7) shows the entire content.

SD_Read Addr: 00000288 //dec

Len:  1

Content:   99     c             63           b01100011

It is true – the first symbol inside the text file is really a “c�? however where are the remaining symbols ? (By the way I also didn’t observed inside the dataflow how the directory data was transferred)

I would be very happy if someone could point me where the remaining data are transferred.

[1] (https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=https%3a%2f%2fmy%2est%2ecom%2fpublic%2fSTe2ecommunities%2fmcu%2fLists%2fSTM32Discovery%2fSTM32F4-Discovery%20USB%20Mass%20storage&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F&currentviews=9633)

2 REPLIES 2
Posted on January 24, 2016 at 19:30

Files are just collections of bytes, you can read them one at a time, or as a group or block.

0690X00000605LDQAY.png

Here dumping the bytes in a file manager/viewer. The Left column representing the byte offset into the file image, the middle is the hex representation of the bytes in the file, and the right side the ASCII translation of those bytes. If you loaded the whole file into memory, it would look the same. If you read one byte you'll see the first, and the next byte you read will be the second.

The file size can be read from the file system, and it's structures describing the size and placement on the media.

I'm not sure why these concepts are alien, perhaps I'm very old, and the basic concepts of bytes, memory, and file representations aren't taught these days. I'd suggest some of the UNIX and C books, and review coverage of file IO operations. If the operation of the FAT file system is of interest, the structures behind the files, directories, and file allocation table, there should be plenty of online and book material.

Files can also contain very complex structures for the data they represent internally, take a look at the .ELF object/executable file format for example.

The executable code for NOTEPAD.EXE runs some 190KB

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jogerh
Associate II
Posted on January 24, 2016 at 23:13

Dear Clive,

thankyou for responding. Actually I didn't read the docu of ''

int8_t STORAGE_Read'' 

before I copied and pasted it without docu:

/**

  * @brief  Read data from the medium

  * @param  lun : logical unit number

  * @param  buf : Pointer to the buffer to save data

  * @param  blk_addr :  address of 1st block to be read

  * @param  blk_len : nmber of blocks to be read

  * @retval Status

  */

Its actually a bulk of 512 bytes which is read by the function. After looking each time on the 512 bytes I can probably see all necessary content – previously I just observed the first byte. Now I also see how the entire content of each file is read from the SD card.

I will try get the suggested literature.