CN114356383A - Firmware upgrading method and system of Bootloader architecture - Google Patents

Firmware upgrading method and system of Bootloader architecture Download PDF

Info

Publication number
CN114356383A
CN114356383A CN202210035756.4A CN202210035756A CN114356383A CN 114356383 A CN114356383 A CN 114356383A CN 202210035756 A CN202210035756 A CN 202210035756A CN 114356383 A CN114356383 A CN 114356383A
Authority
CN
China
Prior art keywords
firmware
program
bootloader
mode
flash
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210035756.4A
Other languages
Chinese (zh)
Inventor
陈杰坪
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Icube Corp ltd
Original Assignee
Icube Corp ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Icube Corp ltd filed Critical Icube Corp ltd
Priority to CN202210035756.4A priority Critical patent/CN114356383A/en
Publication of CN114356383A publication Critical patent/CN114356383A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Stored Programmes (AREA)

Abstract

The invention relates to the field of system architecture design, in particular to a firmware upgrading method and a firmware upgrading system for a Bootloader architecture. The method comprises the following steps: s1, starting an embedded system, initializing a serial port, running boot, reading and printing the state of the bootsel, entering a firmware upgrading mode if the bootsel =2 is recognized, and executing a step S2; if bootsel =0 is recognized, entering a default startup mode and executing step S3; s2, initializing functions such as spi and uart, establishing a connection with a flash in a chip through an spi communication protocol, carrying out erasing and reading-writing operations on the flash, writing firmware into the flash from a serial port through a serial port interrupt function, and completing firmware updating by restarting and switching to a main mode; and S3, adding ddr initialization into the original firmware program, writing the firmware upgrading program into ddr through jlink, running the program in ddr, and updating the original firmware in the flash through serial port interruption to finish firmware upgrading of the bootloader. The invention has strong expandability and obvious advantages in the aspects of software updating and function expansion.

Description

Firmware upgrading method and system of Bootloader architecture
Technical Field
The invention relates to the field of system architecture design, in particular to a firmware upgrading method and a firmware upgrading system for a Bootloader architecture.
Background
The embedded system is centered on application, and the software and hardware can be tailored, so that the embedded system is suitable for a special computer system with strict comprehensive requirements on functions, reliability, cost, volume, power consumption and the like. The method has the characteristics of small software code, high automation, high response speed and the like, and is particularly suitable for a system requiring real time and multiple tasks. The embedded system mainly comprises an embedded processor, related supporting hardware, an embedded operating system, an application software system and the like, and can work independently. BootLoader is a program used for completing the startup of an embedded system and the loading work of system software, and is a key step in system development. The BootLoader provides powerful program downloading and debugging functions on one hand, and is convenient for extension updating and software upgrading on the other hand, so that a friendly software architecture which is convenient for modification and transplantation on all microprocessors is provided for users. The embedded operating system without BootLoader has poor flexibility, lacks the information interaction process with the user, and cannot realize convenient and effective parameter transmission.
Disclosure of Invention
The invention provides a firmware upgrading method and a firmware upgrading system of a Bootloader architecture, and aims to solve the problems of poor flexibility, lack of information interaction and the like of an existing embedded operating system.
The invention provides a firmware upgrading method of a Bootloader framework, which comprises the following steps:
s1, starting an embedded system, initializing a serial port, running boot, reading and printing the state of the bootsel, entering a firmware upgrading mode if the bootsel =2 is recognized, and executing a step S2; if bootsel =0 is recognized, entering a default startup mode and executing step S3;
s2, initializing functions such as spi and uart, establishing a connection with a flash in a chip through an spi communication protocol, carrying out erasing and reading-writing operations on the flash, writing firmware into the flash from a serial port through a serial port interrupt function, and completing firmware updating by restarting and switching to a main mode;
and S3, adding ddr initialization into the original firmware program, writing the firmware upgrading program into ddr through jlink, running the program in ddr, and updating the original firmware in the flash through serial port interruption to finish firmware upgrading of the bootloader.
As a further improvement of the invention, after the embedded system enters the firmware upgrading mode, the following steps are executed:
a1. and printing prompt information by a program, loading a firmware upgrading program, sending a new firmware program from a serial port to a flash to complete firmware upgrading, switching back to a default starting mode of a main mode bootloader =0, and running a brand new firmware to complete operation on upper-layer equipment when the system is powered on and reset again.
As a further improvement of the invention, when a developer makes a new firmware program and needs to upgrade the firmware, the embedded system is switched into a default starting mode to execute:
a2. the method comprises the steps that a program reads data stored in a flash fixing position, the data stores size information and verification information of firmware, firmware data in the flash are copied to sram according to the size information of the firmware, whether copying is accurate or not is judged according to the verification information of the firmware, if the copying is correct, the firmware information is executed, various initialization operations required by upper-layer equipment are loaded, and if the data are copied incorrectly, an error is reported and the process is carried out again.
As a further improvement of the present invention, when firmware data is copied to sram and an error occurs or new program needs to be written into sram for debugging, the program is directly written into sram for running and debugging by switching to enter a debugging mode, and the following steps are performed:
a3. after the program prints the prompt information, the program is in an interrupted state, waiting for a debugger to send the debugged firmware program to the sram and directly run the firmware content, and modifying the firmware by the debugger by checking log information printed by the serial port.
The invention also provides a firmware upgrading system of the Bootloader architecture, which comprises the following components:
an initialization module: executing starting of the embedded system, initializing a serial port, running boot, reading and printing the state of the bootsel, and entering a default starting module, a debugging module or a firmware upgrading module according to the state of the bootsel;
a default starting module: executing a default starting mode of the bootloader program;
a debugging module: executing a debugging mode of the bootloader program;
a firmware upgrading module: and executing a firmware upgrading mode of the bootloader program.
As a further improvement of the present invention, the default starting module specifically executes:
the method comprises the steps that a program reads data stored in a flash fixing position, the data stores size information and verification information of firmware, firmware data in the flash are copied to sram according to the size information of the firmware, whether copying is accurate or not is judged according to the verification information of the firmware, if the copying is correct, the firmware information is executed, various initialization operations required by upper-layer equipment are loaded, and if the data are copied incorrectly, an error is reported and the process is carried out again.
As a further improvement of the present invention, the debugging module specifically executes:
after the program prints the prompt information, the program is in an interrupted state, waiting for a debugger to send the debugged firmware program to the sram and directly run the firmware content, and modifying the firmware by the debugger by checking log information printed by the serial port.
As a further improvement of the present invention, the firmware upgrade module specifically executes:
and printing prompt information by a program, loading a firmware upgrading program, sending a new firmware program from a serial port to a flash to complete firmware upgrading, switching back to the default starting mode of the main mode, and running a brand new firmware to complete the operation of upper-layer equipment when the system is powered on and reset again.
The invention has the beneficial effects that: the mode of upgrading the firmware is added on the basis of the original embedded system architecture, so that the originally independent program loading and debugging module is integrated, the flash in the chip can be directly updated, and meanwhile, another mode is provided for updating the firmware: firmware updating is carried out on the flash in the chip from the ddr memory, and the development efficiency of the Bootloader is greatly improved.
Drawings
Fig. 1 is a flowchart of a Bootloader architecture firmware upgrading method according to the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments.
The invention relates to a BootLoader architecture design method, in particular to a BootLoader architecture design method which has clear architecture, more powerful functions, convenient maintenance and modification, strong expandability and obvious advantages in the aspects of software updating and function expansion.
As shown in fig. 1, a firmware upgrading method of a Bootloader architecture of the present invention includes the following steps:
s1, starting an embedded system, initializing a serial port, running a boot, printing boot is running information, reading and printing a bootsel state, entering a firmware upgrading mode if the bootsel =2, and executing a step S2; if bootsel =0 is recognized, entering a default startup mode and executing step S3;
s2, initializing functions such as spi and uart, establishing a connection with a flash in a chip through an spi communication protocol, performing operations such as erasing and reading-writing operations on the flash, writing firmware into the flash from a serial port through a serial port interrupt function, and completing firmware updating by restarting and switching to a main mode;
and S3, adding ddr initialization into the original firmware program, writing the firmware upgrading program into ddr through jlink, running the program in ddr, and updating the original firmware in the flash through serial port interruption to finish firmware upgrading of the bootloader.
Steps S2 and S3 are two independent firmware upgrading methods. Firstly, the mode of step S2 is to switch from the original default mode to the Bootsel =2 mode, i.e., the firmware upgrade mode, and update the firmware through the mode in the firmware upgrade process; secondly, the mode of step S3 is that during the firmware upgrade, the firmware program is still in the current default mode, and the firmware update of the flash in the chip is completed by loading the update firmware program in ddr through jlink/st-link.
After the system is initialized, the following three cases can be distinguished according to different states of reading and printing bootsel.
When the embedded system enters a firmware upgrading mode, executing the following steps: a1. and printing prompt information by a program, loading a firmware upgrading program, sending a new firmware program from a serial port to a flash to complete firmware upgrading, switching back to a default starting mode of a main mode bootloader =0, and running a brand new firmware to complete operation on upper-layer equipment when the system is powered on and reset again.
When a developer makes a new firmware program and needs to upgrade the firmware, the embedded system is switched into a default starting mode to execute: a2. the method comprises the steps that a program reads data stored in a flash fixing position, the data stores size information and verification information of firmware, firmware data in the flash are copied to sram according to the size information of the firmware, whether copying is accurate or not is judged according to the verification information of the firmware, if the copying is correct, the firmware information is executed, various initialization operations required by upper-layer equipment are loaded, and if the data are copied incorrectly, an error is reported and the process is carried out again.
When firmware data is copied to sram and errors occur or new programs need to be written into sram for debugging, directly writing the programs into sram for running debugging by switching to enter a debugging mode, and executing: a3. after the program prints the prompt information, the program is in an interrupted state, waiting for a debugger to send the debugged firmware program to the sram and directly run the firmware content, and modifying the firmware by the debugger by checking log information printed by the serial port.
As shown in fig. 1, the present invention further provides a firmware upgrading system of a Bootloader architecture, including:
an initialization module: executing starting of the embedded system, initializing a serial port, running boot and printing boot is running information, reading and printing a bootsel state, and entering a default starting module, a debugging module or a firmware upgrading module according to the bootsel state;
a default starting module: executing a default starting mode of the bootloader program;
a debugging module: executing a debugging mode of the bootloader program;
a firmware upgrading module: and executing a firmware upgrading mode of the bootloader program.
The system architecture comprises three modes:
BOOT _ MODE _ SPI _ NOR MODE: defaulting an execution mode corresponding to the starting module; this mode is the default starting mode of the bootloader program of the present invention. When the embedded system is started, initializing a serial port and printing Bootloader/running information to indicate that a boot is running, then reading and printing the status of the boot, entering a default mode if the boot =0 is recognized, reading data stored in a fixed position of a flash by a program, storing size information and verification information of firmware, copying the firmware data in the flash into an sram according to the size information, judging whether the copying is accurate or not through the verification information, executing the firmware information if the copying is correct, loading various initialization operations required by upper-layer equipment, and reporting an error and re-performing the process if the copying of the data is wrong.
In the default starting mode, when the bootloader starts to load, the boot state of the bootloader can be printed out through the serial port, for example: boot stat: 0x0/0x1/0x2 to inform the mode of the boot; the data size and the data accuracy are realized by adding the data size information of the firmware and the sum information of all binary data into the head of the firmware bin file, reading the data size information in the process of writing data into the flash in the chip, determining the receiving amount of the flash in the chip according to the size information, finally, taking the sum of the binary data received by the flash to perform data comparison with the previous sum information, and if the comparison is wrong, reporting an error and prompting to renew the firmware.
BOOT _ MODE _ SERIAL MODE: debugging an execution mode corresponding to the module; this mode is the debug mode of bootloader. When data is copied to sram and errors occur or new programs need to be written into sram for debugging, the programs can be directly written into sram for running and debugging by switching the mode. After entering the debugging mode, the program is in an interrupted state after printing some prompt messages, waiting for a debugger to send the debugged firmware program to the sram and directly run the firmware content, and the debugger can modify the firmware by checking log information printed by the serial port.
BOOT _ update _ FLASH mode: the firmware upgrading module corresponds to an execution mode; this mode is the bootloader's firmware upgrade mode. When a developer makes a new firmware program and needs to upgrade the firmware, the mode can be switched to. After entering, the program firstly prints prompt information to indicate that the program enters the mode, then the firmware upgrading program is loaded, a developer sends a new firmware program prepared in advance to flash from a serial port at the moment so as to complete firmware upgrading, and finally the main mode bootloader =0 is switched back, once the system is powered on and reset again, the brand new firmware can be operated, and a series of supporting operations on upper-layer equipment are completed.
The mainstream architecture design mode of the prior bootloader still takes two modes of program loading and debugging as main modes, the firmware updating mode still uses a flash library function inside stm32 to independently complete the updating of flash in a chip, the firmware needs to be updated each time, the program needs to be recompiled, and then the upgrading and maintenance of the system are completed through the external j-flash, so that the flexibility is very deficient. Aiming at the problems, the invention adds a firmware upgrading mode on the basis of the former, so that the two originally independent modules are integrated, the flash in the chip can be directly updated, and meanwhile, another mode is provided for updating the firmware: firmware updating is carried out on the flash in the chip from the ddr memory, and the development efficiency of the Bootloader is greatly improved.
The foregoing is a more detailed description of the invention in connection with specific preferred embodiments and it is not intended that the invention be limited to these specific details. For those skilled in the art to which the invention pertains, several simple deductions or substitutions can be made without departing from the spirit of the invention, and all shall be considered as belonging to the protection scope of the invention.

Claims (8)

1. A firmware upgrading method of a Bootloader architecture is characterized by comprising the following steps:
s1, starting an embedded system, initializing a serial port, running boot, reading and printing the state of the bootsel, entering a firmware upgrading mode if the bootsel =2 is recognized, and executing a step S2; if bootsel =0 is recognized, entering a default startup mode and executing step S3;
s2, initializing functions such as spi and uart, establishing a connection with a flash in a chip through an spi communication protocol, carrying out erasing and reading-writing operations on the flash, writing firmware into the flash from a serial port through a serial port interrupt function, and completing firmware updating by restarting and switching to a main mode;
and S3, adding ddr initialization into the original firmware program, writing the firmware upgrading program into ddr through jlink, running the program in ddr, and updating the original firmware in the flash through serial port interruption to finish firmware upgrading of the bootloader.
2. The firmware upgrade method of the Bootloader architecture according to claim 1, wherein when the embedded system enters a firmware upgrade mode, the following steps are performed:
a1. and printing prompt information by a program, loading a firmware upgrading program, sending a new firmware program from a serial port to a flash to complete firmware upgrading, switching back to a default starting mode of a main mode bootloader =0, and running a brand new firmware to complete operation on upper-layer equipment when the system is powered on and reset again.
3. The method for upgrading firmware of the Bootloader architecture according to claim 1, wherein when a developer makes a new firmware program and needs to upgrade the firmware, the embedded system switches to enter a default boot mode to execute:
a2. the method comprises the steps that a program reads data stored in a flash fixing position, the data stores size information and verification information of firmware, firmware data in the flash are copied to sram according to the size information of the firmware, whether copying is accurate or not is judged according to the verification information of the firmware, if the copying is correct, the firmware information is executed, various initialization operations required by upper-layer equipment are loaded, and if the data are copied incorrectly, an error is reported and the process is carried out again.
4. The firmware upgrading method of the Bootloader architecture according to claim 3, wherein when firmware data is copied to sram with an error or when sram needs to be debugged by writing a new program, the debugging mode is switched to enter a debugging mode to directly write the program into sram for running and debugging, and the following steps are performed:
a3. after the program prints the prompt information, the program is in an interrupted state, waiting for a debugger to send the debugged firmware program to the sram and directly run the firmware content, and modifying the firmware by the debugger by checking log information printed by the serial port.
5. A firmware upgrade system of a Bootloader architecture, comprising:
an initialization module: executing starting of the embedded system, initializing a serial port, running boot, reading and printing the state of the bootsel, and entering a default starting module, a debugging module or a firmware upgrading module according to the state of the bootsel;
a default starting module: executing a default starting mode of the bootloader program;
a debugging module: executing a debugging mode of the bootloader program;
a firmware upgrading module: and executing a firmware upgrading mode of the bootloader program.
6. The firmware upgrade system of the Bootloader architecture according to claim 5, wherein the default boot module specifically executes:
the method comprises the steps that a program reads data stored in a flash fixing position, the data stores size information and verification information of firmware, firmware data in the flash are copied to sram according to the size information of the firmware, whether copying is accurate or not is judged according to the verification information of the firmware, if the copying is correct, the firmware information is executed, various initialization operations required by upper-layer equipment are loaded, and if the data are copied incorrectly, an error is reported and the process is carried out again.
7. The firmware upgrade system of the Bootloader architecture according to claim 5, wherein the debug module specifically performs:
after the program prints the prompt information, the program is in an interrupted state, waiting for a debugger to send the debugged firmware program to the sram and directly run the firmware content, and modifying the firmware by the debugger by checking log information printed by the serial port.
8. The firmware upgrade system of the Bootloader architecture according to claim 5, wherein the firmware upgrade module specifically executes:
and printing prompt information by a program, loading a firmware upgrading program, sending a new firmware program from a serial port to a flash to complete firmware upgrading, switching back to the default starting mode of the main mode, and running a brand new firmware to complete the operation of upper-layer equipment when the system is powered on and reset again.
CN202210035756.4A 2022-01-10 2022-01-10 Firmware upgrading method and system of Bootloader architecture Pending CN114356383A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210035756.4A CN114356383A (en) 2022-01-10 2022-01-10 Firmware upgrading method and system of Bootloader architecture

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210035756.4A CN114356383A (en) 2022-01-10 2022-01-10 Firmware upgrading method and system of Bootloader architecture

Publications (1)

Publication Number Publication Date
CN114356383A true CN114356383A (en) 2022-04-15

Family

ID=81109329

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210035756.4A Pending CN114356383A (en) 2022-01-10 2022-01-10 Firmware upgrading method and system of Bootloader architecture

Country Status (1)

Country Link
CN (1) CN114356383A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115016850A (en) * 2022-05-16 2022-09-06 北京计算机技术及应用研究所 UEFI (unified extensible firmware interface) firmware starting mode switching method based on domestic processor platform

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115016850A (en) * 2022-05-16 2022-09-06 北京计算机技术及应用研究所 UEFI (unified extensible firmware interface) firmware starting mode switching method based on domestic processor platform
CN115016850B (en) * 2022-05-16 2024-04-19 北京计算机技术及应用研究所 UEFI firmware starting mode switching method based on domestic processor platform

Similar Documents

Publication Publication Date Title
CN105912356B (en) A kind of optical module firmware program on-line upgrading method for supporting version rollback
TWI382346B (en) Computer system with dual bios protection mechanism and control method of the same
US20050268195A1 (en) Apparatus and method for improving emulation speed of high-level languages in on-chip emulation systems
CN113377408B (en) High-reliability SRAM type FPGA online upgrading method and system
CN112947977A (en) Software online upgrading method and system
CN114356383A (en) Firmware upgrading method and system of Bootloader architecture
JPH1078889A (en) Microcomputer
CN112540780A (en) System and method for realizing batch firmware upgrade of formation unmanned aerial vehicles
CN104035757A (en) MIPS-based (microprocessor without interlocked piped stages-based) U-boot (universal boot loader) transplantation implementing method
CN111736882B (en) Remote upgrading method of DSP program
CN102043654A (en) DSP simple development method based on TMS320VC55xx
CN116755749A (en) On-board MCU upgrading method, on-board MCU, board card and information processing system
WO2022199622A1 (en) Method for running startup program of electronic device, and electronic device
CN115904453A (en) Program online upgrading system and method based on double chips
JPH10240568A (en) Emulator device and emulation method
CN111984329A (en) Standardized boot software generation and execution method and system
KR20130040638A (en) Method for restoring error of boot image for fast booting and image forming apparatus for performing the same
KR100402516B1 (en) Method for renewing program code in an embedded micro-controller unit
KR20130040637A (en) Method for updating boot image for fast booting and image forming apparatus for performing the same
CN112883384B (en) Protection method of embedded computer boot loader with strong robustness
CN117931532B (en) Multi-granularity recovery method for embedded system program supported by on-chip hardware
CN212785388U (en) Firmware updating device for switch
CN117971286A (en) Boot loader updating method, microcontroller and computer readable storage medium
JP2521020B2 (en) Information processing system
US20050015580A1 (en) Method for transferring a command among a plurality of devices in a computer system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination