The wireless firmware upgrade method of thing connection positioning system
Technical field
The present invention is specifically related to the wireless firmware upgrade method of a kind of thing connection positioning system.
Background technology
Current most of microprocessor firmware upgrading is all that the fever writes adopting microprocessor to carry carries out firmware renewal, in this case, the renewal of firmware needs to have the instruments such as computer, fever writes, development environment and just can complete, bring much inconvenience to thus technician and client, delay project process.
Existing microprocessor program storage area is divided into Liang Ge district mostly: Bootloader district and APP district; Described APP district is the region at application program place, performs user program; And Bootloader district is program designation district, for loading application programs, carry out the renewal of application program.Present stage, conveniently firmware upgrade mode all adopted Bootloader district to guide, the existing application program of erasing, upgrade the mode of user program, but there is higher risk in this kind of upgrade method, once program upgrade failure, existing program is clashed, when situation is serious, whole equipment can be caused to paralyse, must factory be returned.And most of upgrade method all needs the cooperation of other equipment, as Serial Port Line etc., this also brings a little inconvenience to firmware upgrade.
Summary of the invention
The object of the invention is, provide a kind of effective and rapid, and the wireless firmware upgrade method of the thing connection positioning system of upgrading can be continued after power-off suspension, to overcome the deficiencies in the prior art.
In order to achieve the above object, technical scheme of the present invention is: a kind of wireless firmware upgrade method of thing connection positioning system, comprise the firmware had program stored therein, the program storage of described firmware is divided into Bootloader district, APP district and data temporary storage district, and Bootloader district is boot district, APP district is user program area or application area; It is characterized in that: the step of described wireless firmware upgrading is:
Step a, firmware power on after start, run Bootloader district;
The first character joint in step b, detection data temporary storage district, if first character joint is 1, then represents that firmware starts upgrading, execution step c; If first character joint is 2, then represents that upgrading last time of this firmware is interrupted, perform step f; If first character joint is 0, then represents that this firmware is without the need to upgrading, jump to APP district and perform user program;
Step c, second byte in the data temporary storage district of firmware started after region erasing, and waiting for server sends radio upgrade control signal, and radio upgrade control signal is divided into beginning upgrade signal and terminate upgrade signal, until firmware receives start upgrade signal;
Steps d, when firmware receive start upgrade signal time, wait-receiving mode server sends radio upgrade packet, the radio upgrade packet received is write data temporary storage district by described firmware continuously, and the address of write is first invalid data position that data temporary storage district retrieves from the beginning to the end, the data temporary storage district data bit after being erased of described firmware is invalid data position, when the data bit after write data is valid data position, and perform step e;
If when there is power-off or suspension phenomenon and cause upgrading time-out in firmware in escalation process, the data temporary storage district of firmware can preserve the radio upgrade packet received, and the first character in data temporary storage district joint changes to 2, waits for and again upgrading, and performs step f;
Step e, receive all radio upgrade packets when firmware, and after receiving the end upgrade signal sent by server, first by the data erase in the APP district of firmware, the all data Replicas second, data temporary storage district byte started again are to APP district, last obliterated data working area all the elements more also reset, and complete wireless firmware upgrading;
First invalid data position in step f, retrieve data working area, and show that firmware has received how many radio upgrade packets sent by server by the position of first invalid data position, also just learn that firmware also should continue to receive how many remaining data bag indexes, perform step g;
Step g, wait continue upgrading firmware waiting for server again send radio upgrade packet, until receive the packet of corresponding above-mentioned index, wait for some minutes in the process;
If wait for time period after do not receive valid wireless upgrading data packet yet, then obliterated data working area all the elements and reset, this firmware run upgrading Qian APP district store program;
If when firmware receives the valid wireless upgrading data packet sent by server, then the effective radio upgrade packet received is write data temporary storage district by firmware continuously, and the address of write is first invalid data position that data temporary storage district retrieves from the beginning to the end, when firmware receives all valid wireless upgrading data packet, and after receiving the end upgrade signal sent by server, first by the data erase in the APP district of firmware, the all data Replicas second, data temporary storage district byte started again are to APP district, last obliterated data working area all the elements more also reset, complete wireless firmware upgrading.
In technique scheme, firmware in escalation process, or upgrade complete before, still run in APP district the program stored.
In technique scheme, the program storage of described firmware is in units of sector, divide Bootloader district, APP district and data temporary storage district, and 1 ~ 3 sector of sector is Bootloader district, and 4 ~ 9 sectors are APP district, and 9 ~ 12 sectors are data temporary storage district.
The good effect that the present invention has is: after have employed above-mentioned wireless firmware upgrade method, the present invention has the following advantages: the first, simple to operate, and quickness and high efficiency; The second, without the need to any miscellaneous equipment, user-friendly; Three, because the program storage of firmware is divided into three districts, make firmware upgrade safer, also ensure that the integrality of upgrading data packet; Four, preserve the existing upgrading data packet of firmware after power-off suspension, then during upgrading next time, upgrading can be continued, the time of again again having upgraded after having saved power-off suspension.
Accompanying drawing explanation
Fig. 1 is the structural representation of the program storage of firmware of the present invention;
Fig. 2 is the process flow diagram of wireless firmware of the present invention upgrading.
Embodiment
Below in conjunction with accompanying drawing and the embodiment that provides, the present invention is further illustrated, but be not limited thereto.
As shown in Figure 1, 2, a kind of wireless firmware upgrade method of thing connection positioning system, comprise the firmware had program stored therein, the program storage of described firmware is divided into Bootloader district, APP district and data temporary storage district, and Bootloader district is boot district, APP district is user program area or application area; It is characterized in that: the step of described wireless firmware upgrading is:
Step a, firmware power on after start, run Bootloader district;
The first character joint in step b, detection data temporary storage district, if first character joint is 1, then represents that firmware starts upgrading, execution step c; If first character joint is 2, then represents that upgrading last time of this firmware is interrupted, perform step f; If first character joint is 0, then represents that this firmware is without the need to upgrading, jump to APP district and perform user program;
Step c, second byte in the data temporary storage district of firmware started after region erasing, and waiting for server sends radio upgrade control signal, and radio upgrade control signal is divided into beginning upgrade signal and terminate upgrade signal, until firmware receives start upgrade signal;
Steps d, when firmware receive start upgrade signal time, wait-receiving mode server sends radio upgrade packet, the radio upgrade packet received is write data temporary storage district by described firmware continuously, and the address of write is first invalid data position that data temporary storage district retrieves from the beginning to the end, the data temporary storage district data bit after being erased of described firmware is invalid data position, when the data bit after write data is valid data position, and perform step e;
If when there is power-off or suspension phenomenon and cause upgrading time-out in firmware in escalation process, the data temporary storage district of firmware can preserve the radio upgrade packet received, and the first character in data temporary storage district joint changes to 2, waits for and again upgrading, and performs step f;
Step e, receive all radio upgrade packets when firmware, and after receiving the end upgrade signal sent by server, first by the data erase in the APP district of firmware, the all data Replicas second, data temporary storage district byte started again are to APP district, last obliterated data working area all the elements more also reset, and complete wireless firmware upgrading;
First invalid data position in step f, retrieve data working area, and show that firmware has received how many radio upgrade packets sent by server by the position of first invalid data position, also just learn that firmware also should continue to receive how many remaining data bag indexes, perform step g;
Step g, wait continue upgrading firmware waiting for server again send radio upgrade packet, until receive the packet of corresponding above-mentioned index, wait for some minutes in the process;
If wait for time period after do not receive valid wireless upgrading data packet yet, then obliterated data working area all the elements and reset, this firmware run upgrading Qian APP district store program;
If when firmware receives the valid wireless upgrading data packet sent by server, then the effective radio upgrade packet received is write data temporary storage district by firmware continuously, and the address of write is first invalid data position that data temporary storage district retrieves from the beginning to the end, when firmware receives all valid wireless upgrading data packet, and after receiving the end upgrade signal sent by server, first by the data erase in the APP district of firmware, the all data Replicas second, data temporary storage district byte started again are to APP district, last obliterated data working area all the elements more also reset, complete wireless firmware upgrading.
Firmware of the present invention in escalation process, or upgrade complete before, still run in APP district the program stored.
The program storage of firmware of the present invention is in units of sector, divide Bootloader district, APP district and data temporary storage district, and 1 ~ 3 sector of sector is Bootloader district, 4 ~ 9 sectors are APP district, 9 ~ 12 sectors are data temporary storage district, can first reset when firmware receives the beginning upgrade signal that server sends, in preparation upgrading, and the program of firmware stores restarts to be perform from Bootloader district.
The wireless firmware upgrade method of thing connection positioning system of the present invention, based on thing connection positioning system existing device basis, coordinates without the need to any other equipment and has obvious feature.First, the program storage of firmware (microprocessor) is divided into three districts by the method, i.e. Bootloader district, App district and data temporary storage district.When program starts to upgrade, utilize flash to simulate eeprom function and first the program of renewal is write data temporary storage district, this region content power down is not also lost, the data transmitted can be preserved very well, the program of renewal is moved to APP district by supervisor end of transmission again, and the APP program before guaranteeing to upgrade unsuccessfully equally can be run; Secondly, the method uses wireless radio frequency mode transmission upgrading data packet, and the radio-frequency module of server has strict hardware check mechanism, guarantees the integrality of packet; Finally, the method supports that power-off suspension resumes function, guarantees program updates success.
The above is only the preferred embodiment of the present invention; be noted that for those skilled in the art; under the premise without departing from the principles of the invention, can also make some improvements and modifications, these improvements and modifications also should be considered as protection scope of the present invention.