Disclosure of Invention
In order to solve the problem that the starting time of a camera needs about 60s, and when an emergency repair program or a self-upgrade program needs to be used, the service requirements of some monitoring scenes with high real-time requirements cannot be met due to the long-time starting time, the embodiment of the invention provides a program starting method and a program starting device. The technical scheme is as follows:
in a first aspect, a program starting method is provided, which is applied to a terminal device installed with a first operating system and a second operating system, where the time consumed for starting the first operating system is less than the time consumed for starting the second operating system, and the method includes:
starting a bootstrap program, wherein the bootstrap program is a program used for booting the first operating system or the second operating system to start;
detecting whether a starting condition corresponding to a predetermined application program is met through the bootstrap program;
when a starting condition corresponding to the preset application program is met, starting the first operating system through the bootstrap program;
and starting the predetermined application program in the first operating system.
In a first possible implementation manner of the first aspect, the start-up condition includes: receiving a preset starting signal corresponding to the preset application program;
the detecting, by the bootstrap program, whether a start-up condition corresponding to a predetermined application program is satisfied includes:
receiving an externally input starting signal through the bootstrap program;
detecting whether the starting signal is the preset starting signal or not through the bootstrap program.
In a second possible implementation manner of the first aspect, the start-up condition includes: the preset identification bit of the preset configuration file has a value corresponding to the preset application program;
the detecting, by the bootstrap program, whether a start-up condition corresponding to a predetermined application program is satisfied includes:
reading the preset configuration file through the bootstrap program;
and detecting whether a preset identification bit in the preset configuration file has a value corresponding to the preset application program or not through the bootstrap program.
With reference to the second possible implementation manner of the first aspect, in a third possible implementation manner, before the reading, by the bootstrap program, the method further includes:
receiving a configuration instruction;
and setting a preset identification bit in the preset configuration file as a value corresponding to the preset application program according to the configuration instruction.
In a fourth possible implementation form of the first aspect, the start-up conditions include: the diagnosis result of the self-diagnosis application program is that the fault to be repaired exists;
the detecting, by the bootstrap program, whether a start-up condition corresponding to a predetermined application program is satisfied includes:
acquiring a diagnosis result of the self-diagnosis program through the guide program;
and detecting whether the diagnosis result of the self-diagnosis program is that the fault to be repaired exists or not through the bootstrap program.
With reference to the first aspect, the first possible implementation manner of the first aspect, the second possible implementation manner of the first aspect, the third possible implementation manner of the first aspect, or the fourth possible implementation manner of the first aspect, in a fifth possible implementation manner, the start condition includes:
the predetermined application program includes: a repair procedure and/or a self-upgrade procedure;
the starting the predetermined application program in the first operating system comprises:
starting the repair program in the first operating system to repair the fault;
and/or the presence of a gas in the gas,
and starting the self-upgrade program in the first operating system to upgrade the second operating system, and/or upgrading at least one application program in the second operating system.
In a second aspect, a program starting apparatus is provided, which is applied to a terminal device installed with a first operating system and a second operating system, where the time consumed for starting the first operating system is less than the time consumed for starting the second operating system, and the apparatus includes:
the first starting module is used for starting a bootstrap program, and the bootstrap program is a program used for guiding the first operating system or the second operating system to start;
the condition detection module is used for detecting whether a starting condition corresponding to a preset application program is met or not through the bootstrap program;
the second starting module is used for starting the first operating system through the bootstrap program when the starting condition corresponding to the preset application program is met;
and the third starting module is used for starting the preset application program in the first operating system.
In a first possible implementation manner of the second aspect, the starting condition includes: receiving a preset starting signal corresponding to the preset application program; the condition detection module includes:
the first receiving module is used for receiving an externally input starting signal through the bootstrap program;
and the signal detection module is used for detecting whether the starting signal is the preset starting signal or not through the bootstrap program.
In a second possible implementation manner of the second aspect, the starting condition includes: the preset identification bit of the preset configuration file has a value corresponding to the preset application program; the condition detection module includes:
the configuration reading module is used for reading the preset configuration file through the bootstrap program;
and the configuration detection module is used for detecting whether the preset identification bit of the preset configuration file has a value corresponding to the preset application program.
With reference to the second possible implementation manner of the second aspect, in a third possible implementation manner, the apparatus further includes:
the instruction receiving module is used for receiving a configuration instruction;
and the identification bit setting module is used for setting the preset identification bit in the preset configuration file to a value corresponding to the preset application program according to the configuration instruction.
In a fourth possible implementation manner of the second aspect, the starting condition includes: the diagnosis result of the self-diagnosis program is that the fault to be repaired exists; the condition detection module includes:
a self-diagnosis acquisition module for acquiring a diagnosis result of the self-diagnosis program through the bootstrap program;
and the self-diagnosis detection module is used for detecting whether the diagnosis result of the self-diagnosis program is that the fault to be repaired exists or not through the guide program.
With reference to the second aspect, the first possible implementation manner of the second aspect, the second possible implementation manner of the second aspect, the third possible implementation manner of the second aspect, or the fourth possible implementation manner of the second aspect, in a fifth possible implementation manner, the predetermined application program includes: a repair procedure and/or a self-upgrade procedure;
the third starting module is used for starting the repair program in the first operating system to repair the fault; and/or the third starting module is configured to start the self-upgrade program in the first operating system to upgrade the second operating system, and/or to upgrade at least one application program in the second operating system.
In a third aspect, there is provided a program starting apparatus, the apparatus comprising: a processor; the memory is used for storing the executable instructions of the processor, the memory is provided with a first operating system and a second operating system, and the starting time consumption of the first operating system is less than that of the second operating system; wherein the processor is configured to:
starting a bootstrap program, wherein the bootstrap program is a program used for booting the first operating system or the second operating system to start;
detecting whether a starting condition corresponding to a predetermined application program is met through the bootstrap program;
when a starting condition corresponding to the preset application program is met, starting the first operating system through the bootstrap program;
and starting the predetermined application program in the first operating system.
In a fourth aspect, a computer-readable storage medium is provided, having stored thereon a computer program for implementing the steps of the method according to the first aspect as described above when executed by a processor.
The technical scheme provided by the embodiment of the invention has the following beneficial effects:
by installing two operating systems, namely a first operating system and a second operating system, in the device, and the starting time of the first operating system is less than that of the second operating system, when a predetermined application program (such as a repair program and/or a self-upgrade program) needs to be executed, the first operating system and the predetermined application program in the first operating system are started preferentially, so that the predetermined application program can enter an available state quickly, and the effect of meeting the service requirements of some monitoring scenes with high real-time requirements is achieved.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, embodiments of the present invention will be described in detail with reference to the accompanying drawings.
Fig. 1 is a schematic diagram of a monitoring system provided in an exemplary embodiment of the present invention. As shown in fig. 1, the monitoring system includes: one or moreterminal devices 120 and amanagement device 140.
Theend device 120 may be an embedded device such as: any one of road monitoring cameras, community security cameras, construction site cameras, industrial sensors and other devices.
Theterminal device 120 is connected to themanagement device 140 through a communication network. The communication network may be a wireless network or a wired network.
Themanagement device 140 may be a cell phone, a tablet, a laptop, a desktop, a server, and so on. Themanagement device 140 has the capability of remotely configuring and remotely controlling theterminal device 120. For example, if theterminal device 120 is a road monitoring camera in a certain area, themanagement device 140 is a desktop computer of a traffic management department in the area.
Fig. 2 is a schematic structural diagram of a terminal device according to an exemplary embodiment of the present invention. As shown in fig. 2, the terminal device includes a processor 210, a memory 220, a power supply 230, and a light sensing device 240.
The processor 210 may be at least one of a single core processor, a multi-core processor, an embedded chip, and an image processor having computing capabilities.
Memory 220 stores executable execution by processor 210. Illustratively, the memory 220 stores a boot program 221, a first operating system 222, and a second operating system 225. Wherein, a predetermined application 223 and other applications 224 are installed in the first operating system 222; the second operating system 225 has installed therein predetermined application programs 226 and other functional application programs 208.
The boot program 221 is a program for booting the first operating system and/or the second operating system to start, and when the terminal device is powered on and started, the processor 210 first reads and runs the boot program 221 stored in the memory 220, and the boot program 221 may decompress and load a kernel file of the operating system and run the kernel file to start the operating system. The Boot program 221 may be a U-Boot, Boot Loader, or the like, depending on the hardware platform.
Optionally, the first operating system 222 is a Real-time operating system (RTos), such as: LITEOS, UCOSII and VxWorks. Real-time operating systems are capable of performing system functions within a specified or determined time and systems that respond at external or internal, synchronous or asynchronous times. Typically, the real-time operating system is a single-threaded operating system.
A predetermined application 223 is installed in the first operating system 222, and other applications 224. The predetermined application 223 is a program requiring a start-up time period smaller than a preset condition, for example, the predetermined application 223 is a repair program and a self-upgrade program. The other application 224 may be at least one of a self-diagnosis program, an image processing program, a video input program, an encoding program, and a decoding program.
Optionally, the second operating system 225 is an operating system of the terminal device in a normal operating state. When the terminal device is a camera, the second operating system 225 may be a Linux operating system, and may also be a Windows operating system or an IOS operating system.
Other application programs 226 may be installed in the second operating system 222. The other application 226 may be at least one of an image processing program, a video input program, an encoding program, and a decoding program. Optionally, a predetermined application 223 may also be installed in the second operating system 222 for use in some scenarios (e.g., the first operating system is damaged).
Alternatively, when the predetermined application 223 includes a repair program for repairing a software function that has failed in the second operating system 225; when predetermined application 223 comprises a self-upgrade program, the self-upgrade program is used to repair second operating system 225 and/or individual application 226 in second operating system 225.
The power supply 230 is used to supply power to various hardware devices within the terminal equipment.
The light sensing device 240 is used to capture images or video. The light sensing device 240 may be a CCD light sensing device or a CMOS light sensing device.
It should be noted that the above-mentioned embodiment is an exemplary embodiment of the terminal device, and the terminal device in other embodiments may include more or less elements than the above-mentioned embodiment. For example, the terminal device may further include a sensor, and the terminal device may further include an I/O interface such as a serial interface and a network interface. The embodiment of the present invention is not limited thereto. Since the memory in the terminal device described above stores executable instructions of the processor, the processor is configured to execute the executable instructions in the memory to implement the program start-up method in the following respective method embodiments.
Fig. 3 is a flowchart of a program starting method according to an exemplary embodiment of the present invention. The method is exemplified by being applied to theterminal device 120 shown in fig. 1, and as shown in fig. 3, the program starting method includes:
and step 301, starting power up.
The power-on starting means that the terminal equipment starts a power supply to supply power to internal components. The power-up starting mode includes but is not limited to the following modes: if the terminal equipment is provided with a power key, a user presses the power key on the terminal equipment, and the power supply supplies power to all hardware elements of the terminal equipment for starting; if the terminal equipment does not have a power key, after the terminal equipment is connected with a power supply or after the power supply in the connected state starts to supply power, the power supply supplies power to all hardware elements of the terminal equipment for starting; thirdly, the terminal equipment receives a remote starting instruction or a remote restarting instruction of the management equipment through the network interface, and after the terminal equipment receives the remote starting instruction or the remote restarting instruction, the power supply supplies power to all hardware elements of the terminal equipment for starting; and fourthly, automatically restarting the terminal equipment to be powered on when the fault is diagnosed through the self-diagnosis program.
Step 302, a boot program is initiated.
The boot program is a program for booting the first operating system or the second operating system to start. Taking the bootstrap program as an example of a U-Boot program, after the terminal device is powered on and started, the processor first reads and runs a code of the bootstrap program U-Boot.
Step 303, determining whether a start condition corresponding to a predetermined application is satisfied.
The bootstrap program may detect whether a start condition corresponding to a predetermined application program is satisfied in a current start scene (or in a current start scene). Optionally, the predetermined application is a program requiring a start-up duration less than a preset duration. Optionally, the predetermined application includes a repair program and/or a self-upgrade program.
Optionally, the starting condition corresponding to the predetermined application is used to indicate that the predetermined application needs to be executed after starting, and the starting condition includes, but is not limited to, at least one of the following conditions:
1. a condition corresponding to a control signal of an external input (e.g., a user input);
2. a condition relating to an identification bit in a predetermined configuration file;
3. conditions relating to the diagnostic result of the self-diagnostic program.
When the starting condition corresponding to the preset application program is met, enteringstep 304; when the start-up condition corresponding to the predetermined application is not satisfied,step 306 is entered.
Step 304, the first operating system is started.
The boot program starts a first operating system, which is a system in which a predetermined application program is installed.
Step 305, a predetermined application program in the first operating system is started.
After the first operating system is started, a preset application program in the first operating system is started to execute the work of the preset application program.
Step 306, the second operating system is started.
The boot program starts the second operating system. Optionally, the second operating system is an operating system of the terminal device in a normal operating state.
In summary, according to the program starting method provided in the embodiment of the present invention, two operating systems, namely, the first operating system and the second operating system, are installed in the device, and the starting time of the first operating system is shorter than the starting time of the second operating system, when a predetermined application program (for example, a repair program and/or a self-upgrade program) needs to be executed, the first operating system and the predetermined application program in the first operating system are preferentially started, so that the predetermined application program can quickly enter an available state, and an effect of meeting service requirements of some monitoring scenarios with high real-time requirements is achieved.
In an exemplary implementation scenario, when automatic upgrade of the second operating system in the terminal device is required, a programmer may input a start signal to the terminal device during start-up through the computer and the serial port connection, where the start signal is used to instruct start-up of the first operating system and the self-upgrade program in the first operating system. The concrete implementation is as follows:
fig. 4 is a flowchart of a program start method according to another exemplary embodiment of the present invention. The method is exemplified by being applied to theterminal device 120 shown in fig. 1, and as shown in fig. 4, the application starting method includes:
and step 401, starting power up.
The power-on starting means that the terminal equipment starts a power supply to supply power to internal components. Such as: if the terminal equipment is provided with a power key, a user presses the power key on the terminal equipment, and the power supply supplies power to all hardware elements of the terminal equipment for starting; if the terminal equipment does not have a power key, after the power is connected or after the power in the connected state starts to supply power, the power supplies supply power to all hardware elements of the terminal equipment to start.
Atstep 402, a boot program is initiated.
After the terminal equipment is powered on and started, the processor firstly reads and runs a code of a bootstrap program, and detects whether a starting condition corresponding to a preset application program is met or not through the bootstrap program; and when the starting condition corresponding to the preset application program is met, starting the first operating system through the bootstrap program and starting the preset application program in the first operating system.
Step 403, receiving an externally input start signal.
The external input signal is usually input by an external input device, which is an input peripheral, a serial port connection, or a network interface.
Illustratively, a programmer connects a computer and a terminal device via a serial interface to establish a serial connection. And sending a starting signal to the terminal equipment through the serial port, wherein the starting signal is used for indicating to start the first operating system and/or the preset application program. For example, if the predetermined application is self-upgrade xxx, then the start signal is boot xxx.
Instep 404, it is determined whether the externally input start signal is a predetermined start signal.
The predetermined start signal is a signal corresponding to a predetermined application program. When the predetermined application program is a repair program, the predetermined start signal is a signal for starting the repair program; when the predetermined application program is a self-upgrade program, the predetermined start signal is a signal to start the self-upgrade program.
And the bootstrap program U-Boot judges whether the starting signal received from the serial port is a starting signal corresponding to a preset application program. For example, if the start signal is Boot xxx, the Boot program U-Boot determines that the start signal is a start signal corresponding to the self-upgrade program xxx.
When the externally input start signal is a predetermined start signal,step 405 is executed; when the externally input start signal is not the predetermined start signal,step 407 is executed.
Instep 405, a first operating system is started.
Taking the first operating system as RTos as an example, the boot program U-boot loads RTos kernel code and runs the RTos kernel code. The running RTos kernel code initializes the file system, the application environment, and various applications installed in the RTos operating system.
Atstep 406, a predetermined application of the first operating system is launched.
After the first operating system is started, the first operating system starts a predetermined application program.
Taking the example that the predetermined application is a self-upgrade program, the RTos operating system starts the self-upgrade program, which automatically upgrades each application in the Linux system and/or the Linux system.
Step 407, start the second operating system.
Taking the second operating system as Linux as an example, the bootstrap program U-boot loads the Linux kernel code and runs the Linux kernel code. The running Linux kernel code initializes the file system, the application environment and each application program installed in the Linux operating system and enters a normal working state.
Taking the terminal device as a camera as an example, the camera enters a normal monitoring working state after running the Linux system.
In summary, according to the program starting method provided in the embodiment of the present invention, two operating systems, namely, the first operating system and the second operating system, are installed in the device, and the starting time of the first operating system is shorter than the starting time of the second operating system, when a predetermined application program (for example, a repair program and/or a self-upgrade program) needs to be executed, the first operating system and the predetermined application program in the first operating system are preferentially started, so that the predetermined application program can quickly enter an available state, and an effect of meeting service requirements of some monitoring scenarios with high real-time requirements is achieved.
In this embodiment, the starting condition corresponding to the predetermined application program is that the starting signal input from the outside is the predetermined starting signal, and the first operating system and the predetermined application program in the first operating system can be started preferentially according to the external input from the user, so that the predetermined application program can enter the available state quickly.
In another exemplary scenario, the management device needs to upgrade n terminal devices, where n is a positive integer, and then the management device may send a configuration command to the n terminal devices through the communication network, and remotely control the n terminal devices to restart and automatically upgrade through the configuration command. The concrete implementation is as follows:
fig. 5 is a flowchart of a program start method according to another exemplary embodiment of the present invention. The method is exemplified by being applied to theterminal device 120 shown in fig. 1, and as shown in fig. 5, the program starting method includes:
step 501, a configuration command is received.
When the management equipment needs to remotely upgrade the n terminal equipment, the management equipment sends a configuration command to the n terminal equipment through a communication network. The configuration command is used to modify a configuration file inside the terminal device.
And the terminal equipment receives the configuration command sent by the management equipment. The terminal device stores a preset configuration file which is used for configuring a plurality of parameters of the bootstrap program when the bootstrap program is started. Illustratively, the predetermined profile includes: whether to launch parameters of the first operating system, and/or whether to launch parameters of a predetermined application.
For example, the predetermined configuration file includes an identifier bit 1 and an identifier bit 2, where when a value of the identifier bit 1 is 0, it represents that the first operating system is started, and when a value of the identifier bit 1 is 1, it represents that the second operating system is started; when the identification bit 2 takes a value of 0, the self-upgrading program is not started, and when the identification bit 2 takes a value of 1, the self-upgrading program is started.
In default, the flag bit 1 takes a value of 1, and the flag bit 2 takes a value of 0.
Step 502, setting a predetermined identification bit in a predetermined configuration file to a value corresponding to a predetermined application program.
When upgrading is needed, the terminal equipment receives a configuration command sent by the management equipment, and then a value corresponding to a preset application program is set according to a preset identification bit in a preset configuration file of the configuration command.
For example, flag bit 1 is set to 0, and flag bit 2 is set to 1.
Step 503, the device is turned off.
Optionally, the configuration command is further used to instruct the terminal device to restart after modifying the configuration file, or restart at a specified time. In the restarting process, the terminal equipment firstly shuts down the equipment
And step 504, starting power up.
Step 505, a boot program is initiated.
When the terminal equipment is powered on and started, the processor firstly reads and runs the codes of the bootstrap program.
Step 506, reading a predetermined configuration file.
The bootstrap program stores a file path of a preset configuration file, and reads the preset configuration file from the file path.
Step 507, determining whether the predetermined flag in the predetermined configuration file has a value corresponding to the predetermined application program.
And after reading the preset configuration file, the bootstrap program judges whether the preset identification bit in the preset configuration file has a value corresponding to the preset application program.
For example, the bootstrap program determines whether the value of flag bit 1 in the predetermined configuration file is 0, and whether the value of flag bit 2 is 1.
When the predetermined flag has a value corresponding to the predetermined application, go to step 508; when the predetermined flag does not have a value corresponding to the predetermined application,step 510 is performed.
Atstep 508, the first operating system is started.
Taking the first operating system as RTos as an example, the boot program U-boot loads RTos kernel code and runs the RTos kernel code. The running RTos kernel code initializes the file system, the application environment, and various applications installed in the RTos operating system. .
Instep 509, the first os-subscribed application is launched.
After the first operating system is started, the first operating system starts a predetermined application program.
Taking the example that the predetermined application is a self-upgrade program, the RTos operating system starts the self-upgrade program, which automatically upgrades each application in the Linux system and/or the Linux system.
Step 510, a second operating system is started.
Taking the second operating system as Linux as an example, the bootstrap program U-boot loads the Linux kernel code and runs the Linux kernel code. The running Linux kernel code initializes the file system, the application environment and each application program installed in the Linux operating system and enters a normal working state.
Taking the terminal device as a camera as an example, the camera enters a normal monitoring working state after running the Linux system.
In summary, according to the program starting method provided in the embodiment of the present invention, two operating systems, namely, the first operating system and the second operating system, are installed in the device, and the starting time of the first operating system is shorter than the starting time of the second operating system, when a predetermined application program (for example, a repair program and/or a self-upgrade program) needs to be executed, the first operating system and the predetermined application program in the first operating system are preferentially started, so that the predetermined application program can quickly enter an available state, and an effect of meeting service requirements of some monitoring scenarios with high real-time requirements is achieved.
In this embodiment, the starting condition corresponding to the predetermined application program is that the preset identification bit in the predetermined configuration file has a value corresponding to the predetermined application program, and the identification bit in the predetermined configuration file can be remotely modified by the management device, so that the plurality of terminal devices are controlled in batch to preferentially start the first operating system and the predetermined application program in the first operating system in the starting process, and the predetermined application program can quickly enter an available state, thereby achieving the effect of batch upgrading.
In another exemplary implementation scenario, during the last operation of the terminal device,
fig. 6 is a flowchart of an application startup method according to another exemplary embodiment of the present invention. The method is exemplified by being applied to the terminal device 106 shown in fig. 1, and as shown in fig. 6, the application starting method includes:
step 601, power-on starting.
The power-on starting means that the terminal equipment starts a power supply to supply power to internal components. Such as: and in the process of operating the second operating system, the terminal equipment automatically restarts power-on when the self-diagnosis program diagnoses that the fault exists. .
Atstep 602, a boot program is initiated.
The boot program is a program for booting the first operating system or the second operating system to start. Taking the bootstrap program as an example of a U-Boot program, after the terminal device is powered on and started, the processor first reads and runs a code of the bootstrap program U-Boot.
Step 603, self-diagnostic results are obtained.
The self-diagnosis program is a program for the second operating system to perform self-diagnosis check to detect whether there is a fault to be repaired. After the self-diagnostic program has completed its diagnosis, the self-diagnostic program writes the self-diagnostic result to a specified memory location where the bootstrap program has read capability.
And the bootstrap program reads a self-diagnosis result in the starting process so as to judge whether the second operating system has a fault to be repaired and needs to start the repair program. Alternatively, the repair procedure may also be referred to as a self-repair procedure or an emergency repair procedure.
Step 604, judging whether the diagnosis result of the self-diagnosis program is that the fault to be repaired exists.
And the bootstrap program judges whether the second operating system has the fault to be repaired according to the read self-diagnosis result. In some other embodiments, when the self-diagnosis program is also present in the first operating system, the boot program may further determine whether the fault to be repaired exists in the first operating system according to the read self-diagnosis result.
When the fault to be repaired exists, executingstep 605; when there is no fault to be repaired,step 607 is executed.
Step 605, start the first operating system.
Taking the first operating system as RTos as an example, the boot program U-boot loads RTos kernel code and runs the RTos kernel code. The running RTos kernel code initializes the file system, the application environment, and various applications installed in the RTos operating system.
Step 606, launch the first operating system to reserve the application program.
After the first operating system is started, the first operating system starts a predetermined application program.
Taking the predetermined application program as a repair program as an example, the RTos operating system starts the repair program, and the repair program automatically repairs the to-be-repaired fault in the Linux system and/or each application program in the Linux system.
Instep 607, the second operating system is started.
Taking the second operating system as Linux as an example, the bootstrap program U-boot loads the Linux kernel code and runs the Linux kernel code. The running Linux kernel code initializes the file system, the application environment and each application program installed in the Linux operating system and enters a normal working state.
Taking the terminal device as a camera as an example, the camera enters a normal monitoring working state after running the Linux system.
In summary, according to the program starting method provided in the embodiment of the present invention, two operating systems, namely, the first operating system and the second operating system, are installed in the device, and the starting time of the first operating system is shorter than the starting time of the second operating system, when a predetermined application program (for example, a repair program and/or a self-upgrade program) needs to be executed, the first operating system and the predetermined application program in the first operating system are preferentially started, so that the predetermined application program can quickly enter an available state, and an effect of meeting service requirements of some monitoring scenarios with high real-time requirements is achieved.
In this embodiment, the starting condition corresponding to the predetermined application program is that when the diagnostic result of the self-diagnostic program indicates that a fault to be repaired exists, that is, when a fault to be repaired exists in the second operating system, the terminal device can preferentially start the first operating system and the self-repairing program in the first operating system in the starting process, so that an effect of fast self-repairing is achieved.
The above-mentioned fig. 4 embodiment, fig. 5 embodiment and fig. 6 embodiment can be implemented in combination of two or three. The embodiments when the above three embodiments are combined are realized as follows:
fig. 7 is a flowchart of a program start method according to another exemplary embodiment of the present invention. The method is exemplified by being applied to theterminal device 120 shown in fig. 1, and as shown in fig. 7, the application starting method includes:
and step 701, powering on and starting.
The power-on starting means that the terminal equipment starts a power supply to supply power to internal components. The power-up starting mode includes but is not limited to the following modes: if the terminal equipment is provided with a power key, a user presses the power key on the terminal equipment, and the power supply supplies power to all hardware elements of the terminal equipment for starting; if the terminal equipment does not have a power key, after the terminal equipment is connected with a power supply or after the power supply in the connected state starts to supply power, the power supply supplies power to all hardware elements of the terminal equipment for starting; thirdly, the terminal equipment receives a remote starting instruction or a remote restarting instruction of the management equipment through the network interface, and after the terminal equipment receives the remote starting instruction or the remote restarting instruction, the power supply supplies power to all hardware elements of the terminal equipment for starting; and fourthly, automatically restarting the terminal equipment to be powered on when the fault is diagnosed through the self-diagnosis program.
Atstep 702, a boot program is initiated.
The boot program is a program for booting the first operating system or the second operating system to start, and when the terminal device is powered on and started, the processor runs and reads a code of the boot program in the memory, for example: U-BOOT, BOOT Loader, etc.
Step 703, receiving an externally input start signal.
The external input signal is usually input by an external input device, which is an input peripheral, a serial port connection, or a network interface.
Illustratively, a programmer connects a computer and a terminal device via a serial interface to establish a serial connection. And sending a starting signal to the terminal equipment through the serial port, wherein the starting signal is used for indicating to start the first operating system and/or the preset application program. For example, if the predetermined application is self-upgrade xxx, then the start signal is boot xxx.
Step 704, determine whether the externally input start signal is a predetermined start signal.
The predetermined start signal is a signal corresponding to a predetermined application program. When the predetermined application program is a repair program, the predetermined start signal is a signal for starting the repair program; when the predetermined application program is a self-upgrade program, the predetermined start signal is a signal to start the self-upgrade program.
And the bootstrap program U-Boot judges whether the starting signal received from the serial port is a starting signal corresponding to a preset application program. For example, if the start signal is Boot xxx, the Boot program U-Boot determines that the start signal is a start signal corresponding to the self-upgrade program xxx.
When the externally input start signal is a predetermined start signal,step 709 is executed; when the externally input start signal is not the predetermined start signal, or the externally input start signal is not received instep 703,step 705 is performed.
Step 705, reading a predetermined configuration file.
The bootstrap program stores a file path of a preset configuration file, and reads the preset configuration file from the file path.
For example, the predetermined configuration file includes an identifier bit 1 and an identifier bit 2, where when a value of the identifier bit 1 is 0, it represents that the first operating system is started, and when a value of the identifier bit 1 is 1, it represents that the second operating system is started; when the identification bit 2 takes a value of 0, the self-upgrading program is not started, and when the identification bit 2 takes a value of 1, the self-upgrading program is started. In default, the flag bit 1 takes a value of 1, and the flag bit 2 takes a value of 0.
Step 706, determine whether the predefined flag in the predefined file has a value corresponding to the predefined application.
And after reading the preset configuration file, the bootstrap program judges whether the preset identification bit in the preset configuration file has a value corresponding to the preset application program.
For example, the bootstrap program determines whether the value of flag bit 1 in the predetermined configuration file is 0, and whether the value of flag bit 2 is 1.
When the predetermined identification bit has a value corresponding to the predetermined application program, executestep 709; when the predetermined flag does not have a value corresponding to the predetermined application,step 707 is performed.
Step 707, self-diagnosis results are acquired.
The self-diagnosis program is a program for the second operating system to perform self-diagnosis check to detect whether there is a fault to be repaired. After the self-diagnostic program has completed its diagnosis, the self-diagnostic program writes the self-diagnostic result to a specified memory location where the bootstrap program has read capability.
And the bootstrap program reads a self-diagnosis result in the starting process so as to judge whether the second operating system has a fault to be repaired and needs to start the repair program. Alternatively, the repair procedure may also be referred to as a self-repair procedure or an emergency repair procedure.
Step 708, judging whether the diagnosis result of the self-diagnosis program is that the fault to be repaired exists.
And the bootstrap program judges whether the second operating system has the fault to be repaired according to the read self-diagnosis result. In some other embodiments, when the self-diagnosis program is also present in the first operating system, the boot program may further determine whether the fault to be repaired exists in the first operating system according to the read self-diagnosis result.
When the fault to be repaired exists, executingstep 709; when there is no fault to be repaired,step 711 is performed.
Step 709, start the first operating system.
Taking the first operating system as RTos as an example, the boot program U-boot loads RTos kernel code and runs the RTos kernel code. The running RTos kernel code initializes the file system, the application environment, and various applications installed in the RTos operating system.
Step 710, a first operating system predetermined application is launched.
After the first operating system is started, the first operating system starts a predetermined application program.
Taking the example that the predetermined application is a self-upgrade program, the RTos operating system starts the self-upgrade program, which automatically upgrades each application in the Linux system and/or the Linux system.
Taking the predetermined application program as a repair program as an example, the RTos operating system starts the repair program, and the repair program automatically repairs the to-be-repaired fault in the Linux system and/or each application program in the Linux system.
Atstep 711, the second operating system is launched.
Taking the second operating system as Linux as an example, the bootstrap program U-boot loads the Linux kernel code and runs the Linux kernel code. The running Linux kernel code initializes the file system, the application environment and each application program installed in the Linux operating system and enters a normal working state.
Taking the terminal device as a camera as an example, the camera enters a normal monitoring working state after running the Linux system.
In summary, according to the program starting method provided in the embodiment of the present invention, two operating systems, namely, the first operating system and the second operating system, are installed in the device, and the starting time of the first operating system is shorter than the starting time of the second operating system, when a predetermined application program (for example, a repair program and/or a self-upgrade program) needs to be executed, the first operating system and the predetermined application program in the first operating system are preferentially started, so that the predetermined application program can quickly enter an available state, and an effect of meeting service requirements of some monitoring scenarios with high real-time requirements is achieved.
Fig. 8 is a block diagram of a program starting apparatus according to an exemplary embodiment of the present invention. The apparatus may be implemented by software, hardware or a combination of the two as all or a part of theterminal device 120 shown in fig. 1, as shown in fig. 8, and the program starting apparatus includes:
afirst starting module 801, configured to start a boot program, where the boot program is a program for starting the first operating system or the second operating system;
acondition detection module 802, configured to detect, by the bootstrap program, whether a start condition corresponding to a predetermined application program is satisfied;
asecond starting module 803, configured to start the first operating system through the bootstrap program when a starting condition corresponding to the predetermined application program is satisfied;
athird starting module 804, configured to start the predetermined application program in the first operating system.
In summary, in the program starting apparatus provided in the embodiment of the present invention, two operating systems, namely, the first operating system and the second operating system, are installed in the device, and the starting time of the first operating system is shorter than the starting time of the second operating system, when a predetermined application program (for example, a repair program and/or a self-upgrade program) needs to be executed, the first operating system and the predetermined application program in the first operating system are preferentially started, so that the predetermined application program can quickly enter an available state, and an effect of meeting service requirements of some monitoring scenarios with high real-time requirements is achieved.
Fig. 9 is a diagram of an application startup device according to another exemplary embodiment of the present invention. The apparatus may be implemented by software, hardware or a combination of the two as all or a part of theterminal device 120 shown in fig. 1, as shown in fig. 9, and the program starting apparatus includes:
afirst starting module 910, configured to start a boot program, where the boot program is a program for starting the first operating system or the second operating system;
a condition detecting module 920, configured to detect whether a start condition corresponding to a predetermined application is satisfied through the bootstrap;
asecond starting module 930, configured to start the first operating system through the boot program when a starting condition corresponding to the predetermined application program is satisfied;
athird starting module 940, configured to start the predetermined application program in the first operating system.
In an alternative embodiment, the start-up conditions include: receiving a preset starting signal corresponding to the preset application program; the condition detecting module 920 includes:
afirst receiving module 921, configured to receive an externally input start signal through the bootstrap;
thesignal detecting module 922 is configured to detect whether the start signal is the predetermined start signal through the bootstrap.
In an alternative embodiment, the start-up conditions include: the preset identification bit of the preset configuration file has a value corresponding to the preset application program; the condition detecting module 920 includes:
aconfiguration reading module 923, configured to read the predetermined configuration file through the bootstrap program;
theconfiguration detecting module 924 is configured to detect whether a predetermined identifier of a predetermined configuration file has a value corresponding to the predetermined application program.
In an optional embodiment, the apparatus further comprises:
aninstruction receiving module 902, configured to receive a configuration instruction;
anidentifier setting module 904, configured to set, according to the configuration instruction, a predetermined identifier in the predetermined configuration file to a value corresponding to the predetermined application program.
In an alternative embodiment, the start-up conditions include: the diagnosis result of the self-diagnosis program is that the fault to be repaired exists; the condition detecting module 920 includes:
a self-diagnosis acquisition module 925 for acquiring a diagnosis result of the self-diagnosis program by the bootstrap program;
a self-diagnosis detection module 926, configured to detect, by the bootstrap program, whether a diagnosis result of the self-diagnosis program is that a fault to be repaired exists.
In an alternative embodiment, the predetermined application includes: a repair procedure and/or a self-upgrade procedure;
thethird starting module 940 is configured to start the repair program in the first operating system to perform fault repair;
and/or the presence of a gas in the gas,
thethird starting module 940 is configured to start the self-upgrade program in the first operating system to upgrade the second operating system, and/or upgrade at least one application program in the second operating system.
It should be noted that: the program starting device provided in the above embodiment is only illustrated by the division of the above functional modules when a predetermined application program is started, and in practical applications, the above function distribution may be completed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the above described functions. In addition, the embodiments of the application program starting method and the apparatus provided in the above embodiments belong to the same concept, and specific implementation processes thereof are described in the method embodiments in detail and are not described herein again.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by hardware related to instructions of a computer program, which may be stored in a computer readable storage medium, and when the computer program is executed by a processor, the computer program is used for implementing the steps of the program starting method provided in the above embodiments of the method, and the computer readable storage medium may be a non-volatile memory, a read-only memory, a magnetic or optical disk, and the like.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.