File system migration method, device, equipment and storage medium

By automatically configuring the driver by receiving and utilizing the target storage device parameters in the configuration interface, the problem of low file system porting efficiency is solved, achieving efficient adaptation without manual modification of the driver, thus improving porting efficiency and maintainability.

CN114546934BActive Publication Date: 2026-04-07LOONGSON TECH CORP
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-11-18
Publication Date
2026-04-07

AI Technical Summary

Technical Problem

In existing technologies, file system portability is inefficient, requiring users to manually modify drivers to adapt to different types of storage devices, resulting in cumbersome operations and difficulty in maintenance.

Method used

By adding a configuration component to the configuration interface, the system can receive target memory device parameters input by the user and automatically determine the device parameters called by the driver during the compilation process, generating an executable file to automatically configure memory information when the target operating system is initialized, thus avoiding manual modification of the driver.

Benefits of technology

It improves the efficiency and maintainability of file system porting, reduces the complexity of user operations, and enables adaptation to target storage without modifying the driver.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114546934B_ABST
    Figure CN114546934B_ABST
Patent Text Reader

Abstract

This application provides a file system porting method, apparatus, device, and storage medium. The method includes: displaying a configuration interface, the configuration interface including a configuration component; receiving device parameters of a target memory input by a user for the configuration component; compiling source files of a target operating system according to the device parameters of the target memory to obtain an executable file, wherein the source files of the target operating system include source code of the target file system, and the executable file is executed by a first electronic device to instruct the first electronic device, during the initialization process of the target operating system, to determine device parameters for use by a driver program of the target file system according to the device parameters of the target memory, wherein the first electronic device is equipped with the target memory. This application can improve the porting efficiency of file systems.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, device and storage medium for porting a file system. Background Technology

[0002] In an operating system, the software mechanism responsible for managing and storing file information is called a file system. File systems enable efficient management of data on storage devices. There are many types of file systems, such as TFFS (True Flash File System), YAFFS (Yet Another Flash File System), and HFS (Hierarchical File System). Generally, operating systems support some file system types by default. For file systems not supported by default, they can be added to the operating system through porting. However, because different types of storage devices have different device information, to ensure compatibility between the ported file system and the storage device, users need to modify the file system driver for the storage device after porting. The driver modification process is cumbersome, resulting in low efficiency for file system porting. Summary of the Invention

[0003] This application provides a file system porting method, apparatus, device, and storage medium to solve the problem of low file system porting efficiency.

[0004] In a first aspect, embodiments of this application provide a file system porting method, including:

[0005] Display configuration interface, which includes configuration components;

[0006] Receive device parameters of the target memory input by the user for the configuration component;

[0007] Based on the device parameters of the target memory, the source files of the target operating system are compiled to obtain an executable file. The source files of the target operating system include the source code of the target file system. The executable file is executed by a first electronic device to instruct the first electronic device to determine the device parameters to be invoked by the driver of the target file system based on the device parameters of the target memory during the initialization process of the target operating system. The first electronic device is equipped with the target memory.

[0008] In one possible implementation, the configuration component corresponds one-to-one with the device parameter, and the configuration interface includes the identifier and / or icon of the device parameter corresponding to the configuration component.

[0009] In one possible implementation, the device parameters include at least one of the following:

[0010] Start block number, end block number, chip select information, number of blocks, number of pages, capacity of primary storage space, capacity of spare storage space.

[0011] In one possible implementation, the executable file is executed by a first electronic device to instruct the first electronic device to write device parameters of the target memory into a specified data structure during the initialization of the target operating system, wherein the device parameters in the specified data structure are used by the driver of the target file system.

[0012] In one possible implementation, before compiling the source files of the target operating system based on the device parameters of the target memory, the method further includes:

[0013] Obtain the source code file of the target file system;

[0014] Add the source code from the source code file to the source file of the target operating system;

[0015] After obtaining the executable file, the method further includes:

[0016] The executable file is imported into the first electronic device so that the first electronic device executes the executable file after power-on.

[0017] In one possible implementation, the target operating system is the VxWorks operating system, the target memory includes NAND flash memory, and the target file system includes at least one of the following: YAFFS2 file system and YAFFS file system.

[0018] Secondly, embodiments of this application provide a file system porting method applied to an electronic device, wherein the electronic device is a first electronic device equipped with a target memory, and the method includes:

[0019] Execute the executable file of the target operating system to initialize the target operating system, wherein the executable file is compiled from the source files of the target operating system; the source files of the target operating system include the source code of the target file system; and the executable file includes the device parameters of the target memory.

[0020] During the initialization of the target operating system, device parameters for use by the driver of the target file system are determined based on the device parameters of the target memory.

[0021] In one possible implementation, the device parameters include at least one of the following:

[0022] Start block number, end block number, chip select information, number of blocks, number of pages, capacity of primary storage space, capacity of spare storage space.

[0023] In one possible implementation, creating a target storage for the target storage in the target file system based on the device parameters of the target storage includes:

[0024] Determine whether the start block number and the end block number meet preset conditions;

[0025] When the start block number and the end block number meet the preset conditions, the storage partition of the target memory is determined based on the start block number and the end block number.

[0026] In one possible implementation, device parameters for invocation by the driver of the target file system are determined based on the device parameters of the target memory, including:

[0027] The device parameters of the target memory are written into a specified data structure; the device parameters in the specified data structure are used by the driver of the target file system.

[0028] In one possible implementation, the target operating system is a VxWorks operating system, the target memory is a NAND flash memory, and the target file system includes at least one of the following: a YAFFS2 file system or a YAFFS file system.

[0029] Thirdly, embodiments of this application provide a file system porting apparatus, comprising:

[0030] The display module is used to display the configuration interface, which includes configuration components;

[0031] The receiving module is used to receive device parameters of the target memory input by the user for the configuration component;

[0032] A compilation module is used to compile the source files of the target operating system according to the device parameters of the target memory to obtain an executable file. The source files of the target operating system include the source code of the target file system. The executable file is used to be executed by a first electronic device to instruct the first electronic device to determine the device parameters to be invoked by the driver of the target file system according to the device parameters of the target memory during the initialization process of the target operating system. The first electronic device is equipped with the target memory.

[0033] Fourthly, embodiments of this application provide a file system porting apparatus applied to an electronic device, wherein the electronic device is a first electronic device equipped with a target memory, and the apparatus includes:

[0034] An initialization module is used to execute an executable file of the target operating system to initialize the target operating system, wherein the executable file is compiled from the source files of the target operating system; the source files of the target operating system include the source code of the target file system; and the executable file includes the device parameters of the target memory.

[0035] An initialization module is used to determine, during the initialization of the target operating system, device parameters for use by the driver of the target file system, based on the device parameters of the target memory.

[0036] Fifthly, embodiments of this application provide an electronic device, including: at least one processor and a memory;

[0037] The memory stores computer-executed instructions;

[0038] The at least one processor executes computer execution instructions stored in the memory, causing the at least one processor to perform the file system porting method as described in the first aspect and various possible embodiments of the first aspect.

[0039] Sixthly, embodiments of this application provide an electronic device, including: at least one processor and a memory;

[0040] The memory stores computer-executed instructions;

[0041] The at least one processor executes computer execution instructions stored in the memory, causing the at least one processor to perform the file system porting method as described in the first aspect and various possible embodiments of the first aspect.

[0042] In a seventh aspect, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the file system porting method described in the first aspect and various possible implementations of the first aspect.

[0043] Eighthly, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the file system porting method described in the first aspect and various possible implementations of the first aspect.

[0044] The file system porting method, apparatus, device, and storage medium provided in this application embodiment, through displaying a configuration interface including a configuration component; receiving device parameters of the target memory input by the user for the configuration component; compiling the source files of the target operating system according to the device parameters of the target memory to obtain an executable file, wherein the source files of the target operating system include the source code of the target file system, and the executable file is used to be executed by a first electronic device, so that during the initialization process of the target operating system, the first electronic device is instructed to determine the device parameters to be called by the driver of the target file system according to the device parameters of the target memory. The first electronic device is equipped with the target memory, enabling the user to configure the device information of the target memory through the configuration component, so that when the executable file is executed by the first electronic device, during the initialization process of the target operating system, the first electronic device is instructed to automatically determine the device parameters to be called by the driver of the target file system, without requiring the user to modify the driver of the target file system, thereby improving the porting efficiency of the file system. Attached Figure Description

[0045] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0046] Figure 1 A schematic diagram illustrating a scenario of a file system porting method provided in an embodiment of this application;

[0047] Figure 2 A flowchart illustrating a file system porting method provided in an embodiment of this application;

[0048] Figure 3 A schematic diagram of the configuration interface provided in an embodiment of this application;

[0049] Figure 4 A flowchart illustrating a file system porting method provided in yet another embodiment of this application;

[0050] Figure 5 A flowchart illustrating a file system porting method provided in another embodiment of this application;

[0051] Figure 6 A flowchart illustrating a file system porting method provided in another embodiment of this application;

[0052] Figure 7 A flowchart illustrating the initialization steps provided in this application embodiment;

[0053] Figure 8 This is a schematic diagram of the structure of a file system porting device provided in an embodiment of this application;

[0054] Figure 9 A schematic diagram of the structure of a file system porting device provided in another embodiment of this application;

[0055] Figure 10 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of this application;

[0056] Figure 11 This is a schematic diagram of the hardware structure of an electronic device provided in another embodiment of this application. Detailed Implementation

[0057] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0058] Figure 1 This is a schematic diagram illustrating a scenario of a file system porting method provided in an embodiment of this application. Figure 1 As shown, this scenario includes a first electronic device 11 and a second electronic device 12. The first electronic device 11 is an embedded electronic device, such as an embedded device based on a microcontroller, digital signal processor (DSP), or application-specific integrated circuit (ASIC), like a mobile phone, wearable device, or in-vehicle terminal. The second electronic device 12 can be a desktop computer, laptop computer, or other electronic device equipped with a display screen. An integrated development environment (IDE) is installed on the second electronic device 12. When running the IDE, the second electronic device 12 provides a compilation environment for compiling operating system source files.

[0059] The process of installing the target operating system on the first electronic device 11 is as follows: The user can obtain the source files of the target operating system from the official website platform of the target operating system, a third-party website platform providing target operating system download services, or copy the source files of the target operating system to the second electronic device 12 via a storage device such as a USB flash drive. The user opens and runs the integrated development environment (IDE) on the second electronic device 12, operates the configuration interface of the IDE to compile the source files of the target operating system to obtain the executable file of the target operating system. The user can connect the second electronic device 12 and the first electronic device 11 via a transmission cable and burn the executable file of the target operating system into the program memory of the first electronic device 11. Then, the first electronic device 11 is powered on. The first electronic device 11 executes the executable file of the target operating system to initialize and run the target operating system.

[0060] The target operating system is an embedded operating system, such as VxWorks, Linux, PalmOS, etc.

[0061] The first electronic device 11 is equipped with a target memory, which refers to a memory fixed on the board of the first electronic device 11, rather than a hot-swappable memory. For example, the target memory can be a NAND flash memory. Due to its miniaturization and low cost, NAND flash memory has become the preferred storage medium for embedded devices.

[0062] File systems enable efficient management of data on storage devices. A file system is the software component within an operating system responsible for managing and storing file information. There are many types of file systems, such as TFFS, YAFFS, and HFS. Generally, embedded operating systems support certain file system types by default. For file systems not supported by default in the embedded operating system, they can be ported to the operating system. However, due to differences in device information across different memory models, to ensure compatibility between the ported file system and the memory, the user needs to modify the file system driver for the memory equipped in the electronic device after porting the file system. The driver modification process is cumbersome, resulting in low efficiency for file system porting.

[0063] Taking a target operating system of VxWorks 6.8 and a target file system of YAFFS2 as an example, VxWorks 6.8 does not support the YAFFS2 file system by default. If the YAFFS2 file system needs to be used in the VxWorks 6.8 operating system of the first electronic device 11, file system porting is required, and the YAFFS2 file system driver needs to be modified if the YAFFS2 file system is incompatible with the target memory equipped in the first electronic device 11.

[0064] The traditional file system porting process involves users obtaining the source code files from the target file system's official website or a third-party website offering download services. Alternatively, users can copy the target file system's source code files to the second electronic device 12 using a storage device such as a USB flash drive, and then add the source code from the source code files to the target operating system's source files. The user then checks whether the target storage device equipped on the first electronic device 11 is compatible with the current driver for the target file system.

[0065] If a match is found, no modification to the driver code is required. The user opens and runs the integrated development environment (IDE) on the second electronic device 12, and uses the IDE's configuration interface to compile the target operating system's source files to obtain the target operating system's executable file. The user then burns the target operating system's executable file into the program memory of the first electronic device 11. The first electronic device 11 is then powered on. The first electronic device 11 executes the target operating system's executable file to initialize and run the target operating system. During initialization, the code portion in the file system driver used to parse device information from the device model is executed to parse the target memory's device information and store it. This information is used by the target file system driver to access and manage the data in the target memory after the file system is running.

[0066] If there is a mismatch, the driver code needs to be modified. The user opens and runs the integrated development environment (IDE) on the second electronic device 12. First, the user modifies the code portion in the target file system driver that is used to parse device information from the device model. This code portion is modified to be compatible with the target memory's parsing code. The user then opens and runs the IDE on the second electronic device 12, operates the IDE's configuration interface to compile the target operating system's source files to obtain the target operating system's executable file. The user burns the target operating system's executable file into the program memory of the first electronic device 11. Then, the first electronic device 11 is powered on. The first electronic device 11 executes the target operating system's executable file to initialize and run the target operating system. During initialization, the code portion in the file system driver used to parse device information from the device model is executed to obtain the target memory's device information and stores it. This allows the target file system driver to access and manage the target memory's data after the file system is running.

[0067] The code portion that parses the device information from the device model can be implemented in the following two ways:

[0068] In the first implementation, the device model of the target memory is a string generated by processing device information according to a specific naming rule. Different models or manufacturers have different naming rules. The code portion that parses the device information from the device model is used to extract the device information from the device model using the device model and corresponding command rules. The device model of the target memory can be obtained by the first electronic device 11 from the target memory, or it can be written into the driver code by the user. For the first implementation, when modifying the driver code, the user needs to obtain the naming rules of the target memory from the official website or manual of the device model, and modify the code portion in the driver code that parses the device information from the device model to parse the naming rules of the target memory.

[0069] In the second implementation, the file system driver has a pre-defined mapping table that stores the correspondence between the target storage device model and an array. The array stores device information. The code that parses the device model to obtain the device information is used to look up the corresponding array in the mapping table using the device model, thereby obtaining the device information. However, with this second implementation, since the target storage device may not be in the mapping table (e.g., for a newer model), the user needs to modify the mapping table in the driver.

[0070] As can be seen from the above process, due to the different device information of different types of memory, in order to make the ported file system compatible with the memory, the user needs to modify the file system driver for the memory equipped in the electronic device after porting the file system. The driver modification process is cumbersome, resulting in low efficiency of file system porting and a lack of maintainability.

[0071] This application provides a file system porting method. By adding a configuration component to the configuration interface for configuring the device parameters of the target memory, the user can directly modify the device parameters of the target memory through the configuration component when compiling the operating system. In this way, the executable file of the compiled operating system includes the device parameters of the target memory. When the executable file is executed by the first electronic device, during the initialization process of the target operating system, the device parameters of the target memory are determined as the device parameters called by the driver of the target file system. The configuration component makes it easy for the user to set the device parameters, and file system porting is achieved without modifying the file system driver code, thereby improving the porting efficiency of the file system.

[0072] Figure 2 This is a flowchart illustrating a file system porting method provided in an embodiment of this application. The execution entity in this embodiment can be an electronic device, specifically... Figure 1 The second electronic device in the system. For example... Figure 2 As shown, the method includes:

[0073] S201. Display the configuration interface, which includes configuration components.

[0074] S202, Receive device parameters of the target memory input by the user for the configuration component.

[0075] In this embodiment, after the second electronic device runs the integrated development environment but before compiling the source files of the target operating system, it displays a configuration interface. This configuration interface can be implemented by a configuration file in the source files when called by the compiler. In this embodiment, the configuration file includes newly added code related to configuration components, so that when the compiler calls the configuration file, it adds a configuration component to the configuration interface for inputting device parameters of the target memory. The target memory may include, but is not limited to, NAND Flash memory, NOR Flash memory, etc.

[0076] Optionally, the device parameters include, but are not limited to, at least one of the following: start block number, end block number, chip select information, number of blocks, number of pages, capacity of the primary storage space, and capacity of the spare storage space. The storage space between the start block number and the end block number is the space of the target memory managed by the file system. The chip select information is used by the processor of the first electronic device to select the target memory. The number of storage blocks indicates the number of blocks possessed by the target memory, the number of pages indicates the number of pages per block, the capacity of the primary storage space indicates the size of the primary area on each page, and the capacity of the spare storage space indicates the size of the spare area on each page.

[0077] Optionally, each configuration component corresponds one-to-one with a device parameter, and the configuration interface includes the identifier and / or icon of the device parameter corresponding to the configuration component. For example... Figure 3 As shown, each row within the dashed box corresponds to a configuration component, with a total of seven. The information for each configuration component's row, from left to right, includes the icon of the device parameter corresponding to that component, the identifier of the device parameter, the name of the variable storing the device parameter, the variable type, and the value of the device parameter entered by the user. Specifically, `nand cs select` indicates the chip select information, `blocks per chip` indicates the number of storage blocks, `pages per block` indicates the number of pages, `page mainsize` indicates the capacity of the main storage area, `page spare size` indicates the capacity of the spare storage area, `start block number` indicates the starting block number, and `end block number` indicates the ending block number. The NAND_CS variable is used to store chip select information, BLOCKS_PER_CHIP is used to store the number of blocks, PAGES_PER_BLOCK is used to store the number of pages, PAGE_MAIN_SIZE is used to store the capacity of the primary storage area, PAGE_SPARE_SIZE is used to store the capacity of the spare storage area, START_BLOCK is used to store the starting block number, and END_BLOCK is used to store the ending block number.

[0078] S203. Based on the device parameters of the target memory, the source file of the target operating system is compiled to obtain an executable file. The source file of the target operating system includes the source code of the target file system. The executable file is executed by the first electronic device to instruct the first electronic device to determine the device parameters to be called by the driver of the target file system based on the device parameters of the target memory during the initialization process of the target operating system. The first electronic device is equipped with the target memory.

[0079] In this embodiment, before compiling the source files of the target operating system, the user pre-adds the source code of the target file system to the source files of the target operating system. Upon receiving a compilation command triggered by the user to compile the source files of the target operating system, the compilation of the source files of the target operating system is executed, and the compiled executable file includes the device parameters of the target memory. Optionally, the executable file includes initialization code for initializing the target operating system. The initialization code includes the device parameters of the target memory.

[0080] After the user imports the executable code into the first electronic device via the connection cable, the first electronic device runs the executable code and first initializes the target operating system. During the initialization of the target operating system, the device parameters of the target memory are determined as device parameters to be invoked by the driver of the target file system. Optionally, during the initialization of the target operating system, the first electronic device writes the device parameters of the target memory into a specified data structure. After the target operating system runs, the file system driver manages the target memory by invoking the device parameters in the specified data structure.

[0081] This application embodiment displays a configuration interface, which includes a configuration component; receives device parameters of the target memory input by the user for the configuration component; and compiles the source files of the target operating system according to the device parameters of the target memory to obtain an executable file. The source files of the target operating system include the source code of the target file system. The executable file is executed by a first electronic device to instruct the first electronic device, during the initialization process of the target operating system, to determine the device parameters to be called by the driver of the target file system based on the device parameters of the target memory. The first electronic device is equipped with the target memory, enabling the user to configure the device information of the target memory through the configuration component. This allows the executable file, when executed by the first electronic device, to automatically determine the device parameters to be called by the driver of the target file system during the initialization process of the target operating system, without requiring the user to modify the driver of the target file system, thereby improving the portability efficiency of the file system.

[0082] Figure 4 This is a flowchart illustrating a file system porting method provided in another embodiment of this application. Figure 2 Based on the illustrated embodiment, this embodiment provides a detailed description of the specific implementation process for detecting the status of the device. For example... Figure 4 As shown, the method includes:

[0083] S401. Obtain the source code file of the target file system.

[0084] S402. Add the source code from the source code file to the source file of the target operating system.

[0085] In this embodiment, the source code file of the target file system can be obtained from the official website platform of the target file system, a third-party website platform that provides the target file system download service, or the source code file of the target file system input by the user, such as the source code file of the target file system copied by the user through a storage device such as a USB flash drive.

[0086] The source files of the target operating system can be obtained from the official website platform of the target operating system, third-party website platforms that provide target operating system download services, or the source files of the target operating system can be received from the user, such as the source files of the target operating system copied by the user through a storage device such as a USB flash drive.

[0087] Add the source code from the source code file of the target file system to the source file of the target operating system.

[0088] S403, Display configuration interface, which includes configuration components.

[0089] S404: Receive device parameters of the target memory input by the user for the configuration component.

[0090] It should be noted that S402 is executed after S401, and S404 is executed after S403, while the execution order of S401 and S403 is not limited here. S401 can be executed first and then S403; or S403 can be executed first and then S401; in addition, S401 and S403 can also be executed in parallel.

[0091] S405. Based on the device parameters of the target memory, the source file of the target operating system is compiled to obtain an executable file. The source file of the target operating system includes the source code of the target file system. The executable file is executed by the first electronic device to instruct the first electronic device to determine the device parameters to be called by the driver of the target file system based on the device parameters of the target memory during the initialization process of the target operating system. The first electronic device is equipped with the target memory.

[0092] In this embodiment, the source code file of the target file system is obtained and added to the source file of the target operating system. Before compilation, the target operating system includes the source code of the target file system. Combined with the device information of the memory configured by the user through the configuration component, an executable file is compiled. When the executable file is executed by the first electronic device, during the initialization process of the target operating system, the first electronic device is instructed to automatically determine the device parameters to be called by the driver of the target file system. The user does not need to modify the driver of the target file system, thereby improving the porting efficiency of the file system.

[0093] Optionally, after S405, the above method may further include:

[0094] The executable file is imported into the first electronic device so that the first electronic device can execute the executable file after power-on.

[0095] In this embodiment, the user can connect the second electronic device to the first electronic device via a transmission line and burn the executable file of the target operating system into the program memory of the first electronic device, thereby importing the executable file. The first electronic device executes the executable file after power-on to initialize the target operating system.

[0096] Figure 5 This is a flowchart illustrating a file system porting method provided in another embodiment of this application. The execution entity in this embodiment can be an electronic device, specifically... Figure 1 The first electronic device in the system. The first electronic device is equipped with a target memory. For example... Figure 5 As shown, the method includes:

[0097] S501. Execute the executable file of the target operating system to initialize the target operating system. The executable file is compiled from the source files of the target operating system. The source files of the target operating system include the source code of the target file system. The executable file includes the device parameters of the target memory.

[0098] In this embodiment, the process of generating the executable file can be referred to the above. Figure 2 and Figure 4 The illustrated embodiment will not be described in detail here. The user can connect the second electronic device to the first electronic device via a data cable and burn the executable file of the target operating system into the program memory of the first electronic device, thereby importing the executable file. After the first electronic device is powered on, it executes the executable file of the target operating system to initialize the target operating system.

[0099] S502. During the initialization of the target operating system, the device parameters to be called by the driver of the target file system are determined based on the device parameters of the target memory.

[0100] In this embodiment, the executable file of the target operating system includes device parameters of the target memory configured by the user through a configuration component. During the initialization process of the target operating system by the first electronic device, the first electronic device can determine the device parameters of the target memory as device parameters that can be invoked by the driver of the target file system. This allows the driver of the target file system to invoke the device parameters of the target memory to access and manage the data in the target memory during file system operation.

[0101] The file system porting method, apparatus, device, and storage medium provided in this application initialize the target operating system by executing an executable file of the target operating system. The executable file is compiled from the source files of the target operating system; the source files of the target operating system include the source code of the target file system; the executable file includes device parameters of the target memory. During the initialization of the target operating system, device parameters for use by the driver of the target file system are determined based on the device parameters of the target memory. This enables the executable file, when executed by a first electronic device, to instruct the first electronic device to automatically determine the device parameters for use by the driver of the target file system during the initialization process of the target operating system, without requiring user modification of the driver of the target file system, thereby improving the porting efficiency of the file system.

[0102] Optionally, S502 may include:

[0103] Write the device parameters of the target memory into the specified data structure; the device parameters in the specified data structure are used by the driver of the target file system.

[0104] In this embodiment, the specified data structure may include multiple variables, each of which stores a corresponding device parameter. For example, the specified data structure may be as follows:

[0105] struct nand_config {

[0106] unsigned charnand_cs;

[0107] unsigned int blocks_per_chip;

[0108] unsigned int pages_per_block;

[0109] unsigned int page_main_size;

[0110] unsigned int page_spare_size;

[0111] };

[0112] Here, `nand_config` is the name of this data structure. The `nand_cs` variable is used to represent memory chip select information, `blocks_per_chip` is used to represent the number of memory blocks, `pages_per_block` is used to represent the number of memory pages, `page_main_size` is used to represent the capacity of the memory main area, and `page_spare_size` is used to represent the capacity of the memory spare area.

[0113] The specified data structure is a global data structure. During the initialization of the target operating system, the first electronic device fills the target memory's device information into the corresponding variables in the specified data structure. When the target operating system is running, the file system driver reads this specified data structure to obtain the target memory's device information when it needs to access it.

[0114] Figure 6 This is a flowchart illustrating a file system porting method provided in another embodiment of this application. Figure 5 Based on the illustrated embodiment, the device parameters include a start block number and an end block number. In this embodiment, the storage partition of the target memory is determined by the user-configured start and end block numbers. Figure 6 As shown, the method includes:

[0115] S601. Execute the executable file of the target operating system to initialize the target operating system. The executable file is compiled from the source files of the target operating system. The source files of the target operating system include the source code of the target file system. The executable file includes the device parameters of the target memory.

[0116] S602. During the initialization of the target operating system, the device parameters to be called by the driver of the target file system are determined based on the device parameters of the target memory.

[0117] S603. During the initialization of the target operating system, determine whether the start block number and end block number meet the preset conditions.

[0118] S604. When the start block number and end block number meet the preset conditions, determine the storage partition of the target memory based on the start block number and end block number.

[0119] In this embodiment, during the initialization of the target operating system, the first electronic device can initialize the target file system, create the device node corresponding to the target storage, add the device node to the device list of the target file system, and mount the target file system.

[0120] Before creating the device node corresponding to the target memory, the first electronic device can first determine whether the start block number and end block number configured by the user meet preset conditions. Preset conditions are used to detect whether the start block number and end block number conform to the specifications. The preset conditions are not limited here; for example, preset conditions may include, but are not limited to, at least one of the following: the start block number and end block number do not exceed the number of blocks in the target memory; the start block number is less than the end block number.

[0121] When the start block number and end block number meet preset conditions, the first electronic device determines the storage partition of the target memory based on the start block number and end block number, that is, it determines the storage blocks of the target memory that the target file system can manage. When the start block number and end block number do not meet the preset conditions, the first electronic device may default to determining all block areas of the target memory as the storage partition of the target memory, or the first electronic device may display a prompt message to inform the user that the start block number and end block number do not meet the preset conditions and to re-enter the start block number and end block number.

[0122] It should be noted that S604 is executed after S603, while the execution order of S602 and S603 is not limited. S602 can be executed first, followed by S603; or S603 can be executed first, followed by S602; in addition, S602 and S603 can also be executed in parallel.

[0123] In this embodiment, by including a start block number and an end block number in the device information, the user can configure the storage partition of the target storage, improving the flexibility of the file system in managing the target storage. By determining the storage partition of the target storage based on the start block number and end block number when they meet preset conditions, and by using preset conditions to detect the start block number and end block number configured by the user, it is possible to avoid situations such as incorrect start block number or end block number configuration by the user, avoid errors in device node creation, or the file system being unable to manage the target storage, thereby improving the accuracy of file system migration.

[0124] Optionally, in any of the above embodiments, the target operating system may be the VxWorks operating system, the target memory may include NAND flash memory, and the target file system may include, but is not limited to, at least one of the following: YAFFS2 file system and YAFFS file system.

[0125] The following is a specific implementation example. In this example, the target operating system is VxWorks, the target file system is YAFFS2, and the target memory is NAND flash memory. The specific process of porting the YAFFS2 file system to the VxWorks operating system according to the file system porting method provided in this embodiment of the invention can be as follows:

[0126] Step 1: The second electronic device downloads the YAFFS2 file system source code from the official YAFFS2 file system website and adds the YAFFS2 file system source code to the VxWorks operating system's source files. Furthermore, it modifies the YAFFS2 file system initialization function interface in the source files.

[0127] int yaffs_start_up(

[0128] unsigned int start_block, / / starting block number;

[0129] unsigned int end_block / / End block number

[0130] ).

[0131] And modify the Nand flash device information initialization function interface in the source file:

[0132] void nand_info_set(

[0133] unsigned charnand_cs, / / Chip select information

[0134] unsigned int blocks_per_chip, / / Number of blocks

[0135] unsigned int pages_per_block, / / Number of pages

[0136] unsigned int page_main_size, / / Capacity of main memory area

[0137] unsigned int page_spare_size / / Capacity of spare storage space

[0138] ).

[0139] Step 2: The second electronic device runs an integrated development environment (IDE) that provides a configuration interface. This interface includes a configuration component for inputting device information for the NAND flash memory. The device information for the target memory, input by the user, is received and saved. Upon receiving the user's compilation instructions, the source files of the VxWorks operating system are compiled to obtain an executable file containing the user-configured device information for the target memory.

[0140] Executable files may include the following initialization code:

[0141] The `nand_info_set()` function initializes device information, and its input parameters are the chip select information, number of blocks, number of pages, capacity of primary storage space, and capacity of spare storage space of the target memory configured by the user. The `yaffs_start_up()` function initializes the YAFFS2 file system, and its input parameters are the start and end block numbers of the target memory configured by the user.

[0142] Step 3: After receiving the user's input burning command, the second electronic device calls the burning program to burn the executable file of the VxWorks operating system into the program memory of the first electronic device.

[0143] Step 4: After the first electronic device is powered on and started, the xWorks operating system is initialized. The initialization process includes, but is not limited to, executing nand_info_set() and yaffs_start_up().

[0144] The specific initialization steps are as follows: Figure 7 As shown, during the initialization of the xWorks operating system, `nand_init()` is called, and then `nand_info_set()` and `yaffs_start_up()` are called within `nand_init()`. When `yaffs_start_up()` is called, it first checks whether the start block number and end block number meet the preset conditions. If they do, it further calls the device node creation function interface `yls2xnand_Create()`; otherwise, it terminates `yaffs_start_up()`.

[0145] The `nand_info_set()` function is used to fill the chip select information, block count, page count, main memory capacity, and spare memory capacity of the NAND flash memory onto a global data structure. The YAFFS2 file system driver will then read device information from this data structure when using the NAND flash memory. The specific form of the data structure is not limited here; for example, it can be specified as described above.

[0146] The yaffs_start_up() function is used to initialize the YAFFS2 file system, create the device node corresponding to the NAND flash memory, add the device node to the device list, and mount the YAFFS2 file system.

[0147] The yls2xnand_Create() function is specifically used to create the device node corresponding to the NAND flash memory. Before creation, it checks whether the start block number and end block number of the NAND flash memory meet the preset conditions.

[0148] Step 5: After the first electronic device is initialized, when the user inputs the device information viewing command `devs` in the shell command line, the user can see the device node of the target storage managed by the YAFFS2 file system, and then the user can manage the target storage in this directory.

[0149] This implementation example demonstrates that during file system porting, if the file system needs to be adapted to other types of NAND flash memory, users only need to change the configuration component parameters in the VxWorks operating system's development environment. This allows the file system to flexibly adapt to various types of NAND flash memory. The VxWorks operating system provides a flexible configuration window and components, which, combined with the driver interface in the ported file system, enables excellent versatility and maintainability of the file system. Furthermore, by using the user-configured start and end block numbers, before creating the device node corresponding to the NAND flash memory, the system checks whether the start and end block numbers meet preset conditions to ensure their validity. It also sets the usable storage partition size for the NAND flash memory based on the configured start and end block numbers, allowing a single NAND flash memory to be used in multiple environments without conflict.

[0150] Figure 8 This is a schematic diagram of the structure of a file system porting device provided in an embodiment of this application. Figure 8 As shown, the file system porting device 80 includes: a display module 801, a receiving module 802, and a compilation module 803.

[0151] Display module 801 is used to display the configuration interface, which includes configuration components.

[0152] The receiving module 802 is used to receive device parameters of the target memory input by the user for the configuration component.

[0153] The compilation module 803 is used to compile the source files of the target operating system according to the device parameters of the target memory to obtain an executable file. The source files of the target operating system include the source code of the target file system. The executable file is used to be executed by the first electronic device to instruct the first electronic device to determine the device parameters to be called by the driver of the target file system according to the device parameters of the target memory during the initialization process of the target operating system. The first electronic device is equipped with the target memory.

[0154] Optionally, the configuration components correspond one-to-one with the device parameters, and the configuration interface includes the identifier and / or icon of the device parameter corresponding to the configuration component.

[0155] Optionally, the device parameters include at least one of the following:

[0156] Start block number, end block number, chip select information, number of blocks, number of pages, capacity of primary storage space, capacity of spare storage space.

[0157] Optionally, the executable file is used to be executed by the first electronic device to instruct the first electronic device to write device parameters of the target memory into a specified data structure during the initialization process of the target operating system, wherein the device parameters in the specified data structure are used to be called by the driver of the target file system.

[0158] Optionally, the receiving module 802 is also used to: obtain the source code file of the target file system.

[0159] The compiler module 803 is also used to add source code from source code files to source files in the target operating system.

[0160] The compiler module 803 is also used to import the executable file into the first electronic device after obtaining the executable file, so that the first electronic device can execute the executable file after power-on.

[0161] Optionally, the target operating system is the VxWorks operating system, the target memory includes NAND flash memory, and the target file system includes at least one of the following: YAFFS2 file system or YAFFS file system.

[0162] The file system porting apparatus provided in this application embodiment can be used to execute the above-described method embodiment with the second electronic device as the execution subject. Its implementation principle and technical effect are similar, and will not be described again here.

[0163] Figure 9 This is a schematic diagram of a file system porting apparatus provided in another embodiment of this application. The file system porting apparatus 90 is applied to an electronic device, which is a first electronic device equipped with a target memory. Figure 9 As shown, the file system porting device 90 includes: an initialization module 901.

[0164] Initialization module 901 is used to execute the executable file of the target operating system to initialize the target operating system. The executable file is compiled from the source file of the target operating system. The source file of the target operating system includes the source code of the target file system. The executable file includes the device parameters of the target memory.

[0165] Initialization module 901 is used to determine the device parameters to be called by the driver of the target file system based on the device parameters of the target memory during the initialization process of the target operating system.

[0166] Optionally, the device parameters include at least one of the following:

[0167] Start block number, end block number, chip select information, number of blocks, number of pages, capacity of primary storage space, capacity of spare storage space.

[0168] Optionally, the initialization module 901 is also used for:

[0169] During the initialization of the target operating system, it is determined whether the start block number and end block number meet the preset conditions.

[0170] When the start block number and end block number meet the preset conditions, the storage partition of the target memory is determined based on the start block number and end block number.

[0171] Optionally, the initialization module 901 is used for:

[0172] Write the device parameters of the target memory into the specified data structure; the device parameters in the specified data structure are used by the driver of the target file system.

[0173] Optionally, the target operating system is VxWorks, the target memory is NAND flash memory, and the target file system includes at least one of the following: YAFFS2 file system or YAFFS file system.

[0174] The file system porting apparatus provided in this application embodiment can be used to execute the above-described method embodiment with the first electronic device as the execution subject. Its implementation principle and technical effect are similar, and will not be described again here.

[0175] Figure 10 This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of this application. Figure 10 As shown, the electronic device 100 provided in this embodiment includes at least one processor 1001 and a memory 1002. The electronic device 100 also includes a communication component 1003. The processor 1001, the memory 1002, and the communication component 1003 are connected via a bus 1004.

[0176] In a specific implementation, at least one processor 1001 executes the computer execution instructions stored in the memory 1002, causing at least one processor 1001 to perform the above-mentioned actions. Figure 2 The corresponding embodiment describes the file system porting method.

[0177] The specific implementation process of processor 1001 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.

[0178] Figure 11 This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of this application. Figure 11 As shown, the electronic device 110 provided in this embodiment includes at least one processor 1101 and a memory 1102. The electronic device 110 also includes a communication component 1103. The processor 1101, the memory 1102, and the communication component 1103 are connected via a bus 1104.

[0179] In the specific implementation process, at least one processor 1101 executes the computer execution instructions stored in the memory 1102, causing at least one processor 1101 to execute the file system porting method described above, which uses the second electronic device as the execution subject.

[0180] The specific implementation process of processor 1101 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.

[0181] In the above Figure 10 and Figure 11In the illustrated embodiments, it should be understood that the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in the application can be directly manifested as being executed by a hardware processor, or executed by a combination of hardware and software modules within the processor.

[0182] The memory may include high-speed RAM, and may also include non-volatile storage (NVM), such as at least one disk storage.

[0183] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.

[0184] This application also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the file system porting method described above, with a second electronic device as the execution subject.

[0185] This application also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the file system porting method of the above embodiment with a first electronic device as the execution subject.

[0186] The aforementioned readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The readable storage medium can be any available medium accessible to a general-purpose or special-purpose computer.

[0187] An exemplary readable storage medium is coupled to a processor, enabling the processor to read information from and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can reside in an Application Specific Integrated Circuit (ASIC). Alternatively, the processor and the readable storage medium can exist as discrete components in the device.

[0188] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.

Claims

1. A method for porting a file system, characterized in that, include: A configuration interface is displayed in a second electronic device, the configuration interface including at least one configuration component; The system receives device physical parameters of the target memory input by the user for the configuration component; the device physical parameters include at least one of the following: start block number, end block number, chip select information, number of blocks, number of pages, capacity of primary storage space, and capacity of spare storage space; the configuration component corresponds one-to-one with the device physical parameters; Obtain the source code file of the target file system, and add the source code in the source code file to the source file of the target operating system; the target file system is a file system that is not supported by default by the target operating system. Based on the device physical parameters of the target memory, the source files of the target operating system are compiled to obtain an executable file; The executable file is imported into a first electronic device; wherein the executable file is executed by the first electronic device after power-on, so as to instruct the first electronic device to determine the storage partition of the target memory according to the start block number and the end block number when the start block number and the end block number meet the preset conditions during the initialization process of the target operating system, and instruct the first electronic device to write the device physical parameters of the target memory into a specified data structure; the device physical parameters in the specified data structure are used to be called by the driver of the target file system, and the first electronic device is equipped with the target memory.

2. The method according to claim 1, characterized in that, The target operating system is the VxWorks operating system, the target memory includes NAND flash memory, and the target file system includes at least one of the following: YAFFS2 file system and YAFFS file system.

3. A method for porting a file system, characterized in that, Applied to an electronic device, wherein the electronic device is a first electronic device equipped with a target memory, the method includes: An executable file of the target operating system is executed to initialize the target operating system, wherein the executable file is compiled from the source files of the target operating system; the source files of the target operating system have the source code of the target file system added to them; the executable file includes the device physical parameters of the target memory; the device physical parameters include at least one of the following: start block number, end block number, chip select information, number of blocks, number of pages, capacity of primary storage space, and capacity of spare storage space; the target file system is a file system not supported by default by the operating system; wherein the second electronic device displays a configuration interface including at least one configuration component, the configuration component being used to receive the device physical parameters input by the user; During the initialization of the target operating system, it is determined whether the start block number and the end block number meet preset conditions; When the start block number and the end block number meet the preset conditions, the storage partition of the target memory is determined according to the start block number and the end block number, and the device physical parameters of the target memory are written into a specified data structure; the device physical parameters in the specified data structure are used to be called by the driver of the target file system.

4. A file system porting device, characterized in that, include: A display module is used to display a configuration interface in a second electronic device, the configuration interface including at least one configuration component; The receiving module is used to receive the target memory's physical parameters input by the user for the configuration component; the physical parameters include at least one of the following: start block number, end block number, chip select information, number of blocks, number of pages, capacity of primary storage space, and capacity of spare storage space; the configuration component corresponds one-to-one with the physical parameters of the device; The compilation module is used to obtain the source code file of the target file system and add the source code in the source code file to the source file of the target operating system; the target file system is a file system that is not supported by default by the target operating system. Based on the device physical parameters of the target memory, the source files of the target operating system are compiled to obtain an executable file; The executable file is imported into a first electronic device; wherein the executable file is executed by the first electronic device after power-on, so as to instruct the first electronic device to determine the storage partition of the target memory according to the start block number and the end block number when the start block number and the end block number meet the preset conditions during the initialization process of the target operating system, and instruct the first electronic device to write the device physical parameters of the target memory into a specified data structure; the device physical parameters in the specified data structure are used to be called by the driver of the target file system, and the first electronic device is equipped with the target memory.

5. A file system porting device, characterized in that, Applied to an electronic device, wherein the electronic device is a first electronic device equipped with a target memory, the device includes: An initialization module is used to execute an executable file of the target operating system to initialize the target operating system. The executable file is compiled from the source files of the target operating system; the source files of the target operating system have the source code of the target file system added to them; the executable file includes the device physical parameters of the target memory; the device physical parameters include at least one of the following: start block number, end block number, chip select information, number of blocks, number of pages, capacity of primary storage space, and capacity of spare storage space; the target file system is a file system not supported by default by the operating system; wherein, the second electronic device displays a configuration interface including at least one configuration component, the configuration component being used to receive the device physical parameters input by the user; The initialization module is specifically used to determine whether the start block number and the end block number meet preset conditions during the initialization process of the target operating system; when the start block number and the end block number meet the preset conditions, to determine the storage partition of the target memory based on the start block number and the end block number, and to write the device physical parameters of the target memory into a specified data structure; the device physical parameters in the specified data structure are used to be called by the driver of the target file system.

6. An electronic device, characterized in that, include: At least one processor and memory; The memory stores computer-executed instructions; The at least one processor executes the computer execution instructions stored in the memory, causing the at least one processor to perform the file system porting method as described in any one of claims 1-2.

7. An electronic device, characterized in that, include: At least one processor and memory; The memory stores computer-executed instructions; The at least one processor executes the computer execution instructions stored in the memory, causing the at least one processor to perform the file system porting method as described in claim 3.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by the processor, implement the file system porting method as described in any one of claims 1-2.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by the processor, implement the file system porting method as described in claim 3.

Citation Information

Patent Citations

  • Engineering file processing method and device, computer equipment and storage medium

    CN111552503A