CN113327639B - Firmware storage reading method and device based on LVGL - Google Patents
Firmware storage reading method and device based on LVGL Download PDFInfo
- Publication number
- CN113327639B CN113327639B CN202110580642.3A CN202110580642A CN113327639B CN 113327639 B CN113327639 B CN 113327639B CN 202110580642 A CN202110580642 A CN 202110580642A CN 113327639 B CN113327639 B CN 113327639B
- Authority
- CN
- China
- Prior art keywords
- file
- header
- directory
- address
- partition
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 21
- 238000005192 partition Methods 0.000 claims abstract description 102
- 238000012545 processing Methods 0.000 claims description 4
- 230000003068 static effect Effects 0.000 claims description 3
- 238000010586 diagram Methods 0.000 description 3
- 230000002093 peripheral effect Effects 0.000 description 3
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000013461 design Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G11—INFORMATION STORAGE
- G11C—STATIC STORES
- G11C16/00—Erasable programmable read-only memories
- G11C16/02—Erasable programmable read-only memories electrically programmable
- G11C16/06—Auxiliary circuits, e.g. for writing into memory
- G11C16/26—Sensing or reading circuits; Data output circuits
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0602—Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
- G06F3/062—Securing storage systems
- G06F3/0622—Securing storage systems in relation to access
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Abstract
The application discloses a firmware storage and reading method based on LVGL. The image file of the code is stored in the firmware in a first partition, the resource file is stored in a second partition, and the second partition adopts a read-only file system. And setting a first buffer area and a second buffer area for the read-only file system. When the firmware of the electronic equipment wants to read a certain resource file, a path in the form of a character string of the target file and a file name are sent out, the read-only file system traverses the file header in a second partition to be matched with all levels of catalogues in the path of the target file and the file name of the target file, and the absolute logic address of the file header of the target file is obtained. And finding the starting address of the absolute logical address of the file content according to the absolute logical address of the file header of the target file, and reading out the binary data of the target file. The application supports the independent upgrading of the resource files in the firmware of the electronic equipment.
Description
Technical Field
The present application relates to a method for storing and reading firmware of an electronic device using an embedded system (embedded system).
Background
LVGL (Light and Versatile Graphics Library, lightweight universal graphic library) is a new GUI (graphical user interface, graphic user interface) system framework, and has advantages of small code amount and easy UI (user interface) development. An electronic device employing an embedded system may employ LVGL as a GUI system framework.
The LVGL system framework may use some resource files on the user interface, such as image files, audio files, animation files, font files, etc. The existing LVGL system framework stores resource files in a source file mode and compiles the resource files into firmware codes. The electronic device can only upgrade the whole firmware, but can only upgrade the resource file therein, and does not support the individual upgrade of the resource file. Therefore, the whole firmware needs to be updated in the requirements of changing the animation of the switch, changing the bell sound, changing the background picture, and the like.
Disclosure of Invention
The application aims to solve the technical problem of providing a firmware storage and reading method based on an LVGL system framework, which can conveniently upgrade the resource files in the firmware storage and reading method without upgrading the whole firmware.
In order to solve the technical problems, the application provides a firmware storage and reading method based on LVGL, which comprises the following steps. Step S1: in firmware of an electronic device adopting LVGL as a GUI system frame, storing an image file of a code in a first partition, and storing a resource file in a second partition, wherein the second partition adopts a read-only file system; in the read-only file system, each directory or resource file has a header. The first partition and the second partition are arranged on a NOR gate flash memory of the same QSPI interface; or the first partition is on the NOR flash memory of the QSPI interface, and the second partition is on the NOR flash memory of the SPI interface. Setting a first buffer area and a second buffer area for the read-only file system; the first buffer area is used for storing the file header of the recently read directory or resource file and the name of the recently read directory or resource file; the second buffer area is used for storing the absolute logic address of the file header stored in the first buffer area in the read-only file system, and the memory address and the length of the first buffer area. Step S2: when the firmware of the electronic equipment wants to read a certain resource file, a path in the form of a character string of the target file and a file name are sent out, the read-only file system traverses the file header in a second partition to be matched with all levels of catalogues in the path of the target file and the file name of the target file, and the absolute logic address of the file header of the target file is obtained. Step S3: and finding the starting address of the absolute logical address of the file content of the target file according to the absolute logical address of the file header of the target file. Step S4: the read-only file system reads out binary data of the target file according to the starting address of the absolute logic address of the file content of the target file.
Further, the resource file includes one or more of an image file, an audio file, an animation file, and a font file.
Further, in the step S1, address segments which are not overlapped with each other are allocated to each physical hardware, address segments which are not overlapped with each other are allocated to each partition, and address segment information of each physical hardware, address segment information of each partition and size are recorded in a partition table; when the read-only file system is initialized, the partition table is queried to know which physical hardware the second partition is on, and the starting address of the second partition is acquired.
Further, in the read-only file system, each directory is sequentially stored in the sequence of directory names in the form of a file header and a character string; each resource file is sequentially stored in the sequence of file names in the form of file heads and character strings and file contents in the form of binary data; all the file headers are fixed in length, and the storage space storing the names of each directory or file is fixed in length.
Further, the read-only file system is only used for storing resource files in firmware of the electronic device; in the read-only file system, the catalogue or the resource file is stored sequentially; the file headers are also sequentially stored, and the order of the file headers is consistent with the order of the corresponding directory or resource files.
Further, in the read-only file system, the format of the header of each directory or resource file is consistent, wherein the offset address of the header of the next (according to the sequence) directory or file in the read-only file system is recorded; the type of the file header and whether the attribute is executable; if the directory type is the directory type, recording the logical address of the subdirectory or the subdirectory of the directory; if the file type is the file type, recording the size of the file; a checksum of the file header and the file name; the first byte of a directory or file name in the form of a string.
Further, in the step S2, traversing the file header specifically includes the following steps; traversing from the first directory or the file header of the file in the second partition, and searching the file header of the directory type matched with each level of directory in the path of the target file; after finding the file header of the matched directory type, searching the file header of the directory type matched with the next-level directory in the path of the target file through the first sub-directory or the logic address of the first file recorded in the file header of the directory type until finding the file header of the file type matched with the name of the target file; returning the absolute logical address of the header of this file type; when the directory and the file name of each level in the path of the target file are matched, the following processing mode is adopted. (1) And judging which physical hardware is positioned according to the absolute logical address of the file header of each level of directory or file name in the path of the target file. (2) If the file header of a certain level directory or file name in the path of the target file is positioned in the NOR gate flash memory of the QSPI interface, the absolute logic address of the file header is directly returned to the upper layer interface. (3) If the file header of a certain level of directory or file name in the path of the target file is positioned in the NOR gate flash memory of the SPI interface, the second buffer area is accessed first, and whether the absolute logic address stored in the second buffer area is the same as the absolute logic address of the file header of the level of directory or file name in the path of the target file is judged. And (3-1) if the memory addresses and the lengths of the first cache region are the same, the memory addresses of the first cache region are returned to the upper layer interface. (3-2) if not, subtracting the start address of the second partition from the absolute logical address of the file header of the level directory or file name in the path of the target file to obtain the relative logical address of the file header of the level directory or file name in the path of the target file; and then reading out the file header of the level directory or the file name in the path of the target file in the second partition according to the relative logical address, storing the file header and the file name in the first cache area, updating the absolute logical address recorded in the second cache area, and then returning the memory address of the first cache area to the upper interface.
Further, in the step S2, when updating the absolute logical address recorded in the second buffer, if the first buffer adopts a dynamic memory allocation manner, the memory address of the first buffer recorded in the second buffer is updated; if the first buffer area adopts a static memory allocation mode, the memory address of the first buffer area recorded in the second buffer area is not updated.
Further, in the step S3, the absolute logical address of the header of the target file is added with the fixed length of the header, and added with the length of the file name of the target file, and the address starting with the first byte aligned by 16 bytes after the end character of the file name is used as the start address of the absolute logical address of the file content of the target file.
Further, in the step S4, if the target file is located in the nor gate flash memory of the QSPI interface, the binary data of the target file is directly read out by using the start address of the absolute logical address of the file content of the target file; and if the target file is positioned in the NOR gate flash memory of the SPI interface, reading out binary data of the target file through the SPI interface.
The application also provides a firmware storage and reading device based on the LVGL, which comprises a firmware storage unit, a file header addressing unit, a file addressing unit and a firmware reading unit. The firmware storage unit is used for storing an image file of a code in a first partition and a resource file in a second partition in firmware of the electronic equipment adopting the LVGL as a GUI system frame, and the second partition adopts a read-only file system; in the read-only file system, each directory or resource file has a file header; the first partition and the second partition are arranged on a NOR gate flash memory of the same QSPI interface; or the first partition is arranged on the NOR gate flash memory of the QSPI interface, and the second partition is arranged on the NOR gate flash memory of the SPI interface; setting a first buffer area and a second buffer area for the read-only file system; the first buffer area is used for storing the file header of the recently read directory or resource file and the name of the recently read directory or resource file; the second buffer area is used for storing the absolute logic address of the file header stored in the first buffer area in the read-only file system, and the memory address and the length of the first buffer area. The file header addressing unit is used for sending out a path in the form of a character string of the target file and a file name when the firmware of the electronic equipment wants to read a certain resource file, traversing the file header in the second partition to be matched with all levels of catalogues in the path of the target file and the file name of the target file, and obtaining the absolute logic address of the file header of the target file. The file addressing unit is used for finding the starting address of the absolute logical address of the file content of the target file according to the absolute logical address of the file header of the target file. The firmware reading unit is used for reading binary data of the target file according to the starting address of the absolute logical address of the file content of the target file.
The application has the technical effects of supporting the independent upgrade of the resource files in the firmware of the electronic equipment, and is particularly suitable for the electronic equipment adopting the LVGL system framework.
Drawings
Fig. 1 is a flow chart of a firmware storing and reading method based on an LVGL system framework according to the present application.
FIG. 2 is a schematic diagram of a first partition and a second partition on the same physical hardware.
FIG. 3 is a schematic diagram of a first partition and a second partition on different physical hardware.
Fig. 4 is a schematic structural diagram of a firmware storage and reading device based on an LVGL system framework according to the present application.
The reference numerals in the drawings illustrate: a firmware storage unit 1, a file header addressing unit 2, a file addressing unit 3 and a firmware reading unit 4.
Detailed Description
Referring to fig. 1, the method for storing and reading firmware based on the LVGL system framework according to the present application includes the following steps.
Step S1: in firmware of an electronic device employing an LVGL as a GUI system framework, an image file of a code for execution is stored in a first partition readable and writable, a resource file is stored in a second partition, and the second partition employs a read-only file system. The resource files comprise image files, audio files, animation files, font files and the like, and are mainly used for a user interface of the electronic equipment.
In this step, the image file and the resource file of the code are stored in different partitions, and the second partition in which the resource file is located adopts a read-only file system. The content in the read-only file system can be replaced integrally, so that the resource files of the electronic equipment can be upgraded independently.
The first partition and the second partition are either on the same physical hardware or on different physical hardware. Each physical hardware is allocated with address segments which are not overlapped with each other, each partition is also allocated with address segments which are not overlapped with each other, and address segment information of each physical hardware, address segment information of each partition and size are recorded in a partition table. When the read-only file system is initialized, the partition table is queried to know which physical hardware the second partition is on, and the starting address of the second partition is acquired.
Referring to fig. 2, the second partition and the first partition are the same physical hardware, such as NOR Flash (NOR Flash) with a QSPI (QUAD Serial Peripheral Interface, 4-wire serial peripheral interface) interface. The processor of the electronic device (e.g., ARM chip; where ARM stands for Advanced RISC Machine, advanced reduced instruction set machine) accesses the first partition and the second partition through a QSPI interface. An address field, for example, the head of 0x80000000, is allocated to the nor gate flash memory of the QSPI interface, wherein 0x represents a hexadecimal number. At this time, the address field of the first partition is, for example, 0x80000000 to 0x88FFFFFF, and the address field of the second partition is, for example, 0x89000000 to 0x8FFFFFFF, and the two do not overlap. Each address segment is both a physical address and a logical address.
Referring to fig. 3, the second partition and the first partition are different physical hardware. The first partition is for example on a nor gate flash of a QSPI interface and the second partition is for example on a nor gate flash of an SPI (Serial Peripheral Interface ) interface. A processor of the electronic device (e.g., ARM chip) accesses the first partition through a QSPI interface and accesses the second partition through an SPI interface. The nor gate flash of the QSPI interface is assigned a first address segment, for example, the 0x80000000 start. A second address segment, for example, 0x90000000 beginning, is assigned to the nor gate flash memory of the SPI interface. Obviously, the first address segment and the second address segment do not coincide. At this time, the address field of the first partition is, for example, 0x80000000 to 0x8FFFFFFF, and the address field of the second partition is, for example, 0x90000000 to 0x9FFFFFFF, and the two do not overlap. Each address segment is both a physical address and a logical address.
The nor gate flash of the QSPI interface has the feature of executing on-chip (XIP), which means that the processor reads the program code execution directly from the nor gate flash of the QSPI interface, without reading into memory. The method has the advantages that the program code does not occupy the memory, and the memory requirement is reduced.
The read-only file system is used only to save resource files in the firmware of the electronic device. In the read-only file system, the catalogue or the resource file is stored sequentially. Each directory or resource file has a file header. Each directory is stored in sequence of a file header and a directory name (in the form of a character string). Each resource file is stored in the order of file header, file name (in the form of character string), file content (binary data). The format of the file header of each directory or resource file is consistent, wherein the offset address of the file header of the next directory or file in the read-only file system is recorded; the type of header (directory or file) and whether or not it is executable; if the directory type is the directory type, recording the logical address of the subdirectory or the subdirectory of the directory; if the file type is the file type, recording the size of the file; a checksum of the file header and the file name; the first byte of a directory or file name in the form of a string. Each header is fixed in length, followed by a directory or file name in the form of a string. Each directory or file name has a special character as an end character that is used to calculate the length of the directory or file name. In the case of a file header of a file type, the first byte aligned by 16 bytes after the end character of the file name starts with the file content (binary data). The start address of the absolute logical address of the file content is the absolute logical address of the file header plus the fixed length of the file header plus the length of the file name, the start address of the first byte aligned by 16 bytes after the end character of the file name. In the read-only file system, the file heads are also sequentially stored, and the sequence of the file heads is consistent with the sequence of the corresponding directory or resource files.
And setting a first buffer area and a second buffer area for the read-only file system. The first buffer area is used for storing the file header of the most recently read directory or resource file and the name of the most recently read directory or resource file. The second buffer area is used for storing the absolute logic address of the file header stored in the first buffer area in the read-only file system, and the memory address and the length of the first buffer area.
Step S2: when the firmware of the electronic equipment wants to read a certain resource file, the resource file which is needed to be read is called a target file, and the firmware of the electronic equipment sends a path in the form of a character string of the target file and a file name to the read-only file system. The read-only file system traverses from the first file header in the second partition, and obtains the absolute logical address of the file header of the target file by traversing the file header to match all levels of directories in the path to the target file and the file name of the target file until the file header of the target file is found.
The traversing file header specifically comprises the following processes. The target file is looked up by traversing from the first directory or file header. If the path plus file name of the target file is multi-level, such as a level 1 directory plus a level 1 file name, e.g., "R:/png/background. Png", where R represents the second partition. It is necessary to find the file header of the matching directory type starting from the parent directory (directory name png). After the file header matching the parent directory is found, that is, the directory name recorded in the file header of the directory type is consistent with the parent directory name, the next file header is searched by the first sub-directory or the logical address of the first file recorded in the file header of the parent directory. It is determined whether the next header is of a file type that matches the file name of the target file. If the file headers are not matched, the next file header is continuously searched through the adjacent catalogues of the same level or the logic addresses of the file headers of the adjacent files recorded in the current file header. The search is not ended until the type of the accessed file header is a file type and the file name matches the file name of the target file. The absolute logical address of the header of this file type is then returned. When the directory and the file name of each level in the path of the target file are matched, the following processing mode is adopted.
(1) It is determined which physical hardware it is located in based on the absolute logical address (not the relative logical address) of the file header of each level directory or file name in the path of the target file.
(2) If the file header of a certain level directory or file name in the path of the target file is positioned in the NOR gate flash memory of the QSPI interface, the absolute logic address of the file header is directly returned to the upper layer interface. The absolute logical address is now the physical address.
(3) If the file head of a certain level directory or file name in the path of the target file is positioned in the NOR gate flash memory of the SPI interface, the second buffer area is accessed first, and whether the absolute logic address of the file head stored in the first buffer area and the absolute logic address of the file head of the level directory or file name in the path of the target file are the same or not is judged. And (3-1) if the file addresses and the lengths of the first cache areas are the same, the file header of the level directory or the file name in the path of the target file is the file header stored in the first cache area, and the memory addresses of the first cache area are returned to the upper interface. (3-2) if the file headers of the level directory or file name in the path of the target file are not the file headers stored in the first buffer, subtracting the start address of the second partition from the absolute logical address of the file header of the level directory or file name in the path of the target file to obtain the relative logical address of the file header of the level directory or file name in the path of the target file. And then reading the file header of the level directory or the file name in the path of the target file from the second partition according to the relative logic address of the file header of the level directory or the file name in the path of the target file through the read-write logic time sequence of the SPI interface, storing the file header and the file name in the first cache region, and updating the absolute logic address of the file header stored in the first cache region recorded in the second cache region. If the first buffer area adopts a dynamic memory allocation mode, the memory address of the first buffer area recorded in the second buffer area is updated. If the first buffer area adopts a static memory allocation mode, the memory address of the first buffer area recorded in the second buffer area is not updated. And then the memory address of the first buffer area is returned to the upper interface.
Step S3: the absolute logical address of the header of the target file is added with the fixed length of the header and the length of the file name of the target file, and the address beginning with the first byte aligned by 16 bytes after the end character of the file name is used as the starting address of the absolute logical address of the file content of the target file.
Step S4: the read-only file system reads out binary data of the target file according to the starting address of the absolute logic address of the file content of the target file. At this time, if the target file is located in the nor gate flash memory of the QSPI interface, the binary data of the target file is directly read out by using the start address of the absolute logical address of the file content of the target file. At this time, if the target file is located in the NOR gate flash memory of the SPI interface, binary data of the target file is read out through the SPI interface.
Referring to fig. 4, the firmware storage and reading device based on the LVGL system framework of the present application includes a firmware storage unit 1, a header addressing unit 2, a file addressing unit 3, and a firmware reading unit 4. The apparatus shown in fig. 4 corresponds to the method shown in fig. 1.
The firmware storage unit 1 is used for storing an image file of a code in a first partition and a resource file in a second partition in firmware of the electronic equipment adopting LVGL as a GUI system frame, and the second partition adopts a read-only file system; in the read-only file system, each directory or resource file has a file header; the first partition and the second partition are arranged on a NOR gate flash memory of the same QSPI interface; or the first partition is arranged on the NOR gate flash memory of the QSPI interface, and the second partition is arranged on the NOR gate flash memory of the SPI interface; setting a first buffer area and a second buffer area for the read-only file system; the first buffer area is used for storing the file header of the recently read directory or resource file and the name of the recently read directory or resource file; the second buffer area is used for storing the absolute logic address of the file header stored in the first buffer area in the read-only file system, and the memory address and the length of the first buffer area.
The file header addressing unit 2 is configured to send out a path in a string form of the target file and a file name when the firmware of the electronic device wants to read a certain resource file, traverse the file header in the second partition to match to each level of directory in the path of the target file and the file name of the target file, and obtain an absolute logical address of the file header of the target file.
The file addressing unit 3 is configured to find a start address of an absolute logical address of a file content of the target file according to the absolute logical address of a file header of the target file.
The firmware reading unit 4 is configured to read binary data of the target file according to a start address of an absolute logical address of file content of the target file.
The application enables the resource files in the firmware of the electronic equipment to be independently stored in the second partition, adopts a read-only file system, can be accessed by upper layer codes, and also supports independent upgrading of the resource file partition. The design of the first buffer area and the second buffer area can also reduce the read operation to the physical memory.
The above are only preferred embodiments of the present application, and are not intended to limit the present application. Various modifications and variations of the present application will be apparent to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the protection scope of the present application.
Claims (10)
1. A firmware storage and reading method based on LVGL is characterized by comprising the following steps of;
step S1: in firmware of an electronic device adopting LVGL as a GUI system frame, storing an image file of a code in a first partition, and storing a resource file in a second partition, wherein the second partition adopts a read-only file system; in the read-only file system, each directory or resource file has a file header;
the first partition and the second partition are arranged on a NOR gate flash memory of the same QSPI interface; or the first partition is arranged on the NOR gate flash memory of the QSPI interface, and the second partition is arranged on the NOR gate flash memory of the SPI interface;
setting a first buffer area and a second buffer area for the read-only file system; the first buffer area is used for storing the file header of the recently read directory or resource file and the name of the recently read directory or resource file; the second buffer area is used for storing the absolute logic address of the file header stored in the first buffer area in the read-only file system, and the memory address and the length of the first buffer area;
step S2: when the firmware of the electronic equipment wants to read a certain resource file, sending out a path in the form of a character string of a target file and a file name, and traversing the file header in a second partition by the read-only file system to match all levels of catalogues in the path of the target file and the file name of the target file, so as to obtain an absolute logic address of the file header of the target file;
in the step S2, traversing the file header specifically includes the following steps; traversing from the first directory or the file header of the file in the second partition, and searching the file header of the directory type matched with each level of directory in the path of the target file; after finding the file header of the matched directory type, searching the file header of the directory type matched with the next-level directory in the path of the target file through the first sub-directory or the logic address of the first file recorded in the file header of the directory type until finding the file header of the file type matched with the name of the target file; returning the absolute logical address of the header of this file type; when the directory of each level in the path of the target file is matched with the file name, the following processing mode is adopted;
judging which physical hardware is located according to the absolute logical address of each level of catalogue or file header of the file name in the path of the target file;
if the file header of a certain level directory or file name in the path of the target file is positioned in the NOR gate flash memory of the QSPI interface, directly returning the absolute logic address of the file header to the upper layer interface;
if the file header of a certain grade of directory or file name in the path of the target file is positioned in the NOR gate flash memory of the SPI interface, the second buffer area is accessed first, and whether the absolute logic address stored in the second buffer area is the same as the absolute logic address of the grade of directory or file header of the file name in the path of the target file is judged; if the memory address and the length of the first buffer area are the same, the memory address of the first buffer area is returned to the upper layer interface; if the two addresses are different, subtracting the initial address of the second partition from the absolute logical address of the file header of the level directory or the file name in the path of the target file to obtain the relative logical address of the file header of the level directory or the file name in the path of the target file; reading out the file header of the level directory or the file name in the path of the target file in the second partition according to the relative logical address, storing the file header and the file name in the first cache area, updating the absolute logical address recorded in the second cache area, and then returning the memory address of the first cache area to the upper interface;
step S3: according to the absolute logical address of the file header of the target file, finding the starting address of the absolute logical address of the file content of the target file;
step S4: the read-only file system reads out binary data of the target file according to the starting address of the absolute logic address of the file content of the target file.
2. The LVGL-based firmware storage reading method of claim 1, wherein the resource file includes one or more of an image file, an audio file, an animation file, and a font file.
3. The method according to claim 1, wherein in the step S1, address segments that do not overlap each other are allocated to each physical hardware, address segments that do not overlap each other are allocated to each partition, and address segment information of each physical hardware, address segment information of each partition, and size are recorded in the partition table; when the read-only file system is initialized, the partition table is queried to know which physical hardware the second partition is on, and the starting address of the second partition is acquired.
4. The method for reading and storing firmware based on LVGL according to claim 1, wherein each directory is stored in sequence in the order of directory names in the form of file header and character string in the read-only file system; each resource file is sequentially stored in the sequence of file names in the form of file heads and character strings and file contents in the form of binary data; all the file headers are fixed in length, and the storage space storing the names of each directory or file is fixed in length.
5. The LVGL-based firmware storage read method of claim 1, wherein the read-only file system is used only to save resource files in the firmware of the electronic device; in the read-only file system, the catalogue or the resource file is stored sequentially; the file headers are also sequentially stored, and the order of the file headers is consistent with the order of the corresponding directory or resource files.
6. The LVGL-based firmware storage read method of claim 5, wherein a format of a header of each directory or resource file is identical in the read-only file system, wherein an offset address of a header of a next directory or file in the read-only file system is recorded; the type of the file header and whether the attribute is executable; if the directory type is the directory type, recording the logical address of the subdirectory or the subdirectory of the directory; if the file type is the file type, recording the size of the file; a checksum of the file header and the file name; the first byte of a directory or file name in the form of a string.
7. The method of claim 1, wherein in step S2, when updating the absolute logical address recorded in the second buffer, if the first buffer adopts a dynamic memory allocation manner, the memory address of the first buffer recorded in the second buffer is updated; if the first buffer area adopts a static memory allocation mode, the memory address of the first buffer area recorded in the second buffer area is not updated.
8. The method according to claim 1, wherein in the step S3, the absolute logical address of the header of the target file is added to the fixed length of the header, and the length of the file name of the target file is added, and the address starting with the first byte aligned by 16 bytes after the end character of the file name is used as the start address of the absolute logical address of the file content of the target file.
9. The method according to claim 1, wherein in step S4, if the target file is located in the nor gate flash memory of the QSPI interface, binary data of the target file is directly read out by using a start address of an absolute logical address of a file content of the target file; and if the target file is positioned in the NOR gate flash memory of the SPI interface, reading out binary data of the target file through the SPI interface.
10. The firmware storage and reading device based on the LVGL is characterized by comprising a firmware storage unit, a file header addressing unit, a file addressing unit and a firmware reading unit;
the firmware storage unit is used for storing an image file of a code in a first partition and a resource file in a second partition in firmware of the electronic equipment adopting the LVGL as a GUI system frame, and the second partition adopts a read-only file system; in the read-only file system, each directory or resource file has a file header; the first partition and the second partition are arranged on a NOR gate flash memory of the same QSPI interface; or the first partition is arranged on the NOR gate flash memory of the QSPI interface, and the second partition is arranged on the NOR gate flash memory of the SPI interface; setting a first buffer area and a second buffer area for the read-only file system; the first buffer area is used for storing the file header of the recently read directory or resource file and the name of the recently read directory or resource file; the second buffer area is used for storing the absolute logic address of the file header stored in the first buffer area in the read-only file system, and the memory address and the length of the first buffer area;
the file header addressing unit is used for sending out a path in the form of a character string of the target file and a file name when the firmware of the electronic equipment wants to read a certain resource file, traversing the file header in the second partition to be matched with all levels of catalogues in the path of the target file and the file name of the target file, and obtaining an absolute logic address of the file header of the target file;
the traversing file header specifically comprises the following steps of; traversing from the first directory or the file header of the file in the second partition, and searching the file header of the directory type matched with each level of directory in the path of the target file; after finding the file header of the matched directory type, searching the file header of the directory type matched with the next-level directory in the path of the target file through the first sub-directory or the logic address of the first file recorded in the file header of the directory type until finding the file header of the file type matched with the name of the target file; returning the absolute logical address of the header of this file type; when the directory of each level in the path of the target file is matched with the file name, the following processing mode is adopted;
judging which physical hardware is located according to the absolute logical address of each level of catalogue or file header of the file name in the path of the target file;
if the file header of a certain level directory or file name in the path of the target file is positioned in the NOR gate flash memory of the QSPI interface, directly returning the absolute logic address of the file header to the upper layer interface;
if the file header of a certain grade of directory or file name in the path of the target file is positioned in the NOR gate flash memory of the SPI interface, the second buffer area is accessed first, and whether the absolute logic address stored in the second buffer area is the same as the absolute logic address of the grade of directory or file header of the file name in the path of the target file is judged; if the memory address and the length of the first buffer area are the same, the memory address of the first buffer area is returned to the upper layer interface; if the two addresses are different, subtracting the initial address of the second partition from the absolute logical address of the file header of the level directory or the file name in the path of the target file to obtain the relative logical address of the file header of the level directory or the file name in the path of the target file; reading out the file header of the level directory or the file name in the path of the target file in the second partition according to the relative logical address, storing the file header and the file name in the first cache area, updating the absolute logical address recorded in the second cache area, and then returning the memory address of the first cache area to the upper interface;
the file addressing unit is used for finding out the initial address of the absolute logical address of the file content of the target file according to the absolute logical address of the file header of the target file;
the firmware reading unit is used for reading binary data of the target file according to the starting address of the absolute logical address of the file content of the target file.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110580642.3A CN113327639B (en) | 2021-05-26 | 2021-05-26 | Firmware storage reading method and device based on LVGL |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110580642.3A CN113327639B (en) | 2021-05-26 | 2021-05-26 | Firmware storage reading method and device based on LVGL |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113327639A CN113327639A (en) | 2021-08-31 |
CN113327639B true CN113327639B (en) | 2023-09-15 |
Family
ID=77421400
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110580642.3A Active CN113327639B (en) | 2021-05-26 | 2021-05-26 | Firmware storage reading method and device based on LVGL |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113327639B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116910770B (en) * | 2023-09-13 | 2023-12-19 | 中国海洋大学 | Firmware base address recognition system and method based on density |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
TW201709055A (en) * | 2015-08-19 | 2017-03-01 | 衡宇科技股份有限公司 | Field firmware upgrading method and computer-readable medium |
CN106598576A (en) * | 2016-11-30 | 2017-04-26 | 深圳市泛海三江科技发展有限公司 | Equipment parameter updating method and device based on squashfs read-only file |
WO2019128166A1 (en) * | 2017-12-29 | 2019-07-04 | 北京忆恒创源科技有限公司 | Kv storage device and method of using kv storage device to provide file system |
CN111475178A (en) * | 2020-06-23 | 2020-07-31 | 翱捷科技(上海)有限公司 | Embedded system firmware programming progress calculation method and system |
CN112114849A (en) * | 2020-09-23 | 2020-12-22 | 腾讯科技(深圳)有限公司 | Resource updating method and device |
CN112562022A (en) * | 2021-01-25 | 2021-03-26 | 翱捷科技股份有限公司 | Picture display method and system of electronic equipment |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7320052B2 (en) * | 2003-02-10 | 2008-01-15 | Intel Corporation | Methods and apparatus for providing seamless file system encryption and redundant array of independent disks from a pre-boot environment into a firmware interface aware operating system |
US8051111B2 (en) * | 2008-01-31 | 2011-11-01 | Prowess Consulting, Llc | Method and system for modularizing windows imaging format |
US20200356358A1 (en) * | 2019-05-07 | 2020-11-12 | Dell Products L.P. | Systems and methods for incrementally and dynamically updating firmware |
-
2021
- 2021-05-26 CN CN202110580642.3A patent/CN113327639B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
TW201709055A (en) * | 2015-08-19 | 2017-03-01 | 衡宇科技股份有限公司 | Field firmware upgrading method and computer-readable medium |
CN106598576A (en) * | 2016-11-30 | 2017-04-26 | 深圳市泛海三江科技发展有限公司 | Equipment parameter updating method and device based on squashfs read-only file |
WO2019128166A1 (en) * | 2017-12-29 | 2019-07-04 | 北京忆恒创源科技有限公司 | Kv storage device and method of using kv storage device to provide file system |
CN111475178A (en) * | 2020-06-23 | 2020-07-31 | 翱捷科技(上海)有限公司 | Embedded system firmware programming progress calculation method and system |
CN112114849A (en) * | 2020-09-23 | 2020-12-22 | 腾讯科技(深圳)有限公司 | Resource updating method and device |
CN112562022A (en) * | 2021-01-25 | 2021-03-26 | 翱捷科技股份有限公司 | Picture display method and system of electronic equipment |
Also Published As
Publication number | Publication date |
---|---|
CN113327639A (en) | 2021-08-31 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US8549271B1 (en) | Method, system, and computer readable medium for updating and utilizing the contents of a non-essential region of a memory device | |
US8504792B2 (en) | Methods and apparatuses to allocate file storage via tree representations of a bitmap | |
KR100449708B1 (en) | Flash memory management method | |
US7987190B2 (en) | Filesystem having a filename cache | |
JP4777426B2 (en) | Apparatus, system and method for accessing persistent files in NON-EXECUTE-IN-PLACE flash memory | |
JP4077047B2 (en) | How to run on a computer system | |
US8521790B2 (en) | Increasing efficiency of data storage in a file system | |
US7516296B2 (en) | Flash memory storage device and read/write method | |
WO2017067175A1 (en) | Method, apparatus and device for loading elf file, and computer storage medium | |
JP2008242503A (en) | Memory management apparatus and method, and program | |
JP3827682B2 (en) | Flash memory, mapping control apparatus and method therefor | |
JP2000305839A (en) | Storage device, storage system, memory managing method, and recording medium | |
CN113327639B (en) | Firmware storage reading method and device based on LVGL | |
JPWO2007026484A1 (en) | Information processing system, information processing method, execution binary image creation device, execution binary image creation method, execution binary image creation program, computer-readable recording medium recording the execution binary image creation program, execution binary image execution device, execution binary image Execution method, execution binary image execution program, and computer-readable recording medium on which execution binary image execution program is recorded | |
JPWO2007026484A6 (en) | Apparatus, method, and program for creating and executing executable binary image, and computer-readable recording medium recording the program | |
CN115994122A (en) | Method, system, equipment and storage medium for caching information | |
CN110334057B (en) | File access method and system thereof | |
CN107656753A (en) | A kind of patch-realizing method and device | |
CN101770508B (en) | Data access method in mobile communication terminal and equipment thereof | |
JP2014063358A (en) | Information processor, information processing method, and program | |
JPS639587A (en) | Ic card | |
JP2004206615A (en) | Storage device | |
CN116841657A (en) | Interface function calling method and device | |
CN117473117A (en) | Video cyclic storage method, system and computer | |
JP2006178632A (en) | Information processor, information processing method, and program |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |