Cross-platform SD card access method and system

By building a FatFS file system on the main logic platform and replacing the underlying read and write interface as the interface between SPI and algorithm platform, the directness and efficiency of cross-platform access to SD card data is achieved, and the problem of multiple and time-consuming data processing steps in the existing technology is solved, and development efficiency and data security are improved.

CN120122883APending Publication Date: 2025-06-10ZHENSHI INFORMATION TECH SHANGHAI CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510195861.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-21
Publication Date
2025-06-10

AI Technical Summary

Technical Problem

The existing cross-platform SD card data access method has many data processing steps and takes a long time, resulting in low development efficiency, making it difficult to improve the data processing efficiency of cross-platform systems.

Method used

The SD card data of the algorithm platform is accessed in a fixed-point manner through the file system of the main logic platform, and the FatFS file system is used to replace the underlying read and write interface with the SPI and the algorithm platform's read and write interface, and directly access the SD card data through the file name to avoid group data adapting to the data protocol.

Benefits of technology

It realizes the directness and efficiency of cross-platform access to SD card data, reduces data processing steps, improves development efficiency, and enhances data security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120122883A_ABST
    Figure CN120122883A_ABST
Patent Text Reader

Abstract

The invention discloses a cross-platform SD card access method and a cross-platform SD card access system in the technical field of SD card access, the system comprises an SD card, an algorithm platform, a main logic platform and an SP I communication protocol module, the SD card is used for storing data and providing an external access interface, the external access interface can provide an interface for accessing data in the SD card for the main logic platform, and the SD card is used for storing data in the main logic platform. The main logic platform can access data in the SD card in a cross-platform mode, the algorithm platform is used for executing an algorithm program and storing the data in the SD card, and the algorithm platform returns content in the serial shift register to the main logic platform through the main device input slave device output interface. According to the method, the SD card data of the algorithm platform is accessed in a fixed-point mode through the file system, group data and an adaptive data protocol are not needed any more, the SD card data can be directly accessed through the file name, the file system has the advantages of being safe and reliable, the data can be effectively prevented from being damaged or stolen, and the development efficiency is greatly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of SD card access, and specifically to a method and system for cross-platform access to SD cards. Background Art

[0002] An SD card is a low-cost, non-volatile flash memory card format, and its advantage is that data will not be lost when the power is off. An SD card can store various types of data, such as photos, videos, music, documents, etc. It is mainly used for storage expansion of mobile devices, digital cameras, laptops and other devices. Selecting a suitable SD card helps to maximize the performance of mobile devices.

[0003] Currently, in the process of multi-platform development, if an SD card is connected to an algorithm platform to store algorithm data, the main logic platform cannot directly access the data in the SD card through a file. Currently, the main logic platform can only access the data in the SD card by means of data stream access. In the process of accessing the data in the SD card by means of data stream, the data stream needs to transmit and process the data information between various components (such as programs, modules, subsystems, etc.). When data enters the system from the outside to form an input data stream, the system program needs to read the data source from the input data stream and write the program to the output data stream in order to output the data in the program to the outside world (such as a display, a printer, a file, a network, etc.).

[0004] Therefore, the existing method for accessing cross-platform SD card data has many steps and takes a long time for data processing, which is likely to delay the development efficiency and is not conducive to improving the data processing efficiency and development efficiency of cross-platform systems. Summary of the Invention

[0005] The purpose of the present invention is to provide a method and system for cross-platform access to SD cards, which can access the SD card data of the algorithm platform through the file system of the main logic platform, without the need to adapt the data protocol through group data, and can directly access the SD card data by file name, ensuring that the data is not damaged or stolen, and greatly improving the cross-platform development efficiency.

[0006] To achieve the above purpose, the present invention provides the following technical solutions:

[0007] In a first aspect, the present invention provides a system for cross-platform access to an SD card, including an SD card, an algorithm platform, a main logic platform, and an SPI communication protocol module;

[0008] The SD card is used to store data and provide an external access interface, and the external access interface can provide an interface for the main logic platform to access the data in the SD card, enabling the main logic platform to access the data in the SD card across platforms, which can improve the data access speed and the cross-platform development efficiency;

[0009] The algorithm platform is used to execute the algorithm program and store data in the SD card. The algorithm platform returns the content in the serial shift register to the main logic platform through the master device input and slave device output interface, and at the same time receives the data sent by the main logic platform through the master device output and slave device input interface, so as to complete the exchange of the content in the shift register between the algorithm platform and the main logic platform;

[0010] The main logic platform is used to build the FatFS file system;

[0011] The SPI communication protocol module is a full-duplex and synchronous communication bus. The SPI communication protocol module adopts the control mode architecture of the main logic platform controlling the algorithm platform. Among them, the algorithm platform can include multiple slave algorithm platforms arranged in a distributed manner, which can realize the inter-chip communication between a main logic platform and multiple slave algorithm platforms. The first read / write interface and the second read / write interface of the SPI communication protocol module respectively include a clock signal interface (SCLK), a chip select signal interface (CS), a master device output and slave device input interface (MOSI), and a master device input and slave device output (MISO) interface. The clock signal of the clock signal interface (SCLK) is generated by the main logic platform and provided to the algorithm platform, so that the main logic platform and the algorithm platform have a synchronous clock. The chip select signal of the chip select signal interface is used to select the algorithm platform. Only when the chip select signal is valid, the operation of the main logic platform on the algorithm platform is valid. The master device output and slave device input interface is used to transmit the data output from the main logic platform to the algorithm platform, and the master device input and slave device output interface is used to transmit the data output from the algorithm platform to the main logic platform. The SPI communication protocol module adopts the SPI communication method and is used for data transmission between the algorithm platform and the main logic platform. The main logic platform is electrically connected to the first read / write interface of the SPI communication protocol module through the read / write interface of the FatFS file system, and the second read / write interface of the SPI communication protocol module is electrically connected to the algorithm platform;

[0012] The FatFS file system is used to replace the underlying read / write interface with the read / write interface between SPI and the algorithm platform.

[0013] As a further solution of the present invention: The work area registration unit is the f_mount function. The work area registration unit is used to register the work area. The external C file unit is the code conversion function, which is used to switch the code for building the FatFS file system. The disk initialization unit is the disk_initialize function. The disk initialization unit is used to return a drive letter status as a result. The initialization program code is:

[0014]

[0015]

[0016] As a further solution of the present invention: the FatFS file system includes a work area registration unit, an external C file unit, a disk initialization unit, a current disk drive return unit, a disk sector reading unit, a disk sector writing unit, and an access test unit.

[0017] The current disk drive return unit is the disk_status function, and the current disk drive return unit is used to return the status of the current disk drive, which is convenient for confirming the logical drive number. The program code for returning the status of the current disk drive is as follows:

[0018]

[0019] As a further solution of the present invention: the disk sector reading unit is the disk_read function, and the disk sector reading unit is used to read sectors from the disk of the main logic platform. The program code for reading sectors is as follows:

[0020]

[0021]

[0022]

[0023] As a further solution of the present invention: the disk sector writing unit is the disk_write function, and the disk sector writing unit is used to write one or more sectors to the disk on the main logic platform. The program code for writing one or more sectors is as follows:

[0024]

[0025]

[0026]

[0027] As a further solution of the present invention: the FatFS file system further includes a miscellaneous function unit, the miscellaneous function unit is the disk_ioctl function, and the miscellaneous function unit is used to control the characteristics of the FatFS file system and miscellaneous functions other than reading and writing. The program code of the miscellaneous function unit is as follows:

[0028]

[0029]

[0030]

[0031]

[0032] As a further solution of the present invention: the FatFS file system further includes a current time acquisition unit, and the current time acquisition unit is the get_fattime function, and the current time acquisition unit is used to acquire the current time.

[0033] As a further solution of the present invention: the access test unit is a delay program, and the program code for delaying at the NSSP bit of the CR2 register is:

[0034] SPI_CR2(SPI 1)|=SPI_CR2_NSSP; / / NSSP. By setting the delay program as the access test unit, it is possible to quickly determine whether data access can be performed between the main logic platform and the algorithm platform through the SPI communication protocol module with simple program code, improving the convenience and flexibility of determining whether the FatFS file system is successfully built.

[0035] In a second aspect, the present invention further provides a method for cross-platform accessing an SD card, which is applied to the cross-platform accessing SD card system as described in the above solution. The method for cross-platform accessing an SD card includes:

[0036] Build the FatFS file system using the main logic platform;

[0037] The FatFS file system replaces the underlying read / write interface with the read / write interface of the SPI and the algorithm platform;

[0038] Conduct a test using the access test unit;

[0039] When the test is qualified, perform read / write operations on the SD card of the algorithm platform in the form of accessing files through the main logic platform;

[0040] Conduct read / write operations on the SD card through the algorithm platform, and transmit the read / write data to the main logic platform through the SPI communication protocol module.

[0041] As a further solution of the present invention: the method for the FatFS file system to replace the underlying read / write interface with the read / write interface of the SPI and the algorithm platform includes:

[0042] Establish the FatFS source code;

[0043] Add the FatFS source code to the source code management controller, and the source code management controller is an embedded single-chip microcomputer;

[0044] Write the underlying interface module.

[0045] In a third aspect, the present invention further provides an electronic device, including: a memory and a processor coupled to the memory, where the memory is used to store executable program code, and the processor calls the executable program code stored in the memory, and the executable program code is used to execute the method for cross-platform accessing an SD card described in the above solution.

[0046] In a fourth aspect, the present invention further provides a computer-readable storage medium, which is used to store a computer program, and the computer executes the method for cross-platform accessing an SD card described in the above solution by running the computer program.

[0047] Compared with the prior art, the beneficial effects of the present invention are as follows:

[0048] 1. The main logic platform of the present invention can access the SD card data of the algorithm platform through the file system's fixed-point access algorithm, without the need to group data and adapt data protocols anymore, and can directly access the SD card data by file name. Moreover, the file system has the advantages of being secure and reliable, which can effectively prevent data from being damaged or stolen, greatly improving the construction and development efficiency of system files.

[0049] 2. In the present invention, by setting a delay program as an access test unit, it can quickly determine whether data access can be performed between the main logic platform and the algorithm platform through the SPI communication protocol module with simple program code, improving the convenience and flexibility of determining whether the file system is successfully built. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] Figure 1 It is a system module diagram of the present invention;

[0051] Figure 2 It is a module interface connection diagram of the present invention;

[0052] Figure 3 It is a method step diagram of the method for cross-platform accessing an SD card of the present invention;

[0053] Figure 4 It is a method step diagram of replacing the underlying read / write interface with the read / write interface of the SPI and algorithm platforms in the present invention;

[0054] Figure 5 It is a default clock signal diagram of the present invention;

[0055] Figure 6 It is a delay test clock signal diagram of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0056] The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.

[0057] Embodiment:

[0058] Please refer to Figure 1 - Figure 2 , in the embodiment of the present invention, a system for cross-platform accessing an SD card is provided, including an SD card, an algorithm platform, a main logic platform, and an SPI communication protocol module. Among them, the main logic platform adopts the Platformio platform, and the algorithm platform adopts STM32;

[0059] The SD card is used to store data and provide an external access interface. The external access interface can provide an interface for the main logic platform to access the data in the SD card, enabling the main logic platform to cross-platform access the data in the SD card, which can improve the data access speed and the cross-platform development efficiency;

[0060] The algorithm platform is used to execute algorithm programs and store data in the SD card. The algorithm platform returns the content in the serial shift register to the main logic platform through the master device input slave device output interface, and at the same time receives the data sent by the main logic platform through the master device output slave device input interface, so as to complete the exchange of the content in the shift register between the algorithm platform and the main logic platform;

[0061] The main logic platform is used to build a FatFS file system and replace the underlying read and write interfaces with the read and write interfaces of the SPI and the algorithm platform through the FatFS file system;

[0062] The SPI communication protocol module is a full-duplex, synchronous communication bus. The SPI communication protocol module adopts a control mode architecture in which the main logic platform controls the algorithm platform. Among them, the algorithm platform can include multiple slave algorithm platforms arranged in a distributed manner, enabling inter-chip communication between a main logic platform and multiple slave algorithm platforms. The first read / write interface and the second read / write interface of the SPI communication protocol module respectively include a clock signal interface (SCLK), a chip select signal interface (CS), a master device output slave device input interface (MOSI), and a master device input slave device output (MISO) interface. The clock signal of the clock signal interface (SCLK) is generated by the main logic platform and provided to the algorithm platform, so that the main logic platform and the algorithm platform have a synchronous clock. The chip select signal of the chip select signal interface is used to select the algorithm platform. Only when the chip select signal is valid, the operation of the main logic platform on the algorithm platform is valid. The master device output slave device input interface is used to transmit data output from the main logic platform to the algorithm platform, and the master device input slave device output interface is used to transmit data output from the algorithm platform to the main logic platform. The SPI communication protocol module adopts the SPI communication method for data transmission between the algorithm platform and the main logic platform. The main logic platform is electrically connected to the first read / write interface of the SPI communication protocol module through the read / write interface of the FatFS file system, and the second read / write interface of the SPI communication protocol module is electrically connected to the algorithm platform.

[0063] Preferably, the FatFS file system includes a work area registration unit, an external C file unit, a disk initialization unit, a current disk drive return unit, a disk sector reading unit, a disk sector writing unit, and an access test unit.

[0064] The current disk drive return unit is the disk_status function. The current disk drive return unit is used to return the status of the current disk drive, which is convenient for confirming the logical drive number. The program code for returning the status of the current disk drive is as follows:

[0065]

[0066]

[0067] Preferably, the work area registration unit is the f_mount function.

[0068] The work area registration unit is used to register the work area. The external C file unit is a code conversion function used to switch the code for building the FatFS file system. The disk initialization unit is the disk_initialize function. The disk initialization unit is used to return a drive letter status as a result. The program code for initialization is as follows:

[0069]

[0070]

[0071] Preferably, the disk sector reading unit is the disk_read function. The disk sector reading unit is used to read sectors from the disk of the main logic platform. The program code for reading sectors is as follows:

[0072]

[0073]

[0074]

[0075] Preferably, the disk sector writing unit is the disk_write function. The disk sector writing unit is used to write one or more sectors to the disk on the main logic platform. The program code for writing one or more sectors is:

[0076]

[0077]

[0078]

[0079] Preferably, the FatFS file system further includes a miscellaneous function unit. The miscellaneous function unit is the disk_ioctl function. The miscellaneous function unit is used to control the characteristics of the FatFS file system and miscellaneous functions other than reading and writing. The program code of the miscellaneous function unit is:

[0080]

[0081]

[0082]

[0083] The macro definition of the above program code of the miscellaneous function unit is:

[0084]

[0085]

[0086]

[0087] Preferably, the FatFS file system further includes a current time acquisition unit. The current time acquisition unit is the get_fattime function. The current time acquisition unit is used to acquire the current time.

[0088] Preferably, the access test unit is a delay program. The program code for delaying at the NSSP bit of the CR2 register is:

[0089] SPI_CR2(SPI1) |= SPI_CR2_NSSP; / / NSSP, by setting a delay program as an access test unit, it can quickly determine whether data access can be performed between the main logic platform and the algorithm platform through the SPI communication protocol module by means of simple program code, improving the convenience and flexibility of determining the success of building the FatFS file system.

[0090] Please refer to Figure 3 Moreover, the present invention also provides a method for cross-platform accessing an SD card, which is applied to the system for cross-platform accessing an SD card as described in the above solution. The method for cross-platform accessing an SD card includes:

[0091] S1: Build the FatFS file system using the main logic platform;

[0092] S2: The FatFS file system replaces the underlying read / write interface with the read / write interface of the SPI and the algorithm platform;

[0093] S3: Perform tests using the access test unit;

[0094] S4: After the test is qualified, perform read / write operations on the SD card of the algorithm platform in the way of accessing files through the main logic platform;

[0095] S4: Perform read / write operations on the SD card through the algorithm platform, and transmit the read / write data to the main logic platform through the SPI communication protocol module.

[0096] Preferably, the method for the FatFS file system to replace the underlying read / write interface with the read / write interface of the SPI and the algorithm platform includes:

[0097] S21: Establish the FatFS source code;

[0098] S22: Add the FatFS source code to the source code management controller, and the source code management controller is an embedded microprocessor;

[0099] S23: Write the underlying interface module.

[0100] The present invention also provides an electronic device (not shown in the figure), including a memory and a processor coupled to the memory. The memory is used to store executable program code, and the processor calls the executable program code stored in the memory. The executable program code is used to execute the method for cross-platform accessing an SD card as described in the above solution.

[0101] The present invention also provides a computer-readable storage medium (not shown in the figure). The computer-readable storage medium is used to store a computer program, and the computer executes the method for cross-platform accessing an SD card as described in the above solution by running the computer program

[0102] The above are only the preferred specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present invention, according to the technical solution and inventive concept of the present invention, making equivalent substitutions or changes, shall be covered by the protection scope of the present invention.

Claims

1. A system for accessing SD card across platforms, characterized in that: include: SD card, the SD card is used to store data and provide an external access interface; An algorithm platform, the algorithm platform is used to execute the algorithm program and store the data in the SD card; A main logic platform, wherein the main logic platform is used to build a FatFS file system; An SPI communication protocol module, wherein the SPI communication protocol module adopts an SPI communication mode and is used for data transmission between the algorithm platform and the main logic platform, wherein the main logic platform is electrically connected to a first read-write interface of the SPI communication protocol module through a read-write interface of the FatFS file system, and a second read-write interface of the SPI communication protocol module is electrically connected to the algorithm platform; The FatFS file system is used to replace the underlying read-write interface with the read-write interface of the SPI and algorithm platform.

2. The cross-platform SD card access system according to claim 1, characterized in that: The FatFS file system includes a workspace registration unit, an external C file unit, a disk initialization unit, a current disk drive return unit, a disk sector reading unit, a disk sector writing unit and an access test unit. The current disk drive returning unit is a disk_status function, and the current disk drive returning unit is used to return the status of the current disk drive.

3. The cross-platform SD card access system according to claim 1, characterized in that: The workspace registration unit is the f_mount function, and the workspace registration unit is used to register the workspace.

4. The cross-platform SD card access system according to claim 1, characterized in that: The disk sector reading unit is a disk_read function.

5. The cross-platform SD card access system according to claim 1, characterized in that: The disk sector writing unit is a disk_write function.

6. The cross-platform SD card access system according to claim 1, characterized in that: The FatFS file system further includes a miscellaneous function unit, which is a disk_ioctl function, and is used to control the characteristics of the FatFS file system and miscellaneous functions except reading and writing.

7. The cross-platform SD card access system according to claim 1, characterized in that: The FatFS file system further includes a current time acquisition unit, which is a get_fattime function and is used to acquire the current time.

8. The cross-platform SD card access system according to claim 1, characterized in that: The access test unit is a delay program.

9. A method for cross-platform access to an SD card, applied to the cross-platform access to an SD card system as claimed in any one of claims 1 to 8, characterized in that: The cross-platform method for accessing the SD card includes: Use the main logic platform to build the FatFS file system; The FatFS file system replaces the underlying read-write interface with the read-write interface of the SPI and algorithm platform; Use access test unit for testing; When the test is qualified, the main logic platform reads and writes the SD card of the algorithm platform in the way of accessing files; The algorithm platform performs read and write operations on the SD card, and transmits the read and write data to the main logic platform through the SPI communication protocol module.

10. The method for cross-platform access to SD card according to claim 9, characterized in that: The method for the FatFS file system to replace the underlying read-write interface with the read-write interface of the SPI and algorithm platform includes: Build FatFS source code; Add the FatFS source code to the source code management controller; Write the low-level interface module.