Backtracking information acquisition method, system and equipment

By marking non-initialized areas in the RAM of the MCU to store backtracking information and protecting these areas during initialization, the problems of MCU flash memory capacity and life limitations are solved, and the backtracking data retention and fault location are realized when program exceptions are performed.

CN120508420APending Publication Date: 2025-08-19BOTAI CAR NETWORK (NEIJIANG) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510558918.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-29
Publication Date
2025-08-19

AI Technical Summary

Technical Problem

The flash memory capacity of microcontrollers (MCUs) is small and have limited write life, which makes it difficult to store and locate backtracking information after program exceptions.

Method used

The traceback information is stored in the random access memory RAM of the microcontroller MCU that is marked as uninitialized, and only the memory area not marked as uninitialized is initialized when the MCU is initialized to ensure that the traceback information is not lost and then transferred to the microprocessor MPU.

Benefits of technology

After the MCU is restarted, the traceback information can still be retained and transmitted to achieve effective location of the fault.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120508420A_ABST
    Figure CN120508420A_ABST
Patent Text Reader

Abstract

The invention provides a backtracking information acquisition method and system, electronic equipment, a computer readable storage medium and a computer program product, and relates to the technical field of computers. The method comprises the following steps: in response to obtained backtracking information, storing the backtracking information into a memory area marked as non-initialized in a random access memory (RAM) of a micro controller unit (MCU); mCU initialization is carried out based on a preset rule, and the preset rule comprises the steps that the memory areas which are not marked as non-initialized are initialized, and the memory areas which are marked as non-initialized are not initialized; and transmitting backtracking information to the microprocessor MPU in response to the fact that the initialization is determined to be completed. According to the method, the backtracking data when the program is abnormal can be effectively acquired, and the fault can be positioned.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a method and system for obtaining backtracking information, an electronic device, a computer-readable storage medium, and a computer program product. Background Art

[0002] The flash memory (Flash) inside a microcontroller unit (MCU) typically has a small capacity, and each cell has a limited write / erase lifespan. Consequently, due to the limited capacity and write lifespan of Flash memory, the MCU cannot immediately store logs or backtrace information after program exceptions. If a fault occurs during program execution, triggering an MCU reboot, it becomes difficult to locate the fault. Summary of the Invention

[0003] The embodiments of the present disclosure provide a method, system, electronic device, computer-readable storage medium, and computer program product for obtaining backtracking information, which can ensure effective acquisition of backtracking data when a program is abnormal and can locate the fault.

[0004] In a first aspect, an embodiment of the present disclosure proposes a method for obtaining backtrace information, comprising: in response to obtaining backtrace information, storing the backtrace information in a memory area marked as non-initialized in a random access memory RAM of a microcontroller MCU; initializing the MCU based on preset rules, the preset rules including: initializing memory areas not marked as non-initialized and not initializing memory areas marked as non-initialized; in response to determining that initialization is completed, transmitting the backtrace information to a microprocessor MPU.

[0005] In some embodiments, performing MCU initialization based on preset rules includes: in response to detecting that a preset condition is met, performing MCU initialization based on the preset rule; the preset condition includes at least one of the following: a memory area marked as non-initialized includes backtrace information, and the backtrace information is being transmitted to the memory area marked as non-initialized.

[0006] In some embodiments, performing MCU initialization based on a preset rule includes: in response to detecting that no backtrace information exists in a memory area not marked as non-initialized, initializing the memory area not marked as non-initialized.

[0007] In some embodiments, in response to determining that initialization is completed, backtrace information is transmitted to the microprocessor MPU, including: in response to determining that initialization is completed, detecting whether the memory area marked as non-initialized includes the backtrace information; if the memory area marked as non-initialized includes the backtrace information, transmitting the backtrace information to the MPU.

[0008] In some embodiments, the method further includes: obtaining backtrace information in response to detecting a fault trigger condition; the fault condition includes at least one of the following: a hardware failure of the MCU, an error in the program execution of the MCU is detected based on an assertion function, and an instruction to obtain backtrace information is detected.

[0009] In some embodiments, the memory area marked as non-initialized is obtained by modifying the link script to mark the memory area in the RAM of the MCU as non-initialized.

[0010] In some embodiments, the backtrace information includes at least one of the following: a function call chain of a program of the MCU, a saved timestamp, an error code, and a register status.

[0011] In a second aspect, an embodiment of the present disclosure provides a backtrace information acquisition system, comprising: a microcontroller MCU and a microprocessor MPU; wherein the MCU is configured to, in response to acquiring backtrace information, store the backtrace information in a memory area marked as non-initialized in a random access memory RAM of the MCU; initialize the MCU based on preset rules; the preset rules include: initializing memory areas that are not marked as non-initialized, and not initializing memory areas marked as non-initialized; in response to determining that initialization is completed, transmit the backtrace information to the microprocessor MPU.

[0012] In a third aspect, an embodiment of the present disclosure provides an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can implement the backtracking information acquisition method described in any implementation method of the first aspect when executing the instructions.

[0013] In a fourth aspect, an embodiment of the present disclosure provides a non-transitory computer-readable storage medium storing computer instructions, which are used to enable a computer to implement the backtracking information acquisition method described in any implementation manner in the first aspect when executed.

[0014] In a fifth aspect, an embodiment of the present disclosure provides a computer program product comprising a computer program, which, when executed by a processor, can implement the backtracking information acquisition method as described in any implementation manner in the first aspect.

[0015] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description.

[0016] According to the technical solution of the embodiment of the present disclosure, by storing all backtrace information in a memory area marked as non-initialized in the random access memory RAM of the microcontroller MCU, when an exception occurs when the MCU is running a program and the MCU is restarted, only the memory area not marked as non-initialized is initialized, and the memory area marked as non-initialized is not initialized. This ensures that the backtrace data stored in the memory area marked as non-initialized of the MCU will not be lost after the MCU is initialized, so that the backtrace data can be sent to the MPU for storage after the MCU is initialized. The technical solution of the embodiment of the present disclosure can ensure the effective acquisition of backtrace data when a program exception occurs, and can realize the location of the fault. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Other features, objects and advantages of the present disclosure will become more apparent from a reading of the detailed description of non-limiting embodiments made with reference to the following drawings:

[0018] Figure 1 is an exemplary system architecture in which the present disclosure may be applied;

[0019] Figure 2a A flowchart of a method for obtaining backtracking information provided by an embodiment of the present disclosure;

[0020] Figure 2b A flowchart of another method for obtaining backtracking information provided by an embodiment of the present disclosure;

[0021] Figure 3 A structural block diagram of a backtracking information acquisition system provided by an embodiment of the present disclosure;

[0022] Figure 4 A schematic structural diagram of an electronic device suitable for executing a method for obtaining backtracking information provided by an embodiment of the present disclosure. DETAILED DESCRIPTION

[0023] For a better understanding of the present application, various aspects of the present application will be described in more detail with reference to the accompanying drawings. It should be understood that these detailed descriptions are merely descriptions of exemplary embodiments of the present application and are not intended to limit the scope of the present application in any way. Throughout the specification, the same reference numerals refer to the same elements. The expression "and / or" includes any and all combinations of one or more of the associated listed items.

[0024] It should be understood that expressions such as "comprises," "including," "having," "includes," and / or "comprising" are open rather than closed expressions in this specification, indicating the presence of the stated features, elements, and / or components, but do not exclude the presence of one or more other features, elements, components, and / or combinations thereof. In addition, when expressions such as "at least one of..." appear after a list of listed features, they modify the entire list of features rather than just the individual elements in the list. In addition, when describing embodiments of the present application, "may" is used to mean "one or more embodiments of the present application." And, the term "exemplary" is intended to refer to an example or illustration.

[0025] Unless otherwise defined, all words used herein (including engineering terms and scientific and technological terms) have the same meaning as commonly understood by those skilled in the art to which this application belongs. It should also be understood that, unless otherwise specified in this application, words defined in commonly used dictionaries should be interpreted as having the same meaning as they do in the context of the relevant technology, and should not be interpreted in an idealized or overly formal sense.

[0026] It should be noted that, unless otherwise specified or inconsistent with the context, the embodiments and features of the embodiments in this application may be combined with each other. Furthermore, unless expressly limited or inconsistent with the context, the specific steps included in the methods described in this application are not necessarily limited to the order in which they are described, but may be performed in any order or in parallel. The present application will be described in detail below with reference to the accompanying drawings and in conjunction with the embodiments.

[0027] Figure 1 An exemplary system architecture 100 is shown that can be applied to embodiments of the backtracking information acquisition method, system, electronic device, computer-readable storage medium, and computer program product of the present disclosure.

[0028] like Figure 1 As shown, system architecture 100 may include a first device 101 and a second device 102. The first device 101 and the second device 102 may be connected via a network. The network is used as a medium for providing a communication link between the first device 101 and the second device 102. The network may include various connection types, such as wired or wireless communication links or fiber optic cables.

[0029] The first device 101 and the second device 102 can be hardware or software. When the first device 101 and the second device 102 are hardware, the first device 101 can be various electronic devices that need to be upgraded, including but not limited to microcontrollers, vehicle-mounted devices, vehicle-mounted devices, smart terminals, vehicles, components on vehicles, components on vehicle-mounted devices, components on vehicle-mounted devices, components on smart terminals, etc. The second device 102 can be a cloud server, a server, etc., wherein the server can also be a server of a distributed system, or a server combined with a blockchain. A cloud server, also known as a cloud computing server or cloud host, or cloud, is a host product in a cloud computing service system that addresses the management difficulties and weak business scalability of traditional physical hosts and virtual private server (VPS) services. When the first device 101 and the second device 102 are software, they can be installed in the electronic devices listed above. They can be implemented as multiple software or software modules, or as a single software or software module, without specific limitation here.

[0030] It should be understood that Figure 1 The number of the first device and the second device in the embodiment is merely illustrative. Any number of the first device and the second device may be provided according to implementation requirements.

[0031] The term "vehicle" or other similar terms used in this application includes a broad range of motor vehicles: for example, passenger cars including sport utility vehicles (SUVs), buses, trucks, various commercial vehicles; watercraft including various boats and ships; and aircraft; and includes hybrid vehicles, electric vehicles, hybrid electric vehicles, hydrogen-powered vehicles, and other alternative fuel vehicles (e.g., fuels derived from resources other than petroleum).

[0032] The method provided by the embodiments of the present disclosure can be applied in program running scenarios.

[0033] In some embodiments, during program operation, especially when the MCU is executing program code, it is necessary to store the backtrace information / log after the program exception in the flash memory of the MCU in real time. However, due to the capacity of the flash memory of the MCU and the problem of write life, the key log can only be transmitted by the remote procedure call (RPC) communication of the microprocessor unit (Micro Processor Unit, MPU). However, after loading, if a problem occurs during the operation of the MCU program and a restart is triggered, the backtrace information / log after the program exception may be lost, and it will be difficult to locate the problem. In addition, if the MCU stores the log separately, the log cannot be better collected smoothly by the MPU.

[0034] Please refer to Figure 2a , Figure 2a This is a flowchart of a method for obtaining backtracking information provided in an embodiment of the present disclosure. The execution subject is the first device 101, where process 200 includes the following steps:

[0035] Step 201: In response to obtaining the backtrace information, the backtrace information is stored in a memory area marked as non-initialized in a random access memory RAM of a microcontroller MCU.

[0036] Specifically, backtrace information refers to log information related to program exceptions during the execution of an MCU program. The abnormal program can be located through the backtrace information.

[0037] In some embodiments, backtrace information can be obtained by obtaining a call stack. Wherein, built-in stack frame analysis or tools (such as libunwind tools) can be used to obtain the function call chain to obtain the call stack.

[0038] In some embodiments, the RAM of the MCU may include a memory area marked as non-initialized, where the non-initialized memory area is used to store backtrace information. When the MCU is initialized, the memory area marked as non-initialized is not initialized.

[0039] For example, a section of memory in the RAM is set as reserved memory, the reserved memory is marked as non-initialized, and the backtrace information is stored in the non-initialized memory area. When the MCU is initialized, the non-initialized memory area is identified by the mark and the memory area is not initialized, which can ensure that the backtrace information is not lost.

[0040] Optionally, the RAM of the MCU may further include other memory areas, such as memory areas that are not marked as non-initialized. When the MCU is initialized, the memory areas that are not marked as non-initialized may be initialized.

[0041] In some embodiments, the backtrace information is stored in a memory area marked as non-initialized in the random access memory RAM of the microcontroller MCU, and the storage format of the data is a preset format (such as the preset format can be a ring buffer, or other format) to ensure that the backtrace information can be parsed after the MCU is initialized, so as to locate the abnormal program according to the parsed backtrace information.

[0042] In addition, index data corresponding to the backtrace data is also stored in the RAM of the MCU. The index data is used to describe the corresponding relationship between the backtrace data and the address corresponding to the backtrace data.

[0043] In some embodiments, after storing the backtrace information in a memory area marked as non-initialized in the random access memory (RAM) of the microcontroller MCU, the method further includes updating the index data. By updating the index data, the disclosed embodiments ensure the correct writing and reading of the backtrace data, and maintain the integrity and order of the backtrace data. The specific meaning and update method of the index data may vary in different application scenarios.

[0044] Step 202: Initialize the MCU based on preset rules.

[0045] The preset rule includes: initializing the memory area that is not marked as non-initialized, and not initializing the memory area that is marked as non-initialized.

[0046] Specifically, the purpose of initializing the MCU is to ensure that the MCU is transformed from an initial state after power-on or reset to a state ready to execute application code.

[0047] When an exception occurs during MCU program execution, the MCU restarts to initialize the MCU and ensure that the MCU can subsequently process the stored backtrace information. Memory areas marked as uninitialized are skipped during the MCU initialization process to ensure that data in these areas is not lost when the MCU restarts.

[0048] In the embodiment of the present disclosure, when the program exception initializes the MCU, only the memory area that is not marked as non-initialized is initialized, and the memory area marked as non-initialized is not initialized. In this way, when an exception occurs during program execution and triggers a restart, the memory area marked as non-initialized that stores the backtrace information corresponding to the exception is not initialized, so that the backtrace information is retained even after the MCU is restarted.

[0049] In some embodiments, the RAM may be initialized by identifying an identifier of a memory area in the RAM.

[0050] Step 203: In response to determining that the initialization is completed, the backtrace information is transmitted to the microprocessor MPU.

[0051] Specifically, after the MCU is restarted, the backtrace information stored in the memory area marked as non-initialized in the MCU's RAM is transferred to the MPU. By saving the backtrace data in the MPU, when locating the abnormal program, the backtrace information corresponding to the exception can be directly obtained from the MPU, and the fault can be located based on the backtrace information.

[0052] In some embodiments, the backtrace data in the memory area marked as uninitialized in the RAM of the MCU can be transmitted to the MPU via the RPC communication protocol.

[0053] Specifically, when performing data transmission between the MCU and the MPU, the appropriate communication method should be selected based on the specific hardware interface and application scenario. Specifically, you can choose a Universal Asynchronous Receiver / Transmitter (UART), Serial Peripheral Interface (SPI), Inter-Integrated Circuit (I2C), or Direct Memory Access (DMA) based on the hardware interface to implement data transmission between the MCU and the MPU. In addition, you can also define a binary protocol or a text protocol (such as JSON) to implement data transmission between the MCU and the MPU by defining fields such as timestamps, error codes, and stack addresses related to data transmission.

[0054] In some embodiments, the MPU may read the backtrace data of the hardware interface through an interrupt or polling method.

[0055] In some embodiments, the backtracking data may also be written into a file system, a database, or uploaded to the cloud to ensure that the backtracking data is not lost.

[0056] In the embodiment of the present disclosure, by storing backtrace information in a memory area marked as non-initialized in the random access memory RAM of the microcontroller MCU, when an exception occurs when the MCU is running a program and the MCU is restarted, only the memory area not marked as non-initialized is initialized, and the memory area marked as non-initialized is not initialized. This ensures that the restart of the MCU will not cause the loss of the backtrace data stored in the MCU, and after the MCU is restarted, the backtrace data is sent to the MPU for storage, which can ensure that the backtrace data when the program is abnormal can be effectively obtained, and the fault can be located.

[0057] In some embodiments, the above-mentioned step 202: initializing the MCU based on preset rules specifically includes: in response to detecting that a preset condition is met, initializing the MCU based on the preset rule. The preset condition includes at least one of the following: the memory area marked as non-initialized includes backtrace information, and the backtrace information is being transmitted to the memory area marked as non-initialized. That is, before initializing the MCU, ensure that all backtrace information related to program exceptions has been saved in the memory area marked as non-initialized to ensure that the backtrace information is not lost.

[0058] In some embodiments, the above step 203: initializing the MCU based on preset rules includes: in response to detecting that there is no backtrace information in the memory area not marked as non-initialized, initializing the memory area not marked as non-initialized.

[0059] Specifically, before initializing a memory area that is not marked as non-initialized, it is necessary to detect whether there is backtrace information in the memory area that is not marked as non-initialized; if backtrace information is detected in the memory area that is not marked as non-initialized, the backtrace information in the memory area that is not marked as non-initialized needs to be stored in the memory area that is marked as non-initialized; if it is detected that there is no backtrace information in the memory area that is not marked as non-initialized, the memory area that is not marked as non-initialized can be directly initialized. This ensures that all backtrace information is stored in the memory area that is marked as non-initialized, so that the backtrace information will not be lost when the MCU is subsequently initialized.

[0060] In some embodiments, the above-mentioned step 203: in response to determining that initialization is completed, transmitting the backtrace information to the microprocessor MPU, includes: in response to determining that initialization is completed, detecting whether the memory area marked as non-initialized includes the backtrace information; if the memory area marked as non-initialized includes the backtrace information, transmitting the backtrace information to the MPU.

[0061] In an embodiment of the present disclosure, after initialization, a memory area marked as non-initialized is detected. When there is unuploaded backtrace information in the memory area marked as non-initialized, the backtrace information is transmitted to the MPU.

[0062] Figure 2b A flowchart of another method for obtaining backtracking information provided by an embodiment of the present disclosure.

[0063] like Figure 2b As shown, in some embodiments, the backtrace information acquisition method includes not only steps 201 to 203 described above, but also step 204: acquiring backtrace information in response to detecting a fault trigger condition. The fault condition may include, but is not limited to, at least one of the following: a hardware fault in the MCU, a detection of an error in the execution of the MCU program based on an assertion function, and detection of an instruction to acquire backtrace information.

[0064] Specifically, backtrace information can be obtained based on hardware triggering. For example, when a hardware fault occurs in the MCU, the stack at the time of the exception can be captured by rewriting the handle (HardFault_Handler) of the hard fault, thereby obtaining the backtrace information based on the captured stack. Alternatively, when an error occurs in the program operation of the MCU based on the assertion function, the backtrace information of the triggering fault is obtained based on the assertion function, wherein the assertion function can be customized based on demand. Alternatively, backtrace information can also be obtained based on software triggering. For example, when an instruction to obtain backtrace information (such as a BKPT instruction, or other specific instructions) is received, backtrace information is actively obtained based on the instruction, and of course backtrace information can also be actively saved through the debug interface, etc.

[0065] In some embodiments, in step 201, the memory area marked as non-initialized is obtained by modifying the link script to mark the memory area in the RAM of the MCU as non-initialized.

[0066] The embodiment of the present disclosure uses a script to mark the memory area in the RAM of the MCU, which can quickly perform repetitive marking tasks without manual operation one by one, saving a lot of time and energy. At the same time, batch data can be uniformly marked to maintain the consistency and accuracy of the marking. In addition, the marking rules and logic can be flexibly defined according to specific needs. For example, the marking conditions can be set according to the size, attributes or specific conditions of the memory area to achieve a personalized marking scheme. Of course, the present disclosure can also mark the memory area in other ways, such as manual marking, etc., and the present disclosure is not limited to this.

[0067] In some embodiments, the backtrace information includes at least one of the following: a function call chain of a program of the MCU, a saved timestamp, an error code, and a register status.

[0068] Specifically, during program development, debugging, and exception analysis, backtrace information helps developers understand the program's state and execution path when the exception occurs, and is used to locate the abnormal program.

[0069] The function call chain refers to the sequence and hierarchical relationship of function calls during program execution. This provides a clear understanding of the program's execution flow, including which functions are called from which locations, and the relationships between them. When analyzing program crashes or exceptions, the function call chain can help developers quickly locate the function causing the problem and its source, helping them more accurately pinpoint the root cause.

[0070] A timestamp is the specific time when an exception occurred, typically expressed in seconds or milliseconds since a specific point in time (such as system startup time or UNIX epoch time). Timestamps can be used to understand the chronological order of exception occurrences, helping developers analyze the correlation between multiple exceptions and determine the operating state of the system and program at the time of the exception. This is particularly useful for handling multiple concurrent tasks or analyzing exceptions in long-running systems.

[0071] An error code is an identifier generated by a program when it detects an exception or error. It indicates the specific error type or cause. Different error codes correspond to different error conditions, helping to quickly identify the underlying problem. Error codes provide concise information about the exception, allowing developers to quickly find relevant error handling methods and solutions based on the error code. In complex systems, error codes can serve as important clues for quickly locating and resolving problems.

[0072] Register status refers to the values of various registers in the MCU at the time of a program exception, including the program counter (PC), link register (LR), stack pointer (SP), general-purpose registers, and program status word (PSW). The values of these registers reflect the program's execution status and data environment at the time of the exception. The register status provides information about the instruction being executed (via the PC register), the return address of the called function (via the LR register), stack usage (via the SP register), and the data values stored in the general-purpose registers. This information is crucial for in-depth analysis of the exception's cause and for restoring program execution.

[0073] When a program fault occurs, the embodiment of the present disclosure saves the function call chain, timestamp, error code and register status of the MCU program corresponding to the fault as backtrace information, so that the program fault can be quickly and accurately located based on the backtrace information.

[0074] Further references Figure 3 As an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of a retrospective information acquisition system. The system embodiment corresponds to the above method embodiment, and the system can be specifically applied to various electronic devices.

[0075] like Figure 3As shown, the backtrace information acquisition system 300 of this embodiment may include: a microcontroller MCU 301 and a microprocessor MPU 302. The MCU 301 is configured to, in response to acquiring backtrace information, store the backtrace information in a memory area marked as non-initialized in the MCU's random access memory (RAM); and initialize the MCU based on preset rules; wherein the preset rules include: initializing memory areas not marked as non-initialized and not initializing memory areas marked as non-initialized; and, in response to determining that initialization is complete, transmit the backtrace information to the microprocessor MPU.

[0076] In this embodiment, MCU301 stores all the backtrace information in the memory area marked as non-initialized in the random access memory RAM of the microcontroller MCU. When an exception occurs when the MCU is running a program and the MCU is restarted, only the memory area not marked as non-initialized is initialized, and the memory area marked as non-initialized is not initialized. This ensures that the restart of the MCU will not cause the loss of the backtrace data stored in the MCU, and sends the backtrace data to the MPU for storage after the MCU is restarted, ensuring that the backtrace data is effectively obtained when the program is abnormal, so that the fault can be located.

[0077] In some embodiments, when executing the step of initializing the MCU based on preset rules, the MCU301 is specifically configured to: in response to detecting that a preset condition is met, initialize the MCU based on the preset rule; the preset condition includes at least one of the following: the memory area marked as non-initialized includes backtrace information, and the backtrace information is being transmitted to the memory area marked as non-initialized.

[0078] In some embodiments, when performing MCU initialization based on preset rules, the MCU 301 is specifically configured to: in response to detecting that the backtrace information does not exist in the memory area not marked as non-initialized, initialize the memory area not marked as non-initialized.

[0079] In some embodiments, when MCU301 executes the step of transmitting backtrace information to microprocessor MPU302 in response to determining that initialization is completed, it is specifically configured as follows: in response to determining that initialization is completed, detecting whether the memory area marked as non-initialized includes backtrace information; if the memory area marked as non-initialized includes backtrace information, transmitting the backtrace information to MPU302.

[0080] In some embodiments, MCU301 is further configured to obtain backtrace information in response to detecting a fault trigger condition; the fault condition includes at least one of the following: a hardware failure of the MCU, an error in the program execution of the MCU is detected based on an assertion function, and an instruction to obtain backtrace information is detected.

[0081] In some embodiments, the memory area marked as non-initialized is obtained by modifying the link script to mark the memory area in the RAM of the MCU 301 as non-initialized.

[0082] In some embodiments, the backtrace information includes at least one of the following: a function call chain of a program of the MCU, a saved timestamp, an error code, and a register status.

[0083] This embodiment exists as a system embodiment corresponding to the above method embodiment. The details of the embodiment involved in the backtracking information acquisition system provided by this embodiment and the technical effects brought about can be referred to the corresponding relevant descriptions in the above method embodiment respectively, and will not be repeated here.

[0084] According to an embodiment of the present disclosure, the present disclosure further provides an electronic device, comprising: at least one processor; and a memory in communication with the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can implement the backtracking information acquisition method described in any of the above embodiments when executing. Optionally, the electronic device can be a microcontroller (the processor can be a CPU in the microcontroller), an on-board device, a vehicle-mounted device, a smart terminal, a vehicle, a component on a vehicle, a component on an on-board device, a component on a vehicle-mounted device, a component on a smart terminal, and the like.

[0085] According to an embodiment of the present disclosure, the present disclosure further provides a readable storage medium, which stores computer instructions, and the computer instructions are used to enable a computer to implement the backtracking information acquisition method described in any of the above embodiments when executed.

[0086] According to an embodiment of the present disclosure, the present disclosure further provides a computer program product, which, when executed by a processor, can implement the backtracking information acquisition method described in any of the above embodiments.

[0087] Figure 4 A schematic block diagram of an example electronic device 400 that can be used to implement embodiments of the present disclosure is shown. The term "electronic device" is intended to represent a microcontroller, an in-vehicle device, an in-vehicle device, an intelligent terminal, a vehicle, a component on a vehicle, a component on an in-vehicle device, a component on an in-vehicle device, a component on an intelligent terminal, and the like. The components shown herein, their connections and relationships, and their functions are provided for illustrative purposes only and are not intended to limit the implementation of the present disclosure as described and / or claimed herein.

[0088] like Figure 4As shown, the electronic device 400 includes a computing unit 401, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 402 or a computer program loaded from a storage unit 408 into a random access memory (RAM) 403. Various programs and data required for the operation of the electronic device 400 can also be stored in the RAM 603. The computing unit 401, the ROM 402, and the RAM 403 are connected to each other via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.

[0089] Several components in electronic device 400 are connected to I / O interface 405, including input unit 406, output unit 407, storage unit 408, and communication unit 409. Communication unit 409 allows device 400 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.

[0090] The computing unit 401 can be a variety of general-purpose and / or specialized processing components with processing and computing capabilities. Some examples of the computing unit 401 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units that run machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The computing unit 401 performs the various methods and processes described above, such as the backtracking information acquisition method. For example, in some embodiments, the backtracking information acquisition method can be implemented as a computer software program that is tangibly contained in a machine-readable medium, such as the storage unit 408. In some embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 400 via the ROM 602 and / or the communication unit 409. When the computer program is loaded into the RAM 403 and executed by the computing unit 401, one or more steps of the backtracking information acquisition method described above can be performed. Alternatively, in other embodiments, the computing unit 401 can be configured to perform the backtracking information acquisition method by any other appropriate means (e.g., by means of firmware).

[0091] Various embodiments of the systems and techniques described herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), system-on-chip systems (SOCs), programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0092] The program code for implementing the method of the present disclosure can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device so that when the program code is executed by the processor or controller, the functions / operations specified in the flow chart and / or block diagram are implemented. The program code can be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.

[0093] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0094] To provide user interaction, the systems and techniques described herein can be implemented on an in-vehicle device that includes: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and an input device (e.g., a touch device, a voice input device, a gesture detection device) through which the user can provide input to the computer. Other types of devices can also be used to provide user interaction; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, tactile input, or gesture input).

[0095] The systems and techniques described herein can be implemented in an on-board system that includes back-end components (e.g., as a data server), or an on-board system that includes middleware components (e.g., an application server), or an on-board system that includes front-end components (e.g., an on-board system with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or an on-board system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.

[0096] According to the technical solution of the embodiment of the present disclosure, by storing all the backtrace information in the memory area marked as non-initialized in the random access memory RAM of the microcontroller MCU, when the MCU restarts the program due to an exception, only the memory area not marked as non-initialized is initialized, and the memory area marked as non-initialized is not initialized. This ensures that the restart of the MCU will not cause the loss of the backtrace data stored in the MCU, and after the MCU is restarted, the backtrace data is sent to the MPU for storage, ensuring that the backtrace data when the program is abnormal is effectively obtained, and the fault can be located.

[0097] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this disclosure can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved. This is not a limitation herein.

[0098] The above specific embodiments do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure shall be included within the scope of protection of this disclosure.

Claims

1. A method for obtaining backtracking information, comprising: In response to acquiring the backtrace information, the backtrace information is stored in a memory area marked as non-initialized in a random access memory RAM of a microcontroller MCU; Initializing the MCU based on preset rules, wherein the preset rules include: initializing memory areas that are not marked as non-initialized and not initializing memory areas that are marked as non-initialized; In response to determining that the initialization is completed, the backtrace information is transmitted to the microprocessor MPU.

2. The method according to claim 1, wherein The MCU initialization based on preset rules includes: In response to detecting that a preset condition is met, the MCU is initialized based on the preset rule; the preset condition includes at least one of the following: the memory area marked as non-initialized includes the backtrace information, and the backtrace information is being transmitted to the memory area marked as non-initialized.

3. The method according to claim 1 or 2, wherein: The MCU initialization based on preset rules includes: In response to detecting that the backtrace information does not exist in the memory area not marked as non-initialized, the memory area not marked as non-initialized is initialized.

4. The method according to claim 1 or 2, wherein: In response to determining that the initialization is completed, transmitting the backtrace information to the microprocessor MPU includes: In response to determining that initialization is completed, detecting whether the memory area marked as non-initialized includes the backtrace information; If the memory area marked as uninitialized includes the backtrace information, the backtrace information is transmitted to the MPU.

5. The method according to claim 1 or 2, wherein: The method further comprises: In response to detecting a fault trigger condition, the backtrace information is obtained; the fault condition includes at least one of the following: a hardware fault of the MCU, an error in the program execution of the MCU is detected based on an assertion function, and an instruction to obtain the backtrace information is detected.

6. The method according to claim 1 or 2, wherein: The memory area marked as non-initialized is obtained by marking the memory area in the RAM of the MCU as non-initialized in a manner of modifying a link script.

7. The method according to claim 1 or 2, wherein: The backtrace information includes at least one of the following: a function call chain, a save timestamp, an error code, and a register status of the program of the MCU.

8. A retrospective information acquisition system, comprising: Microcontroller MCU and microprocessor MPU; The MCU is configured to, in response to obtaining backtrace information, store the backtrace information in a memory area marked as non-initialized in a random access memory RAM of the MCU; initialize the MCU based on preset rules; the preset rules include: initializing memory areas that are not marked as non-initialized and not initializing memory areas marked as non-initialized; and in response to determining that initialization is completed, transmit the backtrace information to the microprocessor MPU.

9. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 7.

10. A non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are configured to cause the computer to execute the method according to any one of claims 1 to 7.

11. A computer program product comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements the steps of the method according to any one of claims 1 to 7.