The method of a kind of data process and digital TV terminal
Technical field
The present invention relates to a kind of digital television techniques, particularly relate to method and DTV that a kind of data process
Terminal.
Background technology
Current most of Set Top Box is to use flash memory to store data, and flash memory wiping/writing feature is in units of byte
Write, wipe in units of block.When carrying out the erasable data manipulation of data block, first read user
Data to be erased in district's data block, are then combined with data to be written, finally treat in the data block of erasing user area
Erasing data are again merging data to be written write user area data block.Owing to write and the erasing of flash memory are all
Needing intervals, if occurring write abnormal after data to be erased in erasing block, this may lead
Causing to merge data to be written can not preserve, even data corruption or Set Top Box can not the problem such as normal boot-strap.
Summary of the invention
Embodiment of the present invention technical problem to be solved is, it is provided that the method for a kind of data process and numeral
Television terminal.Can avoid when data writing operation process occurs suddenly to interrupt, system is likely to be due to be carrying out
Erasing work and have little time write data thus cause storage data suffer damage.
In order to solve above-mentioned technical problem, on the one hand, embodiments provide the side that a kind of data process
Method, including:
When the user area data block of digital TV terminal is carried out the erasable data manipulation of data block, it is written into
The relevant information of data and described data to be written stores to recording areas, the relevant information of described data to be written
Address including user area data block corresponding to described data to be written;
Reading user area, address data block according to user area data block corresponding to described data to be written is to be erased
Described data to be erased are also merged by data with described data to be written;
The data of described merging are stored the backup area to described digital TV terminal;
Wipe the data to be erased in the data block of described user area, and the data of described merging are stored to described
User area data block.
Wherein, the relevant information being written into data described in includes: the relevant information of described data to be written
Size, the numbering of relevant information of described data to be written, described data to be written backup mark, described
The address writing the mark described user area data block corresponding with described data to be written of data to be written.
Wherein, it is stored to recording areas in the described relevant information being written into data and described data to be written
Before, also include:
Obtain the size of the remaining space of described recording areas;
Judge whether the remaining space of described recording areas is more than or equal to the size of described data to be written with described
The size summation of the relevant information of data to be written;
When the remaining space of described recording areas is to be written with described more than or equal to the size of described data to be written
During the size summation of the relevant information of data, perform data to be written and the relevant information of described data to be written
Store the step to recording areas;
When the remaining space size of described recording areas is less than the size of described data to be written and described number to be written
According to the size summation of relevant information time, wipe the data stored in described recording areas.
Wherein, described method also includes:
If the data of described merging successfully being stored the backup area to described digital TV terminal, then by described
The backup mark of the data to be written that the data of merging are corresponding described in recording areas arranges backup success flag;
If the data of described merging are successfully written to described user area data block, then by described recording areas
The mark of writing of the data to be written that the data of described merging are corresponding arranges write success flag.
Wherein, described method also includes:
Whether interrupt during judging data writing operation;
During data writing operation occur interrupt time, upper once start digital TV terminal time, perform institute
State the recovery flow process of data writing operation.
Wherein, the recovery flow process of write data operation includes:
Mark is write, it is judged that whether described data to be written become according to data to be written described in described recording areas
Merit writes described user area data block;
When described data to be written write described user area data block failure, according to be written in described recording areas
Enter the backup mark of data, it is judged that whether described data to be written are successfully stored to described backup area;
When described data to be written are successfully stored to described backup area, read described conjunction from described backup area
And data, wipe the data to be erased in the data block of described user area, and the data of described merging write
Described user area data block;
When described data to be written store to described backup area failure, read described to be written from described recording areas
Enter the address of the data user area data block corresponding with described data to be written, read user area data block and wait to wipe
Described data to be erased are also merged by divisor evidence with described data to be written, and by the data of described merging
Store the backup area to described digital TV terminal, wipe the data to be erased in the data block of described user area,
And the data of described merging are write described user area data block.
On the other hand, The embodiment provides a kind of digital TV terminal, including:
Record unit, for carrying out data block erasable data behaviour to the user area data block of digital TV terminal
When making, the relevant information being written into data and described data to be written stores to recording areas, described to be written
The relevant information of data includes the address of user area data block corresponding to described data to be written;
Combining unit, reads user for the address of the user area data block corresponding according to described data to be written
Described data to be erased are also merged by data block data to be erased in district's with described data to be written;
Backup units, for storing the backup area to described digital TV terminal by the data of described merging;
Writing unit, for wiping the data to be erased in the data block of described user area, and by described merging
Data store to described user area data block.
Wherein, the relevant information of the size of the relevant information of described data to be written, described data to be written
Numbering, the backup mark of described data to be written, writing of described data to be written identify and described number to be written
Address according to corresponding described user area data block.
Wherein, described digital TV terminal also includes:
Acquiring unit, for obtaining the size of the remaining space of described recording areas;
First judging unit, for judging that whether the remaining space of described recording areas is more than or equal to described to be written
Enter the size summation of the size of data and the relevant information of described data to be written, when the residue of described recording areas
Space is total with the size of the relevant information of described data to be written more than or equal to the size of described data to be written
And time, notify that described record unit is written into the relevant information of data and described data to be written and stores to note
Record district;
Erasing unit, for being less than the size of described data to be written when the remaining space size of described recording areas
During with the size summation of the relevant information of described data to be written, wipe the data stored in described recording areas.
Wherein, described digital TV terminal also includes:
Backup mark arranges unit, if for successfully storing the data of described merging to described DTV
The backup area of terminal, then by the backup mark of data to be written corresponding for the data merged described in described recording areas
Know and backup success flag is set;
Write mark and unit is set, if for the data of described merging are successfully written to described user area data
Block, then be written to the mark setting of writing of data to be written corresponding for the data merged described in described recording areas
Merit identifies.
Wherein, described digital TV terminal also includes:
Whether the second judging unit, interrupt during being used for judging data writing operation;
Perform recovery unit, for when data writing operation process occurs to interrupt, once start numeral electricity upper
During depending on terminal, perform the recovery flow process of write data operation.
Wherein, described execution recovery unit includes:
3rd judging unit, for writing mark according to data to be written described in described recording areas, it is judged that institute
State whether data to be written are successfully written described user area data block;
4th judging unit, is used for when described data to be written write described user area data block failure, root
Identify according to the backup of data to be written in described recording areas, it is judged that whether described data to be written are successfully stored
To described backup area;
Read backup units, for when described data to be written are successfully stored to described backup area, from institute
Stating backup area and read the data of described merging, treating during then writing unit wipes described user area data block is wiped
The data of described merging are write described user area data block by divisor evidence;
Read address location, for when described data to be written store to described backup area failure, from described
The address of the described data to be written user area data block corresponding with described data to be written is read in recording areas, logical
Know that the data to be erased that described data to be written are corresponding with the address of described user data are entered by described combining unit
Row merges, and notifies that the data of described merging are stored the backup to described digital TV terminal by described backup units
District, and notify the data to be erased in user area data block described in said write cell erasure, and by described conjunction
And data write described user area data block.
Implement the embodiment of the present invention, have the advantages that
The embodiment of the present invention is carrying out the erasable data manipulation of data block to the user area data block of digital TV terminal
Time, use recording areas to store data to be written, and use backup area to store data to be written and data to be erased
Merging data, prevent after data to be erased are wiped free of, interrupt suddenly during data writing operation causing data
By the problem of accidental damage, reduce during production process or test process or user use owing to performing
Preservation data manipulation causes digital TV terminal dysfunction, even scraps the incidence rate that cannot use, carries
The safety that the data of high digital TV terminal preserve.
Accompanying drawing explanation
In order to be illustrated more clearly that the embodiment of the present invention or technical scheme of the prior art, below will be to enforcement
In example or description of the prior art, the required accompanying drawing used is briefly described, it should be apparent that, describe below
In accompanying drawing be only some embodiments of the present invention, for those of ordinary skill in the art, do not paying
On the premise of going out creative work, it is also possible to obtain other accompanying drawing according to these accompanying drawings.
Fig. 1 is the first embodiment schematic flow sheet of the method that a kind of data of the present invention process;
Fig. 2 is the second embodiment schematic flow sheet of the method that a kind of data of the present invention process;
Fig. 3 is the 3rd embodiment schematic flow sheet of the method that a kind of data of the present invention process;
Fig. 4 is the 4th embodiment schematic flow sheet of the method that a kind of data of the present invention process;
Fig. 5 is the first embodiment structural representation of a kind of digital TV terminal of the present invention;
Fig. 6 is the second example structure schematic diagram of a kind of digital TV terminal of the present invention;
Fig. 7 is the 3rd example structure schematic diagram of a kind of digital TV terminal of the present invention;
Fig. 8 is the 4th example structure schematic diagram of a kind of digital TV terminal of the present invention;
Detailed description of the invention
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is carried out clearly
Chu, be fully described by, it is clear that described embodiment be only a part of embodiment of the present invention rather than
Whole embodiments.Based on the embodiment in the present invention, those of ordinary skill in the art are not making creation
The every other embodiment obtained under property work premise, broadly falls into the scope of protection of the invention.
In the embodiment of the present invention, digital TV terminal can be DTV STB, digital TV integrated machine
Etc. possessing the unidirectional or equipment of bi-directional digital television function.
Refer to Fig. 1, for first embodiment flow chart of the method that a kind of data of the present invention process.The present invention
Executive agent can be digital TV terminal.As described in Figure 1, a kind of data described in the present embodiment process
Method include step:
S101, the relevant information being written into data and described data to be written stores to recording areas, described in treat
The relevant information of write data includes the address of user area data block corresponding to described data to be written.
In specific embodiment, if this method is applied at DTV STB, the most described data to be written are for using
System data or user data that flash memory device in DTV STB is stored by family carry out data modification guarantor
The data deposited.Wherein, system data specifically includes that the serial number of machine, version information, mac address, opens
Dynamic parameter etc..User data specifically includes that channel search that Set Top Box carries out by user, switching, volume are adjusted
Joint, the isoparametric data that generation is set of program predetermination.
Wherein, the relevant information of described data to be written includes: the relevant information of described data to be written big
The numbering of the relevant information of data to be written little, described, described data to be written backup mark, described in treat
The address writing the mark described user area data block corresponding with described data to be written of write data.Concrete,
The numbering of the relevant information of described data to be written refers to the amendment each time in data, inside recording areas
Having corresponding record, the sequence number that these records add up successively is exactly the numbering of relevant information.
Recording areas is that a special division is out for storing the relevant of data to be written and described data to be written
The data block of information, the size of general common data block has 64K and 128K, and the present invention is with the data of 128K
Block illustrates as recording areas.
S102, according to reading user area, the address data block of user area data block corresponding to described data to be written
Described data to be erased are also merged by data to be erased with described data to be written.
In specific embodiment, if the data that user area data block does not store, then according to described number to be written
The data write user area data block being directly written into according to the address of corresponding user area data block.
The data of described merging are stored the backup area to described digital TV terminal by S103.
In specific embodiment, walk at the backup area data of described merging stored to described digital TV terminal
Before Zhou, need to detect backup area data and be the most completely erased, if it has, then by the number of described merging
According to the backup area stored to described digital TV terminal, if it is not, after wiping backup area data completely again
The data of described merging are stored the backup area to described digital TV terminal.
Backup area is that a special division is out for backing up the data block merging described data to be written, typically
The size of common data block has 64K and 128K, and the present invention illustrates using the data block of 128K as backup area.
S104, wipes the data to be erased in the data block of described user area, and the data of described merging is stored
To described user area data block.
In specific embodiment, the data in described merging are successfully written after the data block of described user area, need
To wipe the data of backup area completely, ready for Backup Data next time.
After erasing backup area, then judge that the remaining space of recording areas is the biggest less than memory space set in advance
Little.If whether the remaining space of record partitioning is less than storage size set in advance, then wipe record
District's data are until the remaining space of recording areas is more than or equal to storage size set in advance.Wherein, in advance
The storage size first set includes: the first estate storage size, the second storage size, the
Three storage size.Concrete, the first estate storage size is less than the second storage size, the
Two storage size are less than the 3rd storage size.
Refer to Fig. 2, method the second embodiment schematic flow sheet processed for a kind of data of the present invention.This enforcement
The method that a kind of data described in example process includes step:
S201, obtains the size of the remaining space of described recording areas.
S202, it is judged that whether the remaining space of described recording areas is more than or equal to the size of described data to be written
With the size summation of the relevant information of described data to be written, if judged result is no, then perform step S203,
If the determination result is YES, then step S204 is performed.
S203, wipes the data stored in described recording areas.
In specific embodiment, when wiping the data stored in described recording areas until working as the surplus of described recording areas
Step S204 is performed when the size of complementary space is more than or equal to the size summation of the relevant information of data to be written.
S204, the relevant information being written into data and described data to be written stores to recording areas, described in treat
The relevant information of write data includes the address of user area data block corresponding to described data to be written.
S205, according to reading user area, the address data block of user area data block corresponding to described data to be written
Described data to be erased are also merged by data to be erased with described data to be written.
The data of described merging are stored the backup area to described digital TV terminal by S206.
S207, is arranged the backup mark of data to be written corresponding for the data merged described in described recording areas
Backup success flag.
Wherein, backup is designated ' 1 ', represents and backs up successfully, and the data of the most described merging successfully store to institute
State the backup area of digital TV terminal;Backup is designated ' 0 ' expression backup failure, the data of the most described merging
Store the backup area failure to described digital TV terminal.
S208, wipes the data to be erased in the data block of described user area, and the data of described merging is stored
To described user area data block.
S209, writes the mark setting of writing of data to be written corresponding for the data merged described in described recording areas
Enter success flag.
Wherein, writing and be designated ' 1 ', represent and write successfully, the data of the most described merging successfully store to described
User area data block;Writing and be designated ' 0 ', represent and write unsuccessfully, the data of the most described merging store to described
User area data block failure.
Wherein, step S204, step S205, step S206 and step S208, may refer to shown in Fig. 1
Step S101 of embodiment, step S102, step S103 and step S104, be not repeated herein.
Refer to Fig. 3, method the 3rd embodiment schematic flow sheet processed for a kind of data of the present invention.This enforcement
The method that a kind of data described in example process includes step:
S301, it is judged that whether interrupt during data writing operation, if the determination result is YES, then performs step
Rapid S302.
Wherein, interrupt referring to terminal abnormal to crash or the reason such as erasable exception causes erasable can not producing smoothly
Interruption.
S302, upper once start digital TV terminal time, perform write data operation recovery flow process.
Refer to Fig. 4, method the 4th embodiment schematic flow sheet processed for a kind of data of the present invention.This enforcement
The method that a kind of data described in example process includes step:
S401, writes mark according to data to be written described in described recording areas, it is judged that described data to be written
Whether being successfully written described user area data block, if judged result is no, then performing step S402, if judging
Result is yes, then terminate the work of this time described preservation data to be written.
Wherein, writing and be designated ' 1 ', represent and write successfully, the data of the most described merging successfully store to described
User area data block;Writing and be designated ' 0 ', represent and write unsuccessfully, the data of the most described merging store to described
User area data block failure.
S402, identifies according to the backup of data to be written in described recording areas, it is judged that described data to be written are
No it is successfully stored to described backup area, if the determination result is YES, then performs step S403, if judged result
It is no, then performs step S404.
Wherein, backup is designated ' 1 ', represents and backs up successfully, and the data of the most described merging successfully store to institute
State the backup area of digital TV terminal;Backup is designated ' 0 ' expression backup failure mark, the most described merging
Data store the backup area to described digital TV terminal.
S403, reads the data of described merging from described backup area.
S404, reads the user area that described data to be written are corresponding with described data to be written from described recording areas
The address of data block.
S405, according to reading user area, the address data block of user area data block corresponding to described data to be written
Described data to be erased are also merged by data to be erased with described data to be written.
The data of described merging are stored the backup area to described digital TV terminal by S406.
S407, is arranged the backup mark of data to be written corresponding for the data merged described in described recording areas
Backup success flag.
S408, wipes the data to be erased in the data block of described user area, and the data of described merging is stored
To described user area data block.
S409, writes the mark setting of writing of data to be written corresponding for the data merged described in described recording areas
Enter success flag.
Wherein, step S405, step S406 and step S408 may refer to the step of embodiment illustrated in fig. 1
S102, step S103 and step S104, step S407 and step S409 may refer to implement shown in Fig. 2
Step S207 of example and step S209, be not repeated herein.
Implementing of a kind of digital TV terminal that the embodiment of the present invention described below provides.
Refer to Fig. 5, for digital TV terminal first embodiment structural representation of the present invention.Described in the present embodiment
A kind of digital TV terminal include:
Record unit 100, stores to record for being written into the relevant information of data and described data to be written
District, the relevant information of described data to be written includes the ground of user area data block corresponding to described data to be written
Location.
In specific embodiment, if this digital TV terminal is DTV STB, data the most to be written are for using
System data or user data that flash memory device in DTV STB is stored by family carry out data modification guarantor
The data deposited.Wherein, system data specifically includes that the serial number of machine, version information, mac address, opens
Dynamic parameter etc..User data specifically includes that channel search that Set Top Box carries out by user, switching, volume are adjusted
Joint, the isoparametric data that generation is set of program predetermination.
Wherein, the relevant information of described data to be written includes: the relevant information of described data to be written big
The numbering of the relevant information of data to be written little, described, described data to be written backup mark, described in treat
The address writing the mark described user area data block corresponding with described data to be written of write data.Concrete,
The numbering of the relevant information of described data to be written refers to the amendment each time in data, inside recording areas
Having corresponding record, the sequence number that these records add up successively is exactly the numbering of relevant information.
Recording areas is that a special division is out for storing the relevant of data to be written and described data to be written
The data block of information, the size of general common data block has 64K and 128K, and the present invention is with the data of 128K
Block illustrates as recording areas.
Combining unit 200, reads for the address of the user area data block corresponding according to described data to be written and uses
Described data to be erased are also merged by family district data block data to be erased with described data to be written.
In specific embodiment, if the data that user area data block does not store, the number being the most directly written into
According to write user area data block.
Backup units 300, for storing the backup area to described digital TV terminal by the data of described merging.
In specific embodiment, walk at the backup area data of described merging stored to described digital TV terminal
Before Zhou, need to detect backup area data and be the most completely erased, if it has, then by the number of described merging
According to the backup area stored to described digital TV terminal, if it is not, after wiping backup area data completely again
The data of described merging are stored the backup area to described digital TV terminal.
Backup area is that a special division is out for backing up the data block merging described data to be written, typically
The size of common data block has 64K and 128K, and the present invention illustrates using the data block of 128K as backup area.
Writing unit 400, for wiping the data to be erased in the data block of described user area, and by described merging
Data store to described user area data block.
In specific embodiment, the data in described merging are successfully written after the data block of described user area, need
To wipe the data of backup area completely, ready for Backup Data next time.
Wherein, after erasing backup area, then judge that whether the remaining space of recording areas is less than storage set in advance
Space size.If whether the remaining space of record partitioning is less than storage size set in advance, then wipe
Except recording areas data until the remaining space of recording areas is more than or equal to storage size set in advance.Its
In, storage size set in advance includes: the first estate storage size, and the second memory space is big
Little, the 3rd storage size.Concrete, the first estate storage size is big less than the second memory space
Little, the second storage size is less than the 3rd storage size.
Refer to Fig. 6, for one digital TV terminal of the present invention second example structure schematic diagram.The present embodiment
Described a kind of digital TV terminal includes:
Record unit 100, combining unit 200, backup units 300 and writing unit 400.
Wherein, this digital TV terminal also includes:
Acquiring unit 500, for obtaining the size of the remaining space of described recording areas.
First judging unit 600, for judging the remaining space of described recording areas is treated described in whether being more than or equal to
The size of write data and the size summation of the relevant information of described data to be written, when described first judges list
When the judged result of unit 600 is for being, described record unit 100 is written into data and described data to be written
Relevant information store to user area data block, when the judged result of described first judging unit 600 is no,
Described erasing unit 700 wipes the data stored in described recording areas
Erasing unit 700, for wiping the data stored in described recording areas.
In specific embodiment, when wiping the data stored in described recording areas until working as the surplus of described recording areas
When the size of complementary space is more than or equal to the size summation of the relevant information of data to be written, Notification Record unit
100 relevant informations being written into data and described data to be written store to user area data block.
Backup mark arranges unit 301, for corresponding to be written of data that will merge described in described recording areas
The backup mark of data arranges backup success flag.
Wherein, backup is designated ' 1 ', represents and backs up successfully, and the data of the most described merging successfully store to institute
State the backup area of digital TV terminal;Backup is designated ' 0 ' expression backup failure, the data of the most described merging
Store the backup area failure to described digital TV terminal.
Write mark and unit 401 is set, for number to be written corresponding to data that will merge described in described recording areas
According to mark of writing write success flag is set.
Wherein, writing and be designated ' 1 ', represent and write successfully, the data of the most described merging successfully store to described
User area data block.Writing and be designated ' 0 ', represent and write unsuccessfully, the data of the most described merging store to described
User area data block failure.
Refer to Fig. 7, for for one digital TV terminal the 3rd example structure schematic diagram of the present invention.
Digital TV terminal described in the present embodiment includes:
Record unit 100, combining unit 200, backup units 300 and writing unit 400, acquiring unit 500,
First judging unit 600, erasing unit 700, backup mark arrange unit 301, write mark and arrange unit 401.
Wherein, this digital TV terminal also includes:
Whether the second judging unit 800, interrupt during being used for judging data writing operation;
Perform recovery unit 900, for when data writing operation process occurs to interrupt, once starting numeral upper
During television terminal, perform the recovery flow process of write data operation.
Refer to Fig. 8, for for digital TV terminal device the 4th example structure schematic diagram of the present invention.
Digital TV terminal described in the present embodiment includes:
Second judging unit 800 and execution recovery unit 900.
Wherein, described execution recovery unit 900 also can farther include:
3rd judging unit the 10, the 4th judging unit 20, reading backup units 30, reading address location 40.
3rd judging unit 10, for writing mark according to data to be written described in described recording areas, it is judged that
Whether described data to be written are successfully written described user area data block, if judged result is no, and the most described
Four judging units 20 judge whether described data to be written are successfully stored to described backup area, if judged result
It is yes, then terminates this time erasable preservation work.
Wherein, writing and be designated ' 1 ', represent and write successfully, the data of the most described merging successfully store to described
User area data block.Writing and be designated ' 0 ', represent and write unsuccessfully, the data of the most described merging store to described
User area data block failure.
4th judging unit 20, identifies for the backup according to data to be written in described recording areas, it is judged that institute
State whether data to be written are successfully stored to described backup area;Wherein, if the determination result is YES, then read
Backup units 30 reads the data of described merging from described backup area, if judged result is no, then reads address
Unit 40 reads the user area data that described data to be written are corresponding with described data to be written from described recording areas
The address of block.
Wherein, backup is designated ' 1 ', represents and backs up successfully, and the data of the most described merging successfully store to institute
State the backup area of digital TV terminal;Backup is designated ' 0 ' expression backup failure, the data of the most described merging
Store the backup area failure to described digital TV terminal.
Read backup units 30, read the data of described merging from described backup area.
Read address location 40, for reading described data to be written and described number to be written from described recording areas
Address according to corresponding user area data block.
By the description of above-described embodiment, the invention have the advantages that
The embodiment of the present invention is carrying out the erasable data manipulation of data block to the user area data block of digital TV terminal
Time, use recording areas to store data to be written, and use backup area to store data to be written and data to be erased
Merging data, prevent after data to be erased are wiped free of, interrupt suddenly during data writing operation causing data
By the problem of accidental damage, reduce during production process or test process or user use owing to performing
Preservation data manipulation causes digital TV terminal dysfunction, even scraps the incidence rate that cannot use, carries
The safety that the data of high digital TV terminal preserve.
One of ordinary skill in the art will appreciate that all or part of flow process realizing in above-described embodiment method,
Can be by computer program and complete to instruct relevant hardware, described program can be stored in a calculating
In machine read/write memory medium, this program is upon execution, it may include such as the flow process of the embodiment of above-mentioned each method.
Wherein, described storage medium can be magnetic disc, CD, read-only store-memory body (Read-Only Memory,
Or random store-memory body (Random Access Memory, RAM) etc. ROM).
Above disclosed be only present pre-ferred embodiments, certainly can not with this limit the present invention it
Interest field, the equivalent variations therefore made according to the claims in the present invention, still belong to the scope that the present invention is contained.