DE102014104588A1 - microcontrollers - Google Patents
microcontrollers Download PDFInfo
- Publication number
- DE102014104588A1 DE102014104588A1 DE102014104588.2A DE102014104588A DE102014104588A1 DE 102014104588 A1 DE102014104588 A1 DE 102014104588A1 DE 102014104588 A DE102014104588 A DE 102014104588A DE 102014104588 A1 DE102014104588 A1 DE 102014104588A1
- Authority
- DE
- Germany
- Prior art keywords
- memory
- memory area
- microcontroller
- areas
- 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.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/4401—Bootstrapping
- G06F9/4406—Loading of operating system
Abstract
Die Erfindung betrifft einen Mikrocontroller, mit einem Speicher, der mehrere Speicherbereiche aufweist, und der durch den Mikrocontroller bereichsweise löschbar ist, wobei in einem der Speicherbereiche ein Startprogramm gespeichert ist, und wobei der Mikrocontroller dazu ausgebildet ist, nach einem Neustart zuerst einen ersten Speicherbereich aufzurufen, um einen Sprungbefehl zu dem Startprogramm auszuführen, und anschließend einen zweiten Speicherbereich, falls in dem ersten Speicherbereich kein Sprungbefehl enthalten ist, wobei in dem zweiten Speicherbereich ein Sprungbefehl zu dem Startprogramm gespeichert ist.The invention relates to a microcontroller, having a memory which has a plurality of memory areas, and which can be erased by the microcontroller, wherein a start program is stored in one of the memory areas, and wherein the microcontroller is designed to first call a first memory area after a restart to execute a branch instruction to the launcher, and then a second memory area if no branch instruction is contained in the first memory area, wherein in the second memory area a branch instruction to the launcher is stored.
Description
Die Erfindung betrifft einen Mikrocontroller, ein Verfahren zum Einrichten eines Speichers eines Mikrocontrollers, sowie ein Verfahren zum Betrieb eines Mikrocontrollers. The invention relates to a microcontroller, a method for setting up a memory of a microcontroller, and a method for operating a microcontroller.
Mikrocontroller werden in vielen verschiedenen Anwendungsbereichen eingesetzt, beispielsweise als Teil der Steuerungselektronik in Automobilen. Derartige Mikrocontroller verfügen über einen Prozessor und einen Programmspeicher. Ein bekanntes Beispiel eines solchen Mikrocontrollers ist der Mikrocontroller des Typs 8051 von der Firma Intel. Microcontrollers are used in many different applications, for example as part of the control electronics in automobiles. Such microcontrollers have a processor and a program memory. A well-known example of such a microcontroller is the type 8051 microcontroller from Intel.
Bei dem Speicher eines solchen Mikrocontrollers handelt es sich vorzugsweise um einen sogenannten Flashspeicher, der mehrere Bereiche umfasst, jeweils bestehend aus einem oder mehreren Blöcken. In einem der Speicherbereiche ist ein Hauptprogramm (Firmware) gespeichert, während ein anderer Speicherbereich durch ein Startprogramm (Bootloader) belegt ist. Insbesondere kann es sich um einen NAND-Flashspeicher (NAND, von englisch: „not and“ – „nicht und“) handeln. The memory of such a microcontroller is preferably a so-called flash memory comprising a plurality of regions, each consisting of one or more blocks. One of the memory areas stores one main program (firmware), while another memory area is occupied by a bootloader. In particular, it can be a NAND flash memory (NAND, from English: "not and").
Ein solcher Mikrocontroller verfügt außerdem über einen Programmzähler, mit dessen Hilfe die einzelnen Bereiche des Speichers sequentiell aufgerufen und darin gespeicherte Befehle abgearbeitet werden. Bei einem Neustart wird zuerst der erste Speicherblock aufgerufen. Zu Beginn dieses ersten Speicherblocks ist ein Sprungbefehl gespeichert, der den Mikrocontroller dazu veranlasst, zu dem Startprogramm zu springen. Insbesondere kann der Sprungbefehl zu dem Startprogramm zumindest teilweise in der ersten Speicherzelle des ersten Speicherbereichs abgelegt sein. Der erst Speicherblock umfasst außerdem Daten, z.B. Interrupt-Vektoren, die dem Hauptprogramm zugeordnet sind bzw. auf die das Hauptprogramm während der Ausführung zugreift. Dabei ist es oft der Fall, dass die Position der Interrupt-Vektoren nicht veränderbar oder verschiebbar ist. Such a microcontroller also has a program counter, with the aid of which the individual areas of the memory are called sequentially and executed commands stored therein. When restarting, the first memory block is called first. At the beginning of this first memory block, a jump instruction is stored which causes the microcontroller to jump to the start program. In particular, the jump command to the start program may be at least partially stored in the first memory cell of the first memory area. The first memory block also includes data, e.g. Interrupt vectors assigned to the main program or accessed by the main program during execution. It is often the case that the position of the interrupt vectors is not changeable or displaceable.
Bei verschiedenen Anwendungen, insbesondere im Bereich der Steuerungselektronik von Automobilen, kann es wünschenswert sein, von Zeit zu Zeit ein neues Hauptprogramm einzuspielen. Dazu wird der Mikrocontroller mittels einer vorbestimmten Signal- oder Befehlssequenz (z.B. „Power on reset“) dazu veranlasst, über eine Kommunikationsschnittstelle, beispielsweise eine serielle Kommunikationsschnittstelle, mit einem externen Computer zu kommunizieren und ein neues Hauptprogramm zu empfangen und zu speichern. Dieser Vorgang wird als Flashvorgang bezeichnet. Der Flashvorgang erfolgt typischerweise über einen vom Hauptprogramm unabhängigen Programmteil (Bootloader), beispielsweise ein Startprogramm. Beim Flashvorgang muss das Startprogramm zunächst jene Speicherbereiche löschen, in denen das Hauptprogramm gespeichert ist. Zusätzlich müssen diejenigen Speicherbereiche gelöscht werden, in denen Daten gespeichert sind, die dem Hauptprogramm zugeordnet sind, insbesondere also auch der erste Speicherblock. Anschließend können das neue Hauptprogramm und die neuen zugehörigen Daten übertragen und gespeichert werden. Da der üblicherweise vorhandene Zugang zum Flashspeicher, beispielsweise eine JTAG-Schnittstelle oder einer anderen Debug-Schnittstelle, oft von der Applikationssoftware gesperrt wird, stellt in diesen Fällen der Bootloader die einzige Möglichkeit dar den Flashspeicher neu zu beschreiben. In various applications, in particular in the field of control electronics of automobiles, it may be desirable to install a new main program from time to time. To do so, the microcontroller is caused to communicate with an external computer via a communication interface, such as a serial communication interface, by means of a predetermined signal or command sequence (e.g., "power on reset") and to receive and store a new main program. This process is called a flash process. The flash process typically takes place via a program part (boot loader) independent of the main program, for example a start program. During the flash process, the launcher must first clear those memory areas where the main program is stored. In addition, those memory areas must be deleted in which data is stored, which are assigned to the main program, in particular also the first memory block. Subsequently, the new main program and the new associated data can be transmitted and stored. Since the usually existing access to the flash memory, for example a JTAG interface or another debug interface, is often blocked by the application software, in these cases the bootloader is the only way to rewrite the flash memory.
Das Löschen des Speichers erfolgt bereichs- bzw. blockweise, was im Falle eines Flashspeichers durch die Architektur des Speichers festgelegt ist. Beim Löschen des ersten Speicherblocks wird also auch der dort gespeicherte Sprungbefehl zu dem Startprogramm gelöscht. Tritt während des Löschvorganges oder kurz danach eine Störung auf, z.B. ein Abfall der Versorgungsspannung des Mikrocontrollers, so kann es dazu kommen, dass der Flashvorgang nicht abgeschlossen wird. In diesem Fall kann der erste Speicherblock gelöscht aber nicht wieder neu beschrieben worden sein. Der kritische Zeitraum nach dem Löschvorgang liegt typischerweise im Bereich zwischen 1ms und 20 ms. Wird der Mikrocontroller anschließend neu gestartet, so wird bei Abruf des ersten Speicherblocks kein Sprungbefehl zum Startprogramm vorgefunden und der Mikrocontroller kann somit keine Applikationssoftware starten. Der Mikrocontroller wird hierdurch unbrauchbar. Dies ist insbesondere dann der Fall, wenn der Zugang zum Flashspeicher, beispielsweise per JTAG-Schnittstelle, nicht möglich ist oder beispielsweise durch den Einbau der Elektronik nicht zugänglich ist. The erasure of the memory takes place in groups or in blocks, which in the case of a flash memory is determined by the architecture of the memory. When deleting the first memory block so also the jump command stored there is deleted to the launcher. If a fault occurs during the erasing operation or shortly thereafter, e.g. a drop in the supply voltage of the microcontroller, it may happen that the flash process is not completed. In this case, the first memory block may have been deleted but not rewritten again. The critical time period after the erase operation is typically in the range between 1 ms and 20 ms. If the microcontroller is subsequently restarted, no jump command to the start program is found when the first memory block is called up, and the microcontroller can thus not start any application software. The microcontroller becomes unusable as a result. This is the case in particular when access to the flash memory, for example via the JTAG interface, is not possible or is not accessible, for example, by installing the electronics.
Aufgabe der vorliegenden Erfindung ist es, dieses Problem zu lösen oder abzumindern. The object of the present invention is to solve or mitigate this problem.
Diese Aufgabe wird durch die in den unabhängigen Ansprüchen angegebene Erfindung gelöst. Vorteilhafte Ausgestaltungen sind in den Unteransprüchen angegeben. This object is achieved by the invention specified in the independent claims. Advantageous embodiments are specified in the subclaims.
Erfindungsgemäß ist ein Mikrocontroller geschaffen, mit einem Speicher, der mehrere Speicherbereiche aufweist, und der durch den Mikrocontroller bereichsweise löschbar ist, wobei in einem der Speicherbereiche ein Startprogramm gespeichert ist, und wobei der Mikrocontroller dazu ausgebildet ist, nach einem Neustart zuerst einen ersten Speicherbereich aufzurufen, um einen Sprungbefehl zu dem Startprogramm auszuführen, und anschließend einen zweiten Speicherbereich, falls in dem ersten Speicherbereich kein Sprungbefehl enthalten ist, wobei in dem zweiten Speicherbereich ein Sprungbefehl zu dem Startprogramm gespeichert ist. According to the invention, a microcontroller is provided with a memory which has a plurality of memory areas and which can be erased by the microcontroller, wherein a start program is stored in one of the memory areas, and wherein the microcontroller is designed to first call a first memory area after a restart to execute a branch instruction to the launcher, and then a second memory area if no branch instruction is contained in the first memory area, wherein in the second memory area a branch instruction to the launcher is stored.
Ein Speicherbereich kann beispielsweise durch einen Speicherblock, beispielsweise eines Flashspeichers, gegeben sein, wobei ein Speicherblock mehrere Speicherseiten aufweisen kann. Eine Speicherseite wiederrum kann mehrere Speicherzellen aufweisen A memory area can be given, for example, by a memory block, for example a flash memory, wherein a memory block can have several memory pages. A memory page in turn can have a plurality of memory cells
Vorzugsweise steht das Startprogramm zumindest teilweise im letzten Speicherbeich des Speichers. Preferably, the launcher is at least partially in the last Speicherbeich the memory.
Die vorliegende Erfindung beruht auf der Erkenntnis, dass durch eine Speicherung des Sprungbefehls in dem zweiten Speicherbereich verhindert werden kann, dass der Mikrocontroller im Falle eines unvollständigen Flashvorgangs unbrauchbar wird. Insbesondere wird der Mikrocontroller in dem oben beschriebenen Störfall dazu veranlasst, nach erfolgtem Aufruf des ersten Speicherbereiches den zweiten Speicherbereich aufzurufen und dabei den (bereits im ersten Speicherbereich erwarteten) Sprungbefehl zu erhalten. Anschließend kann der Flashvorgang, bzw. Programmiervorgang, wiederholt werden. In manchen Ausführungen wird eine gelöschte Speicherzelle vom Mikrocontroller als eine unkritische Operation, beispielsweise eine NOP(No Operation)-Instruktion, interpretiert. In diesem Fall wird der Mikrocontroller den ersten Speicherbereich abarbeiten und dabei keine Aktionen ausführen, bis er zur nächsten gültigen Instruktion, dem Sprungbefehl im zweiten Speicherbereich, kommt. Anschließend kann der Programmiervorgang wiederholt werden. The present invention is based on the recognition that storage of the jump instruction in the second memory area can prevent the microcontroller from becoming unusable in the event of an incomplete flash operation. In particular, in the fault described above, the microcontroller is caused to call the second memory area after the first memory area has been called up, thereby maintaining the jump command (already expected in the first memory area). Subsequently, the flash process or programming process can be repeated. In some embodiments, an erased memory cell is interpreted by the microcontroller as an uncritical operation, such as a NOP (No Operation) instruction. In this case, the microcontroller will process the first memory area and will not perform any actions until it comes to the next valid instruction, the jump instruction in the second memory area. Subsequently, the programming process can be repeated.
Insbesondere kann der Sprungbefehl zu der Adresse des Startprogramms sowohl in dem ersten als auch dem zweiten Speicherbereich des Mikrocontrollers gespeichert sein. Dies kann der Lieferzustand des Mikrocontrollers sein. Somit bildet der Sprungbefehl im zweiten Speicherbereich einen Ersatzsprungbefehl, der zur Verfügung steht, wenn der erste Speicherbereich gelöscht aber nicht neu beschrieben wird. In particular, the jump command to the address of the start program may be stored in both the first and the second memory area of the microcontroller. This may be the delivery state of the microcontroller. Thus, the jump instruction in the second memory area forms a substitute jump instruction that is available when the first memory area is cleared but not rewritten.
Vorzugsweise schließt sich der zweite Speicherbereich direkt an den ersten Speicherbereich an. Somit steht der Ersatzsprungbefehl im Störfall unmittelbar nach Aufruf des ersten Speicherbereichs zur Verfügung, und es wird verhindert, dass zuerst andere gespeicherte und nicht zur Ausführung vorgesehene Befehle ausgeführt werden. Preferably, the second memory area connects directly to the first memory area. Thus, in the event of a fault, the substitute jump command is available immediately after the first memory area has been called, and it is prevented that other stored and non-executable instructions are executed first.
In einer vorteilhaften Ausgestaltung ist ein weiterer Sprungbefehl zu dem Startprogramm in mindestens einem weiteren Speicherbereich abgespeichert, der sich an den zweiten Speicherbereich anschließt. Dadurch wird der Mikrocontroller auch dann zu einem Sprung zum Startprogramm veranlasst, wenn sowohl im ersten als auch im zweiten Speicherbereich kein solcher Sprungbefehl vorgefunden wird. Dies erhöht die Ausfallsicherheit zusätzlich. In an advantageous embodiment, another jump command to the start program is stored in at least one further memory area, which adjoins the second memory area. As a result, the microcontroller is also caused to jump to the start program, if no such jump command is found in both the first and in the second memory area. This additionally increases the reliability.
In einer alternativen Ausgestaltung der Erfindung ist anstelle eines Sprungbefehls zum Startprogramm das Startprogramm selbst im zweiten Speicherbereich gespeichert. Auch in dieser Variante bleibt das Startprogramm zugänglich, auch wenn der erste Speicher zwar gelöscht aber noch nicht neu beschrieben wurde. In an alternative embodiment of the invention, instead of a jump command to the start program, the start program itself is stored in the second memory area. Even in this variant, the launcher remains accessible, even if the first memory has been deleted but not yet rewritten.
In einer Ausgestaltung des Mikrocontrollers sind die Speicherbereiche jeweils durch einen oder mehrere Speicherblöcke gebildet, wobei der Speicher blockweise löschbar ist, und wobei der Mikrocontroller einen Programmzähler aufweist zum sequentiellen Aufrufen der Speicherbereiche, insbesondere beginnend mit dem ersten Speicherbereich nach einem Neustart des Mikrocontrollers. Beispielsweise kann es sich bei dem Mikrocontroller um einen Mikrocontroller des Typs 8051 handeln. Somit können die Vorteile der vorliegenden Erfindung auch in vorhandenen oder herkömmlich betriebenen Mikrocontrollern zum Tragen kommen. Ein Speicherblock (Englisch: block) kann beispielsweise 8 bis 4096 Kilobyte (KB) groß sein und beispielsweise 16 bis 512 Speicherseiten (Englisch: page) beinhalten, wobei jede Speicherseite im Bereich zwischen 256 und 8192 Bytes für die Datenspeicherung und optional auch 8 bis 256 Bytes zur Fehlerkorrektur, beispielsweise mittels einer Prüfsumme, umfassen kann. Derartig dimensionierte Speicheraufteilungen sind insbesondere bei Flashspeichern üblich. Bei Flashspeichern muss der Löschvorgang immer blockweise erfolgen. In one embodiment of the microcontroller, the memory areas are each formed by one or more memory blocks, wherein the memory is erasable block by block, and wherein the microcontroller has a program counter for sequentially calling the memory areas, in particular starting with the first memory area after a restart of the microcontroller. For example, the microcontroller may be an 8051 microcontroller. Thus, the advantages of the present invention may also be realized in existing or conventionally operated microcontrollers. For example, a block of memory may be 8 to 4096 kilobytes (KB) in size and may include, for example, 16 to 512 page pages, with each page ranging from 256 to 8,192 bytes for data storage and optionally 8 to 256 Bytes for error correction, for example by means of a checksum may include. Such dimensioned memory partitions are common especially with flash memory. For flash memories, the deletion process must always be block by block.
Erfindungsgemäß ist außerdem ein Verfahren zum Einrichten eines Speichers eines Mikrocontrollers geschaffen, wobei der Speicher mehrere Speicherbereiche aufweist, und der Mikrocontroller dazu eingerichtet ist, bei einem Neustart die Speicherbereiche beginnend mit einem ersten Speicherbereich sequentiell aufzurufen und darin gespeicherte Befehle auszuführen, das Verfahren umfassend: Abspeichern eines Sprungbefehls zu einem Startprogramm in einem zweiten Speicherbereich oder abspeichern eines Startprogramms in dem zweiten Speicherbereich, wobei der zweite Speicherbereich bei einem Neustart durch den Mikrocontroller anschließend, insbesondere unmittelbar anschließend an den ersten Speicherbereich, aufgerufen wird. The invention also provides a method for setting up a memory of a microcontroller, wherein the memory has a plurality of memory areas, and the microcontroller is configured to sequentially call the memory areas beginning with a first memory area and execute instructions stored therein, the method comprising: storing a jump command to a start program in a second memory area or store a start program in the second memory area, wherein the second memory area is subsequently called upon a restart by the microcontroller, in particular immediately after the first memory area.
Auch gemäß diesem Aspekt der vorliegenden Erfindung wird in dem zweiten Speicherbereich ein Ersatzsprungbefehl oder das Startprogramms selbst hinterlegt, so dass entweder das Startprogramm oder der Ersatzsprungbefehl im Störfall zur Verfügung stehen. Zur weiteren Verbesserung der Betriebssicherheit kann ein zusätzlicher Ersatzsprungbefehl in mindestens einem weiteren Speicherbereich gespeichert werden, der durch den Mikrocontroller anschließend an den zweiten Speicherbereich aufgerufen wird. Also according to this aspect of the present invention, a spare jump instruction or the start program itself is stored in the second memory area, so that either the start program or the spare jump instruction are available in the event of a fault. To further improve operational safety, an additional replacement jump command can be stored in at least one further memory area, which is then called by the microcontroller to the second memory area.
Weiterhin ist erfindungsgemäß ein Verfahren zum Betrieb eines Mikrocontrollers geschaffen, wobei der Mikrocontroller einen Speicher aufweist, umfassend die folgenden Schritte: Aufrufen eines ersten Speicherbereichs, in dem ein Sprungbefehl zu einem Startprogramm erwartet wird; Aufrufen eines zweiten Speicherbereichs, falls der Mikrocontroller in dem ersten Speicherbereich keinen Sprungbefehl erkennt; und Ausführen eines in dem zweiten Speicherbereich gespeicherten Sprungbefehls zu dem Startprogramm. Furthermore, the invention provides a method for operating a microcontroller, wherein the microcontroller has a memory, comprising the following steps: calling a first memory area in which a jump command to a launcher is expected; Calling a second memory area if the microcontroller in the first memory area does not recognize a jump instruction; and executing a branch instruction stored in the second memory area to the launcher.
Erfindungsgemäß kann es auch vorgesehen sein, dass im zweiten Speicherbereich das Startprogramm selbst gespeichert ist, so dass das Verfahren zum Betreiben des Mikrocontrollers anstelle des Ausführens eines im zweiten Speicherbereich gespeicherten Sprungbefehls ein Ausführen des dort gespeicherten Startprogramms umfasst. According to the invention, it can also be provided that the start program itself is stored in the second memory area, so that the method for operating the microcontroller instead of executing a jump command stored in the second memory area comprises executing the start program stored there.
In manchen Ausgestaltungen der Erfindung umfasst das erfindungsgemäße Verfahren ein bereichsweises Löschen des Speichers, so dass die Speicherbereiche neu beschrieben werden können. In manchen Ausführungen wird dazu mit dem Löschen des ersten Speicherbereiches begonnen. Nach einem erfolgreichen Löschvorgang wird dann der Sprungbefehl zu dem Startprogramm geschrieben. In einem weiteren Schritt werden sequentiell diejenigen, weiteren Speicherbereiche des Speichers gelöscht und neu beschrieben, in denen nicht das Startprogramm gespeichert ist. Insbesondere wird der zweite Speicherbereich und somit der dort abgelegte Sprungbefehl oder das dort abgelegte Startprogramm erst nach dem erfolgreichen Lösch- und Schreibvorgang des ersten Speicherbereichs gelöscht und neu beschrieben. Somit steht dem Verfahren zum Betrieb des Mikrocontrollers zu fast allen Zeitpunkten eine gültige und zugängliche Sprungadresse zum Startprogramm zur Verfügung, so dass der Speicher vor Zerstörung geschützt ist und ein Ausführen eines im Speicher abgelegten Programmes und / oder ein erneutes Schreiben eines ausführbaren Programmes möglich ist. Einzig eine Fehlfunktion während des Löschvorgangs des ersten Speicherbereichs, bei der dieser Speicherbereich teilweise und nicht vollständig gelöscht wurde, kann einen weiteren Betrieb des Speichers verhindern. Beispielsweise können nicht gelöschte Datenfragmente als Sprung in eine unbestimmte und zufällige Adresse des Speichers interpretiert werden, so dass weder das Hauptprogramm noch das Startprogramm zugänglich bleibt. Da dieser Löschvorgang jedoch üblicherweise sehr schnell ist, insbesondere wesentlich schneller als der Schreibvorgang, ist ein Fehler während dieser Zeitspanne sehr unwahrscheinlich, so dass das erfindungsgemäße Verfahren einen guten Schutz vor einem Versagen des Speichers bietet. In some embodiments of the invention, the method according to the invention comprises an area-by-area deletion of the memory so that the memory areas can be rewritten. In some embodiments, this is started with the deletion of the first memory area. After a successful deletion, the jump command is written to the launcher. In a further step, those other memory areas of the memory are sequentially deleted and rewritten in which the launcher program is not stored. In particular, the second memory area and thus the jump instruction stored there or the start program stored there are deleted and rewritten only after the successful erase and write operation of the first memory area. Thus, the method for operating the microcontroller at almost all times a valid and accessible jump address to the launcher is available, so that the memory is protected from destruction and running a program stored in the memory and / or rewriting an executable program is possible. Only a malfunction during the deletion of the first memory area, in which this memory area was partially and not completely deleted, can prevent further operation of the memory. For example, undeleted data fragments can be interpreted as a jump to an indefinite and random address of the memory so that neither the main program nor the launcher remain accessible. However, since this erase operation is usually very fast, in particular much faster than the writing process, an error during this period is very unlikely, so that the inventive method provides good protection against memory failure.
Im Sinne der Erfindung muss dabei nicht die Konsistenz des Hauptprogrammes sichergestellt werden. Jedoch kann mit der beschriebenen Erfindung jederzeit sichergestellt werden, dass durch ein Wiederholen des Programmiervorganges der Mikrocontroller wieder herstellbar ist, auch wenn der vorangegangene Löschvorgang und/oder der Programmiervorgang fehlgeschlagen sind. For the purposes of the invention, it is not necessary to ensure the consistency of the main program. However, it can be ensured at any time with the described invention that the microcontroller can be restored by repeating the programming operation, even if the preceding deletion process and / or the programming operation have failed.
Beim erfindungsgemäßen Betrieb des Mikrocontrollers kann somit verhindert werden, dass der Mikrocontroller im Störfall unbrauchbar wird. Der nach einem Neustart vorgesehene Sprung zum Startprogramm erfolgt in Reaktion auf den Aufruf des ersten oder – im Störfall – zweiten Speicherbereichs. In einer Ausgestaltung wird zusätzlich mindestens ein weiterer einen Sprungbefehl zum Startprogramm enthaltender Speicherbereich aufgerufen, falls der Aufruf sowohl des ersten als auch des zweiten Speicherbereichs nicht zur Ausführung eines solchen Sprungbefehls führt. In the operation of the microcontroller according to the invention can thus be prevented that the microcontroller is unusable in case of failure. The jump to the start program provided after a restart occurs in response to the call of the first or, in the event of a fault, second memory area. In one embodiment, at least one further memory area containing a jump instruction to the launcher program is additionally called if the call of both the first and the second memory area does not lead to the execution of such a jump instruction.
Desweiteren wird ein weiteres, erfindungsgemäßes Verfahren bereitgestellt, in dem es vorgesehen ist, dass nicht der erste Speicherbereich, sondern der letzte Speicherbereich für Programmdaten, der noch vor dem das Startprogramm umfassenden Speicherbereich liegt, zuerst gelöscht wird. Dies kann insbesondere ein direkt an den für das Startprogramm vorgehaltenen Speicherbereich angrenzender Speicherbereich sein. Furthermore, a further method according to the invention is provided in which it is provided that not the first memory area, but the last memory area for program data, which is still before the memory area comprising the starting program, is first deleted. In particular, this can be a storage area adjacent to the memory area reserved for the launcher.
In einer ersten Abwandlung dieses erfindungsgemäßen Verfahrens wird dann der zuerst gelöschte Speicherbereich nach dem erfolgreichen Löschvorgang neu beschrieben, woraufhin der nächste, davor liegende Speicherbeich gelöscht und neu beschrieben wird. Es wird also in einem nächsten Schritt immer der Speicherbereich gelöscht und neu beschrieben, der vor dem im zuvor ausgeführten Schritt gelöschten wurde. Dies wird solange fortgesetzt, bis auch der erste Speicherbereich gelöscht und neu beschrieben wurde, insbesondere bis auch die dort abgespeicherte Sprungadresse zum Startprogramm geschrieben wurde. In a first modification of this method according to the invention, the memory area deleted first is then rewritten after the successful deletion process, whereupon the next memory area in front of it is deleted and rewritten. Thus, in a next step, the memory area which was deleted before the step executed previously is always deleted and rewritten. This is continued until the first memory area has been deleted and rewritten, in particular until the jump address stored there has also been written to the start program.
Es kann dabei vorgesehen sein, dass ein nächster Speicherbereich erst dann gelöscht wird, wenn eine Bestätigung über einen erfolgreichen Schreibvorgang des zuvor gelöschten Speicherbereichs empfangen wurde. It can be provided that a next memory area is only deleted when an acknowledgment of a successful write operation of the previously deleted memory area has been received.
In einer zweiten Abwandlung dieses erfindungsgemäßen Verfahrens wird ebenfalls der letzte Speicherbereich für Programmdaten, der noch vor dem das Startprogramm umfassenden Speicherbereich liegt, zuerst gelöscht. Jedoch werden sukzessive, von hinten nach vorne fortschreitend, auch alle davor liegenden Speicherbereiche in einem Schritt
Das erfindungsgemäße Verfahren, bei dem die Speicherbereiche von hinten nach vorne gelöscht werden, hat den Vorteil, dass beim erfindungsgemäßen Betrieb des Mikrocontrollers alle Löschvorgänge gleich behandelt werden können. Dabei wird bis zum vollständigen Löschen aller Speicherbereiche immer die Sprungadresse zum Startprogramm oder das Starprogramm selbst zugänglich bleiben. Für den Fall, dass ein Fehler auftritt, nachdem auch diese Sprungadresse gelöscht wurde, wird das Startprogramm weiterhin zugänglich bleiben, da alle davor liegenden Speicherbereiche gelöscht wurden und daher leer sind. Der Controller wird dann die Speicherzellen nacheinander abfragen bis er beim Startprogramm angelangt. The inventive method in which the memory areas are deleted from back to front, has the advantage that in the operation of the microcontroller according to the invention all deletions can be treated the same. In doing so, the jump address to the start program or the star program itself will always remain accessible until the complete deletion of all memory areas. In the event that an error occurs after this jump address has also been deleted, the launcher will continue to be accessible, since all previous memory areas have been cleared and are therefore empty. The controller will then poll the memory cells one at a time until it arrives at the boot program.
In einer weiteren, alternativen Ausgestaltung der Erfindung kann es vorgesehen sein, dass der Speicher gespiegelt organisiert ist. Das bedeutet, dass die einzelnen Speicherzellen und damit auch die Speicherbereiche von hinten nach vorne durchlaufen werden. In solchen Ausgestaltungen der Erfindung liegt somit der erste Speicherbereich am Ende des Speichers und der letzte Speicherbereich am Anfang des Speichers In a further alternative embodiment of the invention, it can be provided that the memory is organized mirrored. This means that the individual memory cells and thus the memory areas are traversed from back to front. In such embodiments of the invention, the first memory area is thus at the end of the memory and the last memory area is at the beginning of the memory
Darüber hinaus ist ein Datenverarbeitungsprogramm geschaffen, umfassend Instruktionen, die bei Ausführung durch ein Datenverarbeitungssystem – z.B. einen Mikrocontroller und einen daran angeschlossenen PC – eine Durchführung der oben beschriebenen Verfahren veranlassen. In addition, there is provided a data processing program comprising instructions which, when executed by a data processing system - e.g. a microcontroller and a PC connected thereto - cause an implementation of the methods described above.
Weitere Merkmale und Vorteile der Erfindung ergeben sich aus der folgenden Beschreibung, bei der Bezug genommen wird auf die beigefügten Zeichnungen: Further features and advantages of the invention will become apparent from the following description in which reference is made to the accompanying drawings:
Nach einem Neustart des Mikrocontrollers werden die Speicherblöcke, beziehungsweise die einzelnen Speicherzellen des Flashspeichers, mit Hilfe eines Programmzählers sequentiell abgearbeitet. Durch den Neustart wird der Programmzähler zurückgesetzt, so dass die Verarbeitung bei dem Speicherbereich P1 beginnt. Dadurch wird zuerst der Sprungbefehl in der ersten Speicherzelle des ersten Speicherbereichs P1 aufgerufen und durchgeführt, womit der Mikrocontroller dazu veranlasst wird, zu der in dem Sprungbefehl enthaltenen Zieladresse, d.h. zum Beginn des Speicherblocks Px, zu springen. After a restart of the microcontroller, the memory blocks, or the individual memory cells of the flash memory, are processed sequentially with the aid of a program counter. By restarting, the program counter is reset, so that the processing starts at the memory area P1. This first calls and executes the branch instruction in the first memory cell of the first memory area P1, thereby causing the microcontroller to go to the destination address contained in the branch instruction, i. to the beginning of the memory block Px, jump.
In dem Speicherblock Px ist ein Startprogramm (Bootloader) gespeichert. Zu Beginn der Ausführung des Startprogrammes wartet dieses für einen vorbestimmten Zeitraum (z.B. 50ms) auf den Erhalt von externen Signalen oder Befehlen zum Einspielen eines neuen Hauptprogramms. Werden solche Befehle erhalten, so wird das neue Hauptprogramm in den Flashspeicher geladen, wie nachfolgend beschrieben. Werden innerhalb des vorbestimmen Zeitraumes keine derartigen Signale oder Befehle erhalten, so veranlasst das Startprogramm einen Sprung zum Hauptprogramm. The memory block Px stores a bootloader. At the beginning of the execution of the launcher, it waits for a predetermined period of time (eg 50ms) to receive external signals or instructions to load in a new main program. When such commands are received, the new main program is loaded into the flash memory as below described. If no such signals or commands are received within the predetermined period, the launcher will initiate a jump to the main program.
Der erste Speicherbereich P1 speichert die Einsprungadresse des Hauptprogramms und/oder Daten, auf die das Hauptprogramm zugreifen muss. Dies kann durch die Architektur des Mikrocontrollers vorgegeben sein. Beispielsweise besteht eine derartige Vorgabe bei einem Mikrocontroller des anfangs erwähnten Typs 8051. Einige Typen von Mikrocontrollern weiterer mit einer derartigen Vorgabe sind beispielsweise die PIC Mikrocontroller der Firma Microchip der Serien „24“ und „dsPIC“. The first memory area P1 stores the entry address of the main program and / or data to be accessed by the main program. This may be dictated by the architecture of the microcontroller. For example, such a specification exists in a microcontroller of the type 8051 mentioned at the outset. Some types of microcontrollers further with such a specification are, for example, the Microchip series PIC microcontrollers of the "24" and "dsPIC" series.
Zu Beginn des zweiten Speicherbereichs P2, also zu Beginn dessen erster Speicherzelle, ist ebenfalls ein Sprungbefehl zum Startprogramm, d.h. zu dem Speicherbereich Px, gespeichert. Dieser Sprungbefehl veranlasst den Mikrocontroller dazu, zu dem Startprogramm zu springen, falls bei der Verarbeitung des Inhalts des ersten Speichebereichs P1 kein solcher Sprungbefehl vorgefunden wird. Aufgrund der sequentiellen Bearbeitung des Speicherinhalts stößt der Mikrocontroller somit zwangsläufig im darauffolgenden zweiten Speicherbereich auf eine Sprungadresse zum Startprogramm, selbst wenn der erste Speicherbereich gelöscht wurde. At the beginning of the second memory area P2, that is to say at the beginning of its first memory cell, a jump command to the start program, i. to the memory area Px. This jump instruction causes the microcontroller to jump to the start program if no such jump instruction is encountered in the processing of the contents of the first memory area P1. Due to the sequential processing of the memory contents, the microcontroller thus inevitably encounters a jump address to the start program in the subsequent second memory area, even if the first memory area has been deleted.
Optional kann in dem dritten Speicherbereich P3 ein weiterer Sprungbefehl zu dem Startprogramm gespeichert sein. Optionally, in the third memory area P3, a further jump command to the launcher can be stored.
Des Weiteren kann in einer alternativen Ausführung auch das Startprogramm selbst im Speicherbereich P2 stehen, wodurch eine weitere Einsprungadresse im Bereich P2 überflüssig wird. Furthermore, in an alternative embodiment, the start program itself can also be located in the memory area P2, which makes a further entry address in the area P2 superfluous.
Zu einem Verlust des Sprungbefehls in der ersten Speicherseite kann es beim „Flashen“ des Flashspeichers, d.h. beim Einspielen eines neuen Hauptprogramms kommen. Dieser Vorgang ist in
Durch die Architektur des Speichers kann vorgegeben sein, dass der Speicher blockweise gelöscht werden muss, d.h. die einzelnen Speicherblöcke, beziehungsweise Speicherbeiche, müssen jeweils als Ganzes gelöscht werden. Beispielsweise besteht eine solche Vorgabe bei in Mikrocontrollern integrierten Flashspeichern. The architecture of the memory may dictate that the memory must be erased in blocks, i. the individual memory blocks or memory areas must be deleted as a whole. By way of example, such a specification exists with flash memories integrated in microcontrollers.
Das Beschreiben des Speichers kann im Sinne der Erfindung auf beliebige Art und Weise erfolgen, beispielsweise seitenweise, zeilenweise, Byte-weise oder Bit-weise. The writing of the memory can be carried out in the manner of the invention in any manner, for example, page by page, line by line, byte-wise or bit-wise.
Bezugnehmend auf
In den nächsten Schritten
In einer ersten Ausgestaltung des Verfahrens werden dazu im Schritt
In einer weiteren Ausgestaltung des Verfahrens sind die Schritte
Prinzipiell kann es in allen Abwandlungen des Verfahrens vorgesehen sein, dass nach jedem Lösch- oder Schreibvorgang eine Bestätigungsmeldung empfangen werden muss, bevor der nächste Schritt ausgeführt werden kann. In principle, it may be provided in all modifications of the method that after each erase or write a confirmation message must be received before the next step can be performed.
Nach Abschluss des Schrittes
Die in den Speicherbereichen P2 und optional in P3 abgespeicherten Sprungbefehle können insbesondere Teil des Hauptprogramms sein, wobei dieses vorzugsweise derart konzipiert ist, dass beim Neuschreiben des Hauptprogramm am Anfang des Speicherbereichs P2 und optional am Anfang des Speicherbereichs P3 ein Sprungbefehl zum Bootloader geschrieben wird. Alternativ kann es auch vorgesehen sein, dass der Speicherbereich P2 selbst das Startprogramm enthält. The branch instructions stored in the memory areas P2 and optionally in P3 can in particular be part of the main program, wherein this is preferably designed such that a jump instruction is written to the bootloader when rewriting the main program at the beginning of the memory area P2 and optionally at the beginning of the memory area P3. Alternatively, it can also be provided that the memory area P2 itself contains the start program.
In
In einem zweiten, optionalen Schritt
Anschließend veranlasst der PC in einem Schritt
Im Vergleich zu der in
Die
Die Zeitspanne t1 – t0 in
Die vorliegende Erfindung ist nicht auf Merkmale der beschriebenen beispielhaften Ausgestaltungen beschränkt. The present invention is not limited to features of the described exemplary embodiments.
Claims (23)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
DE102014104588.2A DE102014104588A1 (en) | 2014-04-01 | 2014-04-01 | microcontrollers |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
DE102014104588.2A DE102014104588A1 (en) | 2014-04-01 | 2014-04-01 | microcontrollers |
Publications (1)
Publication Number | Publication Date |
---|---|
DE102014104588A1 true DE102014104588A1 (en) | 2015-10-01 |
Family
ID=54066582
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
DE102014104588.2A Pending DE102014104588A1 (en) | 2014-04-01 | 2014-04-01 | microcontrollers |
Country Status (1)
Country | Link |
---|---|
DE (1) | DE102014104588A1 (en) |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6092190A (en) * | 1995-01-31 | 2000-07-18 | Neopost Limited | Electronic apparatus including a memory device and method of reprogramming the memory device |
US6115814A (en) * | 1997-11-14 | 2000-09-05 | Compaq Computer Corporation | Memory paging scheme for 8051 class microcontrollers |
-
2014
- 2014-04-01 DE DE102014104588.2A patent/DE102014104588A1/en active Pending
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6092190A (en) * | 1995-01-31 | 2000-07-18 | Neopost Limited | Electronic apparatus including a memory device and method of reprogramming the memory device |
US6115814A (en) * | 1997-11-14 | 2000-09-05 | Compaq Computer Corporation | Memory paging scheme for 8051 class microcontrollers |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
DE102012204256B4 (en) | METHOD AND SYSTEM FOR INITIATING A RE-OPERATION PROCESS IN A NON-VOLATILE SOLID STORAGE DEVICE | |
DE112017003641T5 (en) | Data overwrite device and data overwrite program | |
DE102009020389A1 (en) | System for updating firmware and methods therefor, and method for creating firmware | |
DE19839680B4 (en) | Method and device for modifying the memory contents of control units | |
EP1854007A2 (en) | Method, operating system, and computing device for processing a computer program | |
EP1037140B1 (en) | Method and apparatus providing security during modification of memory contents in control devices | |
DE19931184A1 (en) | Altering controller memory contents involves writing new data that is worthy of security into different memory area before transferring to original memory area contg. replaced data | |
EP2608037B1 (en) | Method for managing data in a flash memory, driver assistance device and motor vehicle | |
EP1611517A2 (en) | Program-controlled unit | |
DE10064025B4 (en) | A method for booting a microprocessor and microprocessor with a conditional deterministic reset vector | |
DE102019135079A1 (en) | CANCEL INSTALLATION OF FIRMWARE BUNDLES | |
DE102014104588A1 (en) | microcontrollers | |
DE102014006998A1 (en) | Correction of a programmable memory | |
WO2009074499A1 (en) | Method for operating a control appliance, and control appliance | |
WO2004057465A2 (en) | Method and device for modifying software in a control unit and corresponding control unit | |
DE112019004272T5 (en) | INSTALLING APPLICATION PROGRAM CODE ON A VEHICLE CONTROL SYSTEM | |
DE102004006308B4 (en) | Method for modifying program code of a portable data carrier by means of patch data | |
DE102021002079B3 (en) | Procedures for efficient data filing | |
DE102008010556A1 (en) | Method and device for storing information data | |
EP2151783A2 (en) | Method and device for recognising changes to data | |
DE112015002881T5 (en) | Storage device, flash memory controller and program | |
DE102018213045A1 (en) | Method, control device, computer program and computer program product for updating software for a control device | |
WO2024078825A1 (en) | Changing the memory content of a main memory of a microcontroller without a separate memory management unit | |
DE102013220513A1 (en) | Method for reading a data block of a non-volatile memory of a control device | |
WO2004001586A1 (en) | Device and method for processing a sequence of jump instructions |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
R163 | Identified publications notified | ||
R082 | Change of representative |
Representative=s name: MAUCHER JENKINS, DE Representative=s name: MAUCHER BOERJES JENKINS, DE Representative=s name: MAUCHER JENKINS PATENTANWAELTE & RECHTSANWAELT, DE |
|
R081 | Change of applicant/patentee |
Owner name: MINEBEA MITSUMI INC., JP Free format text: FORMER OWNER: MINEBEA CO., LTD., NAGANO-KEN, JP |
|
R082 | Change of representative |
Representative=s name: MAUCHER JENKINS, DE Representative=s name: MAUCHER JENKINS PATENTANWAELTE & RECHTSANWAELT, DE |
|
R012 | Request for examination validly filed |