A method and system for browsing and updating program firmware when an embedded system is used offline
By integrating large-capacity flash memory on the smart terminal and mounting it as a Snorfs file system, the problem that smart hardware can only store one program is solved, and the firmware of multiple program is switched and browsed at any time when offline is realized, and the storage and loading of multiple user programs is supported.
Patent Information
- Application Number
- CN202110093211.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-01-25
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2041-01-25
AI Technical Summary
Existing smart hardware can only store one program. When users switch programs, they need to connect to a computer to download new programs again. They cannot switch and browse multiple programs firmware at any time when offline.
By integrating large-capacity flash memory on the smart terminal, the bootloader boots the flash as the Snorfs file system. When the user switches the program, there is no need to connect to the computer to download the new program again, and directly update the program of the smart terminal using the firmware files in the mounted Snorfs file system.
It realizes switching the browsing program firmware at any time when offline, solving the problem that smart hardware can only store one program, and supports the storage, browsing and loading of multiple user programs.
Smart Images

Figure CN114791819B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of program firmware browsing and updating when an embedded system is used offline, and in particular to a method and system for browsing and updating program firmware when an embedded system is used offline. Background Art
[0002] Currently, similar smart hardware on the market mainly includes Arduino and micro:bit, as well as variants based on the former two. This type of smart hardware is mainly aimed at children's programming. It requires the use of a computer programming platform to burn the compiled program into the internal storage of the smart hardware, and then the smart hardware can run the corresponding program to perform the corresponding action.
[0003] Smart hardware is generally equipped with a variety of peripherals and can be programmed to achieve a variety of applications. However, there is a problem with current hardware, which is that it can only store one program. When users switch programs, they need to connect to the computer and re-download the new program, which is inconvenient for use. Summary of the invention
[0004] The purpose of the present invention is to provide a method and system for browsing and updating program firmware when an embedded system is used offline, so as to solve the problem that existing intelligent hardware can only store one program, and when the user switches programs, it is necessary to connect to a computer and re-download a new program, and it is impossible to switch and browse multiple program firmware at any time when offline.
[0005] To achieve the above object, the present invention provides the following solutions:
[0006] A method for browsing and updating program firmware when an embedded system is used offline, comprising:
[0007] The boot loader Bootloader running on the microprocessor of the intelligent hardware realizes that the intelligent hardware is a U disk with a FAT16 virtual file system; the intelligent hardware includes a microprocessor, a storage medium and a peripheral unit; the U disk is a USB mass storage device;
[0008] Generate multiple firmware files by computer programming software, and copy the multiple firmware files to the U disk;
[0009] The user program of the intelligent hardware is updated using the multiple firmware files in the storage medium of the intelligent hardware.
[0010] Optionally, the boot loader program Bootloader running on the microprocessor of the intelligent hardware realizes that the intelligent hardware is a USB flash drive with a FAT16 virtual file system; the intelligent hardware includes a microprocessor, a storage medium and a peripheral unit, specifically including:
[0011] Enter the bootloader of the intelligent terminal and mount the storage medium as the Snorfs file system; the Snorfs file system is an open source serial non-volatile flash memory NorFlash file system; the bootloader reads the files in the Snorfs file system and generates a file list according to the read files;
[0012] Constructing a FAT16 virtual file system according to the file linked list;
[0013] When the smart terminal is connected to the computer via a USB cable and enters the boot loader, the smart terminal is mounted as a U disk with a FAT16 virtual file system; the FAT16 virtual file system includes multiple firmware files.
[0014] Optionally, the updating of the user program of the intelligent hardware by using the multiple firmware files in the storage medium of the intelligent hardware specifically includes:
[0015] If there is a backup file of the FAT root directory area in the Snorfs file system, the data in the backup file is read and assigned to the read directory data; the FAT root directory area is the FAT root directory area in the virtual file system FAT16;
[0016] When the root directory data in the FAT root directory area changes, the boot loader reads the root directory data and assigns the directory structure array in the root directory data to the write directory data;
[0017] If the read directory data and the write directory data are different, the write directory data is copied to the read directory data, and the read directory data is saved in a backup file in the FAT root directory area.
[0018] Optionally, the step of saving the read directory data to a backup file in a FAT root directory area further includes:
[0019] Traversing the array of directory data written according to the Directoryentry data structure, if the first byte of the Directoryentry structure instance is 0xE5, determining that the directory or firmware file corresponding to the Directoryentry structure instance is deleted;
[0020] The deleted file name is read, and the corresponding file in the snorfs file system in the intelligent terminal is deleted according to the deleted file name.
[0021] Optionally, the reading of the deleted file name, and deleting the corresponding file in the snorfs file system in the smart terminal according to the deleted file name, further includes:
[0022] If the Block data received by the boot loader is in uf2 format, the boot loader traverses the starting cluster variable of the directory entry Directoryentry structure of the array of the written directory data; if the starting cluster variable is equal to the number of the written Block data, it is determined whether there is a firmware file written or replaced, and if so, the file name of the directory entry Directoryentry structure is read, and the corresponding file is created and written into the Snorfs file system, and the firmware file of the smart terminal is updated at the same time; if not, return to the step "when the root directory data in the FAT root directory area changes, the boot loader reads the root directory data, and assigns the directory structure array in the root directory data to the written directory data".
[0023] A program firmware browsing and updating system for an embedded system when used offline, comprising:
[0024] A FAT16 virtual file system mounting module, which is used to realize the intelligent hardware as a U disk of the FAT16 virtual file system by using the boot loader Bootloader running by the microprocessor of the intelligent hardware; the intelligent hardware includes a microprocessor, a storage medium and a peripheral unit;
[0025] A copy module, used to generate multiple firmware files by computer programming software, and copy the multiple firmware files to the U disk;
[0026] The update module is used to update the user program of the intelligent hardware using multiple firmware files in the storage medium of the intelligent hardware.
[0027] Optionally, the FAT16 virtual file system mounting module specifically includes:
[0028] The Snorfs file system mounting unit is used to enter the boot loader Bootloader of the intelligent terminal and mount the storage medium as the Snorfs file system; the Snorfs file system is an open source serial non-volatile flash memory NorFlash file system; the boot loader Bootloader reads the files in the Snorfs file system and generates a file linked list according to the read files;
[0029] A FAT16 virtual file system construction module, used for constructing a FAT16 virtual file system according to the file linked list;
[0030] The FAT16 virtual file system mounting unit is used to mount the U disk of the FAT16 virtual file system on the smart terminal when the smart terminal enters the boot loader Bootloader after connecting to the computer via a USB cable; the FAT16 virtual file system includes multiple firmware files.
[0031] Optionally, the update module specifically includes:
[0032] A read directory data assignment unit is used for reading data in a backup file of a FAT root directory area and assigning the data to the read directory data if there is a backup file of the FAT root directory area in the Snorfs file system; the FAT root directory area is the FAT root directory area in the virtual file system FAT16;
[0033] A write directory data assignment unit, used for, when the root directory data in the FAT root directory area changes, the boot loader reads the root directory data and assigns the directory structure array in the root directory data to the write directory data;
[0034] The read directory data saving unit is used for copying the write directory data to the read directory data if the read directory data and the write directory data are different, and saving the read directory data to a backup file in the FAT root directory area.
[0035] Optionally, also include:
[0036] An array traversal unit for writing directory data, used for traversing the array of the written directory data according to the directory entry Directoryentry data structure, and if the first byte of the directory entry Directoryentry structure instance is 0xE5, it is determined that the directory or firmware file corresponding to the directory entry Directoryentry structure instance is deleted;
[0037] The deleting unit is used to read the name of the deleted file and delete the corresponding file in the snorfs file system in the intelligent terminal according to the deleted file name.
[0038] Optionally, also include:
[0039] The starting cluster variable writing unit is used for, if the Block data received by the boot loader Bootloader is in uf2 format, the boot loader Bootloader traverses the starting cluster variables of the directory entry Directoryentry structure of the array of the written directory data; if the starting cluster variable is equal to the number of the written Block data, it is determined whether there is a firmware file written or replaced, and if so, the file name of the directory entry Directoryentry structure is read, and the corresponding file is created and written into the Snorfs file system, and the firmware file of the smart terminal is updated at the same time; if not, returning to the step of "when the root directory data in the FAT root directory area changes, the boot loader Bootloader reads the root directory data, and assigns the directory structure array in the root directory data to the written directory data".
[0040] According to the specific embodiments provided by the present invention, the present invention discloses the following technical effects: the present invention provides a method and system for browsing and updating program firmware when an embedded system is used offline. By integrating a large-capacity flash memory on an intelligent terminal, a boot loader mounts the flash as a Snorfs file system. When a user switches programs, there is no need to connect to a computer to re-download a new program. The firmware file in the mounted Snorfs file system can be directly used to update the program of the intelligent terminal. The program firmware can also be switched and browsed at any time when offline, thereby realizing the storage, browsing and loading of multiple user programs. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0042] Figure 1 A flow chart of a method for browsing and updating program firmware when the embedded system provided by the present invention is used offline;
[0043] Figure 2 A flow chart of another method for browsing and updating program firmware when an embedded system is used offline provided by the present invention;
[0044] Figure 3 The firmware update data flow diagram provided by the present invention;
[0045] Figure 4 The software framework diagram provided by the present invention;
[0046] Figure 5A system structure diagram for browsing and updating program firmware when the embedded system provided by the present invention is used offline;
[0047] Figure 6 This is a diagram showing the data flow of the root directory. DETAILED DESCRIPTION
[0048] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0049] The purpose of the present invention is to provide a method and system for browsing and updating program firmware when an embedded system is used offline, so as to realize the storage, browsing and loading of multiple user programs.
[0050] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0051] Figure 1 The flowchart of the method for browsing and updating the program firmware when the embedded system is used offline provided by the present invention is as follows: Figure 1 As shown, a method for browsing and updating program firmware when an embedded system is used offline includes:
[0052] Step 101: The boot loader program Bootloader executed by the microprocessor of the intelligent hardware is implemented so that the intelligent hardware is a USB disk with a FAT16 virtual file system; the intelligent hardware includes a microprocessor, a storage medium and a peripheral unit.
[0053] The step 101 specifically includes: entering the bootloader of the smart terminal and mounting the storage medium as the Snorfs file system; the Snorfs file system is an open source serial non-volatile flash memory NorFlash file system; the bootloader reads the files in the Snorfs file system and generates a file list according to the read files; constructs a FAT16 virtual file system according to the file list; when the smart terminal is connected to the computer via a USB cable and enters the bootloader, the smart terminal is mounted as a U disk of the FAT16 virtual file system; the FAT16 virtual file system includes multiple firmware files.
[0054] Step 102: Generate multiple firmware files by computer programming software, and copy the multiple firmware files to the USB flash drive.
[0055] Step 103: Use the multiple firmware files in the storage medium of the intelligent hardware to update the user program of the intelligent hardware.
[0056] The step 103 specifically includes: if there is a backup file of the FAT root directory area in the Snorfs file system, then read the data in the backup file and assign it to the read directory data; the FAT root directory area is the FAT root directory area in the virtual file system FAT16; when the root directory data in the FAT root directory area changes, the boot loader Bootloader reads the root directory data and assigns the directory structure array in the root directory data to the write directory data; if the read directory data and the write directory data are different, copy the write directory data to the read directory data, and save the read directory data to the backup file of the FAT root directory area. Wherein, the directory structure corresponds to a directory or a firmware file.
[0057] In actual application, the read directory data is saved in a backup file in the FAT root directory area, and then it also includes: traversing the array of written directory data according to the directory entry Directoryentry data structure, if the first byte of the directory entry Directoryentry structure instance is 0xE5, it is determined that the directory or firmware file corresponding to the directory entry Directoryentry structure instance is deleted; read the deleted file name, and delete the corresponding file in the snorfs file system in the smart terminal according to the deleted file name.
[0058] In actual application, the method reads the deleted file name, deletes the corresponding file in the snorfs file system in the smart terminal according to the deleted file name, and then includes: if the Block data received by the boot loader Bootloader is in uf2 format, the boot loader Bootloader traverses the starting cluster variable of the directory entry Directoryentry structure of the array of written directory data; if the starting cluster variable is equal to the number of the written Block data, determines whether there is a firmware file written or replaced, and if so, reads the file name of the directory entry Directoryentry structure, creates and writes the corresponding file to the Snorfs file system, and updates the firmware file of the smart terminal; if not, returns to the step "when the root directory data in the FAT root directory area changes, the boot loader Bootloader reads the root directory data, and assigns the directory structure array in the root directory data to the written directory data".
[0059] The method for browsing and updating the program firmware when the embedded system is used offline provided by the present invention is applied to actual operation, such as Figure 2-Figure 4 As shown, the specific operation process is as follows.
[0060] Step 1: Mount the internal Flash as the Snorfs file system.
[0061] The bootloader program of the intelligent terminal will mount the Snorfs file system of the internal serial non-volatile flash memory SerialNorFlash, and the Snorfs file system is an open source serial non-volatile flash memory NorFlash file system.
[0062] Step 2: Read the files in the Snorfs file system into the file list variable.
[0063] The smart terminal Bootloader program reads the files in the smart terminal flash memory Flash to the file linked list variable of the Snorfs file system, and reads the FATRootDirectoryRegion backup file fatroot.txt in the Snorfs file system. If the file exists, the file is read and assigned to the variable readDirData. If it does not exist, there is no file in the Snorfs file system.
[0064] Step 3: Mount as USBMSC device.
[0065] After the smart terminal is connected to the computer via a USB cable, it enters the bootloader program, at which time the smart terminal will be mounted as a USB mass storage (USBMSC) device.
[0066] Step 4: Construct a FAT16 virtual file system based on the file list of the Snorfs file system. The FAT16 virtual file system in the smart terminal is a virtual file system. Reading and writing are both in the memory of the smart terminal, and there is no direct reading and writing of the flash. In addition to the files in Snorfs, the FAT16 virtual file system also contains some files that provide system information.
[0067] Step 5: Copy or delete files.
[0068] When the FAT root directory (FATRootDirectoryRegion) changes, such as adding files or deleting files, the Bootloader reads the corresponding FA16 file system root directory data into the array writeDirData, compares the two arrays writeDirData and readDirData, and if they are different, copies wirteDirData to readDirData, and saves readDirData to the fatroot.txt backup file in the Snorfs file system.
[0069] Step 6: Firmware file deletion.
[0070] According to the Directoryentry data structure, the writeDirData array is traversed. If the first byte of the Directoryentry structure instance is 0xE5, it means that the file has been deleted. The file name is read and the corresponding file in the snorfs file system of the smart terminal is deleted.
[0071] After the traversal is completed or the file is deleted, jump to step 7, otherwise continue the traversal according to step 6.
[0072] Step 7: Firmware copy.
[0073] If the Block data written is in uf2 format, the Bootloader traverses the starting cluster variable of the Directoryentry structure of the writeDirData array. If the starting cluster variable is equal to the number of the written Block, it is determined that a file has been written or replaced and jumps to step 8, otherwise jumps to step 5.
[0074] Step 8: Read the file name of the corresponding Directoryentry structure, create and write the corresponding file to the Snorfs file system, and update the firmware of the smart terminal.
[0075] Step 9: The file format supported by the programmable game console XtronPro is UF2 format. UF2 is the abbreviation of USB Flash Format. It is organized in the format of 512 bytes per block. Each block contains the block number, the total number of blocks and 256 bytes of data. The file copied in step 7 is judged by comparing the copied block number with the total number of blocks to complete the copy.
[0076] The modular design enriches the functions of XtronPro and makes programming more diverse. For example, if a user writes a game program, he can connect the game controller to the core of XtronPro to complete the game operation. When the user writes a time display or pedometer program, he can put a silicone cover and a strap on the XtronPro core and wear it on the wrist.
[0077] Due to the modular design and diverse forms of XtronPro, different program firmware is required for different forms, so it is necessary to easily switch between different firmware. The bootloader of XtronPro can easily browse the stored firmware programs and load the corresponding firmware programs.
[0078] Step 10: The above steps complete the writing and deletion of the program firmware. The written files are transferred to the flash of the snorfs file system through the FAT file system format. Step 2 describes the read snorfs file list. When the user operates the XtronPro button to browse the file, the file directory corresponding to the snorfs file list is displayed.
[0079] Figure 5 For offline use of embedded systems, browse and update the system structure diagram of the program firmware, such as Figure 5 As shown, a system for browsing and updating program firmware when an embedded system is used offline includes:
[0080] The FAT16 virtual file system mounting module 501 is used to realize the intelligent hardware as a U disk of the FAT16 virtual file system by using the boot loader Bootloader run by the microprocessor of the intelligent hardware; the intelligent hardware includes a microprocessor, a storage medium and a peripheral unit.
[0081] The FAT16 virtual file system mounting module 501 specifically includes: a Snorfs file system mounting unit, which is used to enter the boot loader Bootloader of the smart terminal and mount the storage medium as the Snorfs file system; the Snorfs file system is an open source serial non-volatile flash memory NorFlash file system; the boot loader Bootloader reads the files in the Snorfs file system and generates a file list according to the read files; a FAT16 virtual file system construction module, which is used to construct a FAT16 virtual file system according to the file list; a FAT16 virtual file system mounting unit, which is used to enable the smart terminal to mount a U disk as a FAT16 virtual file system when the smart terminal enters the boot loader Bootloader after connecting to a computer via a USB cable; the FAT16 virtual file system includes multiple firmware files.
[0082] The copy module 502 is used to generate multiple firmware files by computer programming software and copy the multiple firmware files to the U disk.
[0083] The updating module 503 is used to update the user program of the intelligent hardware using the multiple firmware files in the storage medium of the intelligent hardware.
[0084] The update module 503 specifically includes: a read directory data assignment unit, which is used to read the data in the backup file and assign it to the read directory data if there is a backup file of the FAT root directory area in the Snorfs file system; the FAT root directory area is the FAT root directory area in the virtual file system FAT16; a write directory data assignment unit, which is used to read the root directory data by the boot loader Bootloader when the root directory data in the FAT root directory area changes, and assign the directory structure array in the root directory data to the write directory data; a read directory data storage unit, which is used to copy the write directory data to the read directory data if the read directory data and the write directory data are different, and save the read directory data to the backup file of the FAT root directory area.
[0085] The present invention also includes: an array traversal unit for writing directory data, which is used to traverse the array of the written directory data according to the directory entry data structure. If the first byte of the directory entry Directoryentry structure instance is 0xE5, it is determined that the directory or firmware file corresponding to the directory entry Directoryentry structure instance is deleted; a deletion unit, which is used to read the deleted file name and delete the corresponding file in the snorfs file system in the smart terminal according to the deleted file name.
[0086] The present invention also includes: a starting cluster variable writing unit, which is used for, if the Block data received by the boot loader Bootloader is in uf2 format, the boot loader Bootloader traverses the starting cluster variables of the directory entry Directoryentry structure of the array of the written directory data; if the starting cluster variable is equal to the number of the written Block data, it is determined whether there is a firmware file written or replaced, and if so, the file name of the directory entry Directoryentry structure is read, and the corresponding file is created and written into the Snorfs file system, and the firmware file of the smart terminal is updated at the same time; if not, returning to the step of "when the root directory data in the FAT root directory area changes, the boot loader Bootloader reads the root directory data, and assigns the directory structure array in the root directory data to the written directory data", Figure 6This is a schematic diagram of the root directory data flow, such as Figure 6 shown.
[0087] The present invention can realize browsing and loading of multiple program firmwares when the embedded system is used offline.
[0088] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the system disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0089] The principles and implementation methods of the present invention are described in this article using specific examples. The description of the above embodiments is only used to help understand the method and core idea of the present invention. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting the present invention.
Claims
1. A method for browsing and updating program firmware when an embedded system is used offline, characterized in that: include: The boot loader program Bootloader running on the microprocessor of the intelligent hardware realizes that the intelligent hardware is a U disk with a FAT16 virtual file system; the intelligent hardware includes a microprocessor, a storage medium and a peripheral unit; Generate multiple firmware files by computer programming software, and copy the multiple firmware files to the U disk; Updating the user program of the intelligent hardware using a plurality of firmware files in the storage medium of the intelligent hardware; Step 1: Mount the internal Flash as Snorfs file system; The bootloader program of the intelligent terminal will mount the Snorfs file system of the internal serial non-volatile flash memory Serial NorFlash, and the Snorfs file system is an open source serial non-volatile flash memory Nor Flash file system; Step 2: Read the files in the Snorfs file system into the file list variable; The smart terminal Bootloader program reads the file in the smart terminal flash memory to the file list variable of the Snorfs file system, and reads the FAT Root Directory Region backup file fatroot.txt in the Snorfs file system. If the file exists, the file is read and assigned to the variable readDirData. If it does not exist, there is no file in the Snorfs file system. Step 3: Mount as USB MSC device; After the smart terminal is connected to the computer via a USB cable, it enters the bootloader program. At this time, the smart terminal will be mounted as a USB mass storage device; Step 4: Construct a FAT16 virtual file system based on the file list of the Snorfs file system. The FAT16 virtual file system in the smart terminal is a virtual file system. Reading and writing are all in the memory of the smart terminal, and there is no direct reading and writing of flash. In addition to the files in Snorfs, the files in the FAT16 virtual file system also include some files that provide system information. Step 5: Copy or delete files; When the FAT root directory changes, the Bootloader reads the corresponding FA16 file system root directory data into the array writeDirData, compares the two arrays writeDirData and readDirData, and if they are different, copies the writeDirData to readDirData, and saves the readDirData to the fatroot.txt backup file in the Snorfs file system; Step 6: Firmware file deletion; Traverse the writeDirData array according to the Directory entry data structure. If the first byte of the Directory entry structure instance is 0xE5, it means that the file has been deleted. Read the file name and delete the corresponding file in the snorfs file system of the smart terminal. After the traversal is completed or the file is deleted, jump to step 7, otherwise continue the traversal according to step 6; Step 7: Firmware copy; If the Block data written is in uf2 format, the Bootloader traverses the starting cluster variable of the Directoryentry structure of the writeDirData array. If the starting cluster variable is equal to the number of the Block written, it is determined that there is a file written or replaced, and jumps to step 8, otherwise jumps to step 5; Step 8: Read the file name of the corresponding Directory entry structure, create and write the corresponding file to the Snorfs file system, and update the firmware of the smart terminal; Step 9: The file format supported by the programmable game console Xtron Pro is UF2 format. UF2 is the abbreviation of USB FlashFormat. It is organized in the format of 512 bytes per block. Each block contains the block number and the total number of blocks and 256 bytes of data. The file copied in step 7 is judged by comparing the copied block number with the total number of blocks to complete the copy; Step 10: The above steps complete the writing and deletion of the program firmware. The written files are transferred to the flash of the snorfs file system through the FAT file system format. Step 2 describes the read snorfs file list. When the user operates the XtronPro button to browse the file, the file directory corresponding to the snorfs file list is displayed.
2. The method for browsing and updating program firmware when the embedded system is used offline according to claim 1, characterized in that: The boot loader program Bootloader running on the microprocessor of the intelligent hardware realizes that the intelligent hardware is a U disk with a FAT16 virtual file system; the intelligent hardware includes a microprocessor, a storage medium and a peripheral unit, specifically including: Enter the bootloader of the intelligent terminal and mount the storage medium as the Snorfs file system; the Snorfs file system is an open source serial non-volatile flash memory Nor Flash file system; the bootloader reads the files in the Snorfs file system and generates a file list according to the read files; Constructing a FAT16 virtual file system according to the file linked list; When the smart terminal is connected to the computer via a USB cable and enters the boot loader, the smart terminal is mounted as a U disk with a FAT16 virtual file system; the FAT16 virtual file system includes multiple firmware files.
3. The method for browsing and updating program firmware when the embedded system is used offline according to claim 2, characterized in that: The method of updating the user program of the intelligent hardware by using the multiple firmware files in the storage medium of the intelligent hardware specifically includes: If there is a backup file of the FAT root directory area in the Snorfs file system, the data in the backup file is read and assigned to the read directory data; the FAT root directory area is the FAT root directory area in the virtual file system FAT16; When the root directory data in the FAT root directory area changes, the boot loader reads the root directory data and assigns the directory structure array in the root directory data to the write directory data; If the read directory data and the write directory data are different, the write directory data is copied to the read directory data, and the read directory data is saved in a backup file in the FAT root directory area.
4. The method for browsing and updating program firmware when the embedded system is used offline according to claim 3, characterized in that: The step of saving the read directory data to a backup file in the FAT root directory area further comprises: Traversing the array of directory data written according to the Directory entry data structure, if the first byte of the Directory entry structure instance is 0xE5, determining that the directory or firmware file corresponding to the Directory entry structure instance is deleted; The deleted file name is read, and the corresponding file in the snorfs file system in the intelligent terminal is deleted according to the deleted file name.
5. The method for browsing and updating program firmware when the embedded system is used offline according to claim 4, characterized in that: The method further comprises: reading the deleted file name, deleting the corresponding file in the snorfs file system in the smart terminal according to the deleted file name, and then further comprising: If the Block data received by the boot loader is in uf2 format, the boot loader traverses the starting cluster variable of the directory entry structure of the array of the written directory data; if the starting cluster variable is equal to the number of the written Block data, it is determined whether there is a firmware file written or replaced, and if so, the file name of the directory entry structure is read, and the corresponding file is created and written into the Snorfs file system, and the firmware file of the smart terminal is updated at the same time; if not, return to the step "when the root directory data in the FAT root directory area changes, the boot loader reads the root directory data, and assigns the directory structure array in the root directory data to the written directory data".
6. A system for browsing and updating program firmware when an embedded system is used offline, characterized in that: include: A FAT16 virtual file system mounting module, which is used to realize the intelligent hardware as a U disk of the FAT16 virtual file system by using the boot loader Bootloader running by the microprocessor of the intelligent hardware; the intelligent hardware includes a microprocessor, a storage medium and a peripheral unit; A copy module, used to generate multiple firmware files by computer programming software, and copy the multiple firmware files to the U disk; An update module, used to update the user program of the intelligent hardware using a plurality of firmware files in the storage medium of the intelligent hardware; Step 1: Mount the internal Flash as Snorfs file system; The bootloader program of the intelligent terminal will mount the Snorfs file system of the internal serial non-volatile flash memory Serial NorFlash, and the Snorfs file system is an open source serial non-volatile flash memory Nor Flash file system; Step 2: Read the files in the Snorfs file system into the file list variable; The smart terminal Bootloader program reads the file in the smart terminal flash memory to the file list variable of the Snorfs file system, and reads the FAT Root Directory Region backup file fatroot.txt in the Snorfs file system. If the file exists, the file is read and assigned to the variable readDirData. If it does not exist, there is no file in the Snorfs file system. Step 3: Mount as USB MSC device; After the smart terminal is connected to the computer via a USB cable, it enters the bootloader program. At this time, the smart terminal will be mounted as a USB mass storage device; Step 4: Construct a FAT16 virtual file system based on the file list of the Snorfs file system. The FAT16 virtual file system in the smart terminal is a virtual file system. Reading and writing are all in the memory of the smart terminal, and there is no direct reading and writing of flash. In addition to the files in Snorfs, the files in the FAT16 virtual file system also include some files that provide system information. Step 5: Copy or delete files; When the FAT root directory changes, the Bootloader reads the corresponding FA16 file system root directory data into the array writeDirData, compares the two arrays writeDirData and readDirData, and if they are different, copies the writeDirData to readDirData, and saves the readDirData to the fatroot.txt backup file in the Snorfs file system; Step 6: Firmware file deletion; Traverse the writeDirData array according to the Directory entry data structure. If the first byte of the Directory entry structure instance is 0xE5, it means that the file has been deleted. Read the file name and delete the corresponding file in the snorfs file system of the smart terminal. After the traversal is completed or the file is deleted, jump to step 7, otherwise continue the traversal according to step 6; Step 7: Firmware copy; If the Block data written is in uf2 format, the Bootloader traverses the starting cluster variable of the Directoryentry structure of the writeDirData array. If the starting cluster variable is equal to the number of the Block written, it is determined that there is a file written or replaced, and jumps to step 8, otherwise jumps to step 5; Step 8: Read the file name of the corresponding Directory entry structure, create and write the corresponding file to the Snorfs file system, and update the firmware of the smart terminal; Step 9: The file format supported by the programmable game console Xtron Pro is UF2 format. UF2 is the abbreviation of USB FlashFormat. It is organized in the format of 512 bytes per block. Each block contains the block number and the total number of blocks and 256 bytes of data. The file copied in step 7 is judged by comparing the copied block number with the total number of blocks to complete the copy; Step 10: The above steps complete the writing and deletion of the program firmware. The written files are transferred to the flash of the snorfs file system through the FAT file system format. Step 2 describes the read snorfs file list. When the user operates the XtronPro button to browse the file, the file directory corresponding to the snorfs file list is displayed.
7. The system for browsing and updating program firmware when the embedded system is used offline according to claim 6, characterized in that: The FAT16 virtual file system mounting module specifically includes: The Snorfs file system mounting unit is used to enter the boot loader Bootloader of the intelligent terminal and mount the storage medium as the Snorfs file system; the Snorfs file system is an open source serial non-volatile flash memory Nor Flash file system; the boot loader Bootloader reads the files in the Snorfs file system and generates a file linked list according to the read files; A FAT16 virtual file system construction module, used for constructing a FAT16 virtual file system according to the file linked list; The FAT16 virtual file system mounting unit is used to mount the U disk of the FAT16 virtual file system on the smart terminal when the smart terminal enters the boot loader Bootloader after connecting to the computer via a USB cable; the FAT16 virtual file system includes multiple firmware files.
8. The system for browsing and updating program firmware when the embedded system is used offline according to claim 7, characterized in that: The update module specifically includes: A read directory data assignment unit is used for reading data in a backup file of a FAT root directory area and assigning the data to the read directory data if there is a backup file of the FAT root directory area in the Snorfs file system; the FAT root directory area is the FAT root directory area in the virtual file system FAT16; A write directory data assignment unit, used for, when the root directory data in the FAT root directory area changes, the boot loader reads the root directory data and assigns the directory structure array in the root directory data to the write directory data; The read directory data saving unit is used for copying the write directory data to the read directory data if the read directory data and the write directory data are different, and saving the read directory data to a backup file in the FAT root directory area.
9. The system for browsing and updating program firmware when the embedded system is used offline according to claim 8, characterized in that: Also includes: An array traversal unit for writing directory data, used for traversing the array of the written directory data according to the directory entry data structure, and if the first byte of the directory entry structure instance is 0xE5, determining that the directory or firmware file corresponding to the directory entry structure instance is deleted; The deleting unit is used to read the name of the deleted file and delete the corresponding file in the snorfs file system in the intelligent terminal according to the deleted file name.
10. The system for browsing and updating program firmware when the embedded system is used offline according to claim 9, characterized in that: Also includes: A starting cluster variable writing unit, used for, if the Block data received by the bootloader Bootloader is in uf2 format, the bootloader Bootloader traverses the starting cluster variable of the directory entry Directoryentry structure of the array of the written directory data; If the starting cluster variable is equal to the number of the written Block data, determine whether there is a firmware file written or replaced. If so, read the file name of the directory entry structure, create and write the corresponding file into the Snorfs file system, and update the firmware file of the smart terminal at the same time; if not, return to the step "when the root directory data in the FAT root directory area changes, the boot loader Bootloader reads the root directory data and assigns the directory structure array in the root directory data to the written directory data".
Citation Information
Patent Citations
Method and system for updating fastener
CN101030146A
Optimization method for establishing FAT file system on NOR Flash
CN106844583A
Small file system with variable sectors
CN111258499A