[go: up one dir, main page]

CN104866236A - Data reading method and equipment for storage media - Google Patents

Data reading method and equipment for storage media Download PDF

Info

Publication number
CN104866236A
CN104866236A CN201510207732.2A CN201510207732A CN104866236A CN 104866236 A CN104866236 A CN 104866236A CN 201510207732 A CN201510207732 A CN 201510207732A CN 104866236 A CN104866236 A CN 104866236A
Authority
CN
China
Prior art keywords
block
handheld device
information
read
host computer
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201510207732.2A
Other languages
Chinese (zh)
Inventor
俞茂学
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hisense Mobile Communications Technology Co Ltd
Original Assignee
Hisense Mobile Communications Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hisense Mobile Communications Technology Co Ltd filed Critical Hisense Mobile Communications Technology Co Ltd
Publication of CN104866236A publication Critical patent/CN104866236A/en
Pending legal-status Critical Current

Links

Landscapes

  • Storage Device Security (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention relates to the field of data storage, in particular to a data reading method and equipment for storage media, and is used for solving the problem that storage media in handheld devices cannot be used as USB mounting media to be communicated with upper computers. The method comprises the following steps: a handheld device is connected with an upper computer through a USB, and sends information of a block storing preset content and information of a page to the upper computer after receiving a query command from the upper computer; the handheld device reads the stored preset content according to the information of the block after receiving a reading command from the upper computer, and sends the preset content to the upper computer through the USB; the handheld device sends a reading operation accomplishment command to the upper computer after determining the fact that the volume of data transmitted to the upper computer reaches the data volume required to be read. According to the invention, as a fat file system is not required to be loaded in the process that the upper computer performs reading operation on the storage media in the handheld device, the problem that storage media in handheld devices cannot be used as USB mounting media to be communicated with upper computers is solved.

Description

存储介质的数据读取方法和设备Data reading method and device for storage medium

本发明申请是申请日为2012年7月10日、申请号为201210237930.X、发明名称为"存储介质的数据读取方法和设备"的发明申请的分案申请。The application of the present invention is a divisional application of the invention application with the filing date of July 10, 2012, the application number of 201210237930.X, and the invention title of "Data Reading Method and Device for Storage Medium".

技术领域technical field

本发明涉及数据存储领域,尤其涉及一种存储介质的数据读取方法和设备。The invention relates to the field of data storage, in particular to a method and device for reading data from a storage medium.

背景技术Background technique

作为一个开源代码并且免费的操作系统,Linux系统已经广泛应用在各种嵌入式领域。通用串行总线(Univeral Serial Bus,USB)由于其高速的传输速度以及在行业内的通用性,已经成为嵌入式设备与其他设备通信的极为重要的方法。As an open source code and free operating system, Linux system has been widely used in various embedded fields. Universal Serial Bus (Universal Serial Bus, USB) has become an extremely important method for embedded devices to communicate with other devices due to its high-speed transmission speed and versatility in the industry.

比如,使用Linux操作系统的手持设备(例如手机)通过USB与上位机(比如PC机)连接后,可以高速的传递数据,又可以用来充电等,使手持设备可以发挥存储设备,无线网卡以及调试等多种功能。For example, after a handheld device (such as a mobile phone) using the Linux operating system is connected to a host computer (such as a PC) via USB, it can transmit data at high speed and can be used for charging, etc., so that the handheld device can play a role in storage devices, wireless network cards and Debugging and other functions.

目前,手持设备通过USB与PC机连接后,向PC机传递数据的流程大致如下:At present, after the handheld device is connected to the PC through USB, the process of transferring data to the PC is roughly as follows:

步骤一:PC机向手持设备发送数据读取指令;Step 1: The PC sends a data reading command to the handheld device;

步骤二:手持设备接收到数据读取指令后,对该数据读取指令进行解析,得到用来存储数据的存储介质(例如TF卡)的地址信息等;Step 2: After the handheld device receives the data reading instruction, it analyzes the data reading instruction to obtain the address information of the storage medium (such as a TF card) used to store the data, etc.;

步骤三:手持设备调用fat文件系统,由于fat文件系统管理有手持设备内各存储介质的信息,因此fat文件系统可以根据解析得到的地址信息找到对应的存储介质,并通过执行读操作读取存储介质中的数据,将读取到的数据送到USB;USB将数据传递给PC机;Step 3: The handheld device calls the fat file system. Since the fat file system manages the information of each storage medium in the handheld device, the fat file system can find the corresponding storage medium according to the address information obtained by parsing, and read the storage medium by performing a read operation. The data in the medium, send the read data to the USB; the USB transfers the data to the PC;

步骤四:PC机接收到USB传递过来的数据后,执行对该数据的显示操作等。Step 4: After the PC receives the data transmitted by the USB, it performs a display operation on the data, etc.

将使用Linux操作系统的手持设备中能够通过USB向PC机传递数据的存储介质,称为Linux下的USB挂载介质。对Linux下的USB挂载介质的要求是,能透过fat文件系统对该介质进行访问,这就对存储介质本身增加了限制,对于通常用于嵌入式设备的其他存储介质来说,比如nand flash,由于其存储结构等的限制,无法加载fat文件系统,因而无法将该存储介质作为USB挂载介质与PC机进行通信。The storage medium that can transmit data to the PC through USB in the handheld device using the Linux operating system is called the USB mount medium under Linux. The requirement for the USB mount medium under Linux is that the medium can be accessed through the fat file system, which adds restrictions to the storage medium itself. For other storage mediums usually used in embedded devices, such as nand Flash, due to the limitations of its storage structure, etc., cannot load the fat file system, so the storage medium cannot be used as a USB mount medium to communicate with the PC.

发明内容Contents of the invention

本发明实施例提供一种存储介质的数据读取方法和设备,用于解决手持设备中的存储介质由于无法加载fat文件系统而无法作为USB挂载介质与上位机进行通信的问题。Embodiments of the present invention provide a method and device for reading data from a storage medium, which are used to solve the problem that the storage medium in the handheld device cannot be used as a USB mount medium to communicate with a host computer because the fat file system cannot be loaded.

本发明实施例提供了一种存储介质的数据读取方法,包括:An embodiment of the present invention provides a method for reading data from a storage medium, including:

手持设备通过通用串行总线USB与上位机相连,在接收到所述上位机的查询命令后,将存储有预制内容的块的信息、以及存储介质页的信息发送给所述上位机;The handheld device is connected to the host computer through the Universal Serial Bus USB, and after receiving the query command from the host computer, sends the information of the block storing the prefabricated content and the information of the storage medium page to the host computer;

所述手持设备接收到所述上位机的读取命令,根据所述块的信息读取存储的预制内容,并将所述预制内容通过USB发送给上位机;The handheld device receives the read command of the host computer, reads the stored prefabricated content according to the information of the block, and sends the prefabricated content to the host computer through USB;

所述手持设备确定传输给所述上位机的数据量达到根据所述页的信息生成的需要读取的数据量,向所述上位机发送读操作完成命令。The handheld device determines that the amount of data transmitted to the upper computer reaches the amount of data that needs to be read generated according to the information of the page, and sends a read operation completion command to the upper computer.

由于本发明实施例的手持设备在通过USB与上位机连接后,在接收到上位机的查询命令后,将该块的信息、页的信息上报给上位机,在接收到上位机的读取命令后,能够根据块的信息,读取该块中存储的预制内容,并将读取的预制内容通过USB传输给上位机。因此,本发明实施例中实现了上位机对手持设备中的存储介质的读取操作,并且该过程中不需要加载fat文件系统,从而解决了手持设备中的存储介质由于无法加载fat文件系统而无法作为USB挂载介质与上位机进行通信的问题。Since the handheld device in the embodiment of the present invention is connected to the host computer via USB, after receiving the query command from the host computer, it reports the information of the block and the page to the host computer, and after receiving the read command from the host computer Finally, according to the information of the block, the prefabricated content stored in the block can be read, and the read prefabricated content can be transmitted to the host computer through USB. Therefore, in the embodiment of the present invention, the reading operation of the host computer to the storage medium in the handheld device is realized, and the fat file system does not need to be loaded in the process, thereby solving the problem that the storage medium in the handheld device cannot load the fat file system. The problem that it cannot be used as a USB mount medium to communicate with the host computer.

可选的,将所述预制内容通过USB通过USB发送给上位机之后,还包括:Optionally, after sending the prefabricated content to the host computer via USB, it also includes:

所述手持设备确定传输给所述上位机的数据量未达到根据所述页的信息生成的需要读取的数据量,继续执行根据所述块的信息读取存储的预制内容的步骤。The handheld device determines that the amount of data transmitted to the host computer does not reach the amount of data that needs to be read generated according to the information of the page, and continues to execute the step of reading the stored prefabricated content according to the information of the block.

可选的,所述手持设备通过通用串行总线USB与上位机相连之后,在接收到所述上位机的查询命令之前,还包括:Optionally, after the handheld device is connected to the host computer through the Universal Serial Bus USB, before receiving the query command from the host computer, it also includes:

所述手持设备的内核层向用户层上报USB插入事件,用户层接收到该USB插入事件后,从维护的mtd分区列表中读取存储有预制内容的mtd分区的地址,并将读取到的mtd分区的地址发送给内核层;The kernel layer of the handheld device reports the USB insertion event to the user layer, and after receiving the USB insertion event, the user layer reads the address of the mtd partition that stores the prefabricated content from the mtd partition list maintained, and reads the The address of the mtd partition is sent to the kernel layer;

所述手持设备的内核层接收用户层发送的所述mtd分区的地址,执行对该地址对应的mtd分区的读操作,得到所述mtd分区中存储有所述预制内容的块的信息。The kernel layer of the handheld device receives the address of the mtd partition sent by the user layer, executes a read operation of the mtd partition corresponding to the address, and obtains the information of the block storing the prefabricated content in the mtd partition.

可选的,所述手持设备根据所述块的信息读取存储的预制内容,具体包括:Optionally, the handheld device reads the stored prefabricated content according to the block information, specifically including:

所述手持设备根据所述块的信息生成逻辑块地址LBA,并将所述LBA转换成存储介质上的地址偏移量,确定所述地址偏移量所指向的所述mtd分区中的块,读取确定的块中存储的预制内容。The handheld device generates a logical block address LBA according to the information of the block, and converts the LBA into an address offset on the storage medium, and determines the block in the mtd partition pointed to by the address offset, Reads the prefab content stored in the identified block.

可选的,所述手持设备通过USB与上位机连接之前,还包括:Optionally, before the handheld device is connected to the host computer via USB, it also includes:

所述手持设备获取该手持设备中存储介质中存储有预制内容的mtd分区的地址,通过mtd设备的坏块管理函数对该地址对应的分区进行扫描,确定mtd分区中的坏块,并将坏块的信息记录在静态数组中;The handheld device obtains the address of the mtd partition that stores prefabricated content in the storage medium of the handheld device, scans the partition corresponding to the address through the bad block management function of the mtd device, determines the bad block in the mtd partition, and saves the bad block Block information is recorded in a static array;

所述手持设备在确定地址偏移量所指向的所述mtd分区中的块之后,读取确定的块中存储的预制内容之前,还包括:After the handheld device determines the block in the mtd partition pointed to by the address offset and before reading the prefabricated content stored in the determined block, it further includes:

所述手持设备根据记录的坏块的信息,确定所述地址偏移量所指向的块不为坏块。The handheld device determines that the block pointed to by the address offset is not a bad block according to the recorded bad block information.

可选的,若所述手持设备确定所述地址偏移量所指向的块为坏块,则所述手持设备在确定所述地址偏移量所指向的块为坏块之后,还包括:Optionally, if the handheld device determines that the block pointed to by the address offset is a bad block, after determining that the block pointed to by the address offset is a bad block, the handheld device further includes:

所述手持设备将当前的地址偏移量更新为当前块的下一个好块的地址偏移量后,读取更新后的地址偏移量所指向的块中一个页大小的预制内容,并将读取的预制内容通过USB传输给上位机。After the handheld device updates the current address offset to the address offset of the next good block of the current block, it reads the prefabricated content of a page size in the block pointed to by the updated address offset, and The read prefabricated content is transmitted to the host computer through USB.

本发明实施例提供了一种手持设备,包括:An embodiment of the present invention provides a handheld device, including:

信息上报单元,用于通过通用串行总线USB与上位机相连,在接收到所述上位机的查询命令后,将存储有预制内容的块的信息、以及存储介质页的信息发送给所述上位机;The information reporting unit is used to connect to the upper computer through the universal serial bus USB, and after receiving the query command of the upper computer, send the information of the block storing the prefabricated content and the information of the storage medium page to the upper computer machine;

数据读取上报单元,用于接收到所述上位机的读取命令,根据所述块的信息读取存储的预制内容,并将所述预制内容通过USB发送给上位机;以及在确定传输给所述上位机的数据量达到根据所述页的信息生成的需要读取的数据量后,向所述上位机发送读操作完成命令。The data reading reporting unit is used to receive the read command of the host computer, read the stored prefabricated content according to the information of the block, and send the prefabricated content to the host computer through USB; After the amount of data of the upper computer reaches the amount of data that needs to be read generated according to the information of the page, a read operation completion command is sent to the upper computer.

可选的,所述数据读取上报单元,还用于:Optionally, the data reading and reporting unit is also used for:

将所述预制内容通过USB通过USB发送给上位机之后,确定传输给所述上位机的数据量未达到根据所述页的信息生成的需要读取的数据量,继续执行根据所述块的信息读取存储的预制内容的步骤。After the prefabricated content is sent to the host computer via USB, it is determined that the amount of data transmitted to the host computer has not reached the amount of data that needs to be read generated according to the information of the page, and the execution is continued according to the information of the block. Steps to read stored prefab content.

可选的,还包括:Optionally, also include:

内核层单元,用于通过通用串行总线USB与上位机相连之后,在接收到所述上位机的查询命令之前,在该手持设备通过通用串行总线USB与上位机连接后,向用户层单元上报USB插入事件;接收用户层单元发来的mtd分区的地址,执行对该地址对应的mtd分区的读操作,得到所述mtd分区中存储有所述预制内容的块的信息;Kernel layer unit, after being connected with upper computer by universal serial bus USB, before receiving the inquiry command of described upper computer, after this handheld device is connected with upper computer by universal serial bus USB, send user layer unit Report the USB insertion event; receive the address of the mtd partition sent by the user layer unit, execute the read operation of the mtd partition corresponding to the address, and obtain the information of the block storing the prefabricated content in the mtd partition;

用户层单元,用于接收到所述USB插入事件后,从维护的mtd分区列表中读取存储有预制内容的mtd分区的地址,并将读取到的mtd分区的地址发送给内核层单元。The user layer unit is configured to read the address of the mtd partition storing prefabricated content from the maintained mtd partition list after receiving the USB insertion event, and send the read address of the mtd partition to the kernel layer unit.

可选的,所述数据读取上报单元还用于:Optionally, the data reading and reporting unit is also used for:

所述手持设备根据所述块的信息生成逻辑块地址LBA,并将所述LBA转换成存储介质上的地址偏移量,确定所述地址偏移量所指向的所述mtd分区中的块,读取确定的块中存储的预制内容。The handheld device generates a logical block address LBA according to the information of the block, and converts the LBA into an address offset on the storage medium, and determines the block in the mtd partition pointed to by the address offset, Reads the prefab content stored in the identified block.

附图说明Description of drawings

图1为本发明实施例提供的方法流程示意图;Fig. 1 is a schematic flow chart of the method provided by the embodiment of the present invention;

图2为本发明实施例的数据读取流程示意图;FIG. 2 is a schematic diagram of a data reading process according to an embodiment of the present invention;

图3为本发明实施例提供的设备结构示意图。Fig. 3 is a schematic structural diagram of a device provided by an embodiment of the present invention.

具体实施方式Detailed ways

为了解决手持设备中的存储介质由于无法加载fat文件系统而无法作为USB挂载介质与上位机进行通信的问题,本发明实施例提供一种存储介质的数据读取方法。该存储介质包含至少一个存储器工艺设备(mtd)分区,每个mtd分区包含至少一个块,每个块包含至少包含一个页。In order to solve the problem that the storage medium in the handheld device cannot be used as a USB mount medium to communicate with the host computer because the fat file system cannot be loaded, an embodiment of the present invention provides a method for reading data from the storage medium. The storage medium includes at least one memory technology device (mtd) partition, each mtd partition includes at least one block, and each block includes at least one page.

参见图1,本发明实施例提供的存储介质的数据读取方法,包括以下步骤:Referring to Fig. 1, the data reading method of the storage medium provided by the embodiment of the present invention comprises the following steps:

步骤10:手持设备在通过USB与上位机连接后,获取该手持设备的存储介质中存储有预制内容的mtd分区的地址,根据该地址信息得到该mtd分区中存储有预制内容的块的信息,具体可以包括存储有预制内容的块的个数;Step 10: After the handheld device is connected to the host computer via USB, obtain the address of the mtd partition that stores the prefabricated content in the storage medium of the handheld device, and obtain the block information that stores the prefabricated content in the mtd partition according to the address information, Specifically, it may include the number of blocks storing prefabricated content;

步骤11:手持设备接收上位机的查询命令,将该块的信息上报给上位机;Step 11: The handheld device receives the query command from the host computer, and reports the block information to the host computer;

步骤12:手持设备接收上位机的读取命令,该读取命令中携带上位机根据该块的信息生成的逻辑块地址(LBA)信息,确定该LBA信息所指向的存储有预制内容的mtd分区中的块,读取确定的块中存储的预制内容,并将读取的预制内容通过USB传输给上位机。Step 12: The handheld device receives the read command from the host computer, which carries the logical block address (LBA) information generated by the host computer according to the information of the block, and determines the mtd partition that stores the prefabricated content pointed to by the LBA information The blocks in , read the prefabricated content stored in the determined block, and transmit the read prefabricated content to the host computer through USB.

较佳的,在手持设备通过USB与上位机连接后、且获取该手持设备的存储介质中存储有预制内容的mtd分区的地址之前,手持设备在上位机对该手持设备的枚举过程中通知上位机该手持设备的设备类型为只读类型。该只读类型可以为光盘cdrom等。Preferably, after the handheld device is connected to the host computer via USB and before obtaining the address of the mtd partition that stores the prefabricated content in the storage medium of the handheld device, the handheld device notifies the handheld device during the enumeration process of the handheld device by the host computer The device type of the handheld device on the upper computer is read-only. The read-only type may be an optical disc cdrom or the like.

具体的,获取该手持设备的存储介质中存储有预制内容的mtd分区的地址,根据该地址信息得到该mtd分区中存储有预制内容的块的信息,具体实现方法可以如下:Specifically, the address of the mtd partition storing the prefabricated content in the storage medium of the handheld device is obtained, and the information of the block storing the prefabricated content in the mtd partition is obtained according to the address information. The specific implementation method can be as follows:

手持设备的内核层向用户层上报USB插入事件,用户层接收到该USB插入事件后,从维护的mtd分区列表中读取存储有预制内容的mtd分区的地址,并将读取到的mtd分区的地址发送给内核层;The kernel layer of the handheld device reports the USB insertion event to the user layer. After receiving the USB insertion event, the user layer reads the address of the mtd partition that stores the prefabricated content from the maintained mtd partition list, and transfers the read mtd partition The address is sent to the kernel layer;

内核层接收用户层发送的所述mtd分区的地址,执行对该地址对应的mtd分区的读操作,得到所述mtd分区中存储有所述预制内容的块的信息。The kernel layer receives the address of the mtd partition sent by the user layer, executes a read operation on the mtd partition corresponding to the address, and obtains the information of the block storing the prefabricated content in the mtd partition.

较佳的,步骤11中手持设备将块的信息上报给上位机的同时,还将存储介质的页的信息发送给上位机,相应的,步骤12中手持设备接收到的读取命令中还可以携带上位机根据页的信息生成的需要读取的数据量的信息;Preferably, in step 11, while the handheld device reports the block information to the host computer, it also sends the page information of the storage medium to the host computer. Correspondingly, the read command received by the handheld device in step 12 can also be Carry the information of the amount of data that needs to be read generated by the host computer according to the page information;

那么,步骤12中手持设备在将读取的预制内容通过USB传输给上位机后,可以根据该数据量的信息判断是否已传输上位机需要读取的数据量,若是,则向上位机发送读操作完成命令,否则,继续进行预制内容的读取,并将读取的预制内容通过USB传输给上位机,直到传输给上位机的数据量达到上位机需要读取的数据量。Then, in step 12, after the handheld device transmits the read prefabricated content to the host computer via USB, it can judge whether the data volume that the host computer needs to read has been transmitted according to the information of the data amount, and if so, send a read to the host computer. The operation completes the command, otherwise, continue to read the prefabricated content, and transmit the read prefabricated content to the host computer through USB until the amount of data transmitted to the host computer reaches the amount of data that the host computer needs to read.

较佳的,在步骤10中手持设备在通过USB与上位机连接之前,手持设备可以获取该手持设备的存储介质中存储有预制内容的mtd分区的地址,对该地址对应的mtd分区进行扫描,根据扫描结果确定该mtd分区中的坏块,并记录坏块的信息;Preferably, before the handheld device is connected to the host computer via USB in step 10, the handheld device can obtain the address of the mtd partition that stores the prefabricated content in the storage medium of the handheld device, and scan the mtd partition corresponding to the address, Determine the bad blocks in the mtd partition according to the scan results, and record the information of the bad blocks;

相应的,步骤12中手持设备在确定LBA信息所指向的mtd分区中的块之后、并且读取确定的块中存储的预制内容之前,可以根据记录的坏块的信息,判断该LBA信息所指向的块是否为坏块;Correspondingly, in step 12, after the handheld device determines the block in the mtd partition pointed to by the LBA information and before reading the prefabricated content stored in the determined block, it can judge the information pointed to by the LBA information according to the recorded bad block information. Whether the block is a bad block;

在判断该LBA信息所指向的块不为坏块时,读取确定的块中存储的预制内容;When judging that the block pointed to by the LBA information is not a bad block, read the prefabricated content stored in the determined block;

在判断该LBA信息所指向的块为坏块时,确定该LBA信息所指向的块的下一个未被标记为坏块的块,读取该块中存储的预制内容,并将读取的预制内容通过USB传输给上位机。When judging that the block pointed to by the LBA information is a bad block, determine the block that is not marked as a bad block next to the block pointed to by the LBA information, read the prefabricated content stored in the block, and read the prefabricated The content is transmitted to the host computer via USB.

本方法中,存储介质可以为nand flash或嵌入式多媒体存储卡(EmbeddedMultiMediaCard,EMC)等。In this method, storage medium can be nand flash or embedded multimedia memory card (EmbeddedMultiMediaCard, EMC) etc.

具体实施例如下:Specific examples are as follows:

本实施例中,需要预先将预制内容烧写到nand flash中的相关mtd分区中,并将该mtd分区的地址信息写入mtd分区列表中。如图2所示,后续流程如下:In this embodiment, it is necessary to pre-program the prefabricated content into the relevant mtd partition in the nand flash, and write the address information of the mtd partition into the mtd partition list. As shown in Figure 2, the follow-up process is as follows:

步骤20:手持设备开机启动后,从维护的mtd分区列表中读取该手持设备的nand flash中存储有预制内容的mtd分区的地址,对该地址对应的mtd分区进行扫描,得到并记录该mtd分区中的坏块的信息,具体可以将坏块的信息记录在静态数组中;Step 20: After the handheld device is turned on, read the address of the mtd partition with prefabricated content stored in the nand flash of the handheld device from the maintained mtd partition list, scan the mtd partition corresponding to the address, obtain and record the mtd The bad block information in the partition, specifically, the bad block information can be recorded in a static array;

这里,对mtd分区进行扫描,得到并记录该mtd分区中的坏块的信息,具体实现可以为:通过mtd设备的坏块管理函数对当前分区的每个块进行扫描,如果当前块为坏块,则将此块的地址偏移量增加到一个坏块数组里,用以在后续读操作时判断当前要读取的块是否为坏块。Here, the mtd partition is scanned to obtain and record the bad block information in the mtd partition. The specific implementation can be: scan each block of the current partition through the bad block management function of the mtd device, if the current block is a bad block , then add the address offset of this block to a bad block array to determine whether the block to be read is a bad block during subsequent read operations.

步骤21:手持设备通过USB与上位机连接后,上位机建立与USB之间的数据传输通路;手持设备的内核层通过USB通知上位机该手持设备的设备类型为只读类型,比如为cdrom;上位机执行对该手持设备的枚举过程;Step 21: After the handheld device is connected to the host computer via USB, the host computer establishes a data transmission path with the USB; the kernel layer of the handheld device notifies the host computer that the device type of the handheld device is a read-only type, such as a cdrom; The host computer executes the enumeration process of the handheld device;

步骤22:手持设备将mtd分区的地址作为介质挂载点进行加载,具体的,手持设备的内核层向用户层上报USB插入事件,用户层接收到该USB插入事件后,从维护的mtd分区列表中读取存储有预制内容的mtd分区的地址,并将读取到的mtd分区的地址发送给内核层;Step 22: The handheld device loads the address of the mtd partition as the media mount point. Specifically, the kernel layer of the handheld device reports the USB insertion event to the user layer. After the user layer receives the USB insertion event, it starts from the maintained mtd partition list Read the address of the mtd partition that stores the prefabricated content, and send the read address of the mtd partition to the kernel layer;

步骤23:内核层接收用户层发送的mtd分区的地址,执行对该地址对应的mtd分区的读操作,得到该mtd分区中存储有预制内容的块的个数;存储有预制内容的块的个数会预先被保存在该mtd分区的第一个块中;Step 23: The kernel layer receives the address of the mtd partition sent by the user layer, executes the read operation of the mtd partition corresponding to the address, and obtains the number of blocks with prefabricated content stored in the mtd partition; the number of blocks with prefabricated content stored in the mtd partition The number will be pre-saved in the first block of the mtd partition;

内核层对读容量命令(Read capacity Command)和读地址命令(Read TocCommand)这两条命令的上报内容进行初始化,以使上位机获得nand flash的正确的页大小和存储有预制内容的块的个数。Read capacity Command是代码为0x25的小型计算机系统接口(small computer system interface,scsi)命令,ReadToc Command是代码为0x43的scsi命令。The kernel layer initializes the reported content of the two commands of the read capacity command (Read capacity Command) and the read address command (Read TocCommand), so that the host computer can obtain the correct page size of the nand flash and the number of blocks storing prefabricated content. number. Read capacity Command is a small computer system interface (small computer system interface, scsi) command whose code is 0x25, and ReadToc Command is a scsi command whose code is 0x43.

初始化完成后,内核层可以向上位机发送初始化完成的通知;After the initialization is completed, the kernel layer can send a notification of the completion of initialization to the upper computer;

这里,Read capacity Command的上报内容主要包括存储有预制内容的块的个数和nand flash的页大小。Here, the reported content of the Read capacity Command mainly includes the number of blocks storing prefabricated content and the page size of the nand flash.

Read Toc Command的上报内容主要包括逻辑块地址(logical blockadressing,LBA)以及分秒帧(Minute,Second,Frame,MSF)信息。初始化后的LBA的值等于mtd分区中存储有预制内容的块的个数;MSF信息为将mtd分区中的预制内容作为媒体进行播放的总播放时长信息,总播放时长信息包括帧分、秒、帧信息。The reported content of the Read Toc Command mainly includes logical block addressing (logical block addressing, LBA) and minute-second frame (Minute, Second, Frame, MSF) information. The value of the initialized LBA is equal to the number of blocks that store prefabricated content in the mtd partition; the MSF information is the total playback duration information for playing the prefabricated content in the mtd partition as media, and the total playback duration information includes frame minutes, seconds, frame information.

步骤24:上位机向手持设备依次发送Read capacity Command和Read TocCommand这两条命令;Step 24: The host computer sends two commands, Read capacity Command and Read TocCommand, to the handheld device in sequence;

手持设备接收到Read capacity Command后,将初始化后的mtd分区中存储有预制内容的块的个数以及页大小的信息上报给上位机;After the handheld device receives the Read capacity Command, it reports the number of blocks with prefabricated content stored in the initialized mtd partition and the page size information to the host computer;

手持设备接收到Read Toc Command后,将初始化后的LBA信息和MSF信息上报给上位机。After receiving the Read Toc Command, the handheld device reports the initialized LBA information and MSF information to the host computer.

步骤25:上位机获得相关信息后,向手持设备发送读取命令,比如read_10命令,以对nand flash进行读操作;读取命令中携带上位机根据存储有预制内容的块的个数生成的LBA、以及需要读取的数据量的信息;Step 25: After the host computer obtains the relevant information, send a read command to the handheld device, such as the read_10 command, to read the nand flash; the read command carries the LBA generated by the host computer according to the number of blocks storing prefabricated content , and information about the amount of data that needs to be read;

读取命令中携带的LBA的值为0到步骤24中手持设备发送的mtd分区中存储有预制内容的块的个数之间的整数,比如,mtd分区中存储有预制内容的块的个数为5,上位机若需要读取mtd分区中第1个块的内容,则读取命令中携带的LBA的值为1,若需要读取mtd分区中第2个块的内容,则读取命令中携带的LBA的值为2,依次类推。读取命令中携带的需要读取的数据量为nandflash中页大小或页大小的整数倍,因为是以页为单位读取nand flash中的数据。read_10命令是代码为0x28的scsi命令;The value of the LBA carried in the read command is an integer between 0 and the number of blocks storing prefabricated content in the mtd partition sent by the handheld device in step 24, for example, the number of blocks storing prefabricated content in the mtd partition is 5, if the host computer needs to read the content of the first block in the mtd partition, the value of the LBA carried in the read command is 1, and if it needs to read the content of the second block in the mtd partition, then the read command The value of the LBA carried in is 2, and so on. The amount of data to be read carried in the read command is the page size in nandflash or an integer multiple of the page size, because the data in nandflash is read in units of pages. The read_10 command is a scsi command whose code is 0x28;

手持设备将读取命令中携带的LBA转换为nand flash上的地址偏移量,并获得上位机需要读取的数据量的大小,转换后的地址偏移量指向上位机需要读的mtd分区中存储有预制内容的块,转换方法如下:由于nand flash的块大小一般为2048byte或4096byte,LBA为块的个数,则转换后的地址偏移量等于LBA乘以mtd分区中一个块的大小。The handheld device converts the LBA carried in the read command into the address offset on the nand flash, and obtains the size of the data that the host computer needs to read, and the converted address offset points to the mtd partition that the host computer needs to read The conversion method for storing blocks with prefabricated content is as follows: Since the block size of nand flash is generally 2048byte or 4096byte, and LBA is the number of blocks, the address offset after conversion is equal to LBA multiplied by the size of a block in the mtd partition.

步骤26:手持设备根据步骤20中记录的坏块的信息,判断当前地址偏移量指向的块是否为好块,若是,则到步骤27,否则,到步骤28;Step 26: The handheld device judges whether the block pointed to by the current address offset is a good block according to the information of the bad block recorded in the step 20, if so, then go to step 27, otherwise, go to step 28;

步骤27:手持设备读取当前地址偏移量指向的块中一个页大小的预制内容,将读取的预制内容放入缓存区,到步骤29;Step 27: The handheld device reads the prefabricated content of a page size in the block pointed to by the current address offset, puts the read prefabricated content into the cache area, and proceeds to step 29;

步骤28:将当前的地址偏移量更新为当前块的下一个好块的地址偏移量,返回步骤27;Step 28: update the current address offset to the address offset of the next good block of the current block, and return to step 27;

步骤29:通过USB将缓存区中的预制内容发送给上位机;Step 29: Send the prefabricated content in the cache area to the host computer via USB;

步骤30:手持设备判断当前的读操作是否完成,即判断是否已传输完上位机需要读取的数据量,若是,则到步骤31,否则,到步骤32:Step 30: The handheld device judges whether the current read operation is completed, that is, judges whether the amount of data to be read by the host computer has been transmitted, if so, go to step 31, otherwise, go to step 32:

这里,手持设备判断当前的读操作是否完成,具体为:更新需要读取的数据量,更新后的需要读取的数据量等于更新前的需要读取的数据量-本次读取的数据量;若更新后的需要读取的数据量等于0,则当前的读操作完成,否则未完成。Here, the handheld device judges whether the current read operation is completed, specifically: the amount of data to be read after the update, the amount of data to be read after the update is equal to the amount of data to be read before the update - the amount of data to be read this time ; If the amount of data to be read after updating is equal to 0, the current read operation is completed, otherwise it is not completed.

步骤31:手持设备向上位机发送读操作完成命令,通知上位机此次读操作完成,本流程结束;Step 31: The handheld device sends a read operation completion command to the host computer, notifying the host computer that the read operation is completed, and the process ends;

步骤32:将当前的地址偏移量进行更新,更新后的地址偏移量等于更新前的地址偏移量减去页大小,返回步骤26。Step 32: Update the current address offset, the updated address offset is equal to the pre-update address offset minus the page size, and return to step 26.

本实施例中的手持设备可以采用linux 2.6版本的操作系统,nand flash的页大小为2kB,总容量为512MB。The handheld device among the present embodiment can adopt the operating system of linux 2.6 version, and the page size of nand flash is 2kB, and total capacity is 512MB.

本实施例通过直接访问nand flash的方法,配合对scsi命令的配置,使得上位机顺利得到其所需数据,从而完整的读出mtd分区的所有预制内容,以cdrom的方式呈现给用户。由于cdrom只读的特性,所以不会直接对nand flash进行写操作,也就无需对预制内容增加负载均衡算法。通过预制内容到nandflash的操作,降低了手持设备的成本,提供友好的使用方式给用户,扩展了USB的使用方法。In this embodiment, through the method of directly accessing the nand flash, combined with the configuration of the scsi command, the upper computer can successfully obtain the required data, thereby completely reading out all the prefabricated contents of the mtd partition, and presenting it to the user in the form of a cdrom. Due to the read-only nature of the cdrom, it will not directly write to the nand flash, and there is no need to add a load balancing algorithm to the prefabricated content. Through the operation of prefabricated content to nandflash, the cost of the handheld device is reduced, a friendly usage method is provided to users, and the usage method of USB is expanded.

参见图3,本发明实施例还提供一种手持设备,包括存储介质,该存储介质包含至少一个存储器工艺设备mtd分区,每个mtd分区包含至少一个块,每个块包含至少一个页;该手持设备还包括:Referring to FIG. 3 , an embodiment of the present invention also provides a handheld device, including a storage medium, the storage medium contains at least one memory process device mtd partition, each mtd partition contains at least one block, and each block contains at least one page; the handheld Equipment also includes:

信息获取单元31,用于在该手持设备通过通用串行总线USB与上位机连接后,获取该手持设备的存储介质中存储有预制内容的mtd分区的地址,根据该地址信息得到所述mtd分区中存储有所述预制内容的块的信息;The information acquisition unit 31 is used to obtain the address of the mtd partition in the storage medium of the handheld device that stores the prefabricated content after the handheld device is connected to the host computer through the universal serial bus USB, and obtain the mtd partition according to the address information The block information of the prefabricated content is stored in ;

信息上报单元32,用于接收上位机的查询命令,将所述块的信息上报给上位机;The information reporting unit 32 is used to receive the query command of the host computer, and report the information of the block to the host computer;

数据读取上报单元33,用于接收上位机的读取命令,该读取命令中携带上位机根据所述块的信息生成的逻辑块地址LBA信息,确定该LBA信息所指向的所述mtd分区中的块,读取确定的块中存储的预制内容,并将读取的预制内容通过USB传输给上位机。The data reading reporting unit 33 is used to receive the read command of the upper computer, which carries the logical block address LBA information generated by the upper computer according to the information of the block, and determines the mtd partition pointed to by the LBA information The blocks in , read the prefabricated content stored in the determined block, and transmit the read prefabricated content to the host computer through USB.

进一步的,该手持设备还包括:Further, the handheld device also includes:

类型上报单元34,用于在该手持设备通过USB与上位机连接后、且获取该手持设备的存储介质中存储有预制内容的mtd分区的地址之前,在上位机对该手持设备的枚举过程中通知上位机该手持设备的设备类型为只读类型。The type reporting unit 34 is used to enumerate the handheld device in the host computer after the handheld device is connected to the host computer via USB and before obtaining the address of the mtd partition that stores prefabricated content in the storage medium of the handheld device. Notify the host computer that the device type of the handheld device is read-only.

进一步的,所述信息获取单元31包括:Further, the information acquisition unit 31 includes:

内核层单元,在该手持设备通过通用串行总线USB与上位机连接后,向用户层单元上报USB插入事件;接收用户层单元发来的mtd分区的地址,执行对该地址对应的mtd分区的读操作,得到所述mtd分区中存储有所述预制内容的块的信息。The kernel layer unit reports the USB insertion event to the user layer unit after the handheld device is connected to the host computer through the universal serial bus USB; receives the address of the mtd partition sent by the user layer unit, and executes the mtd partition corresponding to the address Read operation to obtain the information of the block storing the prefabricated content in the mtd partition.

用户层单元,用于接收到所述USB插入事件后,从维护的mtd分区列表中读取存储有预制内容的mtd分区的地址,并将读取到的mtd分区的地址发送给内核层单元。The user layer unit is configured to read the address of the mtd partition storing prefabricated content from the maintained mtd partition list after receiving the USB insertion event, and send the read address of the mtd partition to the kernel layer unit.

进一步的,所述信息上报单元32在将所述块的信息上报给上位机的同时,还将所述存储介质的页的信息发送给上位机;所述读取命令中还携带上位机根据所述页的信息生成的需要读取的数据量的信息;Further, when the information reporting unit 32 reports the information of the block to the host computer, it also sends the information of the page of the storage medium to the host computer; Information on the amount of data that needs to be read generated from the information on the above page;

所述数据读取上报单元33还用于:在将读取的预制内容通过USB传输给上位机后,根据所述数据量的信息判断是否已传输上位机需要读取的数据量,若是,则向上位机发送读操作完成命令,否则,继续进行预制内容的读取,并将读取的预制内容通过USB传输给上位机,直到传输给上位机的数据量达到所述需要读取的数据量。The data reading and reporting unit 33 is also used for: after transmitting the read prefabricated content to the host computer via USB, judge whether the data volume that the host computer needs to read has been transmitted according to the information of the data amount, if so, then Send the read operation completion command to the upper computer, otherwise, continue to read the prefabricated content, and transmit the read prefabricated content to the upper computer through USB until the amount of data transmitted to the upper computer reaches the amount of data that needs to be read .

进一步的,该手持设备还包括:Further, the handheld device also includes:

坏块标记单元35,用于在手持设备在通过USB与上位机连接之前,获取该手持设备的存储介质中存储有预制内容的mtd分区的地址,对该地址对应的mtd分区进行扫描,根据扫描结果确定该mtd分区中的坏块,并记录坏块的信息;The bad block marking unit 35 is used to obtain the address of the mtd partition that stores the prefabricated content in the storage medium of the handheld device before the handheld device is connected to the host computer through USB, and scan the mtd partition corresponding to the address. As a result, determine the bad blocks in the mtd partition and record the information of the bad blocks;

所述数据读取上报单元33还用于:在确定该LBA信息所指向的所述mtd分区中的块之后、并且读取确定的块中存储的预制内容之前,根据记录的坏块的信息,判断该LBA信息所指向的块是否为坏块;在判断该LBA信息所指向的块不为坏块时,读取确定的块中存储的预制内容。The data reading reporting unit 33 is further configured to: after determining the block in the mtd partition pointed to by the LBA information and before reading the prefabricated content stored in the determined block, according to the recorded bad block information, Judging whether the block pointed to by the LBA information is a bad block; when judging that the block pointed to by the LBA information is not a bad block, reading the prefabricated content stored in the determined block.

进一步的,所述数据读取上报单元33还用于:Further, the data reading and reporting unit 33 is also used for:

在判断该LBA信息所指向的块为坏块时,确定该LBA信息所指向的块的下一个未被标记为坏块的块,读取该块中存储的预制内容,并将读取的预制内容通过USB传输给上位机。When judging that the block pointed to by the LBA information is a bad block, determine the block that is not marked as a bad block next to the block pointed to by the LBA information, read the prefabricated content stored in the block, and read the prefabricated The content is transmitted to the host computer via USB.

进一步的,所述存储介质为nand flash。Further, the storage medium is nand flash.

综上,本发明的有益效果包括:In summary, the beneficial effects of the present invention include:

本发明实施例提供的方案中,手持设备在通过USB与上位机连接后,获取该手持设备的存储介质中存储有预制内容的mtd分区的地址,根据该地址信息得到该mtd分区中存储有预制内容的块的信息,在接收到上位机的查询命令后,将该块的信息上报给上位机,在接收到上位机的读取命令后,确定该读取命令中携带的根据该块的信息生成的LBA信息所指向的存储有预制内容的块,读取该块中存储的预制内容,并将读取的预制内容通过USB传输给上位机。可见,本方案中实现了上位机对手持设备中的存储介质的读取操作,并且该过程中不需要加载fat文件系统,从而解决了手持设备中的存储介质由于无法加载fat文件系统而无法作为USB挂载介质与上位机进行通信的问题。In the solution provided by the embodiment of the present invention, after the handheld device is connected to the host computer via USB, it obtains the address of the mtd partition that stores the prefabricated content in the storage medium of the handheld device, and obtains the prefabricated content stored in the mtd partition according to the address information. The block information of the content, after receiving the query command from the host computer, report the information of the block to the host computer, and after receiving the read command from the host computer, determine the information carried in the read command according to the block The generated LBA information points to a block storing prefabricated content, reads the prefabricated content stored in the block, and transmits the read prefabricated content to the host computer through USB. It can be seen that in this solution, the upper computer can read the storage medium in the handheld device, and the fat file system does not need to be loaded in this process, thus solving the problem that the storage medium in the handheld device cannot be used as a file system because the fat file system cannot be loaded. The problem of communication between the USB mount medium and the host computer.

本发明利用cdrom只读的特点,通过USB、cdrom直接挂载mtd分区的通路,建立了上位机通过USB直接访问nand flash的通路,使得大容量的nandflash可以预制内容,且无需加载文件系统。通过USB、cdrom与上位机连接,直接读取mtd分区中的预制内容的方法,降低了手持设备的成本,提高了nandflash的使用率以及USB挂载介质的多样性。The present invention utilizes the read-only feature of the cdrom to directly mount the mtd partition through the USB and the cdrom, and establishes a way for the host computer to directly access the nand flash through the USB, so that the large-capacity nandflash can prefabricate the content without loading the file system. The method of directly reading the prefabricated content in the mtd partition by connecting with the host computer through USB and cdrom reduces the cost of the handheld device, improves the utilization rate of nandflash and the diversity of USB mounting media.

本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It should be understood that each procedure and/or block in the flowchart and/or block diagram, and a combination of procedures and/or blocks in the flowchart and/or block diagram can be realized by computer program instructions. These computer program instructions may be provided to a general purpose computer, special purpose computer, embedded processor, or processor of other programmable data processing equipment to produce a machine such that the instructions executed by the processor of the computer or other programmable data processing equipment produce a An apparatus for realizing the functions specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.

这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to operate in a specific manner, such that the instructions stored in the computer-readable memory produce an article of manufacture comprising instruction means, the instructions The device realizes the function specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.

这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded onto a computer or other programmable data processing device, causing a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process, thereby The instructions provide steps for implementing the functions specified in the flow chart or blocks of the flowchart and/or the block or blocks of the block diagrams.

尽管已描述了本发明的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例作出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本发明范围的所有变更和修改。While preferred embodiments of the invention have been described, additional changes and modifications to these embodiments can be made by those skilled in the art once the basic inventive concept is appreciated. Therefore, it is intended that the appended claims be construed to cover the preferred embodiment as well as all changes and modifications which fall within the scope of the invention.

显然,本领域的技术人员可以对本发明进行各种改动和变型而不脱离本发明的精神和范围。这样,倘若本发明的这些修改和变型属于本发明权利要求及其等同技术的范围之内,则本发明也意图包含这些改动和变型在内。Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalent technologies, the present invention also intends to include these modifications and variations.

Claims (10)

1.一种存储介质的数据读取方法,其特征在于,包括:1. A method for reading data from a storage medium, comprising: 手持设备通过通用串行总线USB与上位机相连,在接收到所述上位机的查询命令后,将存储有预制内容的块的信息、以及存储介质页的信息发送给所述上位机;The handheld device is connected to the host computer through the Universal Serial Bus USB, and after receiving the query command from the host computer, sends the information of the block storing the prefabricated content and the information of the storage medium page to the host computer; 所述手持设备接收到所述上位机的读取命令,根据所述块的信息读取存储的预制内容,并将所述预制内容通过USB发送给上位机;The handheld device receives the read command of the host computer, reads the stored prefabricated content according to the information of the block, and sends the prefabricated content to the host computer through USB; 所述手持设备确定传输给所述上位机的数据量达到根据所述页的信息生成的需要读取的数据量,向所述上位机发送读操作完成命令。The handheld device determines that the amount of data transmitted to the upper computer reaches the amount of data that needs to be read generated according to the information of the page, and sends a read operation completion command to the upper computer. 2.如权利要求1所述的方法,其特征在于,将所述预制内容通过USB通过USB发送给上位机之后,还包括:2. The method according to claim 1, characterized in that, after sending the prefabricated content to the host computer via USB, further comprising: 所述手持设备确定传输给所述上位机的数据量未达到根据所述页的信息生成的需要读取的数据量,继续执行根据所述块的信息读取存储的预制内容的步骤。The handheld device determines that the amount of data transmitted to the host computer does not reach the amount of data that needs to be read generated according to the information of the page, and continues to execute the step of reading the stored prefabricated content according to the information of the block. 3.如权利要求1或2所述的方法,其特征在于,所述手持设备通过通用串行总线USB与上位机相连之后,在接收到所述上位机的查询命令之前,还包括:3. The method according to claim 1 or 2, wherein, after the handheld device is connected with the host computer through the Universal Serial Bus USB, before receiving the query command of the host computer, it also includes: 所述手持设备的内核层向用户层上报USB插入事件,用户层接收到该USB插入事件后,从维护的mtd分区列表中读取存储有预制内容的mtd分区的地址,并将读取到的mtd分区的地址发送给内核层;The kernel layer of the handheld device reports the USB insertion event to the user layer, and after receiving the USB insertion event, the user layer reads the address of the mtd partition that stores the prefabricated content from the mtd partition list maintained, and reads the The address of the mtd partition is sent to the kernel layer; 所述手持设备的内核层接收用户层发送的所述mtd分区的地址,执行对该地址对应的mtd分区的读操作,得到所述mtd分区中存储有所述预制内容的块的信息。The kernel layer of the handheld device receives the address of the mtd partition sent by the user layer, executes a read operation of the mtd partition corresponding to the address, and obtains the information of the block storing the prefabricated content in the mtd partition. 4.如权利要求1所述的方法,其特征在于,所述手持设备根据所述块的信息读取存储的预制内容,具体包括:4. The method according to claim 1, wherein the handheld device reads the stored prefabricated content according to the information of the block, specifically comprising: 所述手持设备根据所述块的信息生成逻辑块地址LBA,并将所述LBA转换成存储介质上的地址偏移量,确定所述地址偏移量所指向的所述mtd分区中的块,读取确定的块中存储的预制内容。The handheld device generates a logical block address LBA according to the information of the block, and converts the LBA into an address offset on the storage medium, and determines the block in the mtd partition pointed to by the address offset, Reads the prefab content stored in the identified block. 5.如权利要求4所述的方法,其特征在于,所述手持设备通过USB与上位机连接之前,还包括:5. The method according to claim 4, wherein, before the handheld device is connected to the host computer via USB, further comprising: 所述手持设备获取该手持设备中存储介质中存储有预制内容的mtd分区的地址,通过mtd设备的坏块管理函数对该地址对应的分区进行扫描,确定mtd分区中的坏块,并将坏块的信息记录在静态数组中;The handheld device obtains the address of the mtd partition that stores prefabricated content in the storage medium of the handheld device, scans the partition corresponding to the address through the bad block management function of the mtd device, determines the bad block in the mtd partition, and saves the bad block Block information is recorded in a static array; 所述手持设备在确定地址偏移量所指向的所述mtd分区中的块之后,读取确定的块中存储的预制内容之前,还包括:After the handheld device determines the block in the mtd partition pointed to by the address offset and before reading the prefabricated content stored in the determined block, it further includes: 所述手持设备根据记录的坏块的信息,确定所述地址偏移量所指向的块不为坏块。The handheld device determines that the block pointed to by the address offset is not a bad block according to the recorded bad block information. 6.如权利要求5所述的方法,其特征在于,若所述手持设备确定所述地址偏移量所指向的块为坏块,则所述手持设备在确定所述地址偏移量所指向的块为坏块之后,还包括:6. The method according to claim 5, wherein if the handheld device determines that the block pointed to by the address offset is a bad block, then the handheld device determines that the block pointed to by the address offset After the block is a bad block, it also includes: 所述手持设备将当前的地址偏移量更新为当前块的下一个好块的地址偏移量后,读取更新后的地址偏移量所指向的块中一个页大小的预制内容,并将读取的预制内容通过USB传输给上位机。After the handheld device updates the current address offset to the address offset of the next good block of the current block, it reads the prefabricated content of a page size in the block pointed to by the updated address offset, and The read prefabricated content is transmitted to the host computer through USB. 7.一种手持设备,其特征在于,包括:7. A handheld device, characterized in that, comprising: 信息上报单元,用于通过通用串行总线USB与上位机相连,在接收到所述上位机的查询命令后,将存储有预制内容的块的信息、以及存储介质页的信息发送给所述上位机;The information reporting unit is used to connect to the upper computer through the universal serial bus USB, and after receiving the query command of the upper computer, send the information of the block storing the prefabricated content and the information of the storage medium page to the upper computer machine; 数据读取上报单元,用于接收到所述上位机的读取命令,根据所述块的信息读取存储的预制内容,并将所述预制内容通过USB发送给上位机;以及在确定传输给所述上位机的数据量达到根据所述页的信息生成的需要读取的数据量后,向所述上位机发送读操作完成命令。The data reading reporting unit is used to receive the read command of the host computer, read the stored prefabricated content according to the information of the block, and send the prefabricated content to the host computer through USB; After the amount of data of the upper computer reaches the amount of data that needs to be read generated according to the information of the page, a read operation completion command is sent to the upper computer. 8.如权利要求7所述的手持设备,其特征在于,所述数据读取上报单元,还用于:8. The handheld device according to claim 7, wherein the data reading reporting unit is also used for: 将所述预制内容通过USB通过USB发送给上位机之后,确定传输给所述上位机的数据量未达到根据所述页的信息生成的需要读取的数据量,继续执行根据所述块的信息读取存储的预制内容的步骤。After the prefabricated content is sent to the host computer via USB, it is determined that the amount of data transmitted to the host computer has not reached the amount of data that needs to be read generated according to the information of the page, and the execution is continued according to the information of the block. Steps to read stored prefab content. 9.如权利要求7或8所述的手持设备,其特征在于,还包括:9. The handheld device according to claim 7 or 8, further comprising: 内核层单元,用于通过通用串行总线USB与上位机相连之后,在接收到所述上位机的查询命令之前,在该手持设备通过通用串行总线USB与上位机连接后,向用户层单元上报USB插入事件;接收用户层单元发来的mtd分区的地址,执行对该地址对应的mtd分区的读操作,得到所述mtd分区中存储有所述预制内容的块的信息;Kernel layer unit, after being connected with upper computer by universal serial bus USB, before receiving the inquiry command of described upper computer, after this handheld device is connected with upper computer by universal serial bus USB, send user layer unit Report the USB insertion event; receive the address of the mtd partition sent by the user layer unit, execute the read operation of the mtd partition corresponding to the address, and obtain the information of the block storing the prefabricated content in the mtd partition; 用户层单元,用于接收到所述USB插入事件后,从维护的mtd分区列表中读取存储有预制内容的mtd分区的地址,并将读取到的mtd分区的地址发送给内核层单元。The user layer unit is configured to read the address of the mtd partition storing prefabricated content from the maintained mtd partition list after receiving the USB insertion event, and send the read address of the mtd partition to the kernel layer unit. 10.如权利要求7所述的手持设备,其特征在于,所述数据读取上报单元还用于:10. The handheld device according to claim 7, wherein the data reading reporting unit is also used for: 所述手持设备根据所述块的信息生成逻辑块地址LBA,并将所述LBA转换成存储介质上的地址偏移量,确定所述地址偏移量所指向的所述mtd分区中的块,读取确定的块中存储的预制内容。The handheld device generates a logical block address LBA according to the information of the block, and converts the LBA into an address offset on the storage medium, and determines the block in the mtd partition pointed to by the address offset, Reads the prefab stored in the identified block.
CN201510207732.2A 2012-07-10 2012-07-10 Data reading method and equipment for storage media Pending CN104866236A (en)

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201210237930.XA CN102819514B (en) 2012-07-10 2012-07-10 Data reading method and device for storage medium

Related Parent Applications (1)

Application Number Title Priority Date Filing Date
CN201210237930.XA Division CN102819514B (en) 2012-07-10 2012-07-10 Data reading method and device for storage medium

Publications (1)

Publication Number Publication Date
CN104866236A true CN104866236A (en) 2015-08-26

Family

ID=47303632

Family Applications (2)

Application Number Title Priority Date Filing Date
CN201510207732.2A Pending CN104866236A (en) 2012-07-10 2012-07-10 Data reading method and equipment for storage media
CN201210237930.XA Active CN102819514B (en) 2012-07-10 2012-07-10 Data reading method and device for storage medium

Family Applications After (1)

Application Number Title Priority Date Filing Date
CN201210237930.XA Active CN102819514B (en) 2012-07-10 2012-07-10 Data reading method and device for storage medium

Country Status (1)

Country Link
CN (2) CN104866236A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105204781A (en) * 2015-09-28 2015-12-30 华为技术有限公司 Compression method, device and equipment

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1304509A (en) * 1999-04-05 2001-07-18 M-系统快闪盘开拓者公司 Architecture of PC Flash Disk Based on Universal Serial Bus
CN201780792U (en) * 2010-09-20 2011-03-30 谢坦 Self-starting multi-functional safety universal serial bus (USB) flash drive based on Linux kernel

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR100735774B1 (en) * 2005-09-23 2007-07-06 엘지노텔 주식회사 Data backup method of embedded system

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1304509A (en) * 1999-04-05 2001-07-18 M-系统快闪盘开拓者公司 Architecture of PC Flash Disk Based on Universal Serial Bus
CN201780792U (en) * 2010-09-20 2011-03-30 谢坦 Self-starting multi-functional safety universal serial bus (USB) flash drive based on Linux kernel

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
胡勇其等: "嵌入式Linux下NAND存储系统的设计与实现", 《计算机工程》 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105204781A (en) * 2015-09-28 2015-12-30 华为技术有限公司 Compression method, device and equipment
CN105204781B (en) * 2015-09-28 2019-04-12 华为技术有限公司 Compression method, device and equipment

Also Published As

Publication number Publication date
CN102819514B (en) 2015-05-06
CN102819514A (en) 2012-12-12

Similar Documents

Publication Publication Date Title
CN103309709A (en) Firmware upgrading method, device and communication equipment
CN111538521B (en) Intelligent contract deployment and transaction method and device
CN106575260A (en) Caching technologies employing data compression
US8086763B2 (en) Changing class of device
US20130159613A1 (en) Methods, apparatuses, and computer program products for enhancing memory erase functionality
WO2021115177A1 (en) Application installation method and apparatus, terminal device, server and storage medium
CN104519105A (en) Method and device for acquiring applications matched with terminals
KR20100088210A (en) Apparatus and method for downloadin contents using movinand in portable terminal
CN112463199A (en) System upgrading method and terminal
US8468007B1 (en) Emulating a peripheral mass storage device with a portable device
CN111803917A (en) Resource processing method and device
WO2008132547A2 (en) System, method, device, and computer program product for providing a portable device having drive emulation capabilities
CN113641381A (en) DSP firmware remote upgrading device and method and industrial robot
CN102819514B (en) Data reading method and device for storage medium
CN103049403A (en) Method for communication between embedded terminal device and cell phone
CN103902230A (en) Data processing method, device and system
CN102117245B (en) Embedded device and method for loading and starting operation of cutting system executable file thereof
CN103795806A (en) Method for achieving cloud storage for mobile terminal
CN116884470B (en) Storage product testing method and system, electronic equipment and storage medium
CN101751283A (en) Virtual machine monitor, virtual machine system and client operation system state acquiring method
CN102760061B (en) The method of shielding solid state hard disc memory interface difference and storage system
CN116719724A (en) eMMC multi-platform testing method and device and electronic equipment
CN101170769A (en) Method for binding between Bluetooth address and IMEI number of mobile communication terminal
CN101872429A (en) Plug-and-play data card and driver installation method thereof
CN102567263A (en) Device and method for automatic synchronization and automatic exchanging of user data of serial interface portable device

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
EXSB Decision made by sipo to initiate substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20150826