A method for identifying a memory card and a mobile device
By pulling the command pin of the memory card low and detecting the response of the data pin, the memory card is identified into different categories and initialized accordingly, which solves the problem of slow memory card identification speed and achieves a faster identification process.
Patent Information
- Application Number
- CN201811585274.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2018-12-24
- Publication Date
- 2026-01-06
- Estimated Expiration
- 2038-12-24
AI Technical Summary
Existing technologies have relatively slow memory card recognition speeds and low recognition efficiency.
By pulling the command pin of the memory card low and detecting the response of the data pin, the memory card is identified as a Class I or Class II memory card, and initialized using the corresponding communication protocol.
This avoids the response failure problem in existing technologies and significantly speeds up the recognition speed of memory cards.
Smart Images

Figure CN111428841B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of storage technology, and in particular to a method for identifying a memory card and a mobile device. Background Technology
[0002] Due to their large storage capacity, portability, and fast read / write speeds, memory cards are increasingly supported by terminal devices. Currently, after inserting a memory card, the terminal device uses an identification program to load data onto the memory card, thus recognizing it.
[0003] Taking MMC cards and SD cards as examples, the common method for identifying MMC cards and SD cards is to use the CMD8 and ACMD41 commands to determine if the SD card responds. This method requires two steps, is slow, and has low identification efficiency. Summary of the Invention
[0004] This application mainly provides a method for identifying memory cards and a mobile device, which can solve the problem of slow memory card identification speed in the prior art.
[0005] One approach adopted in this application is to provide a method for identifying a memory card, the method comprising: pulling down the potential of the command pin of the memory card to be identified; detecting whether there is a response on the data pin of the memory card; and identifying the memory card as a first type memory card or a second type memory card based on the response of the data pin.
[0006] The step of identifying a memory card as either a first-type or second-type memory card based on the response of the data pins includes: if a response is received, the memory card is identified as a first-type memory card; if no response is received, the memory card is identified as a second-type memory card.
[0007] The step of pulling down the potential of the command pin of the memory card to be identified includes: pulling down the command pin of the memory card to be identified for at least a preset number of clock cycles.
[0008] The step of detecting whether the data pins of the memory card respond includes: detecting whether the data pins of the memory card output data within a preset time.
[0009] The step of identifying the memory card as a first-type memory card further includes: initializing the first-type memory card using an initialization command of the first-type memory card communication protocol; the step of identifying the memory card as a second-type memory card further includes: initializing the second-type memory card using an initialization command of the second-type memory card communication protocol.
[0010] Before the step of pulling down the potential of the command pin of the memory card to be identified, the method further includes: sending a reset command, which is shared by the first type of memory card communication protocol and the second type of memory card communication protocol, to the command pin of the memory card to be identified, so that the memory card to be identified enters an idle state.
[0011] The first type of memory card is an MMC card, and the second type of memory card is an SD card.
[0012] The initialization command is CMD1; and / or the reset command is CMD0.
[0013] Prior to the step of pulling down the potential of the command pin of the memory card to be identified, the process further includes: powering on the memory card.
[0014] One approach adopted in this application is to provide a mobile device, which includes a controller and a card slot. The card slot is used to accommodate a memory card and to make an electrical connection between the memory card and the controller. The controller is used to identify the memory card using the method described above.
[0015] The memory card identification method provided in this application includes: pulling down the potential of the command pin of the memory card to be identified; detecting whether there is a response on the data pin of the memory card; and identifying the memory card as a first-type memory card or a second-type memory card based on the response of the data pin. Through the above method, this application can avoid the potential response failure problem of existing methods that rely on sending commands, and also speeds up the identification process. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. Wherein:
[0017] Figure 1 This is a flowchart illustrating the first embodiment of the memory card identification method provided in this application;
[0018] Figure 2 This is a flowchart illustrating the second embodiment of the memory card identification method provided in this application;
[0019] Figure 3 This is a flowchart illustrating the third embodiment of the memory card identification method provided in this application;
[0020] Figure 4 This is a flowchart illustrating the fourth embodiment of the memory card identification method provided in this application;
[0021] Figure 5This is a schematic diagram of the structure of an embodiment of the mobile device provided in this application;
[0022] Figure 6 This is a schematic diagram of the card tray structure in one embodiment of the mobile device provided in this application. Detailed Implementation
[0023] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0024] A memory card is an independent storage medium used in mobile phones, digital cameras, laptops, MP3 players, and other digital products. It is generally in the form of a card, hence the general term "memory card," also known as "digital memory card," "storage card," etc.
[0025] See Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the memory card identification method provided in this application. The method includes:
[0026] Step 11: Pull the command pin of the memory card to be identified low.
[0027] One method is to pull the command pin of the memory card to be identified low, which can ground the command pin of the memory card.
[0028] Step 12: Check if there is a response on the data pins of the memory card.
[0029] This mainly involves checking whether the data pins of the memory card can read data.
[0030] Optionally, after power-on or reset, if the CMD line is kept low for at least a preset number of clock cycles, the device recognizes that the boot operation mode has been started and will begin preparing boot data internally. The host can then read the boot data from the boot area selected by EXT_CSD
[178] bytes[5:3]. After pulling the CMD line low for a preset number of clock cycles, the device will start sending the first boot data to the host via the DAT line. The host must keep the CMD line low to read the boot data (push-pull mode).
[0031] Step 13: Identify the memory card as either a Type I or Type II memory card based on the response of the data pins.
[0032] Understandably, in the above embodiments, after the first type of memory card pulls its command pin low for a preset number of clock cycles, its data pin will respond, meaning it can read data, while the second type of memory card will not respond at all. Therefore, the first type of memory card and the second type of memory card can be identified in this way.
[0033] Unlike existing technologies, the memory card identification method provided in this embodiment includes: pulling down the potential of the command pin of the memory card to be identified; detecting whether there is a response on the data pin of the memory card; and identifying the memory card as a first-type memory card or a second-type memory card based on the response of the data pin. Through the above method, this application can avoid the potential response failure problem of existing methods that rely on sending commands, and also speeds up the identification process.
[0034] The following embodiments use an MMC card as the first memory card and an SD card as the second memory card to describe the identification method of the present invention in detail.
[0035] An SD card (Secure Digital Memory Card) is a new generation of memory device based on semiconductor flash memory, boasting high memory capacity, fast data transfer rates, great portability, and excellent security. SD cards generally include standard SD cards and Micro SD cards.
[0036] MMC is an abbreviation for Multi Media Card. It is a non-volatile storage device that is small in size, has a large capacity, low power consumption, and fast transmission speed, and is widely used in consumer electronics products. MMC is an interface protocol (a type of card), and memory devices that conform to this interface can be called MMC storage devices (MMC cards).
[0037] The following describes how to identify MMC cards and SD cards.
[0038] The MMC card has seven pins and two operating modes: MMC mode (also called MMC identification mode) and SPI mode.
[0039] The MMC mode mainly includes the following three states:
[0040] 1. Idle state is the state entered after the MMC card is reset;
[0041] 2. Ready state is the state after the MMC card has been matched with the voltage range;
[0042] 3. Identification status is the state that the MMC card enters after responding to the CID.
[0043] The pinouts of the MMC card are shown in the table below:
[0044]
[0045]
[0046] An SD card has nine pins and operates in two modes: SD mode and SPI mode. This embodiment primarily operates in SD mode; therefore, the DAT3 pin of the SD card must not be grounded to prevent it from switching to SPI mode. Specifically, the DAT3 pin of the memory card to be identified is powered on to ensure it is not grounded.
[0047] The pinouts of the SD card are shown in the table below:
[0048] pin number name Function (SD Mode) Function (SPI mode) 1 DAT3 / CS Data 3 Film Selection 2 CMD / DI Order The main one goes out, the secondary one comes in. 3 VSS1 GND GND 4 VDD power supply power supply 5 CLK clock clock 6 VSS2 GND GND 7 DAT0 / DO Data 0 The main enters, the secondary exits 8 DAT1 / IRQ Data 1 reserve 9 DAT2 / NC Data 2 reserve
[0049] See Figure 2 , Figure 2 This is a flowchart illustrating a second embodiment of the memory card identification method provided in this application. The method includes:
[0050] Step 21: Pull the command pin of the memory card to be identified low for at least a preset number of clock cycles.
[0051] Step 22: Check if there is data output on the data pins of the memory card within a preset time.
[0052] This step primarily checks whether the memory card's data pins can read data. If data is output, proceed to step 23; otherwise, proceed to step 24.
[0053] Optionally, after power-on or reset, if the CMD line is held low for at least 74 clock cycles, the device recognizes that the boot operation mode has been started and begins to prepare boot data internally. The host can then read the boot data from the boot area selected by EXT_CSD
[178] bytes[5:3]. After pulling the CMD line low for a preset time of 74 clock cycles, the device begins to send the first boot data to the host via the DAT line. The host must keep the CMD line low to read the boot data (push-pull mode).
[0054] In one specific embodiment, the method may be to: pull the command pin of the memory card to be identified low for at least 74 clock cycles, and detect whether there is data output on the data pin of the memory card within 1 second.
[0055] Step 23: Recognize the memory card as an MMC card.
[0056] Step 24: Recognize the memory card as an SD card.
[0057] Specifically, in conjunction with step 22 above, since the detection method in this embodiment mainly determines whether the memory card to be identified is an MMC card, the SD card will not respond to the above command. Therefore, when detecting whether the memory card has data output, it is only necessary to detect the 7th pin. If there is no response, it can be determined that it is an SD card.
[0058] The memory card identification method provided in this embodiment includes: pulling down the potential of the command pin of the memory card to be identified; detecting whether there is a response on the data pin of the memory card; and identifying the memory card as an MMC card or an SD card based on the response of the data pin. By utilizing the protocol characteristics of MMC cards to identify MMC protocol cards, unlike the existing technology that uses two steps (CMD8 and ACMD41 commands) to identify SD cards, this embodiment can shorten the identification process and speed up the identification process.
[0059] See Figure 3 , Figure 3 This is a flowchart illustrating a third embodiment of the memory card identification method provided in this application. The method includes:
[0060] Step 31: Send a reset command shared by the MMC and SD protocols to the command pin of the memory card to be identified, so that the memory card to be identified enters the idle state.
[0061] The reset command is CMD0.
[0062] Step 32: Pull the command pin of the memory card low for at least 74 clock cycles.
[0063] Step 33: Check if there is data output on the memory card's data pins within 1 second.
[0064] If there is data output, proceed to step 34; otherwise, proceed to step 35.
[0065] Step 34: Recognize the memory card as an MMC card.
[0066] After the memory card is recognized as an MMC card, corresponding operations can be performed directly on the MMC card based on the MMC protocol.
[0067] Step 35: Recognize the memory card as an SD card.
[0068] In addition, after the identification is complete, the corresponding memory card can also be initialized.
[0069] Specifically, if the card is identified as a first-class memory card, the initialization command of the first-class memory card communication protocol is used to initialize the first-class memory card; if the card is identified as a second-class memory card, the initialization command of the second-class memory card communication protocol is used to initialize the second-class memory card.
[0070] Taking MMC cards and SD cards as examples, the initialization command for MMC cards is CMD1, so initialization can be performed by sending the CMD1 command. SD cards can be initialized using the CMD8 and ACMD41 commands.
[0071] See Figure 4 , Figure 4 This is a flowchart illustrating the fourth embodiment of the memory card identification method provided in this application. The method includes:
[0072] Step 41: Power on the memory card to be identified.
[0073] It is understandable that the working voltage of an MMC card is 2.7V-3.6V, and the identification voltage is 1.8V and 2.7V-3.6V. The working voltage of an SD card is 3.3V. In the process of identifying the memory card, since this embodiment is based on the MMC protocol, a voltage of 1.8V or 3.3V can be used in step 41 to ensure that the MMC protocol can be identified.
[0074] Optionally, in this step, the memory card is powered on using a voltage of 3.3V.
[0075] Optionally, between steps 41 and 42, the process may further include sending a reset command shared by the MMC and SD protocols to the command pin of the memory card to be identified, so that the memory card to be identified enters an idle state.
[0076] The reset command is CMD0.
[0077] Step 42: Pull the command pin of the memory card low for at least 74 clock cycles.
[0078] Step 43: Check if there is data output on the memory card's data pins within 1 second.
[0079] If there is data output, proceed to step 44; otherwise, proceed to step 45.
[0080] Step 44: Recognize the memory card as an MMC card.
[0081] Specifically, since the power-on voltage was 1.8V, after recognizing the memory card as an MMC card, operations can be performed directly on the MMC card based on the MMC protocol. Additionally, since MMC cards also support 3.3V, the voltage can also be adjusted to 3.3V.
[0082] Step 45: Recognize the memory card as an SD card.
[0083] See Figure 5 , Figure 5 This is a schematic diagram of a mobile device embodiment provided in this application. The mobile device 50 includes a controller 51 and a card tray 52 that can be embedded in the main body of the mobile device 50. The card tray 52 is provided with a card slot 52a, which is used to accommodate a memory card and make the memory card electrically connected to the controller 51. The controller 51 is used to identify different types of memory cards in the manner described above.
[0084] Among them, such as Figure 6 As shown, Figure 6 This is a schematic diagram of the structure of a card tray in an embodiment of a mobile device provided in this application. The card tray 52 includes a first card slot 52a and a second card slot 52b. The first card slot 52a and the second card slot 52b have the same shape. The first card slot 52a and the second card slot 52b are used to accommodate various types of memory cards provided in the above embodiment.
[0085] The mobile device can be a wearable device such as a mobile phone, tablet, or smartwatch.
[0086] In addition, the mobile device may also include a memory for storing program data, which, when executed by the controller 51, implements the identification method described above.
[0087] When the embodiments of this application are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0088] The above description is merely an embodiment of this application and does not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.
Claims
1. An identification method of a memory card, characterized by, The method comprises: pulling down the potential of the command pin of the storage card to be identified for a preset clock cycle, so that the storage card to be identified identifies the boot operation mode in response to the potential of the command pin being pulled down for a preset clock cycle, and prepares boot data; detecting whether the data pin of the storage card has a response within a preset time after the potential of the command pin of the storage card to be identified is pulled down for a preset clock cycle; if the data pin of the storage card has a response within the preset time after the potential of the command pin of the storage card to be identified is pulled down for a preset clock cycle, identifying the storage card as an MMC card; if the data pin of the storage card has no response within the preset time after the potential of the command pin of the storage card to be identified is pulled down for a preset clock cycle, identifying the storage card as an SD card.
2. The method according to claim 1, wherein the step of detecting whether the data pin of the storage card has a response comprises: detecting whether the data pin of the storage card has data output within a preset time.
3. The method according to claim 1, wherein after the step of identifying the storage card as an MMC card, the method further comprises: using an initialization command of an MMC card communication protocol to initialize the MMC card; and / or after the step of identifying the storage card as an SD card, the method further comprises: using an initialization command of an SD card communication protocol to initialize the SD card.
4. The method according to claim 3, wherein before the step of pulling down the potential of the command pin of the storage card to be identified, the method further comprises: sending a reset command shared by the MMC card communication protocol and the SD card communication protocol to the command pin of the storage card to be identified, so that the storage card to be identified enters an idle state.
5. The method according to claim 4, wherein the initialization command is a CMD1 command; and / or the reset command is a CMD0 command.
6. The method according to claim 1, wherein before the step of pulling down the potential of the command pin of the storage card to be identified, the method further comprises: powering on the storage card. The mobile device comprises a controller and a card holder which can be embedded in the main body of the mobile device, and a card slot is arranged on the card holder, the card slot being used for accommodating a storage card and forming an electrical connection between the storage card and the controller, and the controller is used for identifying the storage card by using the method according to any one of claims 1-6. 7. A mobile device, characterized by
Citation Information
Patent Citations
Memory card complying with a plurality of standards
CN101361084A
Multi-interface, controller, memory card having the multi-interface controller, and interface setting method
US20070055823A1
Method for booting a host device from an mmc / sd device, a host device bootable from an mmc / sd device and an mmc / sd device method a host device may booted from
CN101361043A