Method for ota upgrading by simulating IIC through embedded software
Through embedded software, the IIC communication protocol is simulated, and the problem of OTA upgrade without reserved interfaces is solved. The OTA upgrade process without removing and washing the shell is realized, which improves work efficiency and product integrity.
Patent Information
- Application Number
- CN202311491002.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-10
- Publication Date
- 2025-05-13
AI Technical Summary
When the microcontroller does not reserve any interface, when performing OTA upgrades, the shell needs to be removed and washed, which can easily lead to damage to the shell, reduced adhesion and excessive workload.
Through embedded software, two GPIOs simulate SCL and SDA signals, and connect them through pull-up resistors to divide the Flash area into BootLoader and App to realize the OTA upgrade process.
It realizes that when the microcontroller has no reserved interface, the OTA upgrade is carried out through embedded software to simulate the IIC, avoiding the risk of shell removal and washing, and improving work efficiency and product integrity.
Smart Images

Figure CN119987819A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of network communication technology, and more specifically, to a method for performing OTA upgrade by simulating IIC through embedded software. Background Art
[0002] More and more mobile devices have entered thousands of households. In normal project development and debugging, the download program generally uses an external downloader or serial port to download and refresh the program of the microcontroller; OTA English full name is Over-The-Air Technology, which means space download technology, mainly for wireless interconnected devices. OTA upgrade is a way to transmit and upgrade firmware directly through the wireless without going through a hardware emulator.
[0003] The inventor believes that after the product is assembled and formed, a shell is added to the product or it is packaged. For the integrity of the product, it is impossible to reserve a download interface on the shell. When the product needs to be upgraded, it is necessary to reopen the product packaging and then update the program through the downloader. In the process of disassembling and cleaning the shell, the shell is easily damaged and the tightness is affected, and the workload is too large. Summary of the invention
[0004] An object of the present invention is to provide a method for performing OTA upgrade when a single-chip microcomputer does not have any reserved interface.
[0005] According to one aspect of the present invention, a method for OTA upgrade by simulating IIC through embedded software is provided: S101: select two GPIOs; S102: one GPIO simulates an SCL signal, and the other GPIO simulates an SDA signal; S103: SDA and SCL are respectively connected to two pull-up resistors; S201: divide the Flash area, one for BootLoader and the other for App, and their spaces must be independently distinguished; S201: divide the Flash area, one for BootLoader and the other for App, and their spaces must be independently distinguished.
[0006] Optionally, the value of the pull-up resistor is chosen to be 4.7K.
[0007] Optionally, BootLoader is the area used to start the program, App is the application firmware, business logic is located, and it is also the area where each firmware update is performed. The role of BootLoader during the upgrade is to move the APP application firmware to the running area.
[0008] Optionally, SDA and SCL are bidirectional lines.
[0009] One technical effect of the present invention is that the firmware of the upgrade package is transmitted by simulating IIC through embedded software, the single-chip microcomputer is adjusted to BootLoader operation, the transmitted upgrade firmware is copied to the Flash space of the App, the integrity of the upgrade firmware is verified, and the running pointer is jumped to the App after the verification is successful. After the jump to the App, the interrupt vector table of the App is reset. The new APP firmware is successfully run. The entire OTA process is completed.
[0010] Further features and advantages of the present invention will become apparent from the following detailed description of exemplary embodiments of the present invention with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] The accompanying drawings, which constitute a part of the specification, illustrate embodiments of the present invention and, together with the description, serve to explain the principles of the present invention.
[0012] Figure 1 It is an overall communication timing of a method of OTA upgrade by simulating IIC through embedded software.
[0013] In the drawings, the same components are denoted by the same reference numerals; the drawings are not drawn according to the actual scale. DETAILED DESCRIPTION
[0014] Various exemplary embodiments of the present invention will now be described in detail with reference to the accompanying drawings. It should be noted that the relative arrangement of components and steps, numerical expressions and numerical values set forth in these embodiments do not limit the scope of the present invention unless otherwise specifically stated.
[0015] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the invention, its application, or uses.
[0016] Techniques and equipment known to ordinary technicians in the relevant art may not be discussed in detail, but where appropriate, the techniques and equipment should be considered part of the specification.
[0017] In all examples shown and discussed herein, any specific values should be interpreted as merely exemplary and not limiting. Therefore, other examples of the exemplary embodiments may have different values.
[0018] It should be noted that like reference numerals and letters refer to similar items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures. Example
[0019] The present invention provides a method for OTA upgrade by simulating IIC through embedded software, such as Figure 1 As shown, First, the terms designed in this application are explained: IIC communication protocol: also known as I2C, is a serial communication protocol widely used for data transmission between various electronic devices. The IIC two-wire standard consists of two signal lines, namely the clock line (SCL) and the data line (SDA).
[0020] The IIC communication protocol includes: idle state, start state, stop signal, response signal, data validity, and data transmission; When in idle state, when the SDA and SCL signal lines of the IIC bus are both at high level, it is defined as the idle state of the bus. At this time, all devices are in the cut-off state, that is, the bus is released; When SCL is at a high level, SDA jumps from high to bottom; When SCL is at a high level, SDA changes from low to high; Every time the transmitter sends a byte, the data line is released at the clock pulse, and the receiver feeds back a response signal: when the response signal is at a low level, it is defined as a valid response bit (ACK for short), indicating that the receiver has successfully received the byte; when the response signal is at a high level, it is defined as a non-response bit (NACK), generally indicating that the receiver has not successfully received the byte.
[0021] When the IIC bus is transmitting data, the data on the data line remains stable while the clock signal is at a high level. The high or low level state of the data line can only change when the signal on the clock line is at a low level.
[0022] S101: Select two GPIOs; S102: One GPIO simulates the SCL signal, and the other GPIO simulates the SDA signal; S103: SDA and SCL are connected to two pull-up resistors respectively; Specifically, the resistance value is selected to be 4.7K, which improves the driving capability of the bus and keeps the bus at a high level when idle, ensuring that the transmission can be started quickly next time.
[0023] S201: Divide the Flash area into two parts: one for BootLoader and the other for App, and their spaces should be separated independently; Specifically, BootLoader is the area used to start the program, App is the application firmware, business logic is located, and it is also the area where each firmware update is performed. The role of BootLoader during the upgrade is to move the APP application firmware to the running area.
[0024] Optionally, SDA and SCL are both bidirectional lines that can exchange information with each other.
[0025] When in use, the embedded software simulates IIC to transmit the upgrade package firmware, the MCU is adjusted to BootLoader operation, the transmitted upgrade firmware is copied to the Flash space of the App, the integrity of the upgrade firmware is verified, and the run pointer is jumped to the App after the verification is successful. After jumping to the App, the interrupt vector table of the App is reset. The new APP firmware is successfully run. The entire OTA process is completed.
[0026] Although some specific embodiments of the present invention have been described in detail by way of example, it will be appreciated by those skilled in the art that the above examples are for illustration only and are not intended to limit the scope of the present invention. It will be appreciated by those skilled in the art that the above embodiments may be modified without departing from the scope and spirit of the present invention. The scope of the present invention is defined by the appended claims.
Claims
1. A method for OTA upgrade by simulating IIC through embedded software, characterized in that: S101: Select two GPIOs; S102: One GPIO simulates the SCL signal, and the other GPIO simulates the SDA signal; S103: SDA and SCL are connected to two pull-up resistors respectively; S201: Divide the Flash area into two parts: one for BootLoader and the other for App, and their spaces should be separated independently; S201: Divide the Flash area into two parts: one for BootLoader and the other for App, and their spaces should be separated independently.
2. The method for performing OTA upgrade by simulating IIC through embedded software according to claim 1, characterized in that: The value of the pull-up resistor is chosen to be 4.7K.
3. The method for performing OTA upgrade by simulating IIC through embedded software according to claim 1, characterized in that: BootLoader is the area used to start the program. App is the application firmware, where the business logic is located, and it is also the area where each firmware update takes place. The role of BootLoader during the upgrade is to move the APP application firmware to the running area.
4. The method for performing OTA upgrade by simulating IIC through embedded software according to claim 1, characterized in that: SDA and SCL are bidirectional lines.