Online upgrade method, device, computer equipment and storage medium
By setting the network transmission rate and time slice allocation on the CAN bus, and using a single cache mechanism to perform online software upgrades in flash, the problems of upgrade failure and large space occupation in the existing technology are solved, and stable and efficient online upgrades are achieved.
Patent Information
- Application Number
- CN202210417440.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-20
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2042-04-20
AI Technical Summary
Existing software upgrade methods are prone to failure when the system is unexpectedly powered off, occupy a large cache space, are highly complex, and are difficult to achieve online upgrade and maintenance.
Using the CAN bus network transmission rate and time slice allocation, the software upgrade program is obtained through the CAN bus, and a single cache mechanism is set up to perform online upgrades in flash to ensure the stability and space efficiency of the upgrade process.
This enables normal upgrades even when the system is unexpectedly powered off, saving cache space and simplifying the online upgrade and maintenance process.
Smart Images

Figure CN114879988B
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of software upgrade, and in particular to an online upgrade method, apparatus, computer equipment and storage medium. Background Art
[0002] In industrial applications, it is often necessary to perform software upgrades and maintenance on product programs. After the product is formed, it is often impossible to upgrade it by manually plugging and unplugging the emulator. At present, the main way to upgrade the program online is to use a double cache mechanism in the flash. That is, add the operation function of the flash in the application to realize the reading and writing of another cache. After the program is powered off and restarted, it jumps to the other cache to execute the function. This method has the following shortcomings: First, it occupies a large cache space and requires two independent spaces to store the application program; second, the reliability is insufficient. During the software upgrade process, if the system loses power unexpectedly, the software program will fail to upgrade and cannot run; third, the complexity of the application increases, which is not convenient for online upgrade and maintenance of the software program. Summary of the invention
[0003] The purpose of the embodiments of the present application is to provide an online upgrade method, apparatus, computer equipment and storage medium to solve the problem that during the existing software upgrade process, if the system loses power unexpectedly, the software program will fail to upgrade and cannot run.
[0004] In order to solve the above technical problems, the present application provides an online upgrade method, which adopts the following technical solution and includes the following steps:
[0005] Set the CAN bus network transmission rate and time slice allocation;
[0006] According to the CAN bus network transmission rate and time slice allocation, the software upgrade program is obtained through the CAN bus;
[0007] Take out the reset interrupt vector address from the first interrupt vector table, execute the first interrupt reset function, and then jump to the main function of the software upgrade program to perform software upgrade;
[0008] After the upgrade program is executed, it jumps to the second interrupt vector table to retrieve the interrupt function entry address, and then executes the second interrupt service function. After executing the second interrupt service function, it returns to the main function of the user application.
[0009] Furthermore, the step of setting the CAN bus network transmission rate and time slice allocation specifically includes:
[0010] Set the CAN bus network transmission rate to 300Kbps~800Kbps, and set the clock crystal of the device to be upgraded to an integer multiple of 8MHz;
[0011] The CAN bus time slice allocation is set to 10 time slices per bit, including 1 bit for the synchronization segment, 5 bits for the propagation segment and the first phase buffer segment, and 4 bits for the second phase buffer segment.
[0012] Furthermore, the step of obtaining the software upgrade program through the CAN bus according to the CAN bus network transmission rate and time slice allocation specifically includes:
[0013] Get the online upgrade logo;
[0014] Enter online upgrade mode;
[0015] Receive ground control system upgrade software via CAN bus according to CAN bus network transmission rate and time slice allocation;
[0016] Writing the upgrade software into flash;
[0017] Clear the online upgrade flag.
[0018] Furthermore, the steps of taking out the reset interrupt vector address from the first interrupt vector table, executing the first interrupt reset function, and jumping to the main function of the software upgrade program to perform software upgrade specifically include:
[0019] Get the stack top pointer;
[0020] Jump to the first interrupt vector table, obtain the address of the reset interrupt vector, the address of the reset interrupt vector points to the entry address of the first interrupt service function;
[0021] After executing the first interrupt reset function, the main function of the upgrade program is started to perform software upgrade.
[0022] Further, after the upgrade program is executed, the steps of jumping to the second interrupt vector table to retrieve the interrupt function entry address, then executing the second interrupt service function, and returning to the user application main function after executing the second interrupt service function specifically include:
[0023] Set the flash storage area into two parts, one for storing the upgrade program and the other for storing the application program;
[0024] After the upgrade program is executed, jump to the second interrupt vector table;
[0025] Take out the interrupt function entry address, and then execute the second interrupt service function;
[0026] After executing the second interrupt service function, return to the main function of the user application.
[0027] Furthermore, the step of receiving the ground control system upgrade software through the CAN bus according to the CAN bus network transmission rate and time slice allocation specifically includes:
[0028] Receiving packet data sent by the ground control system through the CAN bus, wherein the packet data carries a sender verification code;
[0029] Performing CRC algorithm calculation on the packet data and comparing it with the sender verification code;
[0030] If the comparison is consistent, the package data is assembled and connected into the upgraded software, otherwise the package data is discarded.
[0031] Furthermore, the online upgrade method further includes:
[0032] A node data frame reception filtering principle is set on the CAN bus.
[0033] In order to solve the above technical problems, the present application also provides an online upgrade device, which adopts the following technical solution, including:
[0034] Setting module, used to set CAN bus network transmission rate and time slice allocation;
[0035] An acquisition module is used to acquire the software upgrade program through the CAN bus according to the CAN bus network transmission rate and time slice allocation;
[0036] The upgrade module is used to fetch the reset interrupt vector address from the first interrupt vector table, execute the first interrupt reset function, and then jump to the main function of the software upgrade program to perform software upgrade;
[0037] The jump module is used to jump to the second interrupt vector table to retrieve the interrupt function entry address after the upgrade program is executed, and then execute the second interrupt service function. After executing the second interrupt service function, it returns to the main function of the user application.
[0038] In order to solve the above technical problems, the present application also provides a computer device, which adopts the technical solution described below, including a memory and a processor, wherein the memory stores computer-readable instructions, and the processor implements the steps of the above-mentioned online upgrade method when executing the computer-readable instructions.
[0039] In order to solve the above technical problems, the present application also provides a computer-readable storage medium, which adopts the following technical solution: the computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the steps of the above-mentioned online upgrade method are implemented.
[0040] Compared with the prior art, the present application has the following beneficial effects: a mechanism is adopted to separate the online upgrade program and the user application program, the online upgrade program only provides the online upgrade function, and the user application program mainly meets the user needs; a single cache mechanism is adopted in the flash to realize the online software upgrade and save space; during the upgrade process, even if the power is accidentally cut off, it can still be upgraded normally, which is convenient for the online upgrade and maintenance of the program. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the scheme in the present application, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0042] Figure 1 is an exemplary system architecture diagram to which the present application may be applied;
[0043] Figure 2 is a preferred system architecture diagram in which the present application can be applied;
[0044] Figure 3 is a flow chart of an embodiment of the online upgrade method of the present application;
[0045] Figure 4 yes Figure 3 A flowchart of a specific implementation of step S202;
[0046] Figure 5 It is a flow chart of data packet verification by the sender and the receiver in this application;
[0047] Figure 6 It is a startup flow chart of an embedded program in the prior art;
[0048] Figure 7 It is a flowchart of the program operation of this application;
[0049] Figure 8 It is a structural schematic diagram of an embodiment of the online upgrade device of the present application;
[0050] Fig. 9 It is a structural diagram of an embodiment of a computer device of the present application. DETAILED DESCRIPTION
[0051] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of the present application; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit the present application; the terms "including" and "having" and any variations thereof in the specification and claims of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.
[0052] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0053] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.
[0054] like Figure 1 As shown, the system architecture 100 may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a server 105. The network 104 is used to provide a medium for a communication link between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the server 105. The network 104 may include various connection types, such as wired, wireless communication links, or optical fiber cables, etc.
[0055] The user can use the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server 105 through the network 104 to receive or send messages, etc. Various communication client applications can be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0056] The first terminal device 101, the second terminal device 102, and the third terminal device 103 can be various electronic devices with display screens and supporting web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III), MP4 (Moving Picture Experts Group Audio Layer IV) players, laptop computers, desktop computers, etc.
[0057] The server 105 may be a server that provides various services, for example, a background server that provides support for pages displayed on the first terminal device 101 , the second terminal device 102 , and the third terminal device 103 .
[0058] It should be noted that the online upgrade method provided in the embodiment of the present application is generally executed by a server / terminal device, and accordingly, the online upgrade device is generally set in the server / terminal device.
[0059] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to the implementation requirements.
[0060] Figure 2 This is a preferred system architecture diagram in which the present application can be applied. Figure 2 As shown, for ease of understanding, the following embodiments are described using the arrow swing servo stand-alone as the carrier for online software upgrade. The ground control system sends the prepared software upgrade file (such as a bin file) to the arrow swing servo via the CAN bus, thereby realizing the online upgrade process. The ground control system is the sender of the software upgrade file, and the arrow swing servo is the receiver of the software upgrade file. The arrow swing servo stand-alone uses the stm32 chip as the program carrier.
[0061] Embodiment 1
[0062] Continue to refer Figure 3 , shows a flow chart of an embodiment of the online upgrade method of the present application. The online upgrade method comprises the following steps:
[0063] Step S201, setting the CAN bus network transmission rate and time slice allocation.
[0064] In this embodiment, the electronic device (eg Figure 1The server / terminal device shown in the figure can receive the online upgrade request through a wired connection or a wireless connection. It should be noted that the above wireless connection method may include but is not limited to 3G / 4G / 5G connection, WiFi connection, Bluetooth connection, WiMAXX connection, Zigbee connection, UWB (ultra wideband) connection, and other wireless connection methods currently known or to be developed in the future.
[0065] To ensure that the CAN bus load is low, the bus rate is set to 300Kbps-800Kbps. In this embodiment, the bus rate is set to 500Kbps, and the clock crystal oscillator of the device to be upgraded is set to an integer multiple of 8MHz. The time slice allocation scheme is shown in Table 1.
[0066] Table 1 Bus rate time slice allocation table
[0067]
[0068] Bit time tBit=1s / 500kbps=2000ns / bit; crystal oscillator clock period T=1s / 8MHz=125ns.
[0069] The control system CAN bus communication adopts the extended frame format of the CAN2.0B standard. The definition of the 29-bit identifier is shown in Table 2. IDs that do not follow this specification are illegal instructions and the terminal node should discard them or report an exception.
[0070] Table 2 Definition of CAN bus 29-bit identifier composition
[0071]
[0072]
[0073] The message on the arrow is transmitted by one or more CAN bus data frames according to the effective data length to be transmitted. Different data frames that make up a message have the same message code, and the data frame number starts from 0 and increases in sequence. The format of the message description is shown in Table 3.
[0074] Table 3 Message description format
[0075]
[0076] For the 8-byte data field of each data frame, the byte sending order of the CAN bus is to send the low byte first and then the high byte. The 8 bits of each byte are sent first in the high bit and then in the low bit.
[0077] The bus protocol follows the little-endian mode for encoding and storing the data field. The low byte is stored in the low address and the high byte is stored in the high address. The encoding of 8-bit single-byte data follows the mode of placing the high bit of the data in the high bit of the byte and the low bit of the data in the low bit of the byte.
[0078] Step S202: Obtain the software upgrade program through the CAN bus according to the CAN bus network transmission rate and time slice allocation.
[0079] Figure 4 yes Figure 3 A flowchart of a specific implementation of step S202 in FIG. Figure 4 As shown, in this embodiment, step S202 may further include the steps of:
[0080] S2021, online upgrade program initialization;
[0081] S2022, check whether there is an online upgrade mark, if yes, execute step S2023, otherwise execute step S2024;
[0082] S2023, enter online upgrade mode;
[0083] S2024, jump to execute the user application program;
[0084] S2025. Receive ground control system upgrade software;
[0085] S2026, writing the upgrade file into the flash;
[0086] S2027. Clear the online upgrade flag.
[0087] According to the CAN bus network transmission rate and time slice allocation, the steps of receiving the ground control system upgrade software through the CAN bus include:
[0088] Receiving packet data sent by the ground control system through the CAN bus, wherein the packet data carries a sender verification code;
[0089] Performing CRC algorithm calculation on the packet data and comparing it with the sender verification code;
[0090] If the comparison is consistent, the package data is assembled and connected into the upgraded software, otherwise the package data is discarded.
[0091] The ground control system uses the CAN protocol to perform online upgrades on the arrow's swing servo. Since the upgrade file is generally large, the upgrade is performed by transmitting data in batches. To ensure transmission reliability, the size of each data packet can be, for example, 2k bytes, and each data packet has a CRC check code. It is transmitted in batches and the file is verified at the end. The sender and receiver of the CRC check algorithm are consistent. The sender sends the packet data with the check code, and the receiver performs the CRC algorithm calculation on the received packet data and compares it with the sender's verification code to ensure the correctness of the data.
[0092] Table 4 CAN bus block transmission command information characteristics
[0093]
[0094]
[0095] Table 4 illustrates the handshake situation during CAN bus transmission. The CAN2.0b communication protocol consists of three parts: ID, data length, and data content. This table mainly refers to the explanation of the command frame ID and data length.
[0096] Table 5 Block transfer command information content
[0097]
[0098] Table 5 shows the data content of the block transfer command frame. Together with Table 4, it forms a complete command frame. In simple terms, it tells the receiver to prepare to start specific work.
[0099] Table 6 Parameter definitions for different operation types
[0100]
[0101]
[0102] Table 6 shows the setting method of the three parameters in Table 5. According to different operation types in Table 5, the method of setting parameters is slightly different.
[0103] Table 7 Block transfer command response information characteristics
[0104] content source Execution Node (0xYY) Purpose Initiating Node (0xXX) ID 01 11101yyyyyy xxxxxx 00 11111111(0x0Fxxxxxx) Message length 8byte Remark Block transfer data command response between the initiating node and the executing node.
[0105] Table 7 shows the way the receiver responds to the command frame sent by the sender. Together with Table 8, it constitutes the response frame content of the command frame.
[0106] Table 8 Block transfer command response information content
[0107]
[0108]
[0109] Table 8 also shows the way the receiver responds to the command frame sent by the sender.
[0110] Table 9 Transmission data information characteristics
[0111] content source Initiating Node (0xXX) Purpose Execution Node (0xYY) ID 11 11110xxxxxx yyyyyy 00nnnnnnnn Message length 8byte Remark
[0112] Block data transmission between the initiating node and the executing node, n represents the frame number, and the write / read content of the frame data header is located at n*8 bytes in the block. When nnnnnnnn is 0xFF, it means the transmission of the frame is completed. Table 9 and Table 10 together constitute the content of the data frame, which is sent to the receiver to upgrade the file information content.
[0113] Table 10 Block transmission data information content
[0114]
[0115] Table 10 illustrates the Can protocol characteristics. Each frame of data sends 8 valid bytes of upgrade file information.
[0116] Figure 5 This is a flow chart of the sender and receiver performing data packet verification in this application. Figure 5 As shown in FIG. 1 , the process of data packet verification between the sender and the receiver, and the interaction of command reception and transmission between the sender and the receiver through the CAN bus, includes the following steps:
[0117] S401, the sending party sends a data packet binding command to the receiving party;
[0118] S501, the receiving party responds to the binding command;
[0119] S402, the sender determines whether a binding command response is received from the receiver, if yes, executes step S403, otherwise executes step S401;
[0120] S403, after a certain time interval, such as 1 second, the sender sends the binding data to the receiver, and then simultaneously executes step S404 and step S502;
[0121] S404, the sender sends a verification command to the receiver;
[0122] S502, the receiving party receives the received binding data from the sending party;
[0123] S405, the sender determines whether the binding data is correct, if so, executes step S406, otherwise executes step S403;
[0124] S503, the receiving party receives the verification command sent by the sending party and performs data verification;
[0125] S504, the receiving party responds to the verification command to the sending party;
[0126] S406, query the next packet of data;
[0127] S407, determine whether the data binding is completed, if yes, execute step S408, otherwise execute step S403;
[0128] S408, the sender sends a file verification command to the receiver;
[0129] S505, the receiving party receives the file verification command from the sending party and verifies the file;
[0130] S409, the sender determines whether the file verification is correct, if so, executes step S410, otherwise executes step S403;
[0131] S506, the receiving party responds to the sending party regarding the file verification command;
[0132] S410, the sender sends an erase flash command to the receiver;
[0133] Flash operations include flash initialization, flash erase, and flash write. Flash initialization includes unlocking flash, clearing flash status (including operation status and error status), and flash lock. Flash erase mainly uses the sector erase method to erase the specified sector. Flash write writes data of a specified length to the specified flash address.
[0134] S507, the receiver receives the erase flash command from the sender and erases the flash;
[0135] S411, the sender determines whether the flash is erased correctly, if yes, executes step S412, otherwise executes step S410;
[0136] S508, the receiving side responds to the erase flash command to the sending side;
[0137] S412, the sending direction sends a write flash command to the receiving direction;
[0138] S509, the receiver receives the write-in flash command from the sender and performs a write-in flash operation;
[0139] S413, the sender determines whether the flash is written correctly, if yes, the process ends, if no, executes step S412;
[0140] S510: The receiving side responds to the sending side regarding the write-in-flash command.
[0141] Step S203, fetching the reset interrupt vector address from the first interrupt vector table, executing the first interrupt reset function, and then jumping to the main function of the software upgrade program to perform software upgrade.
[0142] Figure 6 It is a startup flow chart of an embedded program in the prior art. Figure 6 As shown in the figure, the stack is a linear table with restricted operations. The restriction is that insertion and deletion operations are only allowed at one end of the table. This end is called the top of the stack, and the other end is called the bottom of the stack. The stack address refers to the address of the top of the stack. When stack memory is allocated for local variables, the system stores the local variables in a memory block of the stack; when the sub-function ends and the local variables should be released, the system clears the data stored in the stack memory of the local variables and restores the original uninitialized state.
[0143] The interrupt vector table refers to the offset and segment base address of the entry address of the interrupt service program. An interrupt vector occupies 4 bytes of space. The interrupt vector table is the lowest 1K byte space in the 8086 system memory. Its function is to store the corresponding interrupt vectors in order from small to large according to the interrupt type number, and a total of 256 interrupt vectors are stored. During the interrupt response process, the CPU calculates the position of the corresponding interrupt vector in the table through the interrupt type number (interrupt vector number) obtained from the interface circuit, and obtains the interrupt vector from the interrupt vector table, and redirects the program flow to the entry address of the interrupt service program.
[0144] Interrupt service routine, the processor handles "urgent matters", which can be understood as a service, which is completed by executing a specific program that has been pre-programmed. This program that handles "urgent matters" is called an interrupt service routine. Get the entry address of the interrupt function from the interrupt vector table;
[0145] The startup process of the embedded program in the prior art is: after obtaining the stack top address, jump to the interrupt vector table, obtain the address of the interrupt service function, execute the interrupt reset function, and then enter the main program.
[0146] In this embodiment, step S203 may further include the following steps:
[0147] Get the entry address of the interrupt function from the first interrupt vector table;
[0148] After getting the stack top pointer, jump to the interrupt vector table to get the address of the reset interrupt vector;
[0149] After executing the first interrupt reset function, the main function of the upgrade program is started to perform software upgrade.
[0150] Step S204, after the upgrade program is executed, jump to the second interrupt vector table to retrieve the interrupt function entry address, then execute the second interrupt service function, and then return to the user application main function after executing the second interrupt service function.
[0151] Figure 7 This is the program operation flow chart of this application. Figure 7 As shown, this embodiment separates the online upgrade program and the user application. The online upgrade program only provides the online upgrade function, and the user application mainly meets the user's needs. After power-on, the program takes out the reset interrupt vector address from the interrupt vector table, executes the first interrupt reset function, and then jumps to the main function of the upgrade program. After the upgrade program is executed, it jumps to the second interrupt vector table to take out the interrupt function entry address, and then jumps to the new interrupt service function for execution. After executing the second interrupt service function, it returns to the main function of the user application.
[0152] The flash storage area is divided into two parts, one for storing the upgrade program and the other for storing the application program. The online upgrade program only takes up a small amount of space (e.g. 8-16K) and is separated from the user application program. Since the online upgrade program is relatively solidified, it is convenient for upgrading, maintaining and using, and is also suitable for online upgrading of other stand-alone products on the arrow. The online upgrade flag can be sent by the ground control system to the user application program through the CAN protocol to record the flag status. Even if the power is accidentally cut off during the upgrade process, the upgrade can be performed again after the power is restored to normal.
[0153] In some optional implementations of this embodiment, node data frame reception filtering principles can also be set on the CAN bus. The CAN bus is a general broadcast channel, and all kinds of information are transmitted on the bus. In order to avoid irrelevant information from interfering with each execution node, each node stand-alone must filter the CAN bus node information and only respond to information related to this node. In the entire CAN bus network, the identifier filtering function of the CAN bus controller is used to filter irrelevant messages by using whether D10 to D15 of the data frame ID is consistent with the node number of this device. A node refers to a device whose software is to be upgraded.
[0154] The present application can also set the node data frame reception filtering principle on the CAN bus, and only respond to information related to the node, thereby improving the efficiency of data interaction and saving time for online upgrades.
[0155] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0156] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through computer-readable instructions, and the computer-readable instructions can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
[0157] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.
[0158] Embodiment 2
[0159] Further references Figure 8 , as a response to the above Figure 3 The present application provides an embodiment of an online upgrade device, and the embodiment of the device is similar to Figure 3 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0160] like Figure 8 As shown, the online upgrade device 600 described in this embodiment includes: a setting module 601, an acquisition module 602, an upgrade module 603 and an adjustment module 604. Among them:
[0161] Setting module 601, used to set CAN bus network transmission rate and time slice allocation;
[0162] An acquisition module 602 is used to acquire a software upgrade program through the CAN bus according to the CAN bus network transmission rate and time slice allocation;
[0163] The upgrade module 603 is used to fetch the reset interrupt vector address from the first interrupt vector table, execute the first interrupt reset function, and then jump to the main function of the software upgrade program to perform software upgrade;
[0164] The jump module 604 is used to jump to the second interrupt vector table to retrieve the interrupt function entry address after the upgrade program is executed, and then execute the second interrupt service function, and then return to the user application main function after executing the second interrupt service function.
[0165] In implementing this embodiment, a mechanism is adopted to separate the online upgrade program and the user application program. The online upgrade program only provides the online upgrade function, and the user application program mainly meets the user's needs. A single cache mechanism is adopted in the flash to realize the online software upgrade and save space. During the upgrade process, even if the power is accidentally cut off, it can still be upgraded normally, which is convenient for online program upgrade and maintenance.
[0166] Embodiment 3
[0167] To solve the above technical problems, the present application also provides a computer device. Fig. 9 , Fig. 9 This is a basic structural block diagram of the computer device in this embodiment.
[0168] The computer device 7 includes a memory 71, a processor 72, and a network interface 73 that are interconnected and communicated through a system bus. It should be noted that the figure only shows a computer device 7 having components of a memory 71, a processor 72, and a network interface 73, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to a microprocessor, an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA), a digital processor (DSP), an embedded device, etc.
[0169] The computer device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The computer device may interact with a user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device.
[0170] The memory 71 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 71 can be an internal storage unit of the computer device 7, such as a hard disk or memory of the computer device 7. In other embodiments, the memory 71 can also be an external storage device of the computer device 7, such as a plug-in hard disk equipped on the computer device 7, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (FlashCard), etc. Of course, the memory 71 can also include both the internal storage unit of the computer device 7 and its external storage device. In this embodiment, the memory 71 is generally used to store the operating system and various application software installed on the computer device 7, such as computer-readable instructions of the online upgrade method, etc. In addition, the memory 71 can also be used to temporarily store various types of data that have been output or are to be output.
[0171] The processor 72 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips in some embodiments. The processor 72 is generally used to control the overall operation of the computer device 7. In this embodiment, the processor 72 is used to run computer-readable instructions stored in the memory 71 or process data, such as computer-readable instructions for running the online upgrade method.
[0172] The network interface 73 may include a wireless network interface or a wired network interface. The network interface 73 is generally used to establish a communication connection between the computer device 7 and other electronic devices.
[0173] In implementing this embodiment, a mechanism is adopted to separate the online upgrade program and the user application program. The online upgrade program only provides the online upgrade function, and the user application program mainly meets the user's needs. A single cache mechanism is adopted in the flash to realize the online software upgrade and save space. During the upgrade process, even if the power is accidentally cut off, it can still be upgraded normally, which is convenient for online program upgrade and maintenance.
[0174] Embodiment 4
[0175] The present application also provides another implementation, namely, providing a computer-readable storage medium, wherein the computer-readable storage medium stores computer-readable instructions, and the computer-readable instructions can be executed by at least one processor to enable the at least one processor to perform the steps of the online upgrade method as described above.
[0176] In implementing this embodiment, a mechanism is adopted to separate the online upgrade program and the user application program. The online upgrade program only provides the online upgrade function, and the user application program mainly meets the user's needs. A single cache mechanism is adopted in the flash to realize the online software upgrade and save space. During the upgrade process, even if the power is accidentally cut off, it can still be upgraded normally, which is convenient for online program upgrade and maintenance.
[0177] Through the description of the above implementation methods, those skilled in the art 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 such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0178] Obviously, the embodiments described above are only some embodiments of the present application, rather than all embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application is described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific implementation methods, or to perform equivalent replacement of some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of this application, directly or indirectly used in other related technical fields, is similarly within the scope of patent protection of this application.
Claims
1. An online upgrade method, applied to CAN bus, characterized in that: The steps include: Set the CAN bus network transmission rate and time slice allocation; According to the CAN bus network transmission rate and time slice allocation, the software upgrade program is obtained through the CAN bus; Take out the reset interrupt vector address from the first interrupt vector table, execute the first interrupt reset function, and then jump to the main function of the software upgrade program to perform software upgrade; The flash storage area is set up in two parts, one part stores the upgrade program, and the other part stores the application program. After the upgrade program is executed, it jumps to the second interrupt vector table, takes out the interrupt function entry address, and then executes the second interrupt service function. After executing the second interrupt service function, it returns to the main function of the user application program. The steps to obtain the software upgrade program through the CAN bus include: Get the online upgrade logo; Enter online upgrade mode; Receive the ground control system upgrade software via the CAN bus according to the CAN bus network transmission rate and time slice allocation; Writing the upgrade software into flash; Clear the online upgrade flag.
2. The online upgrade method according to claim 1, characterized in that: The steps of setting the CAN bus network transmission rate and time slice allocation specifically include: Set the CAN bus network transmission rate to 300Kbps~800Kbps, and set the clock crystal of the device to be upgraded to an integer multiple of 8MHz; The CAN bus time slice allocation is set to 10 time slices per bit, including 1 bit for the synchronization segment, 5 bits for the propagation segment and the first phase buffer segment, and 4 bits for the second phase buffer segment.
3. The online upgrade method according to claim 1, characterized in that: The steps of taking out the reset interrupt vector address from the first interrupt vector table, executing the first interrupt reset function, and jumping to the main function of the software upgrade program to perform software upgrade specifically include: Get the stack top pointer; Jump to the first interrupt vector table, obtain the address of the reset interrupt vector, the address of the reset interrupt vector points to the entry address of the first interrupt service function; After executing the first interrupt reset function, the main function of the upgrade program is started to perform software upgrade.
4. The online upgrade method according to claim 1, characterized in that: The step of receiving the ground control system upgrade software via the CAN bus according to the CAN bus network transmission rate and time slice allocation specifically includes: Receiving packet data sent by the ground control system through the CAN bus, wherein the packet data carries a sender verification code; Performing CRC algorithm calculation on the packet data and comparing it with the sender's check code; If the comparison is consistent, the package data is assembled and connected into the upgraded software, otherwise the package data is discarded.
5. The online upgrade method according to any one of claims 1 to 4, characterized in that: A node data frame reception filtering principle is set on the CAN bus.
6. An online upgrade device, characterized in that: include: Setting module, used to set CAN bus network transmission rate and time slice allocation; An acquisition module is used to acquire the software upgrade program through the CAN bus according to the CAN bus network transmission rate and time slice allocation; The upgrade module is used to fetch the reset interrupt vector address from the first interrupt vector table, execute the first interrupt reset function, and then jump to the main function of the software upgrade program to perform software upgrade; The jump module is used to set the flash storage area into two parts, one part stores the upgrade program, and the other part stores the application program. After the upgrade program is executed, it jumps to the second interrupt vector table to fetch the interrupt function entry address, and then executes the second interrupt service function. After executing the second interrupt service function, it returns to the main function of the user application program; The acquisition module is specifically used for: Get the online upgrade logo; Enter online upgrade mode; Receive the ground control system upgrade software via the CAN bus according to the CAN bus network transmission rate and time slice allocation; Writing the upgrade software into flash; Clear the online upgrade flag.
7. A computer device, comprising a memory and a processor, wherein the memory stores computer-readable instructions, and the processor implements the steps of the online upgrade method according to any one of claims 1 to 5 when executing the computer-readable instructions.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, the steps of the online upgrade method according to any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Remote online upgrading method based on CAN (Controller Area Network) bus
CN103019788A
Bootloader software updating method based on CAN (controller area network) bus
CN103294511A
DSP software online upgrading system based on double FLASH program spaces
CN114115956A
Method for carrying out an operating system update
EP3118739A1
