Summary of the invention
The purpose of the present invention is to provide a kind of burning program method, system, device and computer readable storage medium, withRealization only needs to safeguard a set of program during remote upgrade single-chip microcontroller.
To achieve the above object, the embodiment of the invention provides following technical solutions:
A kind of burning program method, comprising:
Obtain the target program including startup program content and user program content;
Using the default compilation tool based on scatter-loading file technology by the startup program content in the target programCompiling compiles the user program content in the target program to the second operation time domain to the first operation time domain;
The startup program content is burned onto first address, with being burned onto pre-set user program by the user program contentLocation;
Upgraded version contents of program is transmitted to default updated contents memory space;
Using the startup program content in the single-chip microcontroller with the upgraded version contents of program to user's journeySequence content is upgraded with the part to be upgraded in the startup program content.
Optionally, the startup program content includes startup program and interrupt vector table;
Correspondingly, the startup program content using in the single-chip microcontroller and the upgraded version contents of program pairBefore part to be upgraded in the user program content and the startup program content is upgraded, further includes:
Start the single-chip microcontroller so that the single-chip microcontroller by the interrupt vector table with being copied to default interrupt vector tableLocation;
The startup program content using in the single-chip microcontroller and the upgraded version contents of program are to the useFamily contents of program is upgraded with the part to be upgraded in the startup program content, comprising:
Using the startup program in the single-chip microcontroller with the upgraded version contents of program in the user programAppearance is upgraded with the interrupt vector table.
Optionally, the starting single-chip microcontroller, so that the interrupt vector table is copied in default by the single-chip microcontrollerAfter disconnected vector table address, further includes:
The start bit that interrupt vector table is arranged is set to the default interrupt vector table address.
It is optionally, described that upgraded version contents of program is transmitted to default updated contents memory space, comprising:
By first updated contents memory block of the user program content transmission of the upgraded version into the single-chip microcontroller;
The interrupt vector table of the upgraded version is transmitted to the second updated contents memory block in the single-chip microcontroller.
Optionally, the startup program content using in the single-chip microcontroller and the upgraded version contents of program pairThe user program content is upgraded with the part to be upgraded in the startup program content, comprising:
Upgrading mark is sent to the preset configuration conservation zone of the single-chip microcontroller, so that the single-chip microcontroller detects described presetAfter configuring the upgrading mark in conservation zone, by the user program content update to target user's contents of program.
To achieve the above object, the application also provides a kind of system of burning program, comprising:
Target program obtains module, for obtaining the target program including startup program content and user program content;
Collector, for utilizing the default compilation tool based on scatter-loading file technology will be in the target programStartup program content is compiled to the first operation time domain, and the user program content in the target program is compiled to when the second operationDomain;
The user program content is burned by burning module for the startup program content to be burned onto first addressPre-set user program address;
Transmission module, for upgraded version contents of program to be transmitted to default updated contents memory space;
Update module, for utilizing the startup program content and the upgraded version contents of program in the single-chip microcontrollerThe user program content and the part to be upgraded in the startup program content are upgraded.Optionally, the starting journeySequence content includes startup program and interrupt vector table;
Correspondingly, the system also includes:
Single-chip microcontroller starting module, for starting the single-chip microcontroller, so that the single-chip microcontroller replicates the interrupt vector tableTo default interrupt vector table address;
The update module, is specifically used for:
Using the startup program in the single-chip microcontroller with the upgraded version contents of program in the user programAppearance is upgraded with the interrupt vector table.
Optionally, the system also includes:
Start bit sets setup module, and the start bit for interrupt vector table to be arranged is with being set to the default interrupt vector tableLocation.
To achieve the above object, the application also provides a kind of burning program device, comprising:
Memory, for storing computer program;
Processor is realized when for executing the computer program such as the step of any one described program method for burn-recording.
To achieve the above object, the application also provides a kind of computer readable storage medium, the computer-readable storageIt is stored with computer program on medium, is realized when the computer program is executed by processor such as any one described program burning sideThe step of method.By above scheme it is found that a kind of burning program method provided in an embodiment of the present invention, comprising: obtaining includes openingThe target program of dynamic program content and user program content;Using the default compilation tool based on scatter-loading file technology by instituteIt states the startup program content in target program to compile to the first operation time domain, the user program content in the target program is compiledIt translates to the second operation time domain;The startup program content and the user program content are burned onto single-chip microcontroller differently respectivelyLocation space;Target user's contents of program is burned onto the single-chip microcontroller;Utilize the startup program content in the single-chip microcontrollerBy the user program content update to target user's contents of program.
It both may include starting journey it can be seen that a kind of burning program method provided by the present application, in a target programSequence content includes user program content again, before carrying out burning, utilizes the default compiling work based on scatter-loading file technologyTool by target program startup program content and user program content be compiled into different operation time domains respectively, so as to willDifferent contents, different address spaces can be burned onto burning by two kinds of contents separation in one target program.It is realThe remote upgrade that one target program of maintenance also can be realized single-chip microcontroller is showed.
Specific embodiment
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, completeSite preparation description, it is clear that described embodiments are only a part of the embodiments of the present invention, instead of all the embodiments.It is based onEmbodiment in the present invention, it is obtained by those of ordinary skill in the art without making creative efforts every otherEmbodiment shall fall within the protection scope of the present invention.
The embodiment of the invention discloses a kind of burning program method, system, device and computer readable storage mediums, with realityIt only needs to safeguard a set of program during present remote upgrade single-chip microcontroller.
Referring to Fig. 1, a kind of burning program method provided in an embodiment of the present invention is specifically included:
S101 obtains the target program including startup program content and user program content.
Target program is obtained first, had both been included the content of startup program (LD) in a target program, and had also been included user's journeyThe content of sequence (AP).
S102, using the default compilation tool based on scatter-loading file technology by the startup program in the target programContent is compiled to the first operation time domain, and the user program content in the target program is compiled to the second operation time domain.
It should be noted that needing to control upgraded version journey using startup program due to the operation of remote microcontroller upgradingSequence covers original program to be upgraded, such as user program, to realize the upgrading to original program to be upgraded, thus, it is necessary toStartup program and original user program there is into certain interval on memory space, that is, are unable to Coutinuous store.And for sameFor a target program, compile obtained recordable paper also only one, when burning, an initial address can only be specified, burntStartup program content and user program content in record file being programmed successively from initial address in sequence, this cannotMake the address space that there is interval between the content of the two programs.
For this purpose, this programme is compiled target program using scatter-loading file technology, in such a way that parameter is set,Startup program content and user program content are compiled into different operation time domains respectively, although so as to realize compiling fileOnly one, but content therein can be separated.
In a specific embodiment, startup program content includes startup program and interrupt vector table, correspondingly, instituteIt states using the startup program content in the single-chip microcontroller with the upgraded version contents of program to the user program contentBefore being upgraded with the part to be upgraded in the startup program content, further includes:
Start the single-chip microcontroller so that the single-chip microcontroller by the interrupt vector table with being copied to default interrupt vector tableLocation;
The startup program content using in the single-chip microcontroller and the upgraded version contents of program are to the useFamily contents of program is upgraded with the part to be upgraded in the startup program content, comprising:
Using the startup program in the single-chip microcontroller with the upgraded version contents of program in the user programAppearance is upgraded with the interrupt vector table.
Wherein, startup program, that is, above-mentioned is used to control the program of upgrading, and interrupt vector table be also need to be upgraded it is interiorHold.But scatter-loading file technology is merely capable of dividing startup program content and user program content, startup programIn content, the division of startup program and interrupt vector table really be cannot achieve.Therefore single-chip microcontroller operational process is utilized in this programmeIt realizes interrupt vector table and startup program division of teaching contents, in single-chip microcontroller starting, by the interrupt vector in startup program contentTable duplication is a to arrive interrupt vector table address, at this point, just having two parts interrupt vector table in single-chip microcontroller, portion is to be located at startingInterrupt vector table in contents of program, portion is the interrupt vector table positioned at interrupt vector table address, when being upgradedUpgraded using the disconnected vector table of interrupt vector table address centering.
Carrying out upgrading to the interrupt vector table of interrupt vector table address will cause another question, that is, deposit in single-chip microcontrollerIn new version and two interrupt vector tables of legacy version, if still starting legacy version interrupt vector table when operation, upgrading is invalid, isThis, in a specific embodiment, the starting single-chip microcontroller, so that the single-chip microcontroller answers the interrupt vector tableAfter system to default interrupt vector table address, further includes:
The start bit that interrupt vector table is arranged is set to the default interrupt vector table address.In the present solution, modification is interruptedThe starting address of vector table starts interrupt vector table from startup program content for original, is revised as from interrupt vector tableLocation starts interrupt vector table, thereby may be ensured that the interrupt vector table of starting is the interrupt vector table of latest edition, ensure thatThe validity of upgrading.
S103, is burned onto first address for the startup program content, and the user program content is burned onto pre-set userProgram address.
It, can will be different specifically, after the startup program content in target program is separated with user program contentContent is burned onto the different address space of single-chip microcontroller.
Upgraded version contents of program is transmitted to default updated contents memory space by S104.
When needing to upgrade the user program of existing operation, it is necessary first to by the user program of upgraded version, i.e. meshMark user program is burned onto single-chip microcontroller.
In a specific embodiment, described that upgraded version contents of program is transmitted to default updated contents storage skyBetween, comprising:
By first updated contents memory block of the user program content transmission of the upgraded version into the single-chip microcontroller;
The interrupt vector table of the upgraded version is transmitted to the second updated contents memory block in the single-chip microcontroller.
It should be noted that upgraded version program can both be stored in external memory space, single-chip microcontroller can also be stored inIt is internal.In the present solution, in order to which two memory blocks will be marked off inside single-chip microcontroller, that is, the first updated contents memory block and secondUpdated contents memory block, by the user program content transmission of upgraded version to the first updated contents memory block, by upgraded versionInterrupt vector table is transmitted to the second updated contents memory block in single-chip microcontroller to be made to upgrade without additionally increasing storage equipmentProcess is easier.
S105, using the startup program content in the single-chip microcontroller with the upgraded version contents of program to the useFamily contents of program is upgraded with the part to be upgraded in the startup program content.
Current user program content and startup program content to be upgraded are covered using single-chip microcontroller control upgraded version programPart to be upgraded, i.e. interrupt vector table are interrupted, the upgrading of user program can be completed.
In a specific embodiment, the startup program content using in the single-chip microcontroller and the literGrade version program content upgrades the user program content and the part to be upgraded in the startup program content, wrapsIt includes:
Upgrading mark is sent to the preset configuration conservation zone of the single-chip microcontroller, so that the single-chip microcontroller detects described presetAfter configuring the upgrading mark in conservation zone, by the user program content update to target user's contents of program.
It is identified in the present solution, configuring conservation zone for storing upgrading, when needing single-chip microcontroller update user program content,Upgrading mark, which is sent, after single-chip microcontroller detects the upgrading mark of configuration conservation zone to configuration conservation zone executes the operation of upgrading.In above-mentioned specific embodiment, i.e., the user program content of the upgraded version of the first updated contents memory block is copied into applicationThe interrupt vector table content of the upgraded version of second updated contents memory block is copied to interrupt vector table area by program area.
It can be seen that a kind of burning program method provided by the embodiments of the present application, both may include in a target programStartup program content includes user program content again, before carrying out burning, utilizes presetting based on scatter-loading file technologyCompilation tool by target program startup program content and user program content be compiled into different operation time domains respectively, thusTwo kinds of contents in one target program can be separated, it is empty that different contents can be burned onto different addresses in burningBetween.Realizing one target program of maintenance also can be realized the remote upgrade of single-chip microcontroller.
A kind of specific burning program method provided by the embodiments of the present application is introduced below, one kind described belowSpecific burning program method can be cross-referenced with any of the above-described embodiment.
A kind of specific burning program method provided by the embodiments of the present application, specifically includes:
Referring to table 1, single-chip microcontroller is divided in advance in this programme, the program Operational Zone (APROM) of single-chip microcontroller is dividedFor 6 regions.
Table 1
| LDROM | Startup program area |
| VECT_ROM | Interrupt vector table subregion |
| APROM | Application area/user program |
| UPDATE1 | First updated contents memory block |
| UPDATE2 | Second updated contents memory block |
| CONFIG | Configure conservation zone |
Wherein, the area LDROM storage startup program and interrupt vector program;The area VECT_ROM stores in program actual motionDisconnected vector table;The area ARROM store currently practical operation user program (application program be equal to user program add interrupt vector table,I.e. current monolithic machine executes the necessary program of normal function);The area UPDATE1 stores user program and upgrades data;The area UPDATE2 depositsIt stores up interrupt vector and upgrades data;The area CONFIG storage configuration information.
Firstly, be compiled into recordable paper according to soft project compiling file, wherein startup program includes two parts content, onePart is startup program, and another part is interrupt vector table.Based on dispersion loading technique by startup program content and user programContent is divided into two addresses, startup program and interrupt vector program in first address, and user program is in reserved user program address.
Referring to fig. 2, startup program is added interrupt vector and user program by replication tool when burning, is burnt to starting journey respectivelySequence adds interrupt vector area, user program area, and wipes interrupt vector table area, user program upgrading memory block, interrupt vector upgradingMemory block, configuration conservation zone.
Referring to Fig. 3, after the completion of programming, start single-chip microcontroller, startup program brings into operation when single-chip microcontroller first powers on, and is holdingIt detects whether interrupt vector table area has program before row function, finds interruption in startup program area if without interrupt vector programVector portion content copies to interrupt vector table area, then relocates interrupt vector table, later programming jump to application programIt operates normally.It should be noted that since escalation process must also upgrade interrupt vector program, and program cannot upgrade itselfCurrently performed part, so needing interrupt vector program copy to interrupt vector table area, such escalation process only needs to upgradeInterrupt vector table area and user program area, do not need starting and upgrading program area.
Referring to fig. 4, then new version is burnt by data-interfaces such as serial ports if necessary to upgrade procedure in normal use processRecord file content is transferred to single-chip microcontroller, single-chip microcontroller identification startup program, interrupt vector program and user program in transmission process,User program and interrupt vector program are saved in reserved upgrading memory block respectively.
Data, which are written after being transmitted in configuration conservation zone, needs remote upgrade mark, then warm reset single-chip microcontroller.
Referring to Fig. 5, startup program is run after monolithic processor resetting first, startup program reads configuration conservation zone, if there is risingGrade flag bit, then start to upgrade, and interrupt vector upgrading memory block content is first copied to interrupt vector table area, by user programUser program area is copied to, old program is covered, then interrupt vector address is set, user program is jumped to and executes normal function.
A kind of system of burning program provided by the embodiments of the present application is introduced below, a kind of program described below is burntRecording system can be cross-referenced with any of the above-described embodiment.
Referring to Fig. 6, a kind of system of burning program provided by the embodiments of the present application is specifically included:
Target program obtains module 301, for obtaining the target program including startup program content and user program content;
Collector 302, for utilizing the default compilation tool based on scatter-loading file technology by the target programIn startup program content compile to first operation time domain, by the user program content in the target program compile to second fortuneRow time domain;
Burning module 303, for the startup program content to be burned onto first address, by the user program content burningTo pre-set user program address;
Transmission module 304, for upgraded version contents of program to be transmitted to default updated contents memory space;
Update module 305, for utilizing the startup program content and the upgraded version program in the single-chip microcontrollerContent upgrades the user program content and the part to be upgraded in the startup program content.
Optionally, the startup program content includes startup program and interrupt vector table;
Correspondingly, the system also includes:
Single-chip microcontroller starting module, for starting the single-chip microcontroller, so that the single-chip microcontroller replicates the interrupt vector tableTo default interrupt vector table address;
The update module, is specifically used for:
Using the startup program in the single-chip microcontroller with the upgraded version contents of program in the user programAppearance is upgraded with the interrupt vector table.
Optionally, the system also includes: start bit sets setup module, and the start bit for interrupt vector table to be arranged is set toThe default interrupt vector table address.
The system of burning program of the present embodiment is for realizing burning program method above-mentioned, therefore in system of burning programIt is compiled for example, target program obtains module 301 the embodiment part of the visible burning program method hereinbefore of specific embodimentTranslate module 302, burning module 303, transmission module 304, update module 305 is respectively used to realize in above procedure method for burn-recordingStep S101, S102, S103, S104 and S105, so, specific embodiment is referred to corresponding various pieces embodimentDescription, details are not described herein.
A kind of burning program device provided in an embodiment of the present invention is introduced below, a kind of program described below is burntRecording device can be cross-referenced with any of the above-described embodiment.
Referring to Fig. 7, a kind of burning program device provided in an embodiment of the present invention is specifically included:
Memory 100, for storing computer program;
Processor 200, the step of any of the above-described burning program method is realized when for executing the computer program.
Specifically, memory 100 includes non-volatile memory medium, built-in storage.Non-volatile memory medium storageThere are operating system and computer-readable instruction, which is that the operating system and computer in non-volatile memory medium canThe operation of reading instruction provides environment.Processor 200 provides calculating and control ability for burning program device, may be implemented above-mentionedBurning program method described in one embodiment.
Further, the burning program device in the present embodiment can also include:
Input interface 300, for obtaining the computer program of extraneous importing, and the computer program that will acquire save toIn the memory 100, it can be also used for the various instructions and parameter that obtain extraneous terminal device transmission, and be transmitted to processorIn 200, so that processor 200 is handled accordingly using above-mentioned various instructions and parametric evolving.In the present embodiment, the input is connectMouth 300 can specifically include but be not limited to USB interface, serial line interface, speech input interface, fingerprint input interface, hard disk and readsInterface etc..
Output interface 400, the various data for generating processor 200 are exported to coupled terminal device, withOther terminal devices convenient for being connected with output interface 400 can get the various data of the generation of processor 200.The present embodimentIn, the output interface 400 can specifically include but be not limited to USB interface, serial line interface etc..
Communication unit 500, for completing the communication of current device and other equipment.
Keyboard 600, the various parameters data or instruction inputted and tapping keycap in real time for obtaining user.
Display 700 carries out real-time display for the relevant information to burning program process, in time in order to userSolve present procedure burning situation.
Mouse 800 can be used for assisting user input data and simplify the operation of user.
The present invention also provides a kind of computer readable storage mediums, are stored thereon with computer program, the computerStep provided by above-described embodiment may be implemented when program is executed by processor.The storage medium may include: USB flash disk, movementHard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory,RAM), the various media that can store program code such as magnetic or disk.
Each embodiment in this specification is described in a progressive manner, the highlights of each of the examples are with otherThe difference of embodiment, the same or similar parts in each embodiment may refer to each other.
The foregoing description of the disclosed embodiments enables those skilled in the art to implement or use the present invention.Various modifications to these embodiments will be readily apparent to those skilled in the art, as defined hereinGeneral Principle can be realized in other embodiments without departing from the spirit or scope of the present invention.Therefore, of the inventionIt is not intended to be limited to the embodiments shown herein, and is to fit to and the principles and novel features disclosed herein phase oneThe widest scope of cause.