CN108228198B - Programming method and device - Google Patents

Programming method and device Download PDF

Info

Publication number
CN108228198B
CN108228198B CN201611200202.6A CN201611200202A CN108228198B CN 108228198 B CN108228198 B CN 108228198B CN 201611200202 A CN201611200202 A CN 201611200202A CN 108228198 B CN108228198 B CN 108228198B
Authority
CN
China
Prior art keywords
flash memory
program
memory
erasing
storage area
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201611200202.6A
Other languages
Chinese (zh)
Other versions
CN108228198A (en
Inventor
凌和平
陈昊
贝明
赵丽
柴亮亮
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
BYD Co Ltd
Original Assignee
BYD Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by BYD Co Ltd filed Critical BYD Co Ltd
Priority to CN201611200202.6A priority Critical patent/CN108228198B/en
Publication of CN108228198A publication Critical patent/CN108228198A/en
Application granted granted Critical
Publication of CN108228198B publication Critical patent/CN108228198B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Stored Programmes (AREA)
  • Read Only Memory (AREA)

Abstract

The disclosure relates to a programming method and device, which are applied to a program upgrading system of a vehicle controller. The programming method comprises the following steps: the application program codes are sent to the memory in a segmented mode through the upper computer, so that the segmented codes are stored in the application storage area which is distributed in the memory and used for storing the application program codes in sequence; wherein the length of the segmented code is less than or equal to the application storage area; when the application storage area receives each section of the segmented code, judging whether the flash memory is subjected to erasing operation; and when the flash memory is subjected to an erasing operation, writing the segmentation code received by the application storage area into the flash memory. The method for receiving the application program code and writing the application program code into the flash memory in each segmentation can greatly improve the utilization rate of the flash memory space without being limited by the memory space, solves the problem of low utilization rate of the flash memory space in the vehicle control chip, and improves the program upgrading efficiency.

Description

Programming method and device
Technical Field
The present disclosure relates to the field of electronic technologies, and in particular, to a programming method and apparatus.
Background
As the main chip of the freescale is more applied to a VCU (Vehicle Control Unit), a TCU (Transmission Control Unit), and the like of an automobile, the Control strategy thereof directly affects the performance of the automobile, and as the Control strategy is modified and upgraded, the corresponding VCU and TCU are required to download and upgrade the update program. Generally, a developer needs to detach the VCU and the TCU mounted on the vehicle from the shell, and then download and upgrade the program of the VCU and the TCU through a Background Debug Mode (BDM) tool. Doing so can be very tedious, greatly reduced the efficiency of software upgrade.
The Chinese patent application with the application number of 201410004767.1 discloses an application system and a method for program upgrading, which is an application system for program upgrading based on a Controller Area Network (CAN) bus of a Cascade HCS08 series single chip microcomputer, and comprises N (N is more than or equal to 1) HCS08 series single chip microcomputer system modules, a CAN converter and an upper computer; the N HCS08 series single chip microcomputer system modules are respectively connected with a CAN converter through a CAN bus, and the CAN converter is connected with an upper computer. The invention CAN conveniently upgrade the program of the product by using the CAN bus without disassembling the equipment on site and only by using a computer or other equipment with the CAN bus.
However, with the continuous improvement of VCU and TCU control strategies and the continuous complication of functions, the code length of the application program is longer and longer, and the required storage space is larger. However, the above related technologies limit the code length of the application program, and after all the upgrade data are received and stored in the RAM area, the CRC (Cyclic Redundancy Check) Check succeeds in writing the application program into Flash (Flash memory) again. Generally, the RAM space of the control chip is far smaller than the FLASH space, so that the utilization rate of the FLASH is greatly limited, and the program upgrading efficiency is reduced.
Disclosure of Invention
The invention aims to provide a programming method and a device, which are used for solving the problem of low utilization rate of a flash memory space in a vehicle control chip.
In order to achieve the above object, the present disclosure provides a programming method, which is applied to a program upgrading system of a vehicle controller, where the program upgrading system includes an upper computer and a lower computer performing data interaction with the upper computer, and the lower computer includes a memory and a flash memory; the programming method comprises the following steps:
the upper computer sends the application program codes to the memory in a segmented mode so that the segmented codes are stored in an application storage area which is distributed in the memory and used for storing the application program codes in sequence; wherein the length of the segmented code is less than or equal to the application storage area;
when the application storage area receives each section of the segmented code, judging whether the flash memory is subjected to erasing operation;
and when the flash memory is subjected to an erasing operation, writing the segmentation code received by the application storage area into the flash memory.
Optionally, before the application program code is sent to the memory in a segmented manner by the upper computer, the programming method further includes:
and allocating the memory space to enable the memory to comprise the application storage area and an erasing storage area for loading an erasing program and a writing program in the flash memory.
Optionally, before determining whether the flash memory is subjected to an erase operation, the programming method further includes:
judging whether the data sent by the upper computer is received within a preset time period or not through a bootstrap program in the flash memory; wherein the data comprises the section code or an upgrade signal;
when the data sent by the upper computer is received within the preset time period, calling the erasing program and the writing program in the flash memory to the erasing storage area for operation;
and when the data sent by the upper computer is not received within the preset time period, skipping to the flash memory and executing the existing application program codes in the flash memory.
Optionally, the determining whether the flash memory is subjected to an erase operation includes:
judging whether the memory receives the segmented code for the first time;
when the memory receives the segmented code for the first time, erasing the flash memory through the erasing program;
and when the memory does not receive the segmented code for the first time, executing the step of writing the segmented code received by the application storage area into the flash memory.
Optionally, the determining whether the flash memory is subjected to an erase operation includes:
judging whether a target sector used for storing the segmentation codes of the application storage area in the sectors of the flash memory is subjected to erasing operation or not;
when the target sector is not subjected to an erasing operation, erasing the target sector through the erasing program;
when the target sector is subjected to an erasing operation, the step of writing the segment code received by the application storage area into the flash memory is performed.
Optionally, the method further comprises: and reserving the interrupt vector table of the bootstrap program, and repositioning the interrupt vector table of the application program so that the address of the interrupt vector table of the bootstrap program is different from the address of the interrupt vector table of the application program.
Optionally, the method further comprises: and assigning a value to a protection register of the flash memory so as to protect the addresses used for storing the erasing program and the writing program in the flash memory.
The present disclosure also provides a programming device, which is applied to a program upgrading system of a vehicle controller, wherein the program upgrading system includes an upper computer and a lower computer performing data interaction with the upper computer, and the lower computer includes a memory and a flash memory; the programming device comprises:
the sending module is used for sending the application program codes to the memory in a segmented manner through the upper computer so that the segmented codes are sequentially stored in an application storage area which is distributed in the memory and used for storing the application program codes; wherein the length of the segmented code is less than or equal to the application storage area;
the first judging module is used for judging whether the flash memory is subjected to erasing operation or not when the application storage area receives each section of the segmented code;
and the writing module is used for writing the segmentation codes received by the application storage area into the flash memory when the flash memory is subjected to erasing operation.
Optionally, the method further comprises: and the allocation module is used for allocating the memory space so that the memory comprises the application storage area and an erasing storage area for loading an erasing program and a writing program in the flash memory.
Optionally, the method further comprises:
the second judgment module is used for judging whether the data sent by the upper computer is received within the preset time period through a bootstrap program in the flash memory; wherein the data comprises the section code or an upgrade signal;
the calling module is used for calling the erasing program and the writing program in the flash memory to the erasing storage area to run when the data sent by the upper computer is received in the memory within a preset time period;
and the skipping module is used for skipping to the flash memory and executing the existing application program codes in the flash memory when the data sent by the upper computer are not received in the preset time period of the internal memory.
Optionally, the first determining module includes:
the first judgment submodule is used for judging whether the memory receives the segmented code for the first time;
the first erasing submodule is used for erasing the flash memory through the erasing program when the memory receives the segmented code for the first time;
when the memory does not receive the segmented code for the first time, the writing module executes the step of writing the segmented code received by the application storage area into the flash memory.
Optionally, the first determining module includes:
the second judgment submodule is used for judging whether a target sector which is used for storing the segmentation codes of the application storage area in the sectors of the flash memory is subjected to an erasing operation or not;
the second erasing submodule is used for erasing the target sector through the erasing program when the target sector is not subjected to the erasing operation;
when the target sector is subjected to an erasing operation, the writing module executes a step of writing the segment code received by the application storage area into the flash memory.
Optionally, the method further comprises: and the relocation module is used for reserving the interrupt vector table of the bootstrap program and relocating the interrupt vector table of the application program so as to enable the address of the interrupt vector table of the bootstrap program to be different from the address of the interrupt vector table of the application program.
Further comprising: and the assignment module is used for assigning the protection register of the flash memory so as to protect the addresses, which are used for storing the erasing program and the writing program, in the flash memory.
The technical scheme provided by the embodiment of the disclosure can have the following beneficial effects:
by segmenting the application program codes and sending the application program codes to the memory, when the application storage area receives one segment of the segmented codes, whether the flash memory is subjected to erasing operation is judged, and when the flash memory is subjected to erasing operation, the segmented codes received by the application storage area are written into the flash memory, so that the manner of receiving the application program codes segmented every time and writing the application program codes into the flash memory can greatly improve the utilization rate of the flash memory space without being limited by the memory space, the problem of low utilization rate of the flash memory space in a vehicle control chip is solved, and the program upgrading efficiency is improved.
Additional features and advantages of the disclosure will be set forth in the detailed description which follows.
Drawings
The accompanying drawings, which are included to provide a further understanding of the disclosure and are incorporated in and constitute a part of this specification, illustrate embodiments of the disclosure and together with the description serve to explain the disclosure without limiting the disclosure. In the drawings:
FIG. 1 is a flow chart illustrating a method of programming according to an exemplary embodiment.
FIG. 2 is another flow chart illustrating a method of programming according to an exemplary embodiment.
FIG. 3 is another flow chart illustrating a method of programming according to an exemplary embodiment.
FIG. 4 is a flow chart illustrating a method of programming including steps for determining whether a flash memory has undergone an erase operation in accordance with one illustrative embodiment.
FIG. 5 is another flow chart illustrating a method of programming including steps for determining whether a flash memory has undergone an erase operation in accordance with one illustrative embodiment.
FIG. 6 is a diagram illustrating a relocated application interrupt vector table in accordance with an exemplary embodiment.
FIG. 7 is a block diagram illustrating a write device in accordance with an exemplary embodiment.
FIG. 8 is another block diagram illustrating a write device in accordance with an exemplary embodiment.
FIG. 9 is a block diagram illustrating a first determination module of a programming apparatus in accordance with an exemplary embodiment.
FIG. 10 is another block diagram illustrating a first determination module of a programming apparatus in accordance with an illustrative embodiment.
FIG. 11 is another block diagram illustrating a write device in accordance with an exemplary embodiment.
FIG. 12 is another block diagram illustrating a write device in accordance with an exemplary embodiment.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
The programming method is applied to a program upgrading system of a vehicle controller, the program upgrading system comprises an upper computer and a lower computer which is in data interaction with the upper computer, and the lower computer comprises a memory and a flash memory. The vehicle controller CAN be a controller with a Freescale chip, and the upper computer and the lower computer CAN perform data interaction through a CAN module. Of course, in other embodiments, the upper computer and the lower computer may also perform data interaction through other communication modes, such as an RS485 bus, a LIN bus, and the like, where the communication modes of the upper computer and the lower computer are related to specific peripheral functions of a chip in the controller.
FIG. 1 is a flow chart illustrating a method of programming according to an exemplary embodiment. As shown in fig. 1, the programming method includes the following steps.
In step S11, the upper computer sends the application program codes to the memory in a segmented manner, so that the segmented codes are sequentially stored in the application storage area allocated in the memory and used for storing the application program codes; wherein the length of the segmented code is less than or equal to the application storage area.
In step S12, it is determined whether the flash memory has undergone an erase operation every time the application storage area receives one piece of the segment code.
In step S13, when the flash memory is subjected to an erase operation, the segment code received by the application storage area is written into the flash memory.
First, in step S11, the operator sends the application data to the upper computer through a data interface or wireless communication. The upper computer then converts the application program data into application program codes which CAN be executed by the lower computer, and the application program codes are segmented and then sent to the memory of the lower computer through a communication module (such as a CAN module) in the program upgrading system. The memory includes an application storage area for storing the application program code, and when the application program code is segmented, the memory may be divided into a plurality of segment codes of equal length or a plurality of segment codes of unequal length, as long as the length of each segment code is less than or equal to the application storage area.
It should be noted that, when sending the segment code to the memory, only one segment code may be sent each time, or multiple segment codes may be sent each time, as long as the sum of the lengths of the multiple segment codes sent each time is less than or equal to the application storage area.
Taking the example of the S19 file code, firstly, in the upper computer, using SRecCvt-gui. exe software provided by the ricalcar corporation to convert each record of the generated S19 file code into 32 bytes (here, equal byte length processing is performed, which is convenient for subsequent receiving processing of the bootstrap); then, the S19 file codes are further processed (for example, address and effective codes are extracted) through the upper computer; and then, sequentially sending the segmented S19 file codes to a memory of a lower computer through a CAN module.
When the upper computer sends the application program code to the memory in a segmented manner, step S12 is executed, and when the application storage area receives each segment of the segmented code, it is determined whether the flash memory is subjected to an erasing operation. Since the flash memory needs to be erased before the code can be written, the segment code received by the application storage area needs to be written into the flash memory when it is determined that the flash memory is subjected to the erasing operation.
This is disclosed through carry out segmentation with application program code and send to the memory, when every section is received in the application memory area during the segmentation code, judge whether flash memory is through erasing the operation, when flash memory is through erasing the operation, will application memory area is received the segmentation code is write in flash memory, and then, this kind of mode of receiving application program code and writing in flash memory of segmentation at every turn of this disclosure can improve the utilization ratio in flash memory space greatly, and do not receive the restriction in memory space for application code's length furthest can reach and distribute to flash memory space, has adapted functions such as VCU, TCU and has increasingly complicated demand, has solved the low problem of flash memory space utilization ratio in the vehicle control chip, has improved program upgrade efficiency.
FIG. 2 is another flow chart illustrating a method of programming according to an exemplary embodiment. As shown in fig. 2, the programming method includes the following steps.
In step S21, the memory space is allocated so that the memory includes an application program storage area for storing application program codes and an erasure storage area for loading an erasure program and a write program in the flash memory.
In step S22, the application program code is sent to the memory in a segmented manner by the upper computer, so that the segmented code is sequentially stored in the application storage area; wherein the length of the segmented code is less than or equal to the application storage area.
In step S23, it is determined whether the flash memory has undergone an erase operation every time the application storage area receives one piece of the segment code.
In step S24, when the flash memory is subjected to an erase operation, the segment code received by the application storage area is written into the flash memory.
The step of allocating the memory space may be to reallocate the memory space each time the programming method of the present disclosure is executed. When the memory is allocated, the memory space of the application program can be reserved as much as possible according to the allocation requirement, that is, the larger the space occupied by the application storage area in the memory, the better. The memory space is allocated, so that not only can the segmented code sent by the upper computer be temporarily stored, but also the erasing program and the writing program can be loaded into the memory from the flash memory to run.
FIG. 3 is another flow chart illustrating a method of programming according to an exemplary embodiment. As shown in fig. 3, the writing method includes the following steps.
In step 31, the upper computer sends the application program codes to the memory in a segmented manner, so that the segmented codes are sequentially stored in an application storage area which is distributed in the memory and used for storing the application program codes; wherein the length of the segmented code is less than or equal to the application storage area.
In step 32, judging whether the data sent by the upper computer is received within a preset time period through a bootstrap program in the flash memory; wherein the data comprises the segment code or an upgrade signal.
In step 33, when the memory receives the data sent by the upper computer within a preset time period, the erasing program and the writing program in the flash memory are called to the erasing and writing storage area to operate.
In step 34, when the application storage area receives each segment of the segment code, it is determined whether the flash memory has undergone an erase operation.
In step 35, when the flash memory is subjected to an erasing operation, the segment code received by the application storage area is written into the flash memory by the writer.
In step 36, when the data sent by the upper computer is not received within the preset time period, executing the application program code existing in the flash memory.
Wherein, the preset time period may be 5 seconds, 3 seconds or other time periods. And the bootstrap program judges whether a program upgrading system needs upgrading or whether program codes are all written into the flash memory or not by judging whether the segmented codes or upgrading signals sent by the upper computer are received or not within the preset waiting time period.
And when the bootstrap program receives the segmented code or the upgrading signal sent by the upper computer within a waiting preset time period, calling an erasing program and a writing program in the flash memory to an erasing storage area in the memory for running. Then, step 34 is executed to determine whether the flash memory has undergone an erase operation every time the application storage area receives a segment of the segment code. And when the flash memory is subjected to an erasing operation, writing the segmentation code received by the application storage area into the flash memory through the write-in program. The write-in program is called to the memory to run, so that the running speed is accelerated, and the probability of damage to the flash memory caused by accidental reset is reduced.
When the bootstrap program does not receive the segmented code or the upgrading signal sent by the upper computer within the waiting preset time period, the bootstrap program indicates that the program upgrading system does not need to be upgraded or the program codes are all written into the flash memory, and at the moment, the bootstrap program jumps to the flash memory and executes the existing application program codes in the flash memory. The method and the device realize the jump between the bootstrap program and the application program through the timeout mechanism, replace the mode of using a hardware switch to realize the jump between the bootstrap program and the application program in the related technology, and save the hardware cost.
FIG. 4 is a flow chart illustrating a method of programming including steps for determining whether a flash memory has undergone an erase operation in accordance with one illustrative embodiment. As shown in fig. 4, the determining whether the flash memory is subjected to the erase operation may include the following steps.
In step 3411, it is determined whether the memory received the segmented code for the first time.
In step 3412, when the memory is the first time the segment code is received, the flash memory is erased by the erase procedure.
In step 3413, when the memory does not receive the segment code for the first time, the step of writing the segment code received by the application storage area to the flash memory is performed.
The flash memory may include a plurality of sectors for storing the segment codes, and when the memory receives the segment codes for the first time, all the sectors are erased at one time by the erase procedure. That is, when the memory receives the segment code for the first time, the boot program calls the erase program to erase the flash memory. And when the memory does not receive the segmented code for the first time, the erasing operation is not performed any more, and the segmented code received by the application storage area is written into the flash memory by calling a write-in program.
FIG. 5 is another flow chart illustrating a method of programming including steps for determining whether a flash memory has undergone an erase operation in accordance with one illustrative embodiment. As shown in fig. 5, the determining whether the flash memory is subjected to the erase operation may include the following steps.
In step 3421, it is determined whether a target sector of the sectors of the flash memory for storing the section code of the application storage area has undergone an erase operation.
In step 3422, when the target sector has not undergone an erase operation, the target sector is erased by the erase procedure.
In step 3423, when the target sector is subjected to an erase operation, the step of writing the section code received by the application storage area to the flash memory is performed.
The flash memory comprises a plurality of sectors, and each sector is used for storing the corresponding segmentation code. When the application storage area receives a segment code, the bootstrap program firstly judges whether the target sector corresponding to the segment code received by the application storage area is subjected to erasing operation. And if the target sector is not subjected to the erasing operation, calling the erasing program by the bootstrap program to erase the target sector. When the target sector is subjected to an erasing operation, the bootstrap program calls a write program to write the segmentation codes received by the application storage area into the target sector.
Optionally, the writing method further includes: and reserving the interrupt vector table of the bootstrap program, and repositioning the interrupt vector table of the application program so that the address of the interrupt vector table of the bootstrap program is different from the address of the interrupt vector table of the application program. Since all CPUs usually fetch instructions from a certain address (0 xffffe) prearranged by the CPU manufacturer, and the boot program and the application program are in the memory and the flash memory, respectively, in order to prevent the boot program and the application program from being confused in program call due to the same address, as shown in fig. 6, the interrupt vector table (0xFF10-0xFFFF) of the boot program in the memory is reserved, and the interrupt vector table (0xEF10-0 xFFFF) of the application program is reset. Therefore, after the program upgrading system is powered on, the CPU executes the boot program firstly; after the boot is exited, the program jumps to the reset vector of the application program of 0xEFFE, and starts to execute the corresponding application program.
Optionally, the writing method further includes: and assigning a value to a protection register of the flash memory so as to protect the addresses used for storing the erasing program and the writing program in the flash memory. For example, the erase program and the write program are placed at 0xF000-0xF1FF in the flash memory, and FPROT is set to 0x8f to protect the address range of 0xF000-0xFFFF in the flash memory.
Optionally, the writing method further includes: and allocating the flash memory space so that the flash memory comprises a code storage area for storing the segmented codes and a boot storage area for storing the boot program. The step of allocating the flash memory space may be reallocating the flash memory space each time the programming method of the present disclosure is executed.
FIG. 7 is a block diagram illustrating a write device in accordance with an exemplary embodiment. Referring to fig. 7, the programming apparatus 700 includes a sending module 710, and a writing module 730. The programming device 700 is applied to a program upgrading system of a vehicle controller, the program upgrading system comprises an upper computer and a lower computer which performs data interaction with the upper computer, and the lower computer comprises a memory and a flash memory.
The sending module 710 is configured to send the application program code to the memory in a segmented manner through the upper computer, so that the segmented code is sequentially stored in the application storage area allocated in the memory and used for storing the application program code; wherein the length of the segmented code is less than or equal to the application storage area.
The first determining module 720 is configured to determine whether the flash memory has undergone an erasing operation when the application storage area receives each segment of the segment code.
The writing module 730 is configured to write the segment code received by the application storage area into the flash memory when the flash memory is subjected to an erasing operation.
Optionally, as shown in fig. 8, the programming apparatus 700 further includes an allocation module 740 in addition to the sending module 710, and the writing module 730.
The allocating module 740 is configured to allocate the memory space so that the memory includes the application storage area and an erase/write storage area for loading an erase program and a write program in the flash memory.
Optionally, as shown in fig. 8, the writing apparatus 700 includes, in addition to the sending module 710, the writing module 730, and the allocating module 740:
the second judging module 750 is configured to judge whether data sent by the upper computer is received within the preset time period through a bootstrap program in the flash memory; wherein the data comprises the section code or an upgrade signal;
the calling module 760 is used for calling the erasing program and the writing program in the flash memory to the erasing and writing storage area to operate when the data sent by the upper computer is received in a preset time period in the internal memory;
the skip module 770 is configured to skip to the flash memory and execute the existing application program code in the flash memory when the data sent by the upper computer is not received in the preset time period in the memory.
Optionally, as shown in fig. 9, the first determining module 720 includes:
a first determining submodule 7211, configured to determine whether the memory receives the segment code for the first time;
a first erase submodule 7212 configured to erase the flash memory by the erase program when the memory receives the segment code for the first time;
when the memory does not receive the segment code for the first time, the writing module 730 executes the step of writing the segment code received by the application storage area into the flash memory.
Optionally, as shown in fig. 10, the first determining module 720 includes:
a second determination submodule 7221 configured to determine whether a target sector, which is used to store the section code of the application storage area, in the sectors of the flash memory has undergone an erase operation;
a second erase submodule 7222 configured to erase the target sector by the erase program when the target sector has not undergone an erase operation;
when the target sector is subjected to an erase operation, the writing module 730 performs the step of writing the section code received by the application storage area into the flash memory.
Optionally, as shown in FIG. 11, the programming apparatus 700 includes a relocation module 780 in addition to the sending module 710, the writing module 730, and the allocating module 740.
The relocation module 780 is configured to reserve the interrupt vector table of the boot program and relocate the interrupt vector table of the application program so that the address of the interrupt vector table of the boot program is different from the address of the interrupt vector table of the application program.
Optionally, as shown in fig. 12, the programming apparatus 700 further includes an assigning module 790 in addition to the sending module 710, the writing module 730, and the allocating module 740.
The assignment module 790 is configured to assign a value to a protection register of the flash memory to protect an address in the flash memory for storing the erase program and the write program.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
The preferred embodiments of the present disclosure are described in detail with reference to the accompanying drawings, however, the present disclosure is not limited to the specific details of the above embodiments, and various simple modifications may be made to the technical solution of the present disclosure within the technical idea of the present disclosure, and these simple modifications all belong to the protection scope of the present disclosure.
It should be noted that the various features described in the above embodiments may be combined in any suitable manner without departing from the scope of the invention. In order to avoid unnecessary repetition, various possible combinations will not be separately described in this disclosure.
In addition, any combination of various embodiments of the present disclosure may be made, and the same should be considered as the disclosure of the present disclosure, as long as it does not depart from the spirit of the present disclosure.

Claims (10)

1. A programming method is applied to a program upgrading system of a vehicle controller, wherein the program upgrading system comprises an upper computer and a lower computer which performs data interaction with the upper computer, and the lower computer comprises a memory and a flash memory; the programming method is characterized by comprising the following steps:
the upper computer sends the application program codes to the memory in a segmented mode so that the segmented codes are stored in an application storage area which is distributed in the memory and used for storing the application program codes in sequence; wherein the length of the segmented code is less than or equal to the application storage area;
when the application storage area receives each section of the segmented code, judging whether the flash memory is subjected to erasing operation;
when the flash memory is subjected to an erasing operation, writing the segmentation code received by the application storage area into the flash memory;
before the application program codes are sent to the memory in a segmented manner through the upper computer, the programming method further comprises the following steps:
distributing the memory space so that the memory comprises the application storage area and an erasing storage area for loading an erasing program and a writing program in the flash memory;
before the determining whether the flash memory is subjected to the erasing operation, the programming method further includes:
judging whether the data sent by the upper computer is received within a preset time period or not through a bootstrap program in the flash memory; wherein the data comprises the section code or an upgrade signal;
when the data sent by the upper computer is received within the preset time period, calling the erasing program and the writing program in the flash memory to the erasing storage area for operation;
and when the data sent by the upper computer is not received within the preset time period, skipping to the flash memory and executing the existing application program codes in the flash memory.
2. The method of claim 1, wherein the determining whether the flash memory has undergone an erase operation comprises:
judging whether the memory receives the segmented code for the first time;
when the memory receives the segmented code for the first time, erasing the flash memory through the erasing program;
and when the memory does not receive the segmented code for the first time, executing the step of writing the segmented code received by the application storage area into the flash memory.
3. The method of claim 1, wherein the determining whether the flash memory has undergone an erase operation comprises:
judging whether a target sector used for storing the segmentation codes of the application storage area in the sectors of the flash memory is subjected to erasing operation or not;
when the target sector is not subjected to an erasing operation, erasing the target sector through the erasing program;
when the target sector is subjected to an erasing operation, the step of writing the segment code received by the application storage area into the flash memory is performed.
4. The programming method of claim 1, further comprising: and reserving the interrupt vector table of the bootstrap program, and repositioning the interrupt vector table of the application program so that the address of the interrupt vector table of the bootstrap program is different from the address of the interrupt vector table of the application program.
5. The programming method of claim 1, further comprising: and assigning a value to a protection register of the flash memory so as to protect the addresses used for storing the erasing program and the writing program in the flash memory.
6. A programming device is applied to a program upgrading system of a vehicle controller, the program upgrading system comprises an upper computer and a lower computer which performs data interaction with the upper computer, and the lower computer comprises a memory and a flash memory; characterized in that, the programming device comprises:
the sending module is used for sending the application program codes to the memory in a segmented manner through the upper computer so that the segmented codes are sequentially stored in an application storage area which is distributed in the memory and used for storing the application program codes; wherein the length of the segmented code is less than or equal to the application storage area;
the first judging module is used for judging whether the flash memory is subjected to erasing operation or not when the application storage area receives each section of the segmented code;
the writing module is used for writing the segmentation codes received by the application storage area into the flash memory when the flash memory is subjected to erasing operation;
the allocation module is used for allocating the memory space so that the memory comprises the application storage area and an erasing storage area for loading an erasing program and a writing program in the flash memory;
the second judgment module is used for judging whether the data sent by the upper computer is received within the preset time period through a bootstrap program in the flash memory; wherein the data comprises the section code or an upgrade signal;
the calling module is used for calling the erasing program and the writing program in the flash memory to the erasing storage area to run when the data sent by the upper computer is received in the memory within a preset time period;
and the skipping module is used for skipping to the flash memory and executing the existing application program codes in the flash memory when the data sent by the upper computer are not received in the preset time period of the internal memory.
7. The programming apparatus of claim 6, wherein the first determining module comprises:
the first judgment submodule is used for judging whether the memory receives the segmented code for the first time;
the first erasing submodule is used for erasing the flash memory through the erasing program when the memory receives the segmented code for the first time;
when the memory does not receive the segmented code for the first time, the writing module executes the step of writing the segmented code received by the application storage area into the flash memory.
8. The programming apparatus of claim 6, wherein the first determining module comprises:
the second judgment submodule is used for judging whether a target sector which is used for storing the segmentation codes of the application storage area in the sectors of the flash memory is subjected to an erasing operation or not;
the second erasing submodule is used for erasing the target sector through the erasing program when the target sector is not subjected to the erasing operation;
when the target sector is subjected to an erasing operation, the writing module executes a step of writing the segment code received by the application storage area into the flash memory.
9. The programming apparatus of claim 6, further comprising:
and the relocation module is used for reserving the interrupt vector table of the bootstrap program and relocating the interrupt vector table of the application program so as to enable the address of the interrupt vector table of the bootstrap program to be different from the address of the interrupt vector table of the application program.
10. The programming apparatus of claim 6, further comprising:
and the assignment module is used for assigning the protection register of the flash memory so as to protect the addresses, which are used for storing the erasing program and the writing program, in the flash memory.
CN201611200202.6A 2016-12-22 2016-12-22 Programming method and device Active CN108228198B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201611200202.6A CN108228198B (en) 2016-12-22 2016-12-22 Programming method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201611200202.6A CN108228198B (en) 2016-12-22 2016-12-22 Programming method and device

Publications (2)

Publication Number Publication Date
CN108228198A CN108228198A (en) 2018-06-29
CN108228198B true CN108228198B (en) 2021-01-01

Family

ID=62657101

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201611200202.6A Active CN108228198B (en) 2016-12-22 2016-12-22 Programming method and device

Country Status (1)

Country Link
CN (1) CN108228198B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109189405B (en) * 2018-07-19 2022-03-01 山东省科学院自动化研究所 Method and system for verifying Flash data consistency of program
CN114816460A (en) * 2022-06-29 2022-07-29 上海捷勃特机器人有限公司 Device and method for remotely upgrading microcontroller of robot system

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
DE10146609A1 (en) * 2001-09-21 2003-04-10 Abb Patent Gmbh Bus component device has a sub-divided integrated flash memory, so that operating system and application programs can be altered, expanded or corrected without disconnection of the device from the bus
CN101777001A (en) * 2009-01-08 2010-07-14 胡科 DSP (Digital Signal Processor)-based online process curing method
CN104360877A (en) * 2014-10-24 2015-02-18 同济大学 ECU (electronic control unit) firmware updating method based on Bootloader self update
CN104765632A (en) * 2015-04-15 2015-07-08 南京汽车集团有限公司 BootLoader management method
CN105468384A (en) * 2014-08-25 2016-04-06 比亚迪股份有限公司 Vehicle-mounted controller programming system and method, server and programming terminal

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
DE10146609A1 (en) * 2001-09-21 2003-04-10 Abb Patent Gmbh Bus component device has a sub-divided integrated flash memory, so that operating system and application programs can be altered, expanded or corrected without disconnection of the device from the bus
CN101777001A (en) * 2009-01-08 2010-07-14 胡科 DSP (Digital Signal Processor)-based online process curing method
CN105468384A (en) * 2014-08-25 2016-04-06 比亚迪股份有限公司 Vehicle-mounted controller programming system and method, server and programming terminal
CN104360877A (en) * 2014-10-24 2015-02-18 同济大学 ECU (electronic control unit) firmware updating method based on Bootloader self update
CN104765632A (en) * 2015-04-15 2015-07-08 南京汽车集团有限公司 BootLoader management method

Also Published As

Publication number Publication date
CN108228198A (en) 2018-06-29

Similar Documents

Publication Publication Date Title
CN109582227B (en) Solid state disk writing method and device, computer equipment and storage medium
US20050102660A1 (en) Initialization and update of software and/or firmware in electronic devices
KR100988157B1 (en) Method and apparatus for detecting memory device configuration, and computer readable medium containing instructions for performing method for detecting memory device configuration
CN111522659B (en) Space use method and device
CN111694510B (en) Data storage device and data processing method
CN108228198B (en) Programming method and device
CN102667714B (en) Support the method and system that the function provided by the resource outside operating system environment is provided
US8984231B2 (en) Methods and apparatus to perform adaptive pre-fetch operations in managed runtime environments
CN111338779B (en) Resource allocation method, device, computer equipment and storage medium
US7984432B2 (en) Method for patching a read-only memory and a data processing system comprising a means of patching the read-only memory based on patch contexts
KR20140142530A (en) Data storage device and method of scheduling command thereof
CN110851163A (en) Software updating method compatible with multi-device platform based on CAN communication
US8601232B2 (en) Memory management device, memory management method, memory management program, computer-readable recording medium recording memory management program and integrated circuit
US8528007B1 (en) Firmware downloading through process file system
CN110764813A (en) Upgrading method of system software and running method thereof
US20050188365A1 (en) Flash memory and method of dynamically loading firmware operation module in optical drive
CN106682494B (en) Information access method, device and equipment
CN113010195B (en) System upgrading method, storage medium and terminal equipment
CN115934213A (en) Controller stack calling method, device, equipment and storage medium
KR100745256B1 (en) Code overlay method in the embedded system
CN111190658B (en) System for supporting dynamic loading of application program on SoC (system on chip) without MMU (memory management unit) based on-chip execution
CN112486570B (en) Glibc compatible method for CPUs of different types
TWI592803B (en) Method of operating embedded system and control chip thereof
CN114138176A (en) Nor Flash erasing and upgrading method and device, computer equipment and storage medium
CN111913762A (en) DSP dynamic loading method for reserving operation memory space

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant