The invention provides an anti-damage embedded online upgrading method and
system, which is based on a flash peer-to-peer
system multi-partition structure, partitions are completely peer-to-peer, and the upgrading method comprises the following steps: reading partition states to obtain running partition state data and upgrading partition state data, and creating an annular
data cache region in the flash; if the state data of the running partition is normal, the
executable file is read from the running partition, and normal program running is completed; after to-be-upgraded data are downloaded to the annular
data cache region according to an upgrading instruction, the data in the annular
data cache region are written into the upgrading partition, and after the to-be-upgraded data are completely written into the upgrading partition, the state of the upgrading partition is marked as to-be-upgraded; according to the method, the
system is restarted according to the to-be-updated mark, the
executable file is read from the upgrading partition according to the updated upgrading partition state, the upgraded program operation is completed, partition setting and the annular
data buffer area are adopted, and it is guaranteed that online upgrading cannot affect the operation partition and the upgrading partition even if network disconnection occurs.