Flash batch programming circuit and method suitable for microcontrollers
By designing a Flash batch writing circuit in a microcontroller and cooperating with DMA, processing data in batches and monitoring it in real time, the problems of long Flash writing process and data loss are solved, and fast, centralized and reliable Flash writing is achieved. .
Patent Information
- Application Number
- CN202411187230.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-28
- Publication Date
- 2024-12-13
- Estimated Expiration
- 2044-08-28
AI Technical Summary
In microcontrollers, the Flash burning process takes up a long time and takes up a large resource, and it is easy to cause data loss due to abort events, especially when writing large amounts of data.
A Flash batch writing circuit is designed, which is connected to DMA through the Flash batch writing control module. The DMA is requested to transfer data in batches and control the single-time writing module to complete the writing, monitoring in real time and reducing the risk of abortion.
It realizes rapid centralized writing of large data volumes, reduces the risk of microcontroller resource occupation and abortion, and reduces the possibility of data loss.
Smart Images

Figure CN118689498B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of integrated circuits, and in particular to a Flash batch programming circuit and method suitable for a microcontroller. Background Art
[0002] At present, in microcontrollers, Flash (non-volatile memory), which is the main storage for programs and data, takes a lot of time and steps to burn because of the special requirements of process design. If the burning is to be correct, the burning process cannot be terminated at will. At present, Flash burning is a single task based on interrupts or polling. These single burning tasks are generally designed with state machines or driven by separate kernels. The burning of large amounts of data is a collection of such single burning tasks one by one, and scheduling will take up a lot of microcontroller time and resources. In the actual application of microcontrollers, due to the situation that there will be a large amount of data written, it will frequently occupy a lot of microcontroller task scheduling time. In addition, in the AutoSAR software architecture for automotive applications, limited by the influence of the AutoSAR architecture, in order to make its scheduling controllable, interrupts are rarely used, but time-scheduling polling is used to burn Flash. The amount of data that can be burned each time is very limited, resulting in the large data being broken down into many small fragments for scattered burning, which in turn causes the entire burning process to be very scattered, greatly extending the overall total duration of Flash burning. In application scenarios, there is a high probability of encountering various power failures, resets, and forced terminations. The frequent and scattered Flash burning process mentioned above greatly increases the possibility of the Flash burning process being accidentally terminated. It is easy to encounter these termination events, resulting in data being damaged and lost without completing the complete Flash burning process, which directly leads to chip program errors. Summary of the invention
[0003] The purpose of the present invention is to provide a Flash batch burning circuit and method suitable for a microcontroller, which can complete the burning of large amounts of data in a relatively centralized and rapid manner, reduce the occupancy of the microcontroller, reduce the possibility of unexpected termination, and also reduce the possibility of data loss and error.
[0004] To achieve the above object, the present invention provides the following technical solutions:
[0005] The present invention provides a Flash batch burning circuit suitable for a microcontroller, the Flash batch burning circuit comprising a connected Flash batch burning control module and a Flash single burning module, the Flash batch burning control module is also used to connect to DMA, accept batch burning instructions, request the DMA in batches to transfer information to be burned to the Flash batch burning control module, and control the Flash single burning module in batches to complete single burning.
[0006] In one embodiment, the Flash batch burning control module includes a batch burning address control module, a batch burning data control module, and a single burning control module. The batch burning address control module has a Flash burning address register, and the batch burning data control module has a Flash burning data register; the batch burning address control module is connected to the batch burning data control module, the single burning control module, and the DMA, receives the batch burning instruction, starts the batch burning process, sends a request for transferring the batch burning address to the DMA in batches, stores the batch burning address transferred by the DMA in the Flash burning address register, and observes that the single burning control module completes the single burning, starts the next batch of single burning, and ends the entire batch burning process after completing the batch burning; the batch burning data control module The block is connected to the batch burning address control module, the single burning control module and the DMA. After observing that the batch burning address control module writes a new address into the Flash burning address register, it sends a request to the DMA to move the batch burning data, and stores the batch burning data moved by the DMA into the Flash burning data register; the single burning control module is connected to the batch burning address control module, the batch burning data control module and the Flash single burning module. After observing that the batch burning data control module writes new data into the Flash burning data register, it controls the Flash single burning module to start the single burning, performs the single burning monitoring in real time, and promptly closes the current single burning related logic when the single burning is completed or abnormal, and reports the burning result to the batch burning address control module.
[0007] In one embodiment, the Flash batch control module is also used to connect to a memory, which stores batch burning addresses and batch burning data to be burned. The DMA is also connected to the memory to transfer the batch burning addresses and batch burning data to be burned from the memory to the Flash batch burning control module.
[0008] In one embodiment, the Flash batch burning circuit further includes a microcontroller, which is connected to the batch burning address controller, sends the batch burning instruction to the batch burning address controller, and receives a report of burning abnormality from the batch burning address controller.
[0009] The present invention also provides a Flash batch burning method suitable for a microcontroller, the Flash batch burning method comprising: using the Flash batch burning circuit as described above, a Flash batch burning control module accepting a batch burning instruction, requesting DMA in batches to transfer information to be burned to the Flash batch burning control module, and controlling the Flash single burning module in batches to complete single burning.
[0010] In one embodiment, the Flash batch programming method includes:
[0011] Step 1: The batch burning address control module receives the batch burning instruction and starts the entire batch burning process;
[0012] Step 2: The batch burning address control module sends a request to DMA to transfer the batch burning address. After receiving the request, DMA transfers the batch burning address to the Flash burning address register in the batch burning address control module;
[0013] Step 3: After the batch burning data control module observes that the batch burning address control module has written a new address into the Flash burning address register, it sends a request to the DMA to move the batch burning data. After receiving the request, the DMA moves the batch burning data to the Flash burning data register in the batch burning data control module;
[0014] Step 4: After the single-shot burn control module observes that the batch burn data control module has written new data into the Flash burn data register, it starts the Flash single-shot burn module for single-shot burn. During the single-shot burn module, the Flash burn monitoring result is checked in real time. When the burn is completed, the single-shot burn action is closed, and the batch burn address control module is informed to start the next single-shot burn cycle.
[0015] Step 5: After the batch burning address control module detects that the single burning control module has completed a single burning, it automatically starts the next single burning according to the preset number of cycles, and repeats the process from step 2 to step 4 in sequence to complete a new cycle until the overall cycle scale reaches the preset upper limit, automatically ending this batch burning action.
[0016] In one embodiment, the Flash batch burning control module is also used to connect to a memory, the memory pre-stores the batch burning address and batch burning data to be burned, and the DMA is also connected to the memory; in the step two, the DMA moves the pre-stored batch burning address from the memory to the Flash burning address register; in the step three, the DMA moves the pre-stored batch burning data from the memory to the Flash burning data register.
[0017] In one embodiment, the Flash batch burning circuit also includes a microcontroller, which is connected to the batch burning address controller, sends the batch burning instruction to the batch burning address controller, and receives the batch burning address controller to report the burning abnormality; in the step one, the microcontroller triggers the batch burning instruction by setting the batch burning start register; in the step four, if the single burning control module checks the Flash burning abnormality, it reports to the batch burning address control module in real time, and chooses whether to continue the next single burning cycle or jump out of the batch burning cycle; in the step five, if step four chooses to jump out of the batch burning cycle, the batch burning address control module sets the corresponding flag register and reports to the microcontroller for further processing.
[0018] In one implementation, in the step 2, the batch writing address control module automatically completes a transmission handshake with the DMA; in the step 3, the batch writing data control module automatically completes a transmission handshake with the DMA.
[0019] Compared with the prior art, the technical solution of the present invention has the following beneficial effects:
[0020] The Flash batch burning circuit and method suitable for a microcontroller described in the present invention can realize Flash batch burning through the cooperation of a Flash batch burning control module, DMA and a Flash single burning module, thereby realizing relatively concentrated and fast Flash burning of a large amount of data, reducing the occupancy of the microcontroller, and reducing the possibility of power failure and restart being accidentally terminated during the Flash burning process, thereby reducing the possibility of data loss and error. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0022] Figure 1 A schematic structural diagram of a Flash batch programming circuit suitable for a microcontroller provided in the first embodiment of the present invention. DETAILED DESCRIPTION
[0023] The technical solutions in the embodiments of the present invention will be described clearly and completely below. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by those skilled in the art without creative work belong to the scope of protection of the present invention. It should be noted that the description order of the following embodiments is not used as a limitation on the preferred order of the embodiments of the present invention. In the following embodiments, the description of each embodiment has its own emphasis. For the parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0024] See also Figure 1 As shown, the first embodiment of the present invention provides a Flash batch burning circuit suitable for a microcontroller, the Flash batch burning circuit includes a connected Flash batch burning control module and a Flash single burning module, the Flash batch burning control module is also used to connect to DMA (Direct Memory Access), accept batch burning instructions, request the DMA in batches to move the information to be burned to the Flash batch burning control module, and control the Flash single burning module in batches to complete single burning.
[0025] The Flash single-time burning module is the existing Flash single-time burning module, which is located in the Flash. On the basis of the existing Flash single-time burning module, the present invention adds a Flash batch burning control module (also arranged in the Flash) to cooperate with the DMA, and allows the Flash single-time burning module to be connected to the Flash batch burning control module instead of being connected to the microcontroller, so that Flash batch burning can be realized, thereby realizing relatively concentrated and fast Flash burning of a large amount of data, and reducing the occupation of the microcontroller, and reducing the possibility of accidental termination, thereby reducing the possibility of data loss and error.
[0026] In addition, the reason why we do not use DMA directly but design this Flash batch burning control module to cooperate with DMA is that Flash burning has strict burning start timing restrictions, monitoring during burning, and control of closing Flash after burning for safety requirements, and the general DMA module does not have the corresponding control capabilities. This is also the reason why we need to use the existing Flash single burning module. The specific structure of the Flash batch burning control module is described below.
[0027] Please continue reading Figure 1As shown, in one embodiment, the Flash batch burning control module includes a batch burning address control module, a batch burning data control module, and a single burning control module. The batch burning address control module has a Flash burning address register, and the batch burning data control module has a Flash burning data register; the batch burning address control module is connected to the batch burning data control module, the single burning control module, and the DMA, receives the batch burning instruction, starts the batch burning process, sends a request for transferring the batch burning address to the DMA in batches, stores the batch burning address transferred by the DMA in the Flash burning address register, and starts the next batch of single burning after observing that the single burning control module completes the single burning, and ends the entire batch burning process after completing the batch burning; the batch burning data control module The module is connected to the batch burning address control module, the single burning control module and the DMA. After observing that the batch burning address control module writes a new address into the Flash burning address register, it sends a request to the DMA to move the batch burning data, and stores the batch burning data moved by the DMA into the Flash burning data register; the single burning control module is connected to the batch burning address control module, the batch burning data control module and the Flash single burning module. After observing that the batch burning data control module writes new data into the Flash burning data register, it controls the Flash single burning module to start the single burning, performs the single burning monitoring in real time, and promptly closes the current single burning related logic when the single burning is completed or abnormal, and reports the burning result to the batch burning address control module.
[0028] The task of each single-write of the Flash single-write module is to write the batch-write data carried by the DMA stored in the Flash-write data register according to the batch-write address carried by the DMA stored in the Flash-write address register. Therefore, the batch-write address control module, the batch-write data control module, the single-write control module, the Flash single-write module, and the DMA cooperate with each other to realize Flash batch-write.
[0029] Furthermore, in one embodiment, the Flash batch burning control module is also used to connect to a memory, the memory stores the batch burning addresses and batch burning data to be burned, and the DMA is also connected to the memory to transfer the batch burning addresses and batch burning data to be burned from the memory to the Flash batch burning control module. That is, the batch burning addresses and batch burning data to be transferred by the DMA are pre-stored in the memory. After the batch burning address control module sends a request to the DMA, the DMA accesses the memory and transfers the addresses; after the batch burning data control module sends a request to the DMA, the DMA accesses the memory and transfers the data.
[0030] Furthermore, in one embodiment, the Flash batch burning circuit further includes a microcontroller, the microcontroller is connected to the batch burning address controller, sends the batch burning instruction to the batch burning address controller, and receives the batch burning address controller to report the burning abnormality. Of course, the batch burning address controller also reports to the microcontroller when the burning is completed normally. The emphasis here is on reporting the burning abnormality because the microcontroller also needs to perform different corresponding processing according to the specific different situations of the abnormality.
[0031] The second embodiment of the present invention provides a Flash batch burning method applicable to a microcontroller, the Flash batch burning method comprising: using the Flash batch burning circuit as described above, the Flash batch burning control module accepts the batch burning instruction, batches request DMA to transfer the information to be burned to the Flash batch burning control module, and batches control the Flash single burning module to complete the single burning. Here, the information to be burned by the DMA is the batch burning address and the batch burning data.
[0032] More specifically, in one embodiment, the Flash batch programming method includes:
[0033] Step 1: The batch burning address control module receives the batch burning instruction and starts the entire batch burning process;
[0034] Step 2: The batch burning address control module sends a request to DMA to transfer the batch burning address. After receiving the request, DMA transfers the batch burning address to the Flash burning address register in the batch burning address control module;
[0035] Step 3: After the batch burning data control module observes that the batch burning address control module has written a new address into the Flash burning address register, it sends a request to the DMA to move the batch burning data. After receiving the request, the DMA moves the batch burning data to the Flash burning data register in the batch burning data control module;
[0036] Step 4: After the single-shot burn control module observes that the batch burn data control module has written new data into the Flash burn data register, it starts the Flash single-shot burn module for single-shot burn. During the single-shot burn module, the Flash burn monitoring result is checked in real time. When the burn is completed, the single-shot burn action is closed, and the batch burn address control module is informed to start the next single-shot burn cycle.
[0037] Step 5: After the batch burning address control module detects that the single burning control module has completed a single burning, it automatically starts the next single burning according to the preset number of cycles, and repeats the process from step 2 to step 4 in sequence to complete a new cycle until the overall cycle scale reaches the preset upper limit, automatically ending this batch burning action.
[0038] When executing, the target address and source address, data size, and number of loops are configured in advance through registers according to the overall data volume requirements, and then the above steps are followed to achieve relatively centralized, fast, and fully automatic Flash burning of large amounts of data.
[0039] Among them, the batch burning addresses and batch burning data to be burned are pre-stored in the memory; in the step 2, the DMA moves the pre-stored batch burning addresses from the memory to the Flash burning address register; in the step 3, the DMA moves the pre-stored batch burning data from the memory to the Flash burning data register.
[0040] In addition, the microcontroller is not directly connected to the Flash single-time burning module, but the microcontroller is connected to the batch-writing address controller, sends the batch-writing instruction to the batch-writing address controller, and receives the batch-writing address controller to report the burning abnormality; in the step one, the microcontroller triggers the batch-writing instruction by setting the batch-writing start register; in the step four, if the single-time burning control module checks the Flash burning abnormality, it reports to the batch-writing address control module in real time, and chooses whether to continue the next single-time burning cycle or to jump out of the batch-writing cycle; in the step five, if step four chooses to jump out of the batch-writing cycle, the batch-writing address control module sets the corresponding flag register and reports to the microcontroller for further processing.
[0041] Moreover, in the step 2, the batch writing address control module automatically completes the transmission handshake with the DMA; in the step 3, the batch writing data control module automatically completes the transmission handshake with the DMA.
[0042] Compared with the prior art, the technical solution of the present invention has the following beneficial effects:
[0043] The Flash batch burning circuit and method suitable for a microcontroller described in the present invention can realize Flash batch burning through the cooperation of a Flash batch burning control module, DMA and a Flash single burning module, thereby realizing relatively concentrated and fast Flash burning of a large amount of data, reducing the occupancy of the microcontroller, and reducing the possibility of power failure and restart being accidentally terminated during the Flash burning process, thereby reducing the possibility of data loss and error.
[0044] The above is only a specific implementation of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims. In addition, the specification uses specific examples to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. The content of this specification should not be understood as a limitation on the present invention.
Claims
1. A Flash batch programming circuit suitable for a microcontroller, characterized in that: The Flash batch burning circuit comprises a connected Flash batch burning control module and a Flash single burning module, wherein the Flash batch burning control module is further used to be connected to the DMA, receive batch burning instructions, request the DMA to transfer the information to be burned to the Flash batch burning control module in batches, and control the Flash single burning module in batches to complete single burning; The Flash batch burning control module includes a batch burning address control module, a batch burning data control module, and a single burning control module. The batch burning address control module has a Flash burning address register, and the batch burning data control module has a Flash burning data register; the batch burning address control module is connected to the batch burning data control module, the single burning control module, and the DMA, receives the batch burning instruction, starts the batch burning process, sends a request for transporting batch burning addresses to the DMA in batches, stores the batch burning addresses transported by the DMA in the Flash burning address register, and observes that the single burning control module completes the single burning, starts the next batch of single burning, and ends the entire batch burning process after completing the batch burning; the batch burning data control module is connected to the The batch burning address control module, the single burning control module, and the DMA are all connected. After observing that the batch burning address control module writes a new address into the Flash burning address register, a request for moving batch burning data is sent to the DMA, and the batch burning data moved by the DMA is stored in the Flash burning data register; the single burning control module is connected to the batch burning address control module, the batch burning data control module, and the Flash single burning module. After observing that the batch burning data control module writes new data into the Flash burning data register, the Flash single burning module is controlled to start single burning, and single burning monitoring is performed in real time. When single burning is completed or abnormal, the current single burning related logic is promptly closed, and the burning result is reported to the batch burning address control module.
2. The Flash batch programming circuit according to claim 1, characterized in that: The Flash batch burning control module is also used to be connected to a memory, and the memory stores the batch burning addresses and batch burning data to be burned. The DMA is also connected to the memory to transfer the batch burning addresses and batch burning data to be burned from the memory to the Flash batch burning control module.
3. The Flash batch programming circuit according to claim 1, characterized in that: The Flash batch burning circuit also includes a microcontroller, which is connected to the batch burning address controller, sends the batch burning instruction to the batch burning address controller, and receives a report of burning abnormality from the batch burning address controller.
4. A Flash batch programming method suitable for a microcontroller, characterized in that: The Flash batch burning method adopts the Flash batch burning circuit as claimed in claim 1, the Flash batch burning control module receives the batch burning instruction, requests DMA to transfer the information to be burned to the Flash batch burning control module in batches, and controls the Flash single burning module in batches to complete the single burning; The Flash batch programming method comprises: Step 1: The batch burning address control module receives the batch burning instruction and starts the entire batch burning process; Step 2: The batch burning address control module sends a request to DMA to transfer the batch burning address. After receiving the request, DMA transfers the batch burning address to the Flash burning address register in the batch burning address control module; Step 3: After the batch burning data control module observes that the batch burning address control module has written a new address into the Flash burning address register, it sends a request to the DMA to move the batch burning data. After receiving the request, the DMA moves the batch burning data to the Flash burning data register in the batch burning data control module; Step 4: After the single-shot burn control module observes that the batch burn data control module has written new data into the Flash burn data register, it starts the Flash single-shot burn module for single-shot burn. During the single-shot burn module, the Flash burn monitoring result is checked in real time. When the burn is completed, the single-shot burn action is closed, and the batch burn address control module is informed to start the next single-shot burn cycle. Step 5: After the batch burning address control module detects that the single burning control module has completed a single burning, it automatically starts the next single burning according to the preset number of cycles, and repeats the process from step 2 to step 4 in sequence to complete a new cycle until the overall cycle scale reaches the preset upper limit, automatically ending this batch burning action.
5. The Flash batch programming method according to claim 4, characterized in that: The Flash batch burning control module is also used to be connected to a memory, which pre-stores batch burning addresses and batch burning data to be burned, and the DMA is also connected to the memory; in the step 2, the DMA moves the pre-stored batch burning addresses from the memory to the Flash burning address register; in the step 3, the DMA moves the pre-stored batch burning data from the memory to the Flash burning data register.
6. The Flash batch programming method according to claim 5, characterized in that: The Flash batch burning circuit also includes a microcontroller, which is connected to the batch burning address controller, sends the batch burning instruction to the batch burning address controller, and receives the batch burning address controller to report the burning abnormality; in the step one, the microcontroller triggers the batch burning instruction by setting the batch burning start register; in the step four, if the single burning control module checks the Flash burning abnormality, it reports to the batch burning address control module in real time, and chooses whether to continue the next single burning cycle or jump out of the batch burning cycle; in the step five, if step four chooses to jump out of the batch burning cycle, the batch burning address control module sets the corresponding flag register and reports to the microcontroller for further processing.
7. The Flash batch programming method according to claim 4, characterized in that: In the step 2, the batch writing address control module automatically completes a transmission handshake with the DMA; in the step 3, the batch writing data control module automatically completes a transmission handshake with the DMA.
Citation Information
Patent Citations
DSP user program upgrading and Flash downloading method
CN105867977A
Programming method of FPGA accelerator card onboard flash and related components
CN110955435A
