Debugging method and device, computer equipment and program product
By connecting with the host computer server during the boot loader startup stage to download the environment variable file and modify it, the problem of high debugging dependency of existing uboot environment variables is solved, efficient variable modification and debugging is achieved, and debugging efficiency and independence are improved.
Patent Information
- Application Number
- CN202510398248.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-31
- Publication Date
- 2025-07-18
AI Technical Summary
The existing uboot environment variable debugging method requires dependency on debug serial port or other tools, resulting in low debugging efficiency and high dependency, and it is impossible to complete variable modification and debugging without starting the device kernel and root system files.
During the boot loader startup stage, a connection is established with the host computer server, the environment variable file is downloaded, the target variable name and debug value are parsed, and the debugging results are obtained directly in the boot loader, and after restarting.
It realizes that without relying on the debug serial port, it can batch modify the change amount and complete debugging before starting the device kernel and root system files, which improves debugging efficiency and independence and reduces debugging complexity.
Smart Images

Figure CN120336160A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technologies, and in particular, to a debugging method, apparatus, computer device, and program product. Background Art
[0002] As a general bootloader, U-Boot is widely used in embedded systems. As the first program to run after the system is powered on, it can be responsible for initializing multiple hardware components within the device and constructing the most basic kernel running environment. The implementation of the above functions by U-Boot depends on internal environment variables. In order to meet different hardware initialization requirements and construct different kernel running environments, it is necessary to modify and debug the environment variables of U-Boot. However, the existing debugging methods either rely on debugging ports for debugging or need to call other debugging tools (such as the fw_printenv tool) for debugging, which greatly affects the debugging efficiency. Summary of the Invention
[0003] Embodiments of the present disclosure at least provide a debugging method, apparatus, computer device, and program product.
[0004] In a first aspect, an embodiment of the present disclosure provides a debugging method, including:
[0005] At the startup stage of the bootloader of the device, establish a connection with the host server, and after the connection, download the latest environment variable file from the host server;
[0006] Parse out the target variable names and target debugging values corresponding to multiple target environment variables to be debugged from the environment variable file;
[0007] Modify the target environment variables in the bootloader by using the target variable names and target debugging values;
[0008] Restart the bootloader based on the modification result to obtain a debugging result.
[0009] In a possible implementation, the restarting the bootloader based on the modification result to obtain a debugging result includes:
[0010] Restart the bootloader based on the modification result, and when the bootloader restarts successfully, determine that the debugging is successful;
[0011] Alternatively, when the bootloader fails to restart, determine that the debugging fails, and send the reason for the debugging failure to the host server, so that the host server modifies the existing environment variable file based on the reason for the debugging failure.
[0012] In a possible implementation, the device is any one of multiple devices in the same network segment as the host computer server;
[0013] During the startup phase of the device's bootloader, establish a connection with the host computer server, and after the connection is established, download the latest environment variable file from the host computer server, including:
[0014] If the connection with the host computer server is successfully established, send a list download request to the host computer server;
[0015] Receive the request response sent by the host computer server, and parse the environment variable file from the request response.
[0016] In a possible implementation, parsing the target variable names and target debug values corresponding to multiple target environment variables to be debugged from the environment variable file includes:
[0017] Decrypt the environment variable file according to the decryption method that matches the agreed encryption method to obtain the file header content, middle content, and file tail content of the environment variable file;
[0018] When both the file header content and the file tail content meet the preset requirements, parse the target variable names and the target debug values from the middle content.
[0019] In a possible implementation, the environment variable file in the host computer server is generated according to the following steps:
[0020] Receive the target variable names and target debug values corresponding to multiple target environment variables sent by the target network; the target variable names and target debug values corresponding to the target environment variables are input by the tester on the variable management page corresponding to the target network;
[0021] Generate the environment variable file according to the target variable names and the target debug values.
[0022] In a possible implementation, a client program runs in the target network, and a server program runs in the host computer server;
[0023] The receiving the target variable names and target debug values corresponding to multiple target environment variables sent by the target network includes:
[0024] Use the server program to receive the target variable names and target debug values corresponding to multiple target environment variables sent by the target network through the client program.
[0025] In a possible implementation, modifying the target environment variable in the bootloader by using the target variable name and the target debug value includes:
[0026] Using the target variable name, obtain the current variable values of the respective target environment variables in the bootloader from memory;
[0027] Determine whether there is an environment variable to be modified in the target environment variable where the current variable value is inconsistent with the target debug value;
[0028] If so, save the target debug value of the environment variable to be modified in an external memory; or,
[0029] If there is no environment variable to be modified, directly start the bootloader by using the current variable value, and start the kernel and root system files of the device when the bootloader is successfully started.
[0030] In a possible implementation, the method further includes:
[0031] If the connection to the host computer server is not successfully established or the environment variable file is not downloaded, determine whether there is a downloaded historical environment variable file;
[0032] If so, determine whether to directly start the bootloader according to the time difference between the acquisition time of the historical environment variable file and the current time and / or the coverage of the target environment variable in the historical environment variable file;
[0033] If so, obtain the current variable values of the respective environment variables in the bootloader from the external memory, and start the bootloader by using the current variable values.
[0034] In a second aspect, an embodiment of the present disclosure further provides a debugging device, including:
[0035] A download module, configured to establish a connection with a host computer server during the startup phase of the bootloader of the device, and download the latest environment variable file from the host computer server after the connection;
[0036] An analysis module, configured to analyze the target variable name and the target debug value corresponding to each of the multiple target environment variables to be debugged from the environment variable file;
[0037] A modification module, configured to modify the target environment variable in the bootloader by using the target variable name and the target debug value;
[0038] A debugging module, configured to restart the bootloader based on the modification result to obtain a debugging result.
[0039] In a third aspect, an optional implementation of the present disclosure further provides a computer device, a processor, and a memory, wherein the memory stores machine-readable instructions executable by the processor, and the processor is used to execute the machine-readable instructions stored in the memory, and when the machine-readable instructions are executed by the processor, the steps of the above-mentioned first aspect, or any possible implementation of the first aspect are performed.
[0040] In a fourth aspect, an optional implementation of the present disclosure further provides a computer program product, including a computer program, which, when executed, implements the above-mentioned first aspect, or the steps in any possible implementation of the first aspect.
[0041] The debugging method, device, computer equipment and program product provided by the disclosed embodiment, in the startup phase of the boot loader, by directly obtaining the environment variable file in the host computer and using the target variable name and target debugging value in the environment variable file to modify and debug the environment variable, not only can the variables be parsed and batch modified by reading the file text without relying on the debugging serial port, but also the modification and debugging of the variables can be completed before the device kernel and root system files are started, thereby improving the debugging efficiency. Moreover, through the environment variable file in the host computer, the modification and debugging of the environment variables can be realized without the help of other tools, thereby improving the independence of debugging.
[0042] Furthermore, the debugging method, device, computer equipment and program product provided by the embodiments of the present disclosure can also use the same environment variable file in the host computer server to realize batch environment variable modification and debugging of multiple devices in the same network segment, which reduces the debugging complexity and improves the debugging efficiency compared to the method of manually modifying the environment variable files of each device one by one in the prior art. In order to make the above-mentioned purposes, features and advantages of the present disclosure more obvious and easy to understand, the following is a detailed description of the preferred embodiments in conjunction with the attached drawings as follows. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following is a brief introduction to the drawings required for use in the embodiments. The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and are used together with the specification to illustrate the technical solutions of the present disclosure. It should be understood that the following drawings only illustrate certain embodiments of the present disclosure and should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can also be obtained based on these drawings without creative work.
[0044] Figure 1 A flowchart of a debugging method provided by an embodiment of the present disclosure is shown;
[0045] Figure 2 Shows a schematic framework diagram of a device provided by an embodiment of the present disclosure;
[0046] Figure 3 Shows a communication connection diagram of multiple devices and a host computer server provided by an embodiment of the present disclosure;
[0047] Figure 4 Shows a specific implementation flowchart of a debugging method provided by an embodiment of the present disclosure;
[0048] Figure 5 Shows a schematic diagram of a debugging device provided by an embodiment of the present disclosure;
[0049] Figure 6 Shows a schematic structural diagram of a computer device provided by an embodiment of the present disclosure. Detailed implementation manners
[0050] To make the objectives, technical solutions and advantages of the embodiments of the present disclosure clearer, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present disclosure. Apparently, the described embodiments are only a part rather than all of the embodiments of the present disclosure. Usually, the components of the embodiments of the present disclosure described and illustrated herein can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure is not intended to limit the scope of the present disclosure claimed, but merely represents selected embodiments of the present disclosure. All other embodiments obtained by those skilled in the art based on the embodiments of the present disclosure without creative efforts fall within the scope of protection of the present disclosure.
[0051] In addition, the terms "first", "second", etc. in the description and claims of the embodiments of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances so that the embodiments described here can be implemented in an order different from that shown or described here.
[0052] As used herein, "a plurality or several" means two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, and B exists alone. The character " / " generally represents an "or" relationship between the associated objects before and after.
[0053] It has been found that when modifying and debugging the environment variables of U-Boot, common methods can be implemented by calling a debugging serial port. However, once there is a problem with the serial port or a suitable serial cable cannot be found temporarily, the serial port needs to be replaced, which greatly increases the debugging time and affects the debugging efficiency. Or, another method can be implemented by combining the fw_printenv tool with a script at the system level. However, this method can only be implemented after the system starts normally and ensures that the fw_printenv tool has been pre-installed or ported on the device. It not only has a strong dependence on the fw_printenv tool, but also has relatively low debugging efficiency. Or, the existing method of modifying environment variables through the U-Boot interactive mode requires continuously writing the variable name and the value to be written. Since it is easy to make mistakes during input and variables cannot be parsed and batch-modified in the way of reading text, the debugging efficiency is also relatively low.
[0054] Based on the above research, the present disclosure provides a debugging method, device, computer device, and program product. In the startup stage of the bootloader, by directly obtaining the environment variable file on the host computer and using the target variable name and target debugging value in the environment variable file to modify and debug the environment variables, not only can variables be parsed and batch-modified in the way of reading file text without relying on a debugging serial port, but also the modification and debugging of variables can be completed before starting the device kernel and root system files, improving the debugging efficiency. Moreover, by using the environment variable file in the host computer, the modification and debugging of environment variables can be achieved without relying on other tools, improving the independence of debugging.
[0055] Regarding the defects existing in the above solutions, they are all the results obtained by the inventors through practice and careful research. Therefore, the process of discovering the above problems and the solutions proposed by the present disclosure for the above problems in the following text should be the contributions made by the inventors to the present disclosure during the process of the present disclosure.
[0056] It should be noted that similar reference numerals and letters represent similar items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings.
[0057] It can be understood that before using the technical solutions disclosed in the embodiments of the present disclosure, the types, usage scopes, usage scenarios, etc. of the personal information involved in the present disclosure should be informed to users and the authorization of users should be obtained in an appropriate manner in accordance with relevant laws and regulations.
[0058] For the convenience of understanding this embodiment, first, a debugging method disclosed in the embodiments of the present disclosure will be introduced in detail. The execution subject of the debugging method provided in the embodiments of the present disclosure is generally a terminal device or other processing device with certain computing capabilities. The terminal device may be a user equipment (UE), a mobile device, a user terminal, a terminal, a personal digital assistant device (PDA), a handheld device, a computer device, etc.; in some possible implementation manners, the debugging method may be implemented by a processor calling computer-readable instructions stored in a memory.
[0059] Next, the debugging method provided in the embodiments of the present disclosure will be described by taking the execution subject as any device deployed with an embedded system as an example.
[0060] As Figure 1 shown, it is a flowchart of a debugging method provided in the embodiments of the present disclosure, which may include the following steps:
[0061] S101: At the startup stage of the device's bootloader, establish a connection with the host computer server, and after the connection, download the latest environment variable file from the host computer server.
[0062] Here, the device in the embodiments of the present disclosure may be any device with an Ethernet function and / or a WiFi wireless network function, and an embedded system may be deployed in the device. The bootloader may specifically be a uboot program. As the first program to run after the system is powered on, Uboot can complete the initialization of most of the hardware in the system and build the most basic kernel running environment.
[0063] As Figure 2As shown in the figure, it is a schematic diagram of the framework of a device provided by an embodiment of the present disclosure. The device may include an Ethernet / WiFi module, a Central Processing Unit (CPU), a Double Data Rate Random Access Memory (DDR RAM), an input module, an output module, and an external Read-Only Memory (ROM). Among them, the Ethernet / WiFi module is used to establish a network connection with the host server and obtain data from the host server; the CPU is used to process device data; the DDR RAM is used to directly exchange data with the CPU and temporarily store data (such as temporarily storing the variable value of the environment variable); the input module is used to receive input data; the output module is used to output data; the external ROM is used to persistently store data, for example, persistently store the variable value of the environment variable, etc. Communication can be realized between each module through a General-purpose input / output (GPIO) interface.
[0064] The host server can be a pre-set server. For example, the server can be a Trivial File Transfer Protocol (TFTP) server, and the device can communicate with the host server as a TFTP client. In the host server, there is an environment variable file for the environment variables in uboot. The environment variable file may include the variable names and modified values of at least one environment variable to be modified. Environment variables can be understood as a general term for identifiers used to specify certain characteristics and perform specific functions in a computer system. The environment variable file in the host server can be pre-generated by the host server according to the target environment variables set by the tester in the host server.
[0065] The startup process of the device can include three parts: uboot startup, kernel startup, and root file system (rootfs) startup. In the prior art, the uboot debugging method can only modify and debug the environment variables after all three parts are started, and the debugging efficiency is relatively low. However, in this application, modification and debugging can be achieved in the startup stage of uboot without the need for kernel startup and rootfs startup, effectively improving the debugging efficiency.
[0066] Specifically, when the device is powered on, uboot can start. In the startup stage of uboot, the device can attempt to establish a communication connection with the host server. If the connection is successfully established, the latest environment variable file stored in the host server can be downloaded from the host server.
[0067] S102: Parse out the target variable names and target debug values respectively corresponding to multiple target environment variables to be debugged from the environment variable file.
[0068] Here, the environment variable file may include the target variable names respectively corresponding to multiple target environment variables to be debugged and their corresponding target debug values. The target environment variable is one of the multiple environment variables corresponding to uboot. The target variable names and target debug values may be stored in the environment variable file in the form of key-value pairs of varname and varvalue.
[0069] In specific implementation, after the device downloads the environment variable file, it can perform file parsing on the file, so as to parse out each pair of varname and varvalue.
[0070] S103: Modify the target environment variable in the bootloader by using the target variable name and target debug value.
[0071] In specific implementation, it is possible to search for the target environment variable that matches the target variable name from the multiple environment variables corresponding to uboot, and then use the target debug value to modify the current value variable value of the target environment variable to obtain the modified target environment variable.
[0072] S104: Restart the bootloader based on the modification result to obtain the debug result.
[0073] Here, the modification result is used to indicate the value corresponding to the target environment variable after modification.
[0074] Exemplarily, after the modification is completed, it is possible to use the values corresponding to each target environment variable after modification (i.e., the target debug values) and the variable values of the unmodified environment variables to restart uboot, so as to complete the modification and debugging of the uboot environment variable by using the target debug value of the target environment variable and obtain the debug result.
[0075] In one embodiment, the debug result includes debug success and debug failure. Specifically, for the above S104, it can be implemented according to the following steps:
[0076] Restart the bootloader based on the modification result, and determine that the debug is successful when the bootloader restarts successfully. Here, after the modification is completed, it is possible to use the values corresponding to each target environment variable after modification (i.e., the target debug values) and the variable values of the unmodified environment variables to restart uboot. When the restart is successful, it can be determined that the modification and debugging of the target environment variable are successful, and a debug result indicating debug success is obtained.
[0077] Alternatively, in the case of a failed reboot of the bootloader, it is determined that the debugging has failed, and the reason for the debugging failure is sent to the host server, so that the host server modifies the existing environment variable file based on the reason for the debugging failure. Here, in the case of a failed reboot using the modified target environment variables, a debugging result indicating a debugging failure is determined. Moreover, the device can generate a reason for the debugging failure based on the reason for the failed reboot. The reason for the debugging failure is used to indicate the target environment variables that caused the debugging failure and the specific reasons for the failure. The reason for the debugging failure is sent to the host server, so that after receiving the reason for the debugging failure, the host server re-modifies and debugs the target environment variables that caused the debugging failure based on this reason to obtain updated target environment variables. A new environment variable file is generated based on the updated target environment variables, and an update prompt message is generated and sent to the device. After the debugging fails, the device can modify each of the modified target environment variables back to their values before modification, and then, after receiving the update prompt message, restart the U-Boot again. During the startup phase of the restarted U-Boot, the above S101 to S104 are executed again to achieve the re-modification and debugging of the environment variables until the debugging is successful.
[0078] In this way, during the startup phase of the bootloader, by directly obtaining the environment variable file on the host and using the target variable name and target debugging value in the environment variable file to modify and debug the environment variables, not only can variables be parsed and batch-modified in the form of reading file text without relying on a debugging serial port, but also the modification and debugging of variables can be completed before starting the device kernel and root system files, improving the debugging efficiency. Moreover, through the environment variable file in the host, the modification and debugging of the environment variables can be achieved without the help of other tools, improving the independence of the debugging.
[0079] In one embodiment, to improve the debugging efficiency, the embodiments of the present disclosure can also achieve the simultaneous modification of the U-Boot environment variables of multiple devices using the same environment variable file. Specifically, the above device can be any one of multiple devices in the same network segment as the host server, that is, multiple devices and the host server can be set in the same network segment. In this way, multiple devices can use the same environment variable file in the host server to respectively modify their own environment variables. For any one of the multiple devices, the steps of the above S101 to S104 can be used simultaneously to achieve the modification and debugging of its own U-Boot environment variables.
[0080] In the case where multiple devices and the host server are in the same network segment, for any one of the devices, the steps in S101 above can be implemented according to the following steps:
[0081] S101-1: If the connection with the host computer server is successfully established, send a list download request to the host computer server.
[0082] Here, the list download request is used to request the download of the latest environment variable file.
[0083] In specific implementation, for any one of multiple devices in the same network segment, during the startup phase of uboot of this device, if the connection with the host computer server is successfully established, it can actively send a list download request to the host computer server.
[0084] S101-2: Receive the request response sent by the host computer server, and parse the environment variable file from the request response.
[0085] In specific implementation, after receiving the list download request, the host computer server can determine whether it stores the latest environment variable file this time. If so, it can carry the latest environment variable file in the request response and send it to the device. If not, it can send the request response carrying a null value or file indication information to the device. Here, the file indication information is used to indicate that there is no environment variable file.
[0086] After receiving the request response, the device can parse it. If the environment variable file is parsed from it, the environment variable file can be written into the memory, and S102 to S104 can be executed using this environment variable file to implement the modification of the environment variable. If the control or file indication information is parsed from the request response, it can be determined that the environment variable does not need to be modified, and the uboot program can be restarted using the current environment variable value.
[0087] As Figure 3 shown, it is a communication connection diagram between multiple devices and the host computer server provided by an embodiment of the present disclosure. Among them, the host computer server can be a TFTP server, and the multiple devices can include Device 1 to Device n, where n is greater than or equal to 2. Each device acts as a TFTP client and realizes the network connection with the host computer server through a switch / router to obtain the environment variable file.
[0088] In this way, multiple devices and the host computer server are in the same network segment, and multiple devices can use the same environment variable file in the host computer server to realize the simultaneous update of the environment variables in multiple devices, without manually modifying the environment variables of each device one by one and avoiding the time for re-solidifying the modified environment variables into files and burning them to each device, effectively reducing the complexity of variable update and improving the reliability of variable update.
[0089] In one embodiment, to prevent accidental modification of environment variables, the host computer server and the device may also use an encryption method for file transmission. Specifically, for the above S102, it may be implemented according to the following steps:
[0090] S102-1: Decrypt the environment variable file according to the decryption method matching the agreed encryption method to obtain the file header content, intermediate content, and file tail content of the environment variable file.
[0091] Here, after the host computer server obtains the target debugging values corresponding to each target environment variable, it can obtain the preset encrypted file header content and file tail content, and generate the intermediate content according to the key-value pairs composed of the target variable names and target debugging values respectively corresponding to each target environment variable. Then, it combines the file header content, intermediate content, and file tail content in sequence to form the initial environment variable file, and then encrypts the initial environment variable file according to the encryption method agreed with the device to obtain the encrypted environment variable file.
[0092] After the device downloads the environment variable file, it can decrypt the environment variable file according to the decryption method matching the agreed encryption method to obtain the file header content, intermediate content, and file tail content.
[0093] S102-2: When both the file header content and the file tail content meet the preset requirements, parse the target variable name and the target debugging value from the intermediate content.
[0094] Here, the preset requirements are the requirements that the preset file header content and file tail content need to meet. For example, when the file header content and the file tail content are pre-agreed between the device and the host computer server, the preset requirements can specifically be the agreed file header content and file tail content. When the file header content and the file tail content parsed from the environment variable file are consistent with the file header content and file tail content indicated by the preset requirements, it can be determined that the preset requirements are met; otherwise, it is determined that the preset requirements are not met.
[0095] In specific implementation, the device can verify the file header content and the file tail content respectively according to the preset requirements. When both contents meet the preset requirements, it indicates that the environment variable file is the correct file. Then, it can parse each key-value pair from the intermediate content to obtain each target variable name and the target debugging value. When at least one of the two contents does not meet the preset requirements, it can be determined that the environment variable file is an incorrect file. The device refuses to execute the variable modification operation and feeds back an error prompt message to the host computer server to indicate that there is an error in the environment variable file.
[0096] In this way, by using the file header content, file tail content, and encryption method for encrypted transmission of the environment variable file, it is possible to effectively avoid accidental modification of the environment variables in the device and improve the security of variable modification.
[0097] In one embodiment, in order to further reduce the difficulty of modifying environment variables, the host computer server can be generated according to the following steps A and B:
[0098] Step A: Receive the target variable names and target debug values respectively corresponding to multiple target environment variables sent by the target network; the target variable names and target debug values corresponding to the target environment variables are input by the tester on the variable management page corresponding to the target network.
[0099] Here, the target network can be a web network. The present disclosure embodiment can also provide a pre-built web variable management interface, in which various environment variables corresponding to uboot are classified and displayed. When it is necessary to modify the environment variables, the tester can access the web variable management interface through a specific network address and select the target environment variables and set the corresponding target debug values in a visual manner on the interface. After the modification is completed, the web network corresponding to the web management interface can send the target variable names and target debug values respectively corresponding to the target environment variables to the host computer server.
[0100] Step B: Generate an environment variable file according to the target variable name and target debug value.
[0101] Specifically, the host computer server can directly generate an environment variable file according to the target variable names and target debug values sent by the web network. Optionally, the host computer server can also generate an environment variable file according to the target variable names and target debug values sent by the web network in accordance with a pre-agreed encryption method.
[0102] In this way, using the web interface to implement variable modification greatly reduces the operation threshold, does not require the user to have professional command-line operation knowledge, and even ordinary technical personnel can easily get started. Moreover, through the carefully designed interface, the variables can be classified and displayed, which is convenient for users to search and modify.
[0103] In one embodiment, in order to ensure that the web network can accurately transmit the modified environment variables to the host computer server, a server-client model can also be built between the host computer server and the web network. Among them, a client program of the server-client model runs in the web network, and a server program of the server-client model runs in the host computer server. For the above step A, it can be implemented according to the following steps:
[0104] Using a server program, receive the target variable names and target debug values corresponding to multiple target environment variables sent by the target network through a client program.
[0105] Exemplarily, after a tester modifies the environment variables in the web variable management interface, the web network can use the deployed client program to send the target variable names and target debug values corresponding to the multiple target environment variables to the server program running in the host computer server. In this way, the server program can receive each target variable name and target debug value sent by the client program.
[0106] In this way, by using the server-client model established between the host computer server and the web network to transfer the modified environment variables, it is possible to improve the convenience of variable modification while ensuring the accuracy of variable transfer.
[0107] In one embodiment, the above S103 can be implemented according to the following steps:
[0108] S103-1: Use the target variable name to obtain the current variable values of each target environment variable in the bootloader from the memory.
[0109] In specific implementation, during the uboot startup phase, uboot will first obtain the current variable values of each target environment variable from the external ROM and store them in the memory. If there is no environment variable file, uboot can directly use the current variable values in the memory to complete the uboot startup. In the case of the existence of an environment variable file, the application programming interface (API) of uboot can be called to obtain the current variable values of each target environment variable in uboot from the memory. For example, according to the target variable name, the env_get() function can be used to obtain the current variable value of the environment variable with the same name from the memory.
[0110] S103-2: Determine whether there is an environment variable to be modified in the target environment variables where the current variable value is inconsistent with the target debug value.
[0111] In specific implementation, for each target environment variable, it can be determined whether the current variable value of the target environment variable is consistent with the target debug value. If so, it is determined that the target environment variable does not need to be modified. If not, it is determined that the target environment variable is an environment variable to be modified. In this way, by judging each target environment variable, it can be determined whether there is an environment variable to be modified among the target environment variables.
[0112] S103-3: If so, save the target debug value of the environment variable to be modified in the external storage.
[0113] Exemplarily, if it is determined that there are environment variables to be modified, the target debug values of each environment variable to be modified can be stored in the external ROM corresponding to the device. For example, the target debug value of the environment variable to be modified can be used to replace the current variable value of this environment variable in the external ROM.
[0114] If there are no environment variables to be modified, it means that the variable values of each target environment variable currently loaded in the memory are the latest values. Then, the bootloader can be directly started using the current variable values, and when the bootloader is successfully started, the kernel and root system files of the device can be started.
[0115] That is, in the case of no environment variables to be modified, the uboot can be directly started using the variable values already recorded in the memory, and when the start is successful, the kernel and root system files of the device can be started. In this way, the operation of modifying the environment variables using the environment variable file can be implemented before the kernel and root system files are started, effectively improving the debugging efficiency.
[0116] Optionally, since the program needs to be executed inside the memory, when there are environment variables to be modified, the API interface needs to be called first to modify the value of the environment variable to be modified in the DDR, and after the modification is completed, the API interface is called again to write it to the external ROM. For example, in the case of having environment variables to be modified, the env_set() function can be called to write the target debug value of the environment variable to be modified into the memory, and the env_save() function can be called to write the target debug value of the environment variable to be modified into the external ROM.
[0117] Furthermore, after the target debug value is saved in the external memory, the uboot will be restarted. At this time, the target debug values of each target environment variable in the external ROM will be loaded into the memory value, and the variable values of each unmodified environment variable will also be loaded into the memory. Then, the uboot is restarted using the variable values in the memory. At this time, since the latest modified variable values have been stored in the external ROM, the modification and debugging of the uboot environment variables can be realized using the latest modified variable values.
[0118] In one embodiment, if the device fails to successfully establish a connection with the host computer server or fails to download the environment variable file, the uboot can be directly started according to the variable values of each environment variable currently loaded in the memory. Among them, the failure to download the environment variable file may be due to the non-existence of the environment variable file in the host computer server or the failure of the download process due to an error. Or, in the case of successfully establishing a connection with the host computer server or failing to download the environment variable file, the following steps P1 to P3 can also be executed:
[0119] P1: Determine whether there is a downloaded historical environment variable file.
[0120] During specific implementation, the device can first determine whether there is a downloaded historical environment variable file. That is, determine whether the environment variables have been modified historically.
[0121] P2: If so, determine whether to directly start the bootloader based on the time difference between the acquisition time of the historical environment variable file and the current time and / or the coverage of the target environment variables in the historical environment variable file.
[0122] During specific implementation, if there is a historical environment variable file, the time difference between the acquisition time of the most recently downloaded historical environment file and the current time can be determined, and the ratio between the number of target environment variables in the most recently downloaded historical environment file and the total number of environment variables corresponding to uboot can be determined. The coverage of the target environment variables in the most recently downloaded historical environment file can be determined based on this ratio.
[0123] Among them, if the time difference is less than the preset time difference, it can be explained that the environment variables have been updated recently, and the possibility of updating the environment variables again at this time is relatively small. Therefore, it can be determined that uboot can be directly started. On the contrary, if the time difference is not less than the preset time difference, it can be explained that the environment variables have not been updated for a long time, and the possibility of updating the environment variables again at this time is relatively large. Therefore, an attempt can be made to re - establish a connection with the upper - computer server and attempt to re - download the environment variable file until the number of retries reaches the preset number or the latest environment variable file is downloaded. If the preset number of times is reached, it can be determined that uboot can be directly started; if the latest environment variable file is downloaded, the environment variable update and debugging can be performed according to the steps of S102 - S104 above.
[0124] If the coverage is greater than the preset coverage, it can be explained that a large number of environment variables were updated during the most recent variable update, and the possibility of updating the environment variables again at this time is relatively small. Therefore, it can be determined that uboot can be directly started. On the contrary, if the coverage is not greater than the preset coverage, it can be explained that only a small number of environment variables were updated during the most recent variable update, and the possibility of updating the environment variables again at this time is relatively large. Therefore, an attempt can be made to re - establish a connection with the upper - computer server and attempt to re - download the environment variable file until the number of retries reaches the preset number or the latest environment variable file is downloaded.
[0125] Optionally, if at least one of the time difference is less than the preset time difference and the coverage is greater than the preset coverage occurs, it can be determined to directly start the bootloader; if the time difference is not less than the preset time difference and the coverage is not greater than the preset coverage, an attempt can be made to re - establish a connection with the host computer server and attempt to re - download the environment variable file.
[0126] Optionally, in addition to combining the time difference and the coverage, the debugging results corresponding to the historical environment files downloaded last time can also be combined. For example, if at least one of the time difference is less than the preset time difference, the coverage is greater than the preset coverage, the debugging results corresponding to the historical environment files downloaded last time indicate successful debugging or indicate that there are no environment variables to be modified, it can be determined that the bootloader can be directly started; conversely, if the time difference is not less than the preset time difference and the coverage is not greater than the preset coverage, and the debugging results indicate debugging failure, an attempt can be made to re - establish a connection with the host computer server and attempt to re - download the environment variable file.
[0127] P3: If so, obtain the current variable values of each environment variable in the bootloader from the external memory, and use the current variable values to start the bootloader.
[0128] In specific implementation, when it is determined that the uboot can be directly started, the current variable values of each environment variable can be obtained from the external ROM of the device and loaded into the device memory, and then the uboot can be started using these variable values stored therein.
[0129] In this way, by combining the time difference and the coverage, etc., to determine the next operation of the device, it is possible to reasonably handle the situation where the connection with the host computer server fails to be successfully established or the environment variable file fails to be downloaded, and improve the rationality of debugging.
[0130] As Figure 4 shown, the following are the specific implementation flowcharts of a debugging method provided by an embodiment of the present disclosure, which may include the following steps:
[0131] S401: The host computer server generates an environment variable file according to the target variable names and target debugging values corresponding to each target environment variable to be modified.
[0132] S402: Set the host computer server and the device in the same network segment and turn on the device.
[0133] S403: Whether the device has downloaded the environment variable file.
[0134] Specifically, during the startup phase of the device's bootloader, a connection is established with the host computer server, and after the connection is made, an attempt is made to download the latest environment variable file from the host computer server to determine whether the environment variable file can be obtained.
[0135] If so, execute the following S404; if not, execute the following S409.
[0136] S404: Parse the target variable names and target debug values corresponding to multiple target environment variables to be debugged from the environment variable file, and obtain the current variable values of each target environment variable from the memory.
[0137] S405: Determine whether there is an environment variable to be modified among the target environment variables where the current variable value is inconsistent with the target debug value.
[0138] If so, execute the following S406; if not, execute the following S409.
[0139] S406: Write the target debug value of the environment variable to be modified into the memory.
[0140] For example, the current variable value of the environment variable to be modified in the memory can be overwritten with the target debug value of the environment variable to be modified.
[0141] S407: Save the target debug value of the environment variable to be modified in the external ROM corresponding to the device.
[0142] S408: After successful saving, restart the bootloader to obtain the debug result.
[0143] For example, after successful saving, use the do_reset() function to restart the device, and when restarting, restart the bootloader to start the uboot program with the variable values of the modified environment variables.
[0144] S409: Use the current variable values of each environment variable stored in the memory to start the bootloader.
[0145] Regarding the specific implementation processes of the above S401 to S409, reference can be made to the above respective embodiments, and details are not elaborated here.
[0146] In this way, on devices with network functions, the environment variables can be modified through the method provided by the embodiments of the present disclosure without relying on a debug serial port. By modifying the execution logic of the uboot, it can write the environment variables to be written at one time in the form of a file by the host computer server, without the need for multiple operations, improving the writing efficiency. Due to the server / client mechanism, each device in the same network segment as the host computer server can download the environment variable file from the host computer server when starting up, realizing batch update.
[0147] Those skilled in the art can understand that in the above method of the specific implementation manner, the writing order of each step does not mean a strict execution order and does not impose any limitation on the implementation process. The specific execution order of each step should be determined according to its function and possible internal logic.
[0148] Based on the same inventive concept, the embodiments of the present disclosure also provide a debugging device corresponding to the debugging method. Since the principle of solving problems by the device in the embodiments of the present disclosure is similar to the above debugging method of the embodiments of the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be elaborated.
[0149] As Figure 5 shown, it is a schematic diagram of a debugging device provided by an embodiment of the present disclosure, including:
[0150] A download module 501, configured to establish a connection with a host computer server during the startup phase of the device's bootloader, and download the latest environment variable file from the host computer server after the connection is established;
[0151] An analysis module 502, configured to analyze the target variable names and target debugging values corresponding to a plurality of target environment variables to be debugged from the environment variable file;
[0152] A modification module 503, configured to modify the target environment variables in the bootloader by using the target variable names and target debugging values;
[0153] A debugging module 504, configured to restart the bootloader based on the modification result to obtain a debugging result.
[0154] In a possible implementation manner, when the debugging module 504 restarts the bootloader based on the modification result to obtain a debugging result, it is configured to:
[0155] Restart the bootloader based on the modification result, and determine that the debugging is successful when the bootloader restarts successfully;
[0156] Or, when the bootloader fails to restart, determine that the debugging fails, and send the reason for the debugging failure to the host computer server, so that the host computer server modifies the existing environment variable file based on the reason for the debugging failure.
[0157] In a possible implementation manner, the device is any one of a plurality of devices located in the same network segment as the host computer server;
[0158] The download module 501, when establishing a connection with the host computer server during the startup phase of the device's bootloader and downloading the latest environment variable file from the host computer server after the connection is established, is used for:
[0159] If a connection with the host computer server is successfully established, send a list download request to the host computer server;
[0160] Receive the request response sent by the host computer server and parse out the environment variable file from the request response.
[0161] In a possible implementation manner, when the parsing module 502 parses out the target variable names and target debugging values corresponding to multiple target environment variables to be debugged from the environment variable file, it is used for:
[0162] Decrypt the environment variable file according to the decryption method that matches the agreed encryption method to obtain the file header content, middle content, and file tail content of the environment variable file;
[0163] When both the file header content and the file tail content meet the preset requirements, parse out the target variable names and the target debugging values from the middle content.
[0164] In a possible implementation manner, the device further includes:
[0165] A generation module 505, which is used to generate the environment variable file in the host computer server according to the following steps:
[0166] Receive the target variable names and target debugging values corresponding to multiple target environment variables sent by the target network; the target variable names and target debugging values corresponding to the target environment variables are input by the tester on the variable management page corresponding to the target network;
[0167] Generate the environment variable file according to the target variable names and the target debugging values.
[0168] In a possible implementation manner, a client program runs in the target network, and a server program runs in the host computer server;
[0169] When the generation module 505 receives the target variable names and target debugging values corresponding to multiple target environment variables sent by the target network, it is used for:
[0170] Use the server program to receive the target variable names and target debugging values corresponding to multiple target environment variables sent by the target network through the client program.
[0171] In a possible implementation manner, when the modification module 503 modifies the target environment variable in the bootloader by using the target variable name and the target debug value, it is configured to:
[0172] Use the target variable name to obtain the current variable value of each target environment variable in the bootloader from the memory;
[0173] Determine whether there is an environment variable to be modified in the target environment variable whose current variable value is inconsistent with the target debug value;
[0174] If so, save the target debug value of the environment variable to be modified in the external memory; or,
[0175] If there is no environment variable to be modified, directly use the current variable value to start the bootloader, and start the kernel and root system files of the device when the bootloader starts successfully.
[0176] In a possible implementation manner, the device further includes a startup module 506, configured to:
[0177] If the connection with the upper computer server is not successfully established, or the environment variable file is not downloaded, determine whether there is a downloaded historical environment variable file;
[0178] If so, determine whether to directly start the bootloader according to the time difference between the acquisition time of the historical environment variable file and the current time and / or the coverage of the target environment variable in the historical environment variable file;
[0179] If so, obtain the current variable value of each environment variable in the bootloader from the external memory, and use the current variable value to start the bootloader.
[0180] The description of the processing flow of each module in the device and the interaction flow between each module can refer to the relevant description in the above method embodiment, which will not be elaborated here.
[0181] Based on the same technical concept, an embodiment of the present application further provides a computer device. Refer to Figure 6 As shown, it is a schematic structural diagram of a computer device provided by an embodiment of the present application, including:
[0182] A processor 601, a memory 602, and a bus 603. Among them, the memory 602 stores machine-readable instructions executable by the processor 601. The processor 601 is configured to execute the machine-readable instructions stored in the memory 602. When the machine-readable instructions are executed by the processor 601, the processor 601 performs the following steps: S101: At the startup stage of the device's bootloader, establish a connection with the host computer server, and after the connection, download the latest environment variable file from the host computer server; S102: From the environment variable file, parse out the target variable names and target debug values respectively corresponding to multiple target environment variables to be debugged; S103: Use the target variable names and target debug values to modify the target environment variables in the bootloader; and S104: Restart the bootloader based on the modification result to obtain a debug result.
[0183] The above-mentioned memory 602 includes a memory 6021 and an external memory 6022; here, the memory 6021 is also called the internal memory, which is used to temporarily store the operation data in the processor 601 and the data exchanged with the external memory 6022 such as a hard disk. The processor 601 exchanges data with the external memory 6022 through the memory 6021. When the computer device is running, the processor 601 communicates with the memory 602 through the bus 603, so that the processor 601 executes the execution instructions mentioned in the above method embodiments.
[0184] The embodiments of the present disclosure also provide a computer-readable storage medium, on which a computer program is stored. When the computer program is run by a processor, it executes the steps of the debugging method described in the above method embodiments. Among them, the storage medium can be a volatile or non-volatile computer-readable storage medium.
[0185] The embodiments of the present disclosure also provide a computer program product. The computer product carries program code, and the instructions included in the program code can be used to execute the steps of the software update method described in the above method embodiments. For details, refer to the above method embodiments and will not be elaborated here.
[0186] The computer program product can be specifically implemented in a way of hardware, software, or a combination thereof. In an optional embodiment, the computer program product is specifically embodied as a computer storage medium. In another optional embodiment, the computer program product is specifically embodied as a software product, such as a Software Development Kit (SDK), etc.
[0187] Those skilled in the art can clearly understand that for the convenience and conciseness of description, the specific working processes of the systems and devices described above can refer to the corresponding processes in the foregoing method embodiments, and will not be elaborated herein. In several embodiments provided in the present disclosure, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division, and there can be other division methods in actual implementation. For another example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the couplings or direct couplings or communication connections shown or discussed with each other can be through some communication interfaces, and the indirect couplings or communication connections of the devices or units can be in electrical, mechanical, or other forms.
[0188] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they can be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0189] In addition, in each embodiment of the present disclosure, the functional units can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit.
[0190] If the functions are implemented in the form of software function units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium executable by a processor. Based on such an understanding, the technical solution of the present disclosure, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in each embodiment of the present disclosure. The foregoing storage medium includes: various media that can store program codes such as USB flash drives, mobile hard disks, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical discs.
[0191] If the technical solution of this application involves personal information, the product using the technical solution of this application has clearly informed the personal information processing rules and obtained the individual's voluntary consent before processing the personal information. If the technical solution of this application involves sensitive personal information, the product using the technical solution of this application has obtained the individual's separate consent before processing the sensitive personal information, and at the same time meets the "explicit consent" requirement. For example, on personal information collection devices such as cameras, clear and prominent signs are set to inform that the personal information collection scope has been entered and personal information will be collected. If the individual voluntarily enters the collection scope, it is deemed that he or she agrees to the collection of his or her personal information; or on the device that processes personal information, the personal information processing rules are notified by obvious signs / information, and the individual's authorization is obtained through pop-up information or by asking the individual to upload his or her personal information; among them, the personal information processing rules may include information such as the personal information processor, the purpose of personal information processing, the processing method, and the type of personal information processed.
[0192] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure is described in detail with reference to the aforementioned embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the aforementioned embodiments within the technical scope disclosed in the present disclosure, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure shall be based on the protection scope of the claims.
Claims
1. A debugging method, characterized in that, Applied to a device, including: At the startup stage of the device's bootloader, establish a connection with the host server, and after the connection is established, download the latest environment variable file from the host server; From the environment variable file, parse out the target variable names and target debug values corresponding to multiple target environment variables to be debugged; Use the target variable names and target debug values to modify the target environment variables in the bootloader; Restart the bootloader based on the modification result to obtain a debug result.
2. The method according to claim 1, characterized in that The restarting the bootloader based on the modification result to obtain a debug result includes: Restart the bootloader based on the modification result, and when the bootloader restarts successfully, determine that the debugging is successful; Or, when the bootloader fails to restart, determine that the debugging fails and send the reason for the debugging failure to the host server, so that the host server modifies the existing environment variable file based on the reason for the debugging failure.
3. The method according to claim 1, wherein The device is any one of multiple devices in the same network segment as the host server; The establishing a connection with the host server at the startup stage of the device's bootloader and downloading the latest environment variable file from the host server after the connection is established includes: If a connection with the host server is successfully established, send a list download request to the host server; Receive the request response sent by the host server and parse out the environment variable file from the request response.
4. The method according to any one of claims 1 to 3, characterized in that, The parsing out the target variable names and target debug values corresponding to multiple target environment variables to be debugged from the environment variable file includes: Decrypt the environment variable file according to the decryption method matching the agreed encryption method to obtain the file header content, middle content, and file tail content of the environment variable file; When both the file header content and the file tail content meet the preset requirements, parse out the target variable names and the target debug values from the middle content.
5. The method according to any one of claims 1 to 3, characterized in that The environment variable file in the host server is generated according to the following steps: Receive the target variable names and target debug values corresponding to multiple target environment variables sent by the target network; the target variable names and target debug values corresponding to the target environment variables are input by the tester on the variable management page corresponding to the target network; Generate the environment variable file according to the target variable names and the target debug values.
6. The method according to claim 5, wherein A client program runs in the target network, and a server program runs in the host server; The receiving the target variable names and target debug values corresponding to multiple target environment variables sent by the target network includes: Use the server program to receive the target variable names and target debug values corresponding to multiple target environment variables sent by the target network through the client program.
7. The method according to claim 1, wherein The using the target variable names and target debug values to modify the target environment variables in the bootloader includes: Using the target variable name, obtain the current variable values of each of the target environment variables in the bootloader from memory; Determine whether there is an environment variable to be modified in the target environment variables where the current variable value is inconsistent with the target debug value; If so, save the target debug value of the environment variable to be modified in an external memory; or If there is no environment variable to be modified, directly use the current variable value to start the bootloader, and when the bootloader starts successfully, start the kernel and root system files of the device.
8. The method according to claim 1, wherein The method further includes: If the connection to the host computer server cannot be successfully established or the environment variable file cannot be downloaded, determine whether there is a downloaded historical environment variable file; If so, determine whether to directly start the bootloader according to the time difference between the acquisition time of the historical environment variable file and the current time and / or the coverage of the target environment variables in the historical environment variable file; If so, obtain the current variable values of each environment variable in the bootloader from the external memory, and use the current variable values to start the bootloader.
9. A debugging device, characterized in that, Applied to a device, including: A download module, configured to establish a connection with a host computer server during the startup phase of the device's bootloader, and download the latest environment variable file from the host computer server after the connection is established; A parsing module, configured to parse out the target variable names and target debug values corresponding to multiple target environment variables to be debugged from the environment variable file; A modification module, configured to modify the target environment variables in the bootloader by using the target variable names and target debug values; A debugging module, configured to restart the bootloader based on the modification result to obtain a debugging result.
10. A computer device, characterized in that, Including: A processor and a memory, the memory stores machine-readable instructions executable by the processor, the processor is configured to execute the machine-readable instructions stored in the memory, and when the machine-readable instructions are executed by the processor, the processor executes the steps of the debugging method according to any one of claims 1 to 8.
11. A computer program product comprising a computer program, characterized in that, When the computer program is run on a computer device, the computer device executes the steps of the debugging method according to any one of claims 1 to 8.
Citation Information
Cited By
Equipment debugging method and system and computer equipment
CN121901088A