Equipment flashing method and device, electronic equipment and storage medium
By automatically controlling the device to enter the flash mode and using the mirror file to flash, combining the losstup and partclone tools to optimize the flashing process, the existing flashing methods are solved, and the flashing efficiency and transparency are improved.
Patent Information
- Application Number
- CN202411139253.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-16
- Publication Date
- 2024-12-31
AI Technical Summary
The existing flashing method is complex, relies on the hardware port of the host computer, has a lot of manual intervention and is inefficient, especially when there is a large amount of blank data in the mirror file, it is inefficient in flashing.
After receiving the command from the host computer, the device is determined to be flashed, and the device is automatically controlled to enter the flashing mode. The image file is used to flash the machine to reduce manual intervention. The virtual disk device and backup data are avoided by using the losstup and partclone tools to avoid writing blank data .
Reduce the complexity of flashing, improve operation efficiency, reduce dependence on the upper computer, significantly enhance the transparency and controllability of the flashing process, and avoid wasting time by brushing blank data.
Smart Images

Figure CN119225749A_ABST
Abstract
Description
[0001] Technology Neighborhood
[0002] The present application belongs to the field of computer technology, and in particular, relates to a device flashing method, device, electronic device and storage medium. Background Art
[0003] Flashing refers to writing image files (including files, software, operating systems, etc.) to the storage medium of embedded devices through certain methods. In layman's terms, flashing is to reinstall the system for embedded devices. During the research and development process, repeatedly writing image files to embedded devices for debugging and verification requires a lot of flashing work.
[0004] At present, the conventional flashing scheme is to first develop the software tools required for flashing into the host computer software, then install the flashing software on the host computer, and then cooperate with power off, modify the working mode, restart and other operations to make the embedded device enter the "flashing work" mode, and finally start the flashing task in the flashing software of the host computer to write the image file to the embedded device. After the flashing is completed, adjust the power supply and modify the working mode again to restore the device to the "normal working" mode.
[0005] However, when using software installed on the host computer to flash the device, the embedded device needs to stay connected to the host computer all the time, and the host computer's hardware port is occupied by the device being flashed, making it impossible to perform other work. Summary of the invention
[0006] The present application aims to solve at least one of the technical problems existing in the prior art. To this end, the present application proposes a device flashing method, device, electronic device and storage medium to reduce the complexity of flashing and improve the efficiency of flashing operation.
[0007] In a first aspect, the present application provides a device flashing method, comprising:
[0008] In response to the flashing instruction sent by the host computer, determine whether the device to be flashed is performing the flashing work;
[0009] When the device to be flashed does not perform the flashing operation, controlling the device to be flashed to enter the flashing operation mode;
[0010] When the device to be flashed successfully enters the flashing working mode, the device to be flashed is flashed according to the image file.
[0011] According to the device flashing method of the present application, by responding to the flashing instruction sent by the host computer, it is determined whether the device to be flashed is performing the flashing work; when the device to be flashed is not performing the flashing work, the device to be flashed is controlled to enter the flashing work mode; when the device to be flashed successfully enters the flashing work mode, the device to be flashed is flashed according to the image file. The embodiment of the present application evaluates the current state of the device to be flashed when receiving the flashing instruction sent by the host computer, ensuring that the flashing process is triggered only when the device to be flashed is not performing the flashing work. When the device to be flashed is not performing the flashing work, it can automatically control the device to enter the flashing mode, reducing the need for manual intervention, and flashing using the image file in the flashing mode instead of installing the flashing program in the host computer, reducing the problem of over-reliance on the host computer in the existing flashing process, reducing the complexity of flashing, and improving the efficiency of flashing operation.
[0012] According to an embodiment of the present application, controlling the device to be flashed to enter a flashing working mode includes:
[0013] Controlling the relay to be disconnected to disconnect the power supply of the device to be flashed;
[0014] When the power supply of the device to be flashed is disconnected, the level state of the GPIO pin is adjusted to a first target state corresponding to the flashing working mode;
[0015] When the level state of the GPIO pin is in the first target state, the relay is controlled to close to power the device to be flashed, so that the mode pin of the device to be flashed is in the first target state in response to the level state of the GPIO pin, and the device to be flashed is controlled to enter the flashing working mode.
[0016] In this embodiment, the power supply of the flashing device is disconnected by disconnecting the relay. When the power supply of the flashing device is disconnected, the level is controlled by the GPIO pin to be the first target state corresponding to the flashing working mode, and a clear working mode conversion signal is provided to the device to be flashed. Then the relay is controlled to close to power the flashing device, so that the mode pin of the device to be flashed can receive the change of the GPIO pin level state, thereby controlling the device to be flashed to enter the flashing working mode, avoiding manual adjustment of the working mode of the flashing device, reducing manual intervention, and reducing the complexity of the flashing process.
[0017] According to an embodiment of the present application, flashing the device to be flashed according to the image file includes:
[0018] Use the losetup tool to virtualize the image file into a disk device;
[0019] Use the partclone tool to back up the mirror data in the disk device; the mirror data is valid data in the mirror file;
[0020] Sending a minimum system image integrated with the partclone tool to the device to be flashed, so that the device to be flashed formats a storage medium based on the minimum system;
[0021] After the device to be flashed completes formatting the storage medium, the mirror data is sent to the device to be flashed, so that the device to be flashed restores the mirror data to the storage medium based on the partclone tool in the minimum system.
[0022] In this embodiment, the image file is virtualized into a disk device through the losetup tool, so that the image file can be recognized and operated by the system like a physical disk. Since the partclone tool can recognize and process the file system structure on the disk or partition, the partclone tool can back up the valid data in the disk, avoiding the waste of a lot of time in writing blank data when there is a lot of blank data in the image file.
[0023] According to one embodiment of the present application, the method further includes:
[0024] When the flashing of the device to be flashed is completed, controlling the relay to be disconnected to cut off the power supply of the device to be flashed;
[0025] When the power supply of the device to be flashed is disconnected, adjusting the level state of the GPIO pin to a second target state corresponding to the normal working mode;
[0026] When the level state of the GPIO pin is in the second target state, the relay is controlled to close to power the device to be flashed, so that the mode pin of the device to be flashed is in the second target state in response to the level state of the GPIO pin, and the device to be flashed is controlled to enter a normal working mode.
[0027] In this embodiment, the power supply of the flashing device is disconnected by disconnecting the relay. When the power supply of the flashing device is disconnected, the level is controlled by the GPIO pin to be the second target state corresponding to the normal working mode, providing a clear working mode conversion signal for the device to be flashed, and then controlling the relay to close to power the flashing device, so that the mode pin of the flashing device can receive the change of the GPIO pin level state, thereby controlling the device to be flashed to enter the normal working mode, which can avoid the situation of manually adjusting the working mode of the flashing device, reduce manual intervention, and reduce the complexity of the flashing process.
[0028] According to one embodiment of the present application, the method further includes:
[0029] In response to the result instruction sent by the host computer, determine whether the device to be flashed is performing the flashing work;
[0030] When the device to be flashed has not performed the flashing operation, the last flashing result is fed back to the host computer.
[0031] According to one embodiment of the present application, the method further includes:
[0032] When the device to be flashed is executing the flashing operation, the current flashing progress of the device to be flashed is returned to the host computer.
[0033] In this embodiment, the scheme significantly enhances the transparency and controllability of the flashing process by providing the host computer with a monitoring and feedback mechanism for the flashing status. First, when receiving the result instruction from the host computer, by judging whether the device to be flashed is in the flashing state, when the device is not performing the flashing work, the result of the last flashing can be fed back to the host computer, providing the host computer with important historical information, which is helpful for troubleshooting or confirming the success of the last operation; further, if the device is performing the flashing work, the current flashing progress can be returned to the host computer, which enhances the interactivity of the flashing process and provides a strong guarantee for the stability and success rate of the flashing process.
[0034] In a second aspect, the present application provides a device flashing apparatus, comprising:
[0035] The judging module is used to judge whether the device to be flashed is performing the flashing work in response to the flashing instruction sent by the host computer;
[0036] A control module, used for controlling the device to be flashed to enter a flashing operation mode when the device to be flashed does not perform the flashing operation;
[0037] The flashing module is used to flash the device to be flashed according to the image file when the device to be flashed successfully enters the flashing working mode.
[0038] According to the device flashing method of the present application, by responding to the flashing instruction sent by the host computer, it is determined whether the device to be flashed is performing the flashing work; when the device to be flashed is not performing the flashing work, the device to be flashed is controlled to enter the flashing work mode; when the device to be flashed successfully enters the flashing work mode, the device to be flashed is flashed according to the image file. The embodiment of the present application evaluates the current state of the device to be flashed when receiving the flashing instruction sent by the host computer, ensuring that the flashing process is triggered only when the device to be flashed is not performing the flashing work. When the device to be flashed is not performing the flashing work, it can automatically control the device to enter the flashing mode, reducing the need for manual intervention, and flashing using the image file in the flashing mode instead of installing the flashing program in the host computer, reducing the problem of over-reliance on the host computer in the existing flashing process, reducing the complexity of flashing, and improving the efficiency of flashing operation.
[0039] In a third aspect, the present application provides an electronic device, the electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method described in the first aspect is implemented.
[0040] In a fourth aspect, the present application provides a non-transitory computer-readable storage medium storing a computer program, which, when executed by a processor, implements the device flashing method as described in the first aspect above.
[0041] In a fifth aspect, the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the device flashing method as described in the first aspect above.
[0042] The above one or more technical solutions in the embodiments of the present application have at least one of the following technical effects:
[0043] According to the device flashing method of the present application, by responding to the flashing instruction sent by the host computer, it is determined whether the device to be flashed is performing the flashing work; when the device to be flashed is not performing the flashing work, the device to be flashed is controlled to enter the flashing work mode; when the device to be flashed successfully enters the flashing work mode, the device to be flashed is flashed according to the image file. The embodiment of the present application evaluates the current state of the device to be flashed when receiving the flashing instruction sent by the host computer, ensuring that the flashing process is triggered only when the device to be flashed is not performing the flashing work. When the device to be flashed is not performing the flashing work, it can automatically control the device to enter the flashing mode, reducing the need for manual intervention, and flashing using the image file in the flashing mode instead of installing the flashing program in the host computer, reducing the problem of over-reliance on the host computer in the existing flashing process, reducing the complexity of flashing, and improving the efficiency of flashing operation.
[0044] Furthermore, in some embodiments, the power supply of the flashing device is also disconnected by disconnecting a relay. When the power supply of the flashing device is disconnected, the level is controlled by the GPIO pin to be the first target state corresponding to the flashing working mode, thereby providing a clear working mode conversion signal for the device to be flashed, and then controlling the relay to close to power the flashing device, so that the mode pin of the device to be flashed can receive the change in the GPIO pin level state, thereby controlling the device to be flashed to enter the flashing working mode, avoiding manual adjustment of the working mode of the flashing device, reducing manual intervention, and reducing the complexity of the flashing process.
[0045] Furthermore, in some embodiments, in this embodiment, the image file is virtualized into a disk device through the losetup tool, so that the image file can be recognized and operated by the system like a physical disk. Since the partclone tool can recognize and process the file system structure on the disk or partition, the partclone tool can back up the valid data in the disk, avoiding the waste of a lot of time in writing blank data when there is a lot of blank data in the image file.
[0046] Furthermore, in some embodiments, the power supply of the flashing device is also disconnected by disconnecting the relay. When the power supply of the flashing device is disconnected, the level is controlled by the GPIO pin to be the second target state corresponding to the normal working mode, thereby providing a clear working mode conversion signal for the device to be flashed, and then controlling the relay to close to power the flashing device, so that the mode pin of the flashing device can receive the change in the GPIO pin level state, thereby controlling the device to be flashed to enter the normal working mode, which can avoid manual adjustment of the working mode of the flashing device, reduce manual intervention, and reduce the complexity of the flashing process.
[0047] Furthermore, in some embodiments, by providing a monitoring and feedback mechanism for the flashing status to the host computer, the transparency and controllability of the flashing process are significantly enhanced. First, when receiving the result instruction from the host computer, by judging whether the device to be flashed is in the flashing state, when the device is not performing the flashing work, the result of the last flashing can be fed back to the host computer, providing the host computer with important historical information, which is helpful for troubleshooting or confirming the success of the last operation; further, if the device is performing the flashing work, the current flashing progress can be returned to the host computer, which enhances the interactivity of the flashing process and provides a strong guarantee for the stability and success rate of the flashing process.
[0048] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the description of the embodiments in conjunction with the following drawings, in which:
[0050] Figure 1 It is a flowchart of a device flashing method provided in an embodiment of the present application;
[0051] Figure 2 It is a schematic diagram of the connection between the flashing device and the device to be flashed provided in the embodiment of the present application;
[0052] Figure 3 It is a structural schematic diagram of a device flashing device provided in an embodiment of the present application;
[0053] Figure 4 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0054] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field belong to the scope of protection of this application.
[0055] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0056] Flashing refers to writing image files (including files, software, operating systems, etc.) to the storage media of embedded devices through certain methods. Generally speaking, flashing is often used in scenarios such as system upgrades, restoring factory settings, device repairs, developer testing, and clearing data on second-hand devices.
[0057] The traditional flashing method usually develops the software tools required for flashing into the host computer software first, then installs the flashing software on the host computer, and then cooperates with power off, changes the working mode, restarts and other operations to make the embedded device enter the "flashing work" mode, and finally starts the flashing task in the flashing software of the host computer to write the image file to the embedded device. After the flashing is completed, adjust the power supply and change the working mode again to restore the device to the "normal working" mode.
[0058] According to the traditional flashing method, when using the software installed on the host computer to flash the embedded device, the embedded device needs to be connected to the host computer all the time. The host computer hardware port is occupied by the device being flashed, and other work cannot be performed. It is dependent on the host computer installation environment, and installing the flashing software will affect the operation of the host computer. Before flashing, it is necessary to disconnect the power supply, short the pins, and reconnect the power supply to make the embedded device enter the "flashing work" mode. After flashing, it is necessary to disconnect the power supply, restore the pins, and reconnect the power supply again to restore the embedded device to the "normal working" mode. This process requires a high degree of manual participation. When there is a lot of blank data in the image file, flashing the blank data wastes a lot of time and is inefficient.
[0059] This application considers that if the flashing method can be improved, an installation-free flashing device is invented, and the flashing method is integrated into the flashing device. There is no need to install any flashing software in the host computer, thus avoiding the dependence on and influence of the host computer.
[0060] In conjunction with the accompanying drawings, the device flashing method, apparatus, electronic device and storage medium provided in the embodiments of the present application are described in detail through specific embodiments and their application scenarios.
[0061] Among them, the device flashing method can be applied to a terminal, and can be specifically executed by hardware or software in the terminal.
[0062] The terminal includes, but is not limited to, a portable communication device such as a mobile phone or tablet computer with a touch-sensitive surface (e.g., a touch screen display and / or a touch pad). It should also be understood that in some embodiments, the terminal may not be a portable communication device, but a desktop computer with a touch-sensitive surface (e.g., a touch screen display and / or a touch pad).
[0063] In the following various embodiments, a terminal including a display and a touch-sensitive surface is described. However, it should be understood that the terminal may include one or more other physical user interface devices such as a physical keyboard, a mouse and a joystick.
[0064] The device flashing method provided in the embodiment of the present application may be executed by a flashing device, which may be an electronic device or a functional module or functional entity in the electronic device that can implement the device flashing method. The electronic devices mentioned in the embodiment of the present application include but are not limited to mobile phones, tablet computers, computers, cameras, and wearable devices. The device flashing method provided in the embodiment of the present application is described below using an electronic device as an example of the execution subject.
[0065] The device flashing method, apparatus, device and storage medium provided in the embodiments of the present application are described in detail below with reference to the accompanying drawings through specific embodiments and their application scenarios.
[0066] like Figure 1 As shown, the device flashing method includes: step 110, step 120 and step 130.
[0067] Step 110: In response to the flashing instruction sent by the host computer, determine whether the device to be flashed is executing the flashing operation.
[0068] The host computer refers to a computer system that directly controls multiple slave computers in industrial automation and information systems. The slave computers usually refer to field equipment such as PLC-programmable logic controllers, single-chip microcomputers, and intelligent instruments. The device to be flashed can be a slave computer that needs to be flashed, including but not limited to mobile phones, tablet computers, computers, embedded systems, vehicle systems, wearable devices, etc. The flashing device can integrate some electronic devices, such as Ethernet cards, serial interfaces, USB interfaces, etc., and start the service of receiving computer-readable signals (including but not limited to I / O signals, Ethernet signals, storage device signals, etc.) in the program instructions. It can receive various instructions from the host computer, such as receiving flashing commands, file receiving instructions, etc., so as to realize the connection and communication between the host computer and the device to be flashed.
[0069] When flashing is needed, for example, when a flashing command is received from the host computer, the flashing device can perform some checks to determine whether the lower computer is in a state where it can be flashed. In the traditional flashing method, the device to be flashed needs to be connected to the host computer all the time, and the host computer controls the flashing process. The host computer hardware port is occupied by the device being flashed, and other work cannot be performed. During flashing, if the hardware connection is interrupted, the flashing progress will also be affected.
[0070] In the embodiment of the present application, the method for determining whether the device to be flashed is currently performing a flashing operation includes but is not limited to query instructions, communication response detection, log file checking, etc. Among them, the query instruction method is to request the device to be flashed to report the current status through a specific query instruction, and return the status information of the flashing in progress if the device to be flashed is currently performing a flashing operation. The communication response detection method refers to establishing communication with the device to be flashed. If the device to be flashed does not respond to conventional operation instructions but responds to instructions related to the flashing operation, it is highly likely that the flashing operation is currently being performed. The log file checking method refers to determining whether the flashing operation is currently being performed by checking whether there is a record of the flashing operation in the log file of the device to be flashed. In the embodiment of the present application, it is possible to determine whether the device to be flashed is currently performing a flashing operation in any manner, and the embodiment of the present application does not limit this.
[0071] In this embodiment, the flashing device can receive the image file and flashing command of the host computer through a computer readable signal. When flashing is in progress, the communication between the host computer and the flashing device can be disconnected, freeing up the signal port of the host computer and solving the problem that the physical connection interruption affects the flashing progress.
[0072] Step 120: When the device to be flashed does not perform the flashing operation, control the device to be flashed to enter the flashing operation mode.
[0073] The device to be flashed may include multiple working modes, such as normal working mode, flashing working mode, etc. Among them, the normal working mode is the standard operating state of the device, which is used for daily operation and application execution. It does not allow easy changes to system files and has high security; the flashing working mode is a special maintenance or recovery mode used to install or update the operating system firmware. In the flashing working mode, users have a higher level of access rights, allowing users and software to change system files and settings. System files need to be modified during the flashing process, so the flashing device needs to enter the flashing working mode before performing the flashing work.
[0074] The flashing working mode may include but is not limited to Bootloader mode, Fastboot mode, Recovery mode, etc. Different flashing devices may have different categories of flashing working modes according to their own characteristics. Bootloader mode is a pre-operating system startup environment that allows users to flash or update the operating system by pressing a specific combination of keys to enter this mode; Fastboot mode is usually implemented through the ADB (Android Debug Bridge) tool and is applied to Android devices; Recovery mode is another mode for recovering and updating devices in Android devices. Users can press a special key at startup to enter Recovery mode and flash a new system image from an SD card or internal storage. In the embodiment of the present application, the device to be flashed can be controlled to enter the flashing working mode in any way, and the embodiment of the present application is not limited to this.
[0075] Step 130: When the device to be flashed successfully enters the flashing working mode, the device to be flashed is flashed according to the image file.
[0076] The image file during flashing usually refers to a data file containing the operating system, firmware or software update, which is used to reinstall or upgrade the system on the device. Image files can have different formats, including but not limited to ISO files, IMG files, WIM files, DMG files, etc. These files usually include information such as the boot manager, file and directory structure, operating system configuration, hardware drivers required for system operation, shared libraries that support application operation, etc., which can meet the needs of booting and running the device.
[0077] During the flashing process, the storage partitions on the device to be flashed can be identified, such as boot, system, recovery, data, etc. Before writing the image file, you can format the specific partition on the device to be flashed to prevent interference from old data. Then write the data in the image file to the corresponding partition. For example, the system file will be written to the system partition, and the startup-related files will be written to the boot partition. In this way, the flashing process is completed. Of course, after the image file is written to the device to be flashed, some verification, testing, etc. can also be performed.
[0078] According to the device flashing method of the present application, by responding to the flashing instruction sent by the host computer, it is determined whether the device to be flashed is performing the flashing work; when the device to be flashed is not performing the flashing work, the device to be flashed is controlled to enter the flashing work mode; when the device to be flashed successfully enters the flashing work mode, the device to be flashed is flashed according to the image file. The embodiment of the present application evaluates the current state of the device to be flashed when receiving the flashing instruction sent by the host computer, ensuring that the flashing process is triggered only when the device to be flashed is not performing the flashing work. When the device to be flashed is not performing the flashing work, the device can be automatically controlled to enter the flashing mode, reducing the need for manual intervention, and flashing using the image file in the flashing mode instead of installing the flashing program in the host computer, reducing the problem of over-reliance on the host computer in the existing flashing process, reducing the complexity of flashing, and improving the efficiency of flashing operation.
[0079] In some embodiments, controlling the device to be flashed to enter the flashing working mode includes:
[0080] The control relay is disconnected to cut off the power supply of the device to be flashed;
[0081] When the power supply of the device to be flashed is disconnected, the level state of the GPIO pin is adjusted to a first target state corresponding to the flashing working mode;
[0082] When the level state of the GPIO pin is in the first target state, the control relay is closed to power the device to be flashed, so that the mode pin of the device to be flashed is in the first target state in response to the level state of the GPIO pin, and the device to be flashed is controlled to enter the flashing working mode.
[0083] GPIO (General Purpose Input / Output) is a digital signal pin on a microcontroller, integrated circuit, circuit board or computer motherboard that can be used for multi-purposes.
[0084] Pins refer to the metal contact points used by electronic components for connection. These contact points allow electronic components to form electrical connections with other components or circuit boards to transfer signals or power. When the pins of two electronic components are connected, electrical signals can be transferred. Mode pins are special input pins that can set or configure the operating mode of the integrated circuit. Mode pins allow devices to switch between different operating modes to adapt to different application scenarios or performance requirements.
[0085] A relay is an electronic device that uses the on and off of a control circuit to achieve remote control, protection, switching and automatic control of a working circuit.
[0086] An example is used to illustrate how this embodiment can control the device to be flashed to enter the flashing working mode. Figure 2 As shown, the GPIO pin is connected to the mode pin of the device to be flashed. When the level of the GPIO pin is high, it is the first target state, or when the level is low, it is the first target state. If the high level is used as the first target state, the high level corresponds to the flashing working mode, and if the low level is used as the first target state, the low level corresponds to the flashing working mode. The relay can be connected to the power supply through the power interface, and the closing state of the relay is controlled by the instruction, thereby controlling the on and off of the power supply of the flashing device. When the instruction of the working mode switching module is executed, the relay is disconnected, so that the connection between the power supply and the power interface is interrupted, and the device to be flashed cannot be powered. Adjusting the level of the GPIO pin to a low level provides a clear working mode conversion signal for the device to be flashed, and then controlling the relay to close to power the flashing device, so that the mode pin of the device to be flashed can receive the change in the level state of the GPIO pin, and the working mode pin of the device to be flashed changes to the flashing working mode corresponding to the low level of the GPIO pin.
[0087] In this embodiment, the power supply of the flashing device is disconnected by disconnecting the relay. When the power supply of the flashing device is disconnected, the level is controlled by the GPIO pin to be the first target state corresponding to the flashing working mode, providing a clear working mode conversion signal for the device to be flashed, and then controlling the relay to close to power the flashing device, so that the mode pin of the device to be flashed can receive the change of the GPIO pin level state, thereby controlling the device to be flashed to enter the flashing working mode, avoiding manual adjustment of the working mode of the flashing device, reducing manual intervention, and reducing the complexity of the flashing process.
[0088] In some embodiments, flashing the device to be flashed according to the image file includes:
[0089] Use the losetup tool to virtualize the image file into a disk device;
[0090] Use the partclone tool to back up the image data in the disk device; the image data is the valid data in the image file;
[0091] Send the minimum system image with the partclone tool integrated to the device to be flashed, so that the device to be flashed formats the storage medium based on the minimum system;
[0092] After the device to be flashed completes formatting the storage medium, the image data is sent to the device to be flashed, so that the device to be flashed restores the image data to the storage medium based on the partclone tool in the minimum system.
[0093] losetup is a command line tool used in Linux systems that can associate disk image files (such as .img, .iso or other files containing a file system) to a loop device. A loop device is a virtual block device that allows the system to use a file as a physical device. partclone is an open source Linux tool. After selecting the source partition you want to clone, you can use partclone's command line interface to perform cloning, compression, and recovery of image files. It is particularly suitable for tasks such as system backup, disk image creation, and data recovery.
[0094] A minimal system image is a stripped-down version of an operating system image that contains only the core components of the operating system. Because it only includes the most basic functions and drivers required for the operation of the operating system, it is small in size and easy to download and deploy quickly. A streamlined system requires fewer programs and services to be loaded, which can reduce the startup time, occupy less system memory and storage space, and has higher stability and security. When the operating system is damaged, the minimal system image can also be used to restore the system to a bootable state, so the minimal system image is usually used for flashing.
[0095] Valid data refers to information on the disk or partition that is actually useful to the user and the system, including but not limited to operating system boot records, configuration files, drivers, log files, software settings, backup information, user personal settings, data records stored in the database, etc. In the image file, there are usually some invalid data, such as blank data. If there is a lot of blank data in the image file, when writing the file to the device to be flashed, writing the blank data will waste a lot of time and be inefficient.
[0096] In this embodiment, valid data in the image file can be extracted. When extracting valid data, the losetup tool can be used to virtualize the image file into a disk device. By mounting the loop device, the user can browse, copy or restore valid data without directly writing to the original disk, and then use the partclone tool to back up the valid data in the virtual disk, providing the ability to restore valid data to a partition or directory, thereby realizing the extraction of valid data in the image file.
[0097] When flashing valid data, first send the minimum system image integrated with the partclone tool to the RAM of the device to be flashed to send the command to start the minimum system. The device to be flashed starts the minimum system and sends the formatting command, using the storage medium driver integrated in the minimum system to format the storage medium. After the formatting is completed, the flashing device can send the extracted valid data to the device to be flashed. After the device to be flashed receives the valid data, it uses the partclone tool integrated in the minimum system to restore each bit of valid data to the corresponding position of the storage medium.
[0098] In this embodiment, the image file is virtualized into a disk device through the losetup tool, so that the image file can be recognized and operated by the system like a physical disk. Since the partclone tool can recognize and process the file system structure on the disk or partition, the partclone tool can back up the valid data in the disk, avoiding the waste of a lot of time in writing blank data when there is a lot of blank data in the image file.
[0099] In some embodiments, the method further comprises:
[0100] When the device to be flashed is finished flashing, the control relay is disconnected to cut off the power supply of the device to be flashed;
[0101] When the power of the device to be flashed is disconnected, the level state of the GPIO pin is adjusted to a second target state corresponding to the normal working mode;
[0102] When the level state of the GPIO pin is in the second target state, the control relay is closed to power the device to be flashed, so that the mode pin of the device to be flashed is in the second target state in response to the level state of the GPIO pin, and the device to be flashed is controlled to enter the normal working mode.
[0103] In this embodiment, the second target state is a state opposite to the first target state. For example, if the first target state is at a high level, the second target state is at a low level. If the first target state is at a low level, the second target state is at a high level.
[0104] In this embodiment, if Figure 2 As shown, the relay can be disconnected to disconnect the device to be flashed from the power supply, and the level of the GPIO pin can be adjusted to provide a clear working mode conversion signal for the device to be flashed. Then the relay can be controlled to close so that the power supply can supply power to the flashing device again, so that the mode pin of the device to be flashed can receive the change of the GPIO pin level state, and the working mode pin of the device to be flashed becomes the same level state as the GPIO pin, so that the working mode of the flashing device becomes the normal working mode.
[0105] In this embodiment, the power supply of the flashing device is disconnected by disconnecting the relay. When the power supply of the flashing device is disconnected, the level is controlled by the GPIO pin to be the second target state corresponding to the normal working mode, providing a clear working mode conversion signal for the device to be flashed, and then controlling the relay to close to power the flashing device, so that the mode pin of the flashing device can receive the change in the GPIO pin level state, thereby controlling the device to be flashed to enter the normal working mode, which can avoid manual adjustment of the working mode of the flashing device, reduce manual intervention, and reduce the complexity of the flashing process.
[0106] In some embodiments, the method further comprises:
[0107] In response to the result instruction sent by the host computer, determine whether the device to be flashed is performing the flashing work;
[0108] When the device to be flashed has not performed the flashing work, the last flashing result is fed back to the host computer.
[0109] In some scenarios, the host computer needs to understand the flashing status of the device to be flashed, and can send a result instruction. After receiving the result instruction, the flashing device can determine whether the flashing device is performing the flashing work by querying instructions, checking log files, and detecting communication responses. If the flashing device is not performing the flashing work, the flashing device can obtain the result of the last flashing and feed it back to the host computer by querying log files, checking firmware versions, etc.
[0110] In some embodiments, the method further comprises:
[0111] When the device to be flashed is performing the flashing work, the current flashing progress of the device to be flashed is returned to the host computer.
[0112] If it is found that the device to be flashed is performing the flashing work, the current flashing progress of the device to be flashed can be obtained, for example, by reading and parsing the log file generated during the flashing process to obtain the flashing progress, and then the current flashing progress is returned to the host computer.
[0113] In this embodiment, by providing the host computer with a monitoring and feedback mechanism for the flashing status, the transparency and controllability of the flashing process are significantly enhanced. First, when receiving the result instruction from the host computer, by judging whether the device to be flashed is in the flashing state, when the device is not performing the flashing work, the result of the last flashing can be fed back to the host computer, providing the host computer with important historical information, which is helpful for troubleshooting or confirming the success of the last operation; further, if the device is performing the flashing work, the current flashing progress can be returned to the host computer, which enhances the interactivity of the flashing process and provides a strong guarantee for the stability and success rate of the flashing process.
[0114] The device flashing method provided in the embodiment of the present application can be executed by a device flashing apparatus. In the embodiment of the present application, the device flashing apparatus provided in the embodiment of the present application is described by taking the device flashing apparatus executing the device flashing method as an example.
[0115] The embodiment of the present application also provides a device flashing device.
[0116] like Figure 3 As shown, the device flashing device includes:
[0117] The judging module 310 is used to judge whether the device to be flashed is performing the flashing operation in response to the flashing instruction sent by the host computer;
[0118] The control module 320 is used to control the device to be flashed to enter the flashing working mode when the device to be flashed does not perform the flashing work;
[0119] The flashing module 330 is used to flash the device to be flashed according to the image file when the device to be flashed successfully enters the flashing working mode.
[0120] According to the device flashing device of the present application, by responding to the flashing instruction sent by the host computer, it is determined whether the device to be flashed is performing the flashing work; when the device to be flashed is not performing the flashing work, the device to be flashed is controlled to enter the flashing work mode; when the device to be flashed successfully enters the flashing work mode, the device to be flashed is flashed according to the image file. The embodiment of the present application evaluates the current state of the device to be flashed when receiving the flashing instruction sent by the host computer, ensuring that the flashing process is triggered only when the device to be flashed is not performing the flashing work. When the device to be flashed is not performing the flashing work, it can automatically control the device to enter the flashing mode, reducing the need for manual intervention, and flashing using the image file in the flashing mode instead of installing the flashing program in the host computer, reducing the problem of over-reliance on the host computer in the existing flashing process, reducing the complexity of flashing, and improving the efficiency of flashing operation.
[0121] In some embodiments, the determination module 310 is further configured to:
[0122] In response to the result instruction sent by the host computer, determine whether the device to be flashed is performing the flashing work;
[0123] When the device to be flashed has not performed the flashing work, the last flashing result is fed back to the host computer.
[0124] In some embodiments, the determination module 310 is further configured to:
[0125] When the device to be flashed is performing the flashing work, the current flashing progress of the device to be flashed is returned to the host computer.
[0126] In some embodiments, the control module 320 is further configured to:
[0127] The control relay is disconnected to cut off the power supply of the device to be flashed;
[0128] When the power supply of the device to be flashed is disconnected, the level state of the GPIO pin is adjusted to a first target state corresponding to the flashing working mode;
[0129] When the level state of the GPIO pin is in the second target state, the control relay is closed to power the device to be flashed, so that the mode pin of the device to be flashed responds to the first target state of the GPIO pin, and the device to be flashed enters the flashing working mode.
[0130] In some embodiments, the control module 320 is further configured to:
[0131] When the device to be flashed is finished flashing, the control relay is disconnected to cut off the power supply of the device to be flashed;
[0132] When the power supply of the device to be flashed is disconnected, the level state of the GPIO pin is adjusted to a second target state corresponding to the normal working mode;
[0133] When the level state of the GPIO pin is in the second target state, the relay is controlled to close to power the device to be flashed, so that the mode pin of the device to be flashed responds to the second target state of the GPIO pin, and the device to be flashed enters the normal working mode.
[0134] In some embodiments, the flash module 330 is further used to:
[0135] Use the losetup tool to virtualize the image file into a disk device;
[0136] Use the partclone tool to back up the image data in the disk device; the image data is the valid data in the image file;
[0137] Send the minimum system image with the partclone tool integrated to the device to be flashed, so that the device to be flashed formats the storage medium based on the minimum system;
[0138] After the device to be flashed completes formatting the storage medium, the image data is sent to the device to be flashed, so that the device to be flashed restores the image data to the storage medium based on the partclone tool in the minimum system.
[0139] In some embodiments, the control module 320 is further configured to:
[0140] When the level state of the GPIO pin is in the second target state, the control relay is closed to power the device to be flashed, so that the mode pin of the device to be flashed is in the second target state in response to the level state of the GPIO pin, and the device to be flashed is controlled to enter the normal working mode.
[0141] In some embodiments, the device flashing apparatus further includes:
[0142] The feedback module is used to respond to the result instruction sent by the host computer to determine whether the device to be flashed is performing the flashing work; if the device to be flashed is not performing the flashing work, the last flashing result is fed back to the host computer.
[0143] In some embodiments, the feedback module is further configured to:
[0144] When the device to be flashed is performing the flashing work, the current flashing progress of the device to be flashed is returned to the host computer.
[0145] The device flashing device in the embodiment of the present application can be an electronic device, or a component in the electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal, or it can be other devices other than a terminal. Exemplarily, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, a car-mounted electronic device, a mobile Internet device (Mobile Internet Device, MID), an augmented reality (augmented reality, AR) / virtual reality (virtual reality, VR) device, a robot, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc. It can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., and the embodiment of the present application is not specifically limited.
[0146] The device flashing device in the embodiment of the present application may be a device having an operating system. The operating system may be a Microsoft (Windows) operating system, an Android (Android) operating system, an IOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0147] In some embodiments, Figure 4As shown, an embodiment of the present application also provides an electronic device 400, including a processor 401, a memory 402, and a computer program stored in the memory 402 and executable on the processor 401. When the program is executed by the processor 401, each process of the embodiment of the method for identifying potential users of the above-mentioned target product is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0148] It should be noted that the electronic devices in the embodiments of the present application include the above-mentioned mobile electronic devices and non-mobile electronic devices.
[0149] An embodiment of the present application also provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the various processes of the above-mentioned device flashing method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0150] The processor is the processor in the electronic device in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.
[0151] An embodiment of the present application also provides a computer program product, including a computer program, which implements the above-mentioned device flashing method when executed by a processor.
[0152] The processor is the processor in the electronic device in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.
[0153] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, the communication interface and the processor are coupled, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned device flashing method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0154] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0155] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0156] Through the description of the above implementation methods, technicians in this field can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course, by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, disk, CD), including a number of instructions for a terminal (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0157] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the scope of protection of the purpose of the present application and the claims, all of which are within the protection of the present application.
[0158] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "illustrative embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials, or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0159] Although the embodiments of the present application have been shown and described, those skilled in the art will appreciate that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present application, and that the scope of the present application is defined by the claims and their equivalents.
Claims
1. A device flashing method, characterized in that: include: In response to the flashing instruction sent by the host computer, determine whether the device to be flashed is performing the flashing work; When the device to be flashed does not perform the flashing operation, controlling the device to be flashed to enter the flashing operation mode; When the device to be flashed successfully enters the flashing working mode, the device to be flashed is flashed according to the image file.
2. The method according to claim 1, characterized in that The controlling the device to be flashed to enter the flashing working mode includes: Controlling the relay to be disconnected to disconnect the power supply of the device to be flashed; When the power supply of the device to be flashed is disconnected, the level state of the GPIO pin is adjusted to a first target state corresponding to the flashing working mode; When the level state of the GPIO pin is in the first target state, the relay is controlled to close to power the device to be flashed, so that the mode pin of the device to be flashed is in the first target state in response to the level state of the GPIO pin, and the device to be flashed is controlled to enter the flashing working mode.
3. The method according to claim 1, characterized in that The flashing of the device to be flashed according to the image file includes: Use the losetup tool to virtualize the image file into a disk device; Use the partclone tool to back up the mirror data in the disk device; the mirror data is valid data in the mirror file; Sending a minimum system image integrated with the partclone tool to the device to be flashed, so that the device to be flashed formats a storage medium based on the minimum system; After the device to be flashed completes formatting the storage medium, the mirror data is sent to the device to be flashed, so that the device to be flashed restores the mirror data to the storage medium based on the partclone tool in the minimum system.
4. The method according to claim 1, characterized in that: The method further comprises: When the flashing of the device to be flashed is completed, controlling the relay to be disconnected to cut off the power supply of the device to be flashed; When the power supply of the device to be flashed is disconnected, adjusting the level state of the GPIO pin to a second target state corresponding to the normal working mode; When the level state of the GPIO pin is in the first target state, the relay is controlled to close to power the device to be flashed, so that the mode pin of the device to be flashed is in the second target state in response to the level state of the GPIO pin, and the device to be flashed is controlled to enter a normal working mode.
5. The method according to claim 1, characterized in that The method further comprises: In response to the result instruction sent by the host computer, determine whether the device to be flashed is performing the flashing work; When the device to be flashed has not performed the flashing operation, the last flashing result is fed back to the host computer.
6. The method according to claim 1, characterized in that The method further comprises: When the device to be flashed is executing the flashing operation, the current flashing progress of the device to be flashed is returned to the host computer.
7. A device for flashing a device, characterized in that: include: The judging module is used to judge whether the device to be flashed is performing the flashing work in response to the flashing instruction sent by the host computer; A control module, used for controlling the device to be flashed to enter a flashing operation mode when the device to be flashed does not perform the flashing operation; The flashing module is used to flash the device to be flashed according to the image file when the device to be flashed successfully enters the flashing working mode.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 6 is implemented.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
