Printer equipment-oriented firmware multi-sector intelligent guiding method and system
The firmware download control channel is established through the MCU hardware circuit, the startup key signal is monitored and the header file characteristics are analyzed, and the I/O port status is dynamically adjusted, which solves the problem of failed printer firmware upgrade and achieves the stability and efficiency improvement of the device.
Patent Information
- Application Number
- CN202510361814.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-26
- Publication Date
- 2025-07-08
AI Technical Summary
The firmware upgrade process of traditional printers is easily disturbed and fails, causing the device to fail to start or work normally, and the operation is complex, which affects the normal use of the device.
The firmware download control channel is established through the hardware circuit of the microcontroller unit MCU, the power-on key trigger signal is monitored to distinguish the startup mode, analyze the binary header file format characteristics, and dynamically adjust the I/O port level status to control the firmware data flow directionally write to the designated sector of the Flash memory.
Improves the stability of firmware upgrades and the efficiency of printer equipment, avoiding the risk of complete unavailability of the equipment due to failure of firmware upgrades.
Smart Images

Figure CN120276776A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of printers, and particularly to a multi-sector intelligent boot method and system for printer device firmware. Background Art
[0002] In the traditional firmware upgrade process, the firmware file transfer, download, and writing processes are vulnerable to interference. For example, unstable network, external interrupts (such as power outage, improper operation, etc.), or damaged downloaded data packets can all lead to upgrade failure. If the upgrade fails, the device may be in an incomplete firmware state, resulting in the device being unable to start or work properly. During the upgrade process, the printer or other devices may be temporarily unavailable. Especially when the device is restarted before the upgrade is completed, it may cause the device to be unable to start, and even unable to recover without a backup. Traditional firmware updates rely on external tools, specialized upgrade programs, or complex interfaces (such as USB, serial ports, etc.), increasing the operation complexity, prone to improper user operations, increasing the probability of firmware upgrade failure, and thus affecting the normal use of printer devices.
[0003] In summary, there are technical problems in the prior art that the upgrade device may occur during the printer firmware upgrade, further affecting the normal use of printer devices. Summary of the Invention
[0004] The purpose of this application is to provide a multi-sector intelligent boot method and system for printer device firmware to solve the technical problem in the prior art that the upgrade device may occur during the printer firmware upgrade, further affecting the normal use of the device.
[0005] In view of the above problems, this application provides a multi-sector intelligent boot method and system for printer device firmware.
[0006] In the first aspect, this application provides a multi-sector intelligent boot method for printer device firmware. The multi-sector intelligent boot method for printer device firmware is implemented through a multi-sector intelligent boot system for printer device firmware. Among them, the multi-sector intelligent boot method for printer device firmware includes: establishing a firmware download control channel through the hardware circuit of the microcontroller unit (MCU); monitoring the power-on key trigger signal connected to the MCU, and distinguishing the normal startup mode and the download mode according to the key press duration; in the download mode, parsing the binary header file format features of the firmware to be written, and identifying the target sector address; controlling the firmware data stream to be directionally written into the specified sector of the Flash memory by dynamically adjusting the I / O port level state of the MCU.
[0007] Optionally, the port configuration of the MCU includes setting the PA0 port as an external interrupt input port, configuring the PA1 port as a general-purpose output port, setting the PA2 port as a clock interface, setting the PA5 and PA6 ports as LED drive ports, and configuring the PA7 port as a wake-up function pin.
[0008] Optionally, when the VDD power is turned on, the PA6 port outputs a high level; detect the interrupt trigger signal of the PA0 port, and if no falling edge is detected, jump to the BootLoader normal startup process.
[0009] Optionally, when the PA0 port remains low for more than a preset time limit, the PA7 port outputs a high level to start the download mode.
[0010] Optionally, extract the header identification code generated by firmware compilation, match the preset sector allocation rule library; based on the header identification code, determine the starting address and offset according to the header file feature differences between BootLoader and Kernel; perform real-time data verification during the writing process, and after the PA5 port flashes 3 times, enter the standby state.
[0011] Optionally, in the normal startup mode, the PA5 port remains constantly on, and the PA6 port displays the operating state in a breathing light mode; in the download mode, the PA5 and PA6 ports flash alternately, and the flashing frequency is positively correlated with the data transfer rate.
[0012] Optionally, the full-brightness current of the VSS power-on LED is 155 mA, and the ready current after VSS power-on is 108.7 mA.
[0013] Optionally, maintain a base current of 26.3 mA in the VSS standby state to keep the MCU core module running.
[0014] Optionally, verify the firmware digital signature during the boot process, and if the verification fails, roll back to the previous available version; when the write fails three times in a row, lock the programming function of the MCU and trigger the hardware self-check process.
[0015] In a second aspect, the present application also provides a firmware multi-sector intelligent boot system for a printer device, which is used to execute the firmware multi-sector intelligent boot method for a printer device as described in the first aspect. Among them, the firmware multi-sector intelligent boot system for a printer device includes: a channel establishment module, which is used to establish a firmware download control channel through the hardware circuit of the microcontroller unit (MCU); a mode discrimination module, which is used to monitor the power-on key trigger signal connected to the MCU and distinguish the normal startup mode and the download mode according to the key press duration; an address recognition module, which is used to parse the binary header file format characteristics of the firmware to be written and recognize the target sector address in the download mode; a status adjustment module, which is used to control the directional writing of the firmware data stream to the specified sector of the Flash memory by dynamically adjusting the I / O port level status of the MCU.
[0016] One or more technical solutions provided in the present application have at least the following beneficial effects:
[0017] Establish a firmware download control channel through the hardware circuit of the microcontroller unit (MCU); monitor the power-on key trigger signal connected to the MCU and distinguish the normal startup mode and the download mode according to the key press duration; in the download mode, parse the binary header file format characteristics of the firmware to be written and recognize the target sector address; control the directional writing of the firmware data stream to the specified sector of the Flash memory by dynamically adjusting the I / O port level status of the MCU. That is to say, by controlling the download process through the MCU hardware, when the firmware upgrade fails or is interrupted, the device can still continue to work with the original firmware, avoiding the risk that the device becomes completely unavailable due to the failure of the firmware upgrade, and greatly improving the stability of the firmware upgrade and the usage efficiency of the printer device.
[0018] The above description is only an overview of the technical solutions of the present application. In order to be able to understand the technical means of the present application more clearly, it can be implemented according to the content of the specification. And in order to make the above and other purposes, features and advantages of the present application more obvious and understandable, the following specifically gives the specific implementation manners of the present application. It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present application, nor is it used to limit the scope of the present application. Other features of the present application will become easily understandable through the following description. Description of the Drawings
[0019] In order to more clearly illustrate the technical solutions in the present application or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings described below are only exemplary, and for those of ordinary skill in the art, other drawings can be obtained according to the provided drawings without creative efforts.
[0020] Figure 1This is a schematic flowchart of the firmware multi-sector intelligent boot method for printer devices in this application.
[0021] Figure 2 This is a schematic structural diagram of the firmware multi-sector intelligent boot system for printer devices in this application.
[0022] Explanation of reference numerals: Channel establishment module 11, Mode differentiation module 12, Address recognition module 13, Status adjustment module 14. Detailed implementation manners
[0023] By providing a firmware multi-sector intelligent boot method and system for printer devices, this application solves the technical problem in the prior art that during printer firmware upgrade, there may be upgraded devices, which further affects the normal use of the devices. By controlling the download process through the MCU hardware, when the upgrade fails or is interrupted, the device can still continue to work with the original firmware, avoiding the risk of the device being completely unavailable due to firmware upgrade failure, and greatly improving the stability of firmware upgrade and the usage efficiency of printer devices.
[0024] Next, the technical solutions in this application will be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, rather than all the embodiments of this application. It should be understood that this application is not limited by the example embodiments described here. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope of protection of this application. Additionally, it should be noted that for the sake of description, only the parts related to this application are shown in the accompanying drawings rather than all of them.
[0025] Embodiment 1, please refer to the attached Figure 1 , this application provides a firmware multi-sector intelligent boot method for printer devices. Among them, the firmware multi-sector intelligent boot method for printer devices is executed by a firmware multi-sector intelligent boot system for printer devices. The firmware multi-sector intelligent boot method for printer devices specifically includes the following steps:
[0026] S100: Establish a firmware download control channel through the hardware circuit of the microcontroller unit (MCU).
[0027] Specifically, the microcontroller unit (MCU) refers to an embedded system integrating multiple functions such as a processor, memory, and I / O ports. It is widely used in intelligent devices and is responsible for controlling and managing various operations of the device. The hardware circuit is composed of electronic components (such as resistors, capacitors, diodes, transistors, etc.) and the connections between them. The hardware circuit realizes the processing, transmission, and control of physical signals. The microcontroller exchanges data with external devices (such as sensors, actuators, displays, etc.) through the hardware circuit.
[0028] The MCU needs to be connected to other peripherals (such as the power-on button, LED indicator, Flash memory, etc.) through circuits, ensuring that the MCU can receive the trigger signal for firmware download and control data transmission. It is connected to devices such as the power-on button, LED lights, and Flash memory through I / O ports. For example, the PA0 port can be connected to the power-on button, the PA1 port is used to control the state of the LED light, the PA2 port provides a clock signal, the PA5 and PA6 ports control the on / off state of the LED, and the PA7 port can be used to trigger the wake-up function.
[0029] The firmware download control channel refers to the communication path used to transfer the firmware program from an external device to a target system (such as a printer), ensuring that the firmware can be smoothly transferred from the download source (such as a PC or other device) to the memory of the target device. The establishment of the control channel involves the configuration of hardware interfaces (such as serial ports, USB, I2C, etc.) and the setting of protocols (such as data verification, transmission rate, delay, etc.).
[0030] S200: Monitor the trigger signal of the power-on button connected to the MCU, and distinguish between the normal startup mode and the download mode according to the button press duration.
[0031] Specifically, the power-on button trigger signal refers to the signal that the user triggers the startup of the printer device by pressing the power-on button (usually a physical button), which is detected by the microcontroller unit (MCU). The MCU decides subsequent operations according to the state of the button (pressed or released). For example, long pressing the power-on button may trigger a special startup mode (such as the firmware download mode), while short pressing triggers the normal startup mode.
[0032] The button press duration refers to the length of time the user presses the power-on button. This duration is used to distinguish different operation modes. For example, short pressing indicates normal startup, while long pressing indicates entering the firmware download mode. The MCU judges the user's intention by detecting the button press duration and thus selects the appropriate mode for operation.
[0033] The normal startup mode is the default startup mode of the device, usually used to load and execute the device's operating system or main program. When the MCU detects that the button is short pressed, it enters this mode. The download mode refers to a special startup mode that needs to be entered in some cases (such as firmware update), allowing the firmware to be downloaded from an external device (such as a PC) to the device. The MCU enters the download mode by detecting whether the power-on button is long pressed.
[0034] A certain port of the MCU (such as PA0) is connected to the power-on button. Usually, the power-on button is a mechanical button. When pressed, the input port of the MCU will read a low-level signal (i.e., the pressed state), and when released, it will read a high-level signal (i.e., the released state). The power-on button is connected to the PA0 port of the MCU through a circuit, and the MCU determines whether the button is pressed by monitoring the level change of this port.
[0035] The MCU detects the duration of the button press through a timer or a delay function. When the MCU detects that the PA0 port changes from high level to low level, it means the power-on button is pressed. At this time, the MCU starts timing. The MCU monitors the duration of the button press. According to the design requirements, assume that the short press time is 1 second and the long press time is 5 seconds. If the duration of the button press is less than the set time threshold (such as 1 second), the MCU enters the normal startup mode. If the duration of the button press is greater than the set threshold (such as 5 seconds), the MCU enters the firmware download mode.
[0036] Based on the judgment result of the button press duration, the MCU will enter different operation modes: If the button press duration is less than 1 second, the MCU will skip the firmware download process and directly execute the normal startup process; if the button press duration exceeds 3 seconds, the MCU will switch to the firmware download mode and wait for an external device (such as a PC) to transfer firmware data. The MCU will parse the received firmware, identify and write it to the appropriate sector of the Flash memory.
[0037] To accurately judge the button press duration, the MCU can use a hardware timer or a software delay function for time management. Hardware timers are usually more accurate than software delays. Therefore, in applications with high real-time requirements, hardware timers are more commonly used for such tasks. The MCU can enable the timer to start timing when the power-on button is pressed. When the timer reaches the set time threshold, the MCU can trigger different mode switches. By judging the button press duration to distinguish between the normal startup mode and the download mode, users only need to perform a simple button operation to select the startup mode without complex configuration or operation steps.
[0038] S300: In the download mode, parse the binary header file format characteristics of the firmware to be written and identify the target sector address.
[0039] Specifically, when the device enters the download mode, the MCU first receives firmware data from an external device (such as a PC). The received firmware file usually consists of two parts: a header file and a data section. The MCU needs to extract relevant metadata information from the header file of the firmware, especially the target sector address. There is usually a specific header structure at the beginning of the firmware file, which may be a data block of fixed length containing key information of the firmware (such as start address, size, version, etc.). The MCU needs to read and parse this header. In the firmware header file, there are usually fields dedicated to indicating the start address of the firmware (such as 0x08008000). The MCU needs to extract the value of this field and use it as the target sector address for subsequent data writing.
[0040] The firmware binary header file is a part of the firmware file, usually located at the beginning of the firmware file, containing some metadata about the firmware, such as the type of the firmware, version number, size, target storage address, etc. By parsing the information in these header files, it is determined how to correctly process and store the firmware data. The format characteristics of the firmware refer to the structured data in the firmware file header used to describe the layout and storage requirements of the firmware, including the start address of the firmware, the length of the firmware, the type or version information of the firmware, etc.
[0041] After the MCU extracts the start address from the firmware header file, it then needs to calculate the target sector address. Flash memory is usually divided into multiple sectors (each sector has a fixed size, such as 16KB, 64KB, etc.), so the start address actually refers to a specific sector location. The target sector address refers to the location where the firmware data should be written in the storage device (such as Flash memory). Each memory is usually divided into multiple sectors, and each sector has a unique address. The firmware will be written to the corresponding sector according to the start address information in the header file.
[0042] The firmware header file may also contain the firmware type (such as BootLoader, Kernel, file system, etc.) and version information, which helps the MCU identify different types of firmware during the firmware update process and ensures that each firmware is written to the correct location. After the MCU determines the target sector address, it will direct the firmware data flow to the corresponding storage location according to the parsed sector address. The MCU writes the data to the Flash memory through SPI, I2C or directly through the Flash programming interface. By accurately identifying the target sector address, the MCU ensures that each firmware module is written to the correct Flash sector, avoiding overwriting important data or firmware.
[0043] S400: Control the directional writing of the firmware data flow to the specified sector of the Flash memory by dynamically adjusting the level state of the I / O ports of the MCU.
[0044] Specifically, an MCU usually has multiple I / O ports, which are used to interact with external hardware devices. The I / O ports can be configured as input or output to receive or send signals. For example, some ports can be used to receive key signals, connect to external sensors, or control other devices (such as LED lights, motors, etc.). During the firmware download process, the level status of the I / O ports can be used to control the direction and behavior of the data stream.
[0045] The level status of the I / O port refers to the voltage value on the port, which can usually be a low level (0V) or a high level (usually 3.3V or 5V). By dynamically adjusting the level status of the I / O ports, the MCU can control the behavior of different external devices. For example, the MCU can control the write operation of the memory or start different hardware functions by outputting high or low level signals.
[0046] During the firmware download process, the MCU configures multiple I / O ports for specific functions to control the direction of the data stream and the write operation. Common I / O port configurations are as follows: The PA0 port is usually configured as an external interrupt input port to receive the trigger signal of the power-on key; the PA1 port can be configured as an output port to control the direction of data transmission; the PA2 port is a clock interface to control the transmission timing of data; the PA5 and PA6 ports are LED drive ports to display status information; the PA7 port is a wake-up function pin to wake up the device into the download mode at a specific moment. By adjusting the level status of these I / O ports, the MCU can control the direction of the data stream, so that the data can be correctly transmitted and written to the target sector of the Flash memory.
[0047] The MCU initializes the communication interfaces with external devices (such as USB, SPI, I2C, etc.) and prepares to receive the firmware data stream. By setting the I / O port (such as PA1) to the output mode, the MCU can control the data flow direction. For example, the MCU can set the PA1 port to a high level, indicating that the firmware data flows to the Flash memory. The MCU reads the firmware data from the received stream and writes the data to a specific sector of the Flash memory by dynamically adjusting the level status of the I / O ports. For example, the MCU can write data to a specified address in the Flash through the SPI interface and synchronize the timing by controlling PA2 (the clock interface) to ensure the correct writing of the data.
[0048] During the firmware writing process, the MCU dynamically adjusts the level status of the I / O ports according to actual needs. The MCU controls the level status of the PA1 port to indicate the start, pause, or end of the firmware data stream. The MCU synchronizes the timing of data transmission through the clock signal of the PA2 port. During the data flow, the clock signal ensures that each data byte is written into the Flash in the correct order. The MCU can also control the status of the LED lights through the PA5 and PA6 ports to display the current status of the device.
[0049] Directed writing of the firmware data stream into the Flash memory means that through appropriate control, the firmware data is written into each sector of the Flash memory in a specific order and at a specific target address. During the firmware update process, the MCU needs to import the firmware data stream from an external device (such as a computer or other peripheral) through a certain communication interface (such as SPI, I2C, or USB), and write this data into the specified sector of the Flash memory. The Flash memory is composed of multiple sectors, and each sector has a fixed size (for example, 64KB or 128KB). A sector is the smallest erasable unit in the Flash memory. When writing data, the MCU needs to store the data in a sector-aligned manner in the Flash to ensure the correctness of the data.
[0050] The MCU directs the firmware data stream to be written into the specified sector of the Flash memory by dynamically controlling the direction of the data stream. During the writing process, the MCU determines the starting address for data writing according to the target address information in the firmware header file. For example, the firmware header file may indicate that the target address is 0x08008000, and the MCU writes the data into the 128th sector of the Flash based on this information.
[0051] If the firmware file is large, the MCU may divide the firmware into multiple data blocks for writing. Each block is sector-aligned and written one by one. After writing each block, the MCU adjusts the signal through the I / O port to prepare for writing the next block. After writing is completed, the MCU performs data verification (such as CRC verification) to ensure that the written data has no errors. If the verification fails, the MCU will trigger a rewrite or roll back to the previous firmware version.
[0052] Through the control of the level status of the I / O ports, the MCU can precisely control the direction of the data stream, ensuring that the firmware data is accurately written into the specified sector of the Flash. Through automated data stream control and sector writing, the firmware update process becomes more convenient and efficient, and users can complete the update without manual intervention.
[0053] Furthermore, the present application S100 includes:
[0054] Synchronize the operation timing using the clock interface of the MCU; the port configuration of the MCU includes setting the PA0 port as an external interrupt input port, configuring the PA1 port as a general-purpose output port, the PA2 port as a clock interface, setting the PA5 and PA6 ports as LED drive ports, and configuring the PA7 port as a wake-up function pin.
[0055] Specifically, during the firmware download process, the clock interface of the MCU is used to synchronize the operation timing to ensure the accurate transmission and storage of data. The clock signal of the MCU (usually a continuous pulse signal) is used to control the transmission process of the firmware data stream, thereby ensuring that the data writing process is synchronized with the clock pulse. The combined configuration of multiple ports of the MCU completes the firmware update operation through precise signal control. The MCU has multiple I / O (input / output) ports, and each port can be configured with different functions to meet different application requirements. The ports can be input ports, output ports, clock interfaces, external interrupt inputs, etc., and each configuration interacts with specific hardware functions or signals.
[0056] The PA0 port is configured as an external interrupt input port, enabling the MCU to monitor the pressing signal of the power-on button. When the power-on button is pressed, the PA0 port will receive a level change signal (usually triggered by a falling edge), and the MCU immediately responds to this signal through the interrupt mechanism and decides whether to enter the firmware download mode. Through this configuration, the MCU can quickly identify external events and respond.
[0057] The PA1 port, as a general-purpose output port, is responsible for controlling the status of other external devices. For example, the PA1 port can control the status of the connected LED. When the firmware download is in progress, the PA1 port will output a high level to turn on the LED, indicating that the device is in the download state. During this process, the MCU transmits control signals or data to external devices through the PA1 port. The PA2 port, as a clock interface, provides a clock signal to synchronize data transmission. During the process of transmitting firmware data from an external device to the MCU and writing it into the Flash memory, the MCU needs to ensure that each data byte is accurately written in sequence. In this timing synchronization process, the clock signal of the PA2 port provides a time reference for data transmission.
[0058] The PA5 and PA6 ports are configured as LED drive ports to display the operating status of the device. During the firmware download process, the MCU can control the level status of these two ports to make the connected LED blink or stay on, providing visual feedback to the user. For example, when the firmware is being written, the LED on the PA5 port may blink, indicating that data is being transmitted; while the LED on the PA6 port can display the completion status of the firmware writing or stay on in the standby mode.
[0059] The PA7 port is configured as a wake-up function pin. When the device needs to be woken up or restarted, the MCU can send a wake-up signal through the PA7 port, thereby starting the firmware download process or restoring the device to the normal working state. In this way, the MCU can flexibly control the various working modes of the device.
[0060] Furthermore, the S200 of the present application includes:
[0061] When the VDD power supply is powered on, the PA6 port outputs a high level; detect the interrupt trigger signal of the PA0 port, and if a falling edge is not detected, jump to the BootLoader normal startup process.
[0062] Specifically, VDD is a port or power supply in the circuit that provides positive voltage for the device, usually providing power for the MCU (Microcontroller Unit) or other components. In most cases, VDD is a stable positive voltage source, usually 3.3V or 5V, depending on the design of the MCU. When the VDD power supply is powered on, the PA6 port outputs a high-level signal, which is usually used to indicate that the device has been powered on normally and can enter the subsequent working process. At this stage, the output state of the PA6 port helps in the status monitoring of the device. For example, the user can use an LED to indicate that the device is ready for operation.
[0063] The MCU starts to detect the external interrupt trigger signal of the PA0 port. The PA0 port is configured as an external interrupt input port to monitor the power-on button or other external signals. If the PA0 port detects a falling-edge signal (i.e., the power-on button is pressed and released), the MCU will interrupt the current execution process and perform specific operations. A falling-edge trigger refers to the process where the signal jumps from a high level to a low level. In the interrupt system of the MCU, a falling-edge trigger signal usually indicates the occurrence of an action of an external device or button. The MCU decides whether to enter a specific processing process by detecting the falling edge. The detection of the falling-edge signal means that the user may want to enter the firmware download mode, so the MCU will trigger the subsequent firmware loading process based on this signal.
[0064] If the PA0 port does not detect a falling-edge signal (i.e., the power-on button is not pressed), the MCU will not enter the firmware download mode but will directly jump to the BootLoader normal startup process. As the startup program of the embedded device, BootLoader will boot the printer device to start the operating system or the main firmware to complete the normal startup process of the device.
[0065] The MCU can intelligently determine whether to enter the firmware download mode based on the pressing situation of the power-on button. When the power-on button is pressed, the MCU will trigger an interrupt and enter the firmware update process. Without pressing the power-on button, the MCU will directly enter the BootLoader normal startup process, improving the intelligence and flexibility of the device, ensuring that the device can automatically switch between normal startup and firmware update, and being able to precisely control the loading and updating process of the firmware, thus avoiding errors or abnormal situations during the device startup process.
[0066] Furthermore, the present application further includes the following steps:
[0067] When the PA0 port remains at a low level for more than a preset time limit, the PA7 port outputs a high level to start the download mode.
[0068] Specifically, the MCU needs to monitor the level status of the PA0 port to determine whether the user wishes to enter the download mode. When the PA0 port receives a low-level signal, the MCU knows that the power-on button or other trigger has been pressed. To avoid false triggering, the MCU needs to confirm whether the low-level signal of the PA0 port has lasted for more than the preset time limit. For example, set a time threshold (such as 5 seconds), and only when the low level of the PA0 port lasts for more than this threshold is it considered that the user intends to enter the download mode. Once the low level of the PA0 port lasts for more than the predetermined time limit, the MCU will output a high-level signal through the PA7 port to start the download mode. The high-level signal of the PA7 port may drive the connected hardware or change the working mode of the device to enter the firmware download process. In the download mode, the device can receive new firmware and write it into the Flash memory.
[0069] The continuous low level refers to the low-level signal received by the PA0 port remaining for more than a specific time threshold. For example, the MCU can be set to trigger subsequent actions only when the low-level signal detected at the PA0 port lasts for more than a few hundred milliseconds or a few seconds. This setting is often used to ensure that the user's input behavior is intentional (such as long pressing the power-on button) rather than a short-term misoperation.
[0070] After the download mode is started, the device begins to establish a communication channel with an external device (such as a firmware update tool or a computer) to receive new firmware data. Through techniques such as firmware header file parsing and sector allocation, the firmware is written into the specified storage area. The download mode refers to a special mode that the device enters during the firmware update process. In this mode, the device allows an external system to load new firmware code (such as an operating system, Kernel, etc.) into the device's memory to update its functions or fix potential problems. The download mode is generally triggered by a specific hardware signal or a button.
[0071] By introducing the judgment of the time threshold, it is ensured that the download mode will only be triggered when the user has a clear intention, avoiding the unnecessary start of the download mode caused by accidental key presses or short presses of the key, and improving the accuracy and stability of the firmware update process.
[0072] Furthermore, the present application further includes the following steps:
[0073] Extract the header identification code generated by firmware compilation and match the preset sector allocation rule library; based on the header identification code, determine the starting address and offset according to the header file feature differences of BootLoader and Kernel; during the writing process, verify the data in real time, and enter the standby state after the PA5 port flashes 3 times.
[0074] Specifically, in the binary file of the firmware, there is usually a header area for storing important information such as the version information, type, size, entry address, etc. of the firmware, which is called the header identification code and helps to identify and verify the validity of the firmware file. For example, the header identification code can include information such as the version number, identifier of the firmware, and the target sector where the firmware should be written into the memory.
[0075] The MCU extracts this header identification code by parsing the binary file of the firmware. The header identification code contains information such as the type, version, and target sector address of the firmware. By matching the preset sector allocation rule library, the MCU can determine the specific sector address in the Flash memory where the firmware should be written.
[0076] The sector allocation rule library is preset to guide the MCU to write different types of data (such as BootLoader, Kernel, etc.) into the correct storage area when writing the firmware. The sector allocation rule library is a preset database used to map different parts of the firmware (such as BootLoader, Kernel, file system, etc.) to specific sectors of the Flash memory. In the Flash memory, data is read and written in units of sectors. The sector allocation rule library defines which parts of the firmware should be written to which specific sector addresses, which helps to correctly write different types of firmware files into the corresponding storage areas during the firmware update process.
[0077] BootLoader is the preliminary loading program executed by the embedded device at startup, responsible for loading the main operating system or other firmware. It is usually located at the front of the Flash memory and provides basic functions for the entire printer device. Kernel is the core part of the operating system, responsible for managing system resources, scheduling tasks, handling hardware interactions, etc. It is usually located after BootLoader and starts running after the device is started.
[0078] The differences in header file features refer to the differences in the information or formats contained in the binary header files of the BootLoader and the Kernel. By identifying these differences, the firmware type can be identified and decisions can be made on how to process and write this data. The starting address is the starting position where the firmware is written in the Flash memory, and the offset is the relative position when data is written starting from the starting address. By parsing the header identification code, the MCU can determine the starting position and offset of the firmware data in the memory, thus ensuring that the data is written accurately.
[0079] During the firmware writing process, real-time verification of the written data is carried out through certain verification algorithms (such as CRC, hash, etc.) to ensure that there are no errors in the data during transmission or storage. Verification can ensure the integrity and correctness of the firmware and avoid firmware damage caused by transmission errors. Usually, the MCU uses some verification algorithms (such as CRC32, SHA256, etc.) to verify the integrity of the data. Each time data is written, the MCU calculates and compares the verification value to ensure that the data has not erred during transmission or storage. If the verification passes, the data will continue to be written. If the verification fails, the MCU can attempt to rewrite or report an error.
[0080] The PA5 port is one of the I / O ports of the MCU and can usually be used to drive devices such as LEDs. During the firmware writing process, the PA5 port will flash 3 times to indicate that the data writing process has been completed or there is a specific status change. Flashing 3 times usually indicates that the operation has been completed, and then it will enter the standby state, ready to perform other operations or wait for the next startup. By extracting the firmware header identification code, matching the sector allocation rules, verifying the data in real time, and giving status indications, it is ensured that the firmware data is written into the correct Flash storage area. Through the hint of the PA5 port flashing 3 times, users can clearly know that the firmware update has been completed and the device has entered the standby state, avoiding accidental interruptions or incorrect operations.
[0081] Furthermore, the present application further includes the following steps:
[0082] In the normal startup mode, the PA5 port remains constantly lit, and the PA6 port displays the operating status in a breathing light mode; in the download mode, the PA5 and PA6 ports flash alternately, and the flashing frequency is positively correlated with the data transmission rate.
[0083] Specifically, the PA5 port is usually used to indicate the working state of the device. In the normal startup mode, the device has completed initialization and starts to execute its main operating system. At this time, the LED connected to the PA5 port remains constantly on, indicating that the device is in a normal working state and no update operation is required. The LED of the PA5 port will always be on, indicating that the device is running normally. The LED of the PA6 port operates in a breathing light mode, simulating the breathing rhythm of a person, gradually changing its brightness, so that users can intuitively feel the active state of the device.
[0084] When the device enters the download mode for firmware update, the LED states of the PA5 and PA6 ports will change. In the download mode, the LED of the PA5 port will no longer remain constantly on but start to flash. Each flash indicates that the transmission of a data block has been completed. The flashing frequency of the LED is positively correlated with the data transmission rate, that is, the faster the data transmission rate, the higher the flashing frequency. This design enables users to intuitively understand the progress of the firmware update. The LED of the PA6 port will also start to flash, and its flashing frequency is also positively correlated with the data transmission rate. Since the PA6 port uses a breathing light mode, the brightness of the LED will show periodic changes, which may become more obvious as the flashing frequency increases.
[0085] The MCU controls the outputs of the PA5 and PA6 ports according to the current working mode (normal startup mode or download mode). The MCU can precisely adjust the brightness or flashing frequency of the PA5 and PA6 ports through timer or PWM control. To achieve the positive correlation between the data transmission rate and the flashing frequency, the MCU may dynamically adjust the flashing frequency of the LED according to the actual data transmission rate.
[0086] Exemplarily, when the firmware update starts, the LED of the PA5 port starts to flash, and the flashing frequency increases as the data transmission rate increases. At low-speed transmission, it flashes once per second, while at high-speed transmission, it flashes 10 times per second. The LED of the PA6 port is also flashing and adjusts synchronously according to the data transmission rate, and the flashing frequency of the breathing light effect changes accordingly.
[0087] Through the constant-on and flashing states of the PA5 port and the breathing light mode of the PA6 port, users can easily distinguish whether the device is in the normal working mode or the firmware download mode, thus avoiding confusion, enabling users to clearly understand the current operation state, without the need for an additional display screen or other complex indicators, thereby simplifying the operation and status monitoring of the device.
[0088] Furthermore, the present application further includes the following steps:
[0089] The full-brightness current of the VSS power-on LED is 155 mA, and the ready current after VSS power-on is 108.7 mA.
[0090] Specifically, VSS usually represents the ground wire or the negative power supply. In the power supply system of an MCU (Microcontroller Unit), VSS is the common ground terminal of the circuit, usually connected to the negative pole of the power supply. When the device is powered on, the LED is in the fully lit state, meaning the brightness of the LED reaches the maximum. In this state, the LED needs to consume a relatively large current, namely 155 mA. This fully lit state is usually used to guide the user to know that the device is powered on and starting to initialize, or to be used as a warning light or a prompt light of the device in certain states.
[0091] Once the device successfully starts and completes the initialization process, it will enter the ready state. At this time, the brightness of the LED is usually lowered to reduce power consumption. At this time, the overall current consumption of the device is reduced to 108.7 mA, including the normal operating current of the MCU and the current required to control the LED in the normal operating state. The ready state indicates that the device has completed startup, consumes relatively low power, but still maintains the operation of the basic functions of the device, and is ready to receive user instructions or perform other operations.
[0092] By adjusting the brightness of the LED in different states, the power consumption of the device can be effectively managed. Consuming a relatively high current (155 mA) when powered on is to attract the user's attention, and after the device enters the ready state, the power consumption is reduced (108.7 mA) to extend the service life of the device and reduce energy consumption.
[0093] Furthermore, the present application further includes the following steps:
[0094] Maintain a base current of 26.3 mA in the VSS standby state to keep the MCU core module running.
[0095] Specifically, the VSS standby state refers to the low-power operation mode of the device when it is not performing active operations. Usually in this state, the core components of the device still maintain the most basic working ability to facilitate a quick recovery to the normal working state. The standby state is sometimes also called the sleep mode or the low-power mode, which means the device is in an idle state and does not perform any complex operations, usually used to reduce power consumption. The main functions of the device are temporarily turned off, but some basic functions (such as the MCU core module, clock, etc.) are still working to respond to external signals or instructions at any time.
[0096] In the VSS standby state, the power consumption of the device is controlled to the minimum by turning off most of the unnecessary circuits and functions. Only the core module of the MCU still remains running. The core module of the MCU can include a clock, an external interrupt detector, etc. The MCU can still respond to external events (such as key presses, signal inputs, etc.). When an external event occurs, the MCU can wake up the device to enter a higher-power active state.
[0097] In the standby mode, the device consumes only 26.3 mA of current, which means that the device maintains the lowest power consumption to keep the basic functions of the MCU core module (such as the clock and interrupt mechanism), ensuring that the MCU can resume from the standby mode to the normal working state at any time. The current at this time is very low, which helps to extend the standby time of the device. For example, when the printer is not used for a long time, it can be placed in the standby mode to greatly reduce the power consumption.
[0098] By consuming only 26.3 mA of base current in the standby mode, the device can maintain extremely low power consumption when not performing active operations, extending the standby time of the device, which helps to reduce the energy consumption of the device during long-term use. Especially for battery-powered devices, this low-power standby mode can significantly extend the service life of the battery.
[0099] Furthermore, the present application further includes the following steps:
[0100] During the boot process, verify the digital signature of the firmware. If the verification fails, roll back to the previous available version; when the write fails three times in a row, lock the programming function of the MCU and trigger the hardware self-check process.
[0101] Specifically, during the boot process, verify the digital signature of the firmware file to be written to ensure the solid legitimacy and prevent malicious or tampered firmware from entering the printer device. Decrypt the digital signature in the firmware through the preset public key to verify the integrity and source of the firmware. If the signature does not match, it means that the firmware may be tampered with or the source is unreliable. At this time, the firmware update will be stopped and the printer device will not execute the firmware. The digital signature of the firmware is an authentication identifier generated through an encryption algorithm to ensure that the firmware file has not been tampered with during transmission or storage and its source is trustworthy.
[0102] In the case of failed digital signature verification, roll back to the previous normally running firmware version to avoid firmware problems during the update process, resulting in the device being in an unavailable state. By checking the backup version or historical firmware version in the memory and loading it into the MCU for execution, ensure that the device can continue to run. Rollback means that during the firmware upgrade process, if the current firmware fails to pass the verification or malfunctions, it will automatically revert to the previous, normally working version to ensure that the device is always in an available state, even if there are problems with the new firmware version.
[0103] During the firmware writing process, a certain number of writing attempts will be made. If three consecutive writing failures occur (e.g., due to hardware failures, memory problems, etc.), the programming function of the MCU will be automatically locked. The purpose of locking the programming function is to prevent the device from entering an unstable state due to firmware writing failures. By locking the programming function, users or technicians must first solve the firmware problem before they can restore the programming function, avoiding the device continuously encountering irreparable writing errors. Locking the programming function of the MCU means that during the firmware update process, if consecutive failures occur, further firmware writing operations will be prohibited to prevent the printer device from entering an unstable state. Locking the programming function is to prevent the adverse effects after firmware update failures and ensure the safety and stability of the device.
[0104] After consecutive writing failures and the programming function is locked, a hardware self - test process is started. The self - test process checks the hardware components of the device, including the MCU, memory, I / O ports, power supply system, etc., to ensure that the hardware is working properly. The self - test process can help locate hardware failures and ensure that the device is in good condition when it resumes normal operation. If the self - test detects problems, the printer device will give corresponding prompts or enter the maintenance mode, asking the user to make repairs. The hardware self - test process is a self - diagnostic program carried out when the device starts up or when a failure occurs. By checking the hardware functions, connections, and status of the device, it ensures that the device is in good working condition after startup. The self - test process can check whether there are faults in the hardware such as the MCU, memory, input / output ports, etc., to ensure that the device can work properly.
[0105] Through digital signature verification, it is ensured that the firmware has not been tampered with during transmission and storage, and the source is reliable, effectively avoiding the device being attacked or malfunctioning due to malicious firmware. If problems occur during the firmware upgrade process, through the rollback mechanism, the device will automatically revert to the previous available version to prevent the device from falling into an unavailable state. The locked programming function and the hardware self - test process after consecutive writing failures are used to detect potential hardware failures and effectively prevent the device from being in an unstable state for a long time due to hardware or firmware problems. By locking the programming function and starting the hardware self - test, the device will protect users from further incorrect operations when problems occur, ensuring that users will not cause more serious problems due to incorrect operations when operating the device.
[0106] In summary, the firmware multi - sector intelligent boot method for printer devices provided by this application has the following beneficial effects:
[0107] A firmware download control channel is established through the hardware circuit of the microcontroller unit (MCU); the trigger signal of the power-on key connected to the MCU is monitored, and the normal startup mode and the download mode are distinguished according to the key press duration; in the download mode, the binary header file format features of the firmware to be written are parsed to identify the target sector address; by dynamically adjusting the I / O port level status of the MCU, the firmware data stream is controlled to be directionally written into the specified sector of the Flash memory. That is to say, the download process is controlled by the MCU hardware. When the firmware upgrade fails or is interrupted, the device can still continue to work with the original firmware, avoiding the risk that the device becomes completely unavailable due to firmware upgrade failure, and greatly improving the stability of firmware upgrade and the usage efficiency of the printer device.
[0108] Embodiment 2, based on the same inventive concept as the firmware multi-sector intelligent boot method for printer devices in the foregoing Embodiment 1, the present application also provides a firmware multi-sector intelligent boot system for printer devices. Please refer to the appended Figure 2 , the firmware multi-sector intelligent boot system for printer devices includes:
[0109] A channel establishment module 11, configured to establish a firmware download control channel through the hardware circuit of the microcontroller unit (MCU); a mode discrimination module 12, configured to monitor the trigger signal of the power-on key connected to the MCU, and distinguish the normal startup mode and the download mode according to the key press duration; an address recognition module 13, configured to, in the download mode, parse the binary header file format features of the firmware to be written, and identify the target sector address; a status adjustment module 14, configured to control the firmware data stream to be directionally written into the specified sector of the Flash memory by dynamically adjusting the I / O port level status of the MCU.
[0110] Further, the channel establishment module 11 in the firmware multi-sector intelligent boot system for printer devices is further configured to:
[0111] Synchronize the operation timing using the clock interface of the MCU; the port configuration of the MCU includes that the PA0 port is set as an external interrupt input port, the PA1 port is configured as a general-purpose output port, the PA2 port is a clock interface, the PA5 port and the PA6 port are set as LED drive ports, and the PA7 port is configured as a wake-up function pin.
[0112] Further, the mode discrimination module 12 in the firmware multi-sector intelligent boot system for printer devices is further configured to:
[0113] When the VDD power supply is powered on, the PA6 port outputs a high level; detect the interrupt trigger signal of the PA0 port, and if the falling edge is not detected, jump to the BootLoader normal startup process.
[0114] Further, the mode discrimination module 12 in the firmware multi-sector intelligent boot system for the printer device is further configured to:
[0115] When the PA0 port maintains a low level for more than a preset time limit, the PA7 port outputs a high level to start the download mode.
[0116] Further, the mode discrimination module 12 in the firmware multi-sector intelligent boot system for the printer device is further configured to:
[0117] Extract the header identification code generated by firmware compilation, and match the preset sector allocation rule library; based on the header identification code, determine the starting address and offset according to the header file feature differences of BootLoader and Kernel; during the writing process, verify the data in real time, and enter the standby state after the PA5 port flashes 3 times.
[0118] Further, the address identification module 13 in the firmware multi-sector intelligent boot system for the printer device is further configured to:
[0119] In the normal startup mode, the PA5 port remains constantly on, and the PA6 port displays the operating state in a breathing light mode; in the download mode, the PA5 and PA6 ports alternate and flash, and the flashing frequency is positively correlated with the data transmission rate.
[0120] Further, the address identification module 13 in the firmware multi-sector intelligent boot system for the printer device is further configured to:
[0121] The full-brightness current of the VSS power-on LED is 155 mA, and the ready current after VSS power-on is 108.7 mA.
[0122] Further, the address identification module 13 in the firmware multi-sector intelligent boot system for the printer device is further configured to:
[0123] Maintain a basic current of 26.3 mA in the VSS standby state to keep the MCU core module running.
[0124] Further, the address identification module 13 in the firmware multi-sector intelligent boot system for the printer device is further configured to:
[0125] Verify the firmware digital signature during the boot process. If the verification fails, roll back to the previous available version; when the writing fails three times in a row, lock the programming function of the MCU and trigger the hardware self-check process.
[0126] The various embodiments in this specification are described in a progressive manner. The key point of each embodiment is the difference from other embodiments. The foregoing Figure 1The firmware multi-sector intelligent boot method and specific examples in Embodiment 1 are equally applicable to the firmware multi-sector intelligent boot system for printer devices in this embodiment. Through the detailed description of the firmware multi-sector intelligent boot method for printer devices above, those skilled in the art can clearly understand the firmware multi-sector intelligent boot system for printer devices in this embodiment. Therefore, for the sake of brevity of the specification, it will not be elaborated here.
[0127] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be obvious to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to these embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
[0128] Obviously, for those skilled in the art, without departing from the principles of the present application, several improvements and modifications can still be made to the present application, and these improvements and modifications also fall within the protection scope of the present application.
Claims
1. A firmware multi-sector intelligent boot method for a printer device, characterized in that Including: Establish a firmware download control channel through the hardware circuit of the microcontroller unit (MCU); Monitor the trigger signal of the power-on key connected to the MCU, and distinguish the normal startup mode and the download mode according to the key press duration; In the download mode, analyze the binary header file format characteristics of the firmware to be written, and identify the target sector address; Control the firmware data stream to be directed and written to the specified sector of the Flash memory by dynamically adjusting the I / O port level status of the MCU.
2. The firmware multi-sector intelligent boot method for a printer device according to claim 1, wherein, Among them, Use the clock interface of the MCU to synchronize the operation timing; The port configuration of the MCU includes: the PA0 port is set as an external interrupt input port, the PA1 port is configured as a general-purpose output port, the PA2 port is a clock interface, the PA5 port and the PA6 port are set as LED drive ports, and the PA7 port is configured as a wake-up function pin.
3. The firmware multi-sector intelligent boot method for a printer device according to claim 2, characterized in that The multi-sector intelligent boot method for the firmware of the printer device includes: When the VDD power is powered on, the PA6 port outputs a high level; Detect the interrupt trigger signal of the PA0 port. If the falling edge is not detected, jump to the BootLoader normal startup process.
4. The firmware multi-sector intelligent boot method for a printer device according to claim 3, characterized in that, The multi-sector intelligent boot method for the firmware of the printer device includes: When the PA0 port remains low for more than the preset time limit, the PA7 port outputs a high level to start the download mode.
5. The firmware multi-sector intelligent boot method for a printer device according to claim 4, wherein, Extract the header identification code generated by the firmware compilation, and match the preset sector allocation rule library; Based on the header identification code, determine the starting address and offset according to the header file feature differences between BootLoader and Kernel; Perform real-time data verification during the writing process. After the PA5 port flashes 3 times, enter the standby state.
6. The firmware multi-sector intelligent boot method for a printer device according to claim 5, characterized in that, The multi-sector intelligent boot method for the firmware of the printer device includes: In the normal startup mode, the PA5 port remains constantly on, and the PA6 port displays the operating status in a breathing light mode; In the download mode, the PA5 and PA6 ports flash alternately, and the flashing frequency is positively correlated with the data transmission rate.
7. The firmware multi-sector intelligent boot method for a printer device according to claim 6, wherein The full-bright current of the VSS power-on LED is 155 mA, and the ready current after VSS power-on is 108.7 mA.
8. The firmware multi-sector intelligent boot method for a printer device according to claim 7, characterized in that, Maintain a basic current of 26.3 mA in the VSS standby state to keep the MCU core module running.
9. The firmware multi-sector intelligent boot method for a printer device according to claim 8, characterized in that, Verify the firmware digital signature during the boot process. If the verification fails, roll back to the previous available version; When the writing fails three times in a row, lock the programming function of the MCU and trigger the hardware self-check process.
10. A firmware multi-sector intelligent boot system for a printer device, characterized in that, For implementing the steps of the multi-sector intelligent boot method for the firmware of the printer device described in any one of claims 1 to 9, the multi-sector intelligent boot system for the firmware of the printer device includes: A channel establishment module for establishing a firmware download control channel through the hardware circuit of the microcontroller unit (MCU); A mode discrimination module for monitoring the trigger signal of the power-on key connected to the MCU and distinguishing the normal startup mode and the download mode according to the key press duration; An address identification module for analyzing the binary header file format characteristics of the firmware to be written and identifying the target sector address in the download mode; A status adjustment module for controlling the firmware data stream to be directed and written to the specified sector of the Flash memory by dynamically adjusting the I / O port level status of the MCU.
Citation Information
Cited By
Distributed firmware upgrading and real-time monitoring method for embedded board-level system
CN120821616A