Summary of the invention
A kind of upgrade-system and the method based on the DSP embedded system that the purpose of this invention is to provide are to solve the manual service problem of existing system upgrading.
For achieving the above object, the invention provides a kind of upgrade-system based on DSP, be used for the DSP master routine based on the embedded system of DSP is upgraded, described embedded system receives a transport stream signal from the outside, described upgrade-system comprises: a flash memory wherein stores upgrade-system program and initial DSP master routine; One start-up loading module is used for the initialization of executive system hardware device, and internally deposits into the row distribution, does the initialization preparation for loading described upgrade-system program; One demultiplexing module, be used to carry out described upgrade-system program, version information according to the upgrade data that comprises in the transport stream, judge whether described initial DSP master routine is latest edition, if not, then from transport stream, extract upgrade data, form the upgrading image file, and write in the flash memory as new DSP master routine, finish edition upgrading; And an interactive module, be used to provide the user to understand the situation that described embedded system upgrading is carried out in real time.
Demultiplexing module of the present invention further comprises: a judging unit, be used for judging whether current transport stream exists upgrade data, and obtain the version information of described upgrade data, judge according to this version information whether described initial DSP master routine is latest edition again; And a resolution unit, be used for when described initial DSP master routine is not latest edition, further resolving described transport stream, and integrate described upgrade data forming the upgrading image file, and write flash memory as new DSP master routine.Wherein, the version information of described upgrade data comprises the specific transmission package sequence number PID of upgrade data, the sum of AKU, the version number of wrapping sequence number and upgrade data.
Start-up loading module of the present invention further comprises: an initialization unit, be used for the initialization of executive system hardware device, and shield all interruptions simultaneously, speed and the clock frequency of CPU are set, and internally deposit into the row distribution; And a preparation unit, be used to call the corresponding informance of described resolution unit, prepare to load described DSP master routine after finishing.
Flash memory of the present invention is divided into a plurality of continuous subregions by physical address, and the storage start address of described initial DSP master routine is the first address of next subregion of subregion at the place, storage tail address of described upgrade-system program.In addition, described flash memory also comprises a parameter subregion, is used to store the version information of DSP master routine.Interactive module of the present invention is a graphic interface.
The present invention also provides a kind of upgrade method, is used for the DSP master routine based on the DSP embedded system is upgraded, and it comprises the following steps: 1) flash memory is carried out the physical address division, and in flash memory, store upgrade-system program and initial DSP master routine; 2) set the start-up loading correlation function, do the initialization preparation for loading described upgrade-system program; 3) carry out described upgrade-system program,, judge whether described initial DSP master routine is latest edition, if then directly withdraw from upgrading according to the version information of the upgrade data that comprises in the transport stream; If not, then from transport stream, extract upgrade data, form the upgrading image file, and write in the flash memory as new DSP master routine, finish edition upgrading; 4) set user's interactive interface, show various situations in the escalation process in patterned mode.
Above-mentioned steps 3) comprise in more detail: initialization section starts the driving of tuner and modulation chip, and transport stream is stored among the direct memory access DMA in the dsp system; Reading DMA is to obtain real-time transport stream; Analyzing atransmission stream is to obtain the primary flow PES grouping of packing; Resolve the PES grouping, judge and whether have upgrade data in the current transport stream, if do not have upgrade data in the current transport stream, the SP pointer of then resetting, dsp system is loaded into internal memory with initial DSP master routine and carries out described initial DSP master routine, if comprised upgrade data in the current transport stream, then transport stream is further resolved according to the parameter in the PES grouping; Wherein, the step of transport stream further being resolved according to the parameter in the PES grouping comprises in more detail: Version Control, and current version that flash memory is read and the version information of obtaining from the PES grouping compare, to determine whether and will upgrade; If the system version unanimity does not then need upgrading, if version is inconsistent,, determine the upgrade data grouping by the PID that obtains in the PES grouping with further analyzing atransmission stream, at last the upgrading grouping is integrated, form complete upgrading image file; Form after the complete image file, after initial DSP master routine is wiped, the upgrading image file of the latest edition that obtains is write flash memory as new DSP master routine; At last, the DSP master routine version information in last subregion of flash memory is made amendment.
Above-mentioned steps 2) comprises in more detail: divide and distribution in conjunction with the subregion of described flash memory, the start-up loading correlation function is divided at least two independent parts; Wherein, first's function comprises, the initialization of hardware device shields all interruptions, and speed and the clock frequency of CPU is set, the distribution of internal memory, and after the program initialization success, carry out the replacement of SP pointer; The function of second portion comprises, system initialization is prepared, calling interface, and Version Control, flash upgrade, and the replacement of SP pointer is provided.
Above-mentioned steps 1) in, according to physical address flash memory is divided into a plurality of continuous subregions, described upgrade-system program and the initial storage mode of DSP master routine in flash memory are as follows: store described upgrade-system program and described initial DSP master routine in flash memory successively, wherein, the start address of described initial DSP master routine is the first address of next subregion of subregion at the place, tail address of described upgrade-system program.In addition, when the tail address of described upgrade-system program is not the tail address of upgrade-system program place subregion, also be included in the step of filling redundant data between the tail address of the tail address of upgrade-system program and this subregion.
Upgrade-system of the present invention and upgrade method combine multiple application technology to realize the aerial upgrade based on the embedded system of DSP, solved the manual service problem of software system updating in the past, saved the cost of labor in later stage, for the upgrading of project implementation and later stage increment module provides convenient, reliable and cheap embodiment.
Embodiment
Below with reference to a preferred embodiment upgrade-system of the present invention and upgrade method are described in further detail.
See also Fig. 1, the structured flowchart that has wherein shown upgrade-system of the present invention, this upgrade-system are used for the embedded system based on DSP is carried out aerial upgrade, can be applicable to all kinds of portable terminals based on dsp system, more typically, can be applicable to digital TV set-top box.As shown in the figure, upgrade-system of the present invention comprises demultiplexing module 1, start-up loading module 2, flash memory (Flash) 3 and interactive module 4.Wherein, described upgrade-system receives a transport stream (TS code stream) from the outside, and for digital TV set-top box, this TS code stream is the encapsulated data packet that comprises the digital television signal data, and described upgrade data is encapsulated in the TS code stream in the mode of private data.
Described demultiplexing module 1 is used for obtaining upgrade data from the TS code stream, and it further comprises: a judging unit 10 is used for judging whether the current TS code stream exists a upgrade data, and obtains the concrete parameter of described upgrade data; And a resolution unit 12, be used for further resolving described TS code stream, and integrate described upgrade data to form corresponding upgrade file according to the concrete parameter of described upgrade data.Wherein, the concrete parameter of described upgrade data comprises the specific transmission package sequence number (PID) of upgrade data, the sum of AKU, the version number of wrapping sequence number and upgrade data.
Described start-up loading module 2 is used to carry out the initialization of hardware device, and Flash3 distributed, it further comprises: an initialization unit 20, be used to carry out the initialization of hardware device, shield all interruptions simultaneously, speed and the clock frequency of CPU are set, and internally deposit into the row distribution; And a preparation unit 22, be used to call the corresponding informance of described resolution unit 12, prepare to load described DSP master routine after finishing.
Please in conjunction with Fig. 2, wherein further show the synoptic diagram that the Flash3 in the present embodiment divides, wherein said Flash is divided at least three subregions (Bank) 30,32 and 34, is respectively applied for and stores initialize routine, preliminary program and DSP master routine.In addition, described Flash3 also comprises the B parameter ank 36 of an expansion, is used for the correlation parameter of store recording upgrading implementation.In the present embodiment, each Bank 30,32,34 and 36 includes header section, boot segment and code segment, and each code segment can further be divided into the header of block and each block correspondence again.
In the present embodiment, described interactive module 4 is a graphic interface, more detailed it, can be the visual window that is presented on the screen, the user sees through watch window just can in time understand the situation that ROMPaq is carried out, and knows whether wrong generation at any time.
Then, see also Fig. 3, wherein shown the simple flow chart of upgrade method of the present invention.
At first execution in step S1 promptly sets to start and puts down in writing relevant function, promptly sets the framework of BootLoader program, illustrates in greater detail as follows:
The BootLoader of first is responsible for the initialization of hardware device, shields all interruptions, and speed and the clock frequency of CPU is set, and the replacement of SP pointer is carried out in the distribution of internal memory at last.This part function is to do the initialization preparation for loading second portion BootLoader program; This part physical address corresponding is that 0x00000000 is to 0x00000F58 in this method.In the present embodiment, concrete address determine that LDR documenting is in the end finished after, just can accurately determine.
The BootLoader major function of second portion then is to judge whether to need upgrading and do the preceding preparation of system start-up for the DSP master routine.The initial phase of this part also can carry out the setting of CPU speed and clock frequency and the distribution associative operation of internal memory, and provide upgrade function, the calling interface of demultiplexing function, reset system SP pointer after functions of modules to be called is finished is prepared load store at the DSP of third part master routine.In the present embodiment, the corresponding code that loads the physical address 0x00000F58 of Flash to the 0x00030000 section of this part.
So far, the program frame of BootLoader is finished.
Then, execution in step S2 promptly after the framework of BootLoader is finished, adds self-defining function at the second portion of BootLoader, and function realizes that more detailed description is as follows:
Demultiplexing: initialization section has started the driving of Tuner and modulation chip, and TS stream will be stored in the direct memory access (DMA) in the dsp system, and the mode of table tennis formula buffer memory is used in the DMA storage in the dsp system.To reading of DMA, can obtain real-time TS code stream.Wherein, upgrade data is that the mode with private data is encapsulated in the TS stream, by parsing to the TS code stream, can obtain primary flow (PES) grouping of packing, further resolve the PES grouping again, promptly can know in current TS stream whether have upgrade data, and obtain the concrete parameter of upgrade data, for example: determine the specific PID of upgrade data, the sum of AKU and bag sequence number.
Need to prove, will run into two kinds of situations during upgrade data in resolving the TS code stream:
If do not have upgrade data in the current TS code stream, the SP pointer of can resetting so, dsp system will be loaded into internal memory with the DSP master routine from the start address of Flash third part, carries out the program function in the main system afterwards.
Another kind of situation is to have comprised upgrade data in the code stream, the demultiplexing part will be according to the parameter that obtains from PES, TS stream is further analyzed: at first be Version Control, version information is among last Bank that leaves among the Flash, has deposited the channel information of Digital Television and the version information of current dsp system in the dsp system among this Bank.In the present embodiment, current version information that Flash is read and the version information of obtaining from the PES grouping compare, thereby know whether will upgrade; If version unanimity, just do not need upgrading, system's SP pointer of can resetting, dsp system will if version is inconsistent, will be upgraded from the start address of Flash third part, the demultiplexing program will further be resolved the TS code stream, determine the upgrade data grouping by the PID that obtains in the PES grouping, at last the upgrading grouping is integrated, form complete upgrading image file; After forming complete image file, at first the DSP master routine is wiped, be from 0x00030000 in the present embodiment, be erased to the penult Bank of Flash always, last Bank places channel information and version information in the present embodiment, be the information that to wipe, after wiping, the upgrading image file of the latest edition that obtains write Flash; At last, write after the Flash, the master routine version information among last Bank of Flash is made amendment.
Then, execution in step S3 promptly sets user's interactive interface, shows various situations in the escalation process in patterned mode.In more detail, in the present embodiment, the user can understand the progress of upgrading and the information of correlation step by the window of transmission display on screen.
In addition, upgrade method of the present invention also comprises execution in step S4, promptly makes many DEX system.
In more detail, at first, the repertoire code of second portion among the BootLoader is integrated in the item file, generates independently DEX file, the master routine of dsp system also generates independently DEX file.Wherein, the generation of these two DEX files, the setting in Project Option does not require.
Secondly, the repertoire code of first among the BootLoader is integrated in the item file, generate the LDR file, in Project Option, to add specific parameter especially: add BootLoader second portion DEX file path and the DSP principal program path that generates in the Post-Build parameter respectively, and specify the path and the title of output LDR file.Since then, generated complete LDR file.
Upgrade method of the present invention also comprises execution in step S5, promptly determine the physical division of Flash, adjust the position and revise the tail address, can check the LDR file of generation in actual use, thereby understand the distribution of Flash various piece code by LdrViewer.exe.
Can see in the present embodiment that in conjunction with Fig. 2 the Flash physical address is divided at least 3 parts, the physical address 0x00000000 of first has stored first's code of BootLoader to the 0x00000F57 section; Second portion physical address 0x00000F58 has stored the second portion code of BootLoader to the 0x00030000 section; Third part is a mother block, and physical address is the later space of 0x00030000 section.
In the present embodiment, for making the channeling conduct that start-up routine can be correct, need check the LDR file.When checking the LDR file, determine two problems, first will be determined is the start address first address of N Bank whether of master routine, if not start address, then to adjust the program code of second portion, add redundant data therein, regenerate the DEX file, and being linked into new LDR file, constantly test is till the start address of master routine is the start address of N Bank; Second problem that will determine is to revise second the tail address of BootLoader in Flash, and this tail address is the sign that pointer is reset, after the modification, and after the SP pointer is reset, the loading master routine that system just can be correct.To revise the tail address in the present embodiment, after tool using is opened, the Flags of last Block of editor's second portion DEX1, the modification value is 000A.
Finish above step, promptly generated complete upgrading image file, use the Flash instrument at last among the burned Flash of image file.
Of particular note, upgrade-system of the present invention and upgrade method are not limited to module and the step execution sequence defined in the foregoing description, although the present invention is had been described in detail with reference to preferred embodiment, those of ordinary skill in the art is to be understood that, can make amendment or be equal to replacement the present invention, and not breaking away from the spirit and scope of the present invention, it all should be encompassed in the middle of the claim scope of the present invention.