Summary of the invention
Technical matters to be solved by this invention is, how under the situation of household unit SFU memory headroom less than the routine data size of needs upgrading of living alone, realizes program data updating.
The present invention for realizing the technical scheme that goal of the invention adopts is: the adaptive program data updating method of memory headroom in the single user optical network unit, above method is based on the upgrade management program that is provided with among the MCU of optical network unit and is that intermediate store realizes by the flash storage unit, be provided with in single user optical network unit and store the private memory of revising data comparison algorithm model, upgrade method may further comprise the steps:
1) by the upgrade management program among the optical network management device startup single user optical network unit MCU;
2) by the size of the MCU of optical network unit record ROMPaq, mark code header, CRC first proof test value, and the remaining space size of internal memory, typing intermediate store;
3) call comparison algorithm model in the private memory size of the size of ROMPaq and internal memory remaining space compared, calculate by the MCU of optical network unit after, ROMPaq is divided into the n segment file, and the initial and end identification code is set respectively in the compressed encoding of above each segment file, n is a positive integer;
4) the n segment file of ROMPaq is deposited successively in the remaining space of internal memory, go into the flash storage unit from the remaining space unloading of internal memory successively according to the first-in first-out principle, after any segment file is gone into the flash storage unit from the remaining space unloading of internal memory, wipe this segment file in the remaining space of internal memory;
5) finish the unloading of whole file after, carry out CRC check, and relatively, if unanimity is carried out step 6) with CRC second proof test value that generates and CRC first proof test value; If inconsistent, return step 1);
6) restart terminal device, move new routine data.
Implement to realize in the single user optical network unit of the present invention the adaptive program data updating method of memory headroom, the mailbox memory that stores comparison algorithm is set in optical network unit, realization can be according to big young pathbreaker's ROMPaq automatic segmentation of internal memory free space, change over to according to the first-in first-out principle then and be stored in flash, finish the upgrading of routine data program.Such upgrade method need not manual intervention, has realized the adaptive program data updating of memory headroom, utilizes the first-in first-out algorithm to solve the difficult problem that memory headroom is little, ROMPaq is big dexterously.
Embodiment
The adaptive program data updating method of memory headroom in the single user optical network unit, above method is based on the upgrade management program that is provided with among the MCU of optical network unit and is that intermediate store realizes by the flash storage unit, be provided with in single user optical network unit and store the private memory of revising data comparison algorithm model, upgrade method may further comprise the steps:
1) by the upgrade management program among the optical network management device startup single user optical network unit MCU;
2) by the size of the MCU of optical network unit record ROMPaq, mark code header, CRC first proof test value, and the remaining space size of internal memory, typing intermediate store;
3) call comparison algorithm model in the private memory size of the size of ROMPaq and internal memory remaining space compared, calculate by the MCU of optical network unit after, ROMPaq is divided into the n segment file, and the initial and end identification code is set respectively in the compressed encoding of above each segment file, n is a positive integer;
4) the n segment file of ROMPaq is deposited successively in the remaining space of internal memory, go into the flash storage unit from the remaining space unloading of internal memory successively according to the first-in first-out principle, after any segment file is gone into the flash storage unit from the remaining space unloading of internal memory, wipe this segment file in the remaining space of internal memory;
5) finish the unloading of whole file after, carry out CRC check, and relatively, if unanimity is carried out step 6) with CRC second proof test value that generates and CRC first proof test value; If inconsistent, return step 1);
6) restart terminal device, move new routine data.
In the described step 3), the method that ROMPaq is divided into the n segment file is: by the ratio algorithm in the mailbox memory, with the size of the ROMPaq size divided by the internal memory remaining space, be divided into the n section by advancing a method principle.
Consider the problem of the program code modification of terminal device, all users are upgraded privately or upgrade, also be provided with the private cipher key of download and upgrade program in the upgrade management program in MCU, the terminal device of single user optical network unit at first detects the accuracy of private cipher key before upgrading.
The present invention in the specific implementation, utilize the comparison algorithm in the mailbox memory that internal memory remaining space and ROMPaq are carried out size relatively, big young pathbreaker's ROMPaq automatic segmentation according to the internal memory remaining space, specific algorithm is: the size of ROMPaq is divided into the n section divided by the size of internal memory remaining space by advancing a method principle.Each segment file does not need to take whole internal memory remaining space yet, can leave certain spare space in the internal memory remaining space, prevents in the future supplemental content, parameter or code and not enough.Each section ROMPaq that is divided into enters internal memory in order under the effect of pointer, according to the principle of first-in first-out, in unloading of each section ROMPaq and flash in the internal memory, finish program data updating then.The control of first-in first-out realizes like this:
1. an indexed variable m is set, and whether judgement symbol variable m is smaller or equal to the total hop count n of upgrade service program, if then at m section upgrade service program segment head banner string block_m is set; And skip to 2., if not, stop storage.
2. detecting m section upgrade service program segment head, whether banner string is set be block_m, if, skip to step 3., if not, stop storage;
3. the one section upgrade service procedure stores that will the section of having initial character string be block_m is wiped this section upgrade service program in the internal memory in flash, change indexed variable m is indexed variable m+1, skips to step 1..
The invention solves the problem that to implement the optical network unit program data updating because memory headroom is little, ROMPaq is big, adopted the adaptive program data updating method of memory headroom, and the algorithm of first-in first-out in addition, reduced memory usage, successfully realize the upgrading of routine data.