A device, method and medium for testing processor peripheral use cases
By using μCOS-II real-time operating system and parallel processing technology in processor peripheral use case testing, the problem of insufficient multi-task parallel processing and real-time feedback support in traditional testing methods is solved, and efficient testing and debugging is achieved.
Patent Information
- Application Number
- CN202410109219.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-25
- Publication Date
- 2025-03-11
- Estimated Expiration
- 2044-01-25
AI Technical Summary
Traditional processor peripheral use case testing methods lack support for multitasking parallel processing and real-time feedback, resulting in increased test time and reduced efficiency.
Using μCOS-II real-time operating system, a device and method is designed, including a command line task module and a peripheral test task processing module, which supports multi-port parallel processing and serial debugging assistant, and realizes parallel testing and real-time monitoring of multiple peripherals.
Parallel testing of all modules is realized, testing efficiency is improved, debugging convenience is increased, and chip development and application rate is improved.
Smart Images

Figure CN117931551B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of chip and peripheral testing. Specifically, embodiments of the present application relate to an apparatus, method and medium for testing processor peripheral use cases. Background Art
[0002] During the development of microcontrollers and similar devices, multiple peripheral interfaces usually need to be tested to ensure the compatibility and performance of hardware and software. Traditional testing methods usually focus on single functional testing and lack support for multi-task parallel processing and real-time feedback, which increases testing time and reduces efficiency. Summary of the invention
[0003] The purpose of the embodiments of the present application is to provide a device, method and medium for testing processor peripheral use cases. The embodiments of the present application can be used to implement parallel testing of all modules. The device and method also provide a serial port debugging assistant, which can obtain the test status and CPU usage of each test case, and can start and terminate the operation of each test task, thereby facilitating debugging. The embodiments of the present application not only improve the test efficiency, but also increase the convenience of debugging, thereby improving the rate of chip development and application.
[0004] In the first aspect, an embodiment of the present application provides a device for testing processor peripheral use cases, the device adopts the μCOS-II real-time operating system, and the device includes: a command line task module, configured to configure serial port communication parameters, enable SCI interrupts, and register a command table to enter a loop to parse the input command when the input is read; a peripheral test task processing module, configured to create a peripheral test task function through a start task, the peripheral test task function is used to perform peripheral testing of the corresponding peripheral, the peripheral test task function of each test task is stored in the corresponding peripheral task folder, the peripheral function for initializing, configuring, sending and receiving data for each peripheral to be tested is implemented in a respective C file, and the corresponding test task realizes the decoupling of the task function and the peripheral initialization function by calling the operations in the C file.
[0005] In some embodiments, the peripheral test task processing module further includes: a peripheral program parallel processing sub-module, configured to perform multi-port parallel processing so that different test tasks can run in parallel within the same time period; a serial port debugging assistant sub-module, configured to provide real-time feedback on the test status and CPU usage of each port in the multiple ports, start or terminate test cases in real time, and monitor or debug the test tasks of each port in real time.
[0006] In some embodiments, the peripheral test task function is used to test multiple peripherals, wherein the multiple peripherals include: an integrated circuit module IIC, a direct memory access unit DMA, a digital-to-analog converter ADC, a serial peripheral interface SPI, a serial communication interface SCI, a controller area network CAN or a local interconnect network LIN, and the peripheral test task function includes a peripheral test task function, and the peripheral test task function includes: a peripheral test module startup test function, a peripheral test module result detection function or a peripheral test module initialization function.
[0007] In some embodiments, each test task file has two global variables, the first global variable is used to represent the number of rounds that have been tested for the corresponding peripheral device, and the second global variable is used to represent the number of times the test for the corresponding peripheral device has failed.
[0008] In some embodiments, the command line task module is also used to store initialization functions, command processing functions, text display functions, and command lists, corresponding command functions, and command parsing functions related to the serial port communication SCI.
[0009] In a second aspect, some embodiments of the present application provide a method for testing processor peripheral use cases, which is applied to the device as described in the above-mentioned first aspect embodiment, and the method includes: when the system starts, initializing the μCOS-II real-time operating system, wherein the initialization process includes task creation and resource allocation; creating a start task and a command CMD task; according to the requirements of the peripheral use case, creating a corresponding number of test tasks, and assigning each test task to the μCOS-II real-time operating system for management; starting to execute the peripheral test task; and providing real-time feedback on the test results.
[0010] In some embodiments, the creation of the start task and the command CMD task includes: configuring the serial communication SCI serial port information and initializing the command table.
[0011] In some embodiments, the initiating and executing the test task of the peripheral device includes: each test task executes the test of the peripheral device use case in parallel, and operates and monitors multiple peripheral devices at the same time.
[0012] In some embodiments, the real-time feedback of test results includes: collecting and displaying the execution status and results of peripheral use cases in real time through the task scheduling and communication mechanism of the μCOS-II real-time operating system.
[0013] In a third aspect, some embodiments of the present application provide a computer-readable communication medium having a computer program stored thereon, wherein the computer program, when executed by a processor, can implement the method described in any embodiment of the second aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0015] Figure 1 One of the block diagrams of the apparatus for testing a processor peripheral use case provided in an embodiment of the present application;
[0016] Figure 2 The second block diagram of the device for testing a processor peripheral use case provided in an embodiment of the present application;
[0017] Figure 3 One of the method flow charts for processor peripheral use case testing provided in an embodiment of the present application;
[0018] Figure 4 A second flowchart of a method for testing a processor peripheral use case provided in an embodiment of the present application;
[0019] Figure 5 A third flowchart of a method for testing a processor peripheral use case provided in an embodiment of the present application;
[0020] Figure 6 A block diagram of the composition of an apparatus for testing processor peripheral use cases provided in an embodiment of the present application. DETAILED DESCRIPTION
[0021] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.
[0022] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0023] At least in order to overcome the technical problems existing in the background technology and the defect that only one use case can be tested in the bare metal state of the related technology, the device for processor peripheral use case testing provided by the embodiment of the present application is characterized by its multi-port parallel processing capability, which can simultaneously process peripheral programs such as integrated circuit module IIC, direct memory access unit DMA, digital-to-analog converter ADC, serial peripheral interface SPI, serial communication interface SCI, controller area network CAN and local interconnect network LIN, and it can display the running status of each process in real time through the serial port debugging assistant, such as the total number of runs, successes and failures of each task. At the same time, some embodiments of the present application can also send commands to the chip through the serial port to control some parameters of each peripheral routine and the start and suspension of tasks. If there is no serial port debugging assistant provided by the embodiment of the present application, the system also supports the use of GPIO pins to represent the running status of each peripheral thread, flashing indicates normal operation, and constant light indicates an abnormality.
[0024] Compared with the related technologies, some embodiments of the present application have at least the following technical advantages: First, some embodiments of the present application can process multiple test tasks in parallel, significantly improving the test efficiency; Second, some embodiments of the present application monitor and adjust the test process in real time, making the test more flexible and accurate; Third, some embodiments of the present application simplify the test process through an intuitive interface and reduce operating requirements; Fourth, the automatic statistics and reporting functions of some embodiments of the present application reduce human errors and provide detailed test records.
[0025] Please see Figure 1 , Figure 1 A device for testing processor peripheral use cases is provided for an embodiment of the present application. The device adopts a μCOS-II real-time operating system and includes: a command line task module 110, a peripheral test task processing module 120 and a μCOS-II real-time operating system 130.
[0026] The command line task module is configured to configure serial port communication parameters, enable SCI interrupts, and register the command table to enter a loop to parse the input command when the input is read.
[0027] The peripheral test task processing module is configured to create a peripheral test task function through a start task, wherein the peripheral test task function is used to perform peripheral testing of the corresponding peripheral. The peripheral test task function of each test task is stored in the corresponding peripheral task folder, and the peripheral functions for initializing, configuring, sending and receiving data for each peripheral to be tested are implemented in their respective C files, and the corresponding test task realizes the decoupling of the task function and the peripheral initialization function by calling the operations in the C file.
[0028] like Figure 2As shown, in some embodiments of the present application, Figure 1 The peripheral test task processing module 120 further includes: a peripheral program parallel processing submodule 121 and a serial port debugging assistant submodule 122 .
[0029] The peripheral program parallel processing submodule is configured to perform multi-port parallel processing so that different test tasks can run in parallel within the same time period.
[0030] The serial port debugging assistant submodule is configured to provide real-time feedback on the test status and CPU usage of each port in the multiple ports, start or terminate test cases in real time, and monitor or debug the test tasks of each port in real time.
[0031] In some embodiments of the present application, the peripheral test task function is used to test multiple peripherals, wherein the multiple peripherals include: integrated circuit module IIC, direct memory access unit DMA, digital-to-analog converter ADC, serial peripheral interface SPI, serial communication interface SCI, controller area network CAN or local interconnect network LIN, the peripheral test task function includes SPI peripheral test task function, the peripheral test task function includes: peripheral test module startup test function, peripheral test module result detection function or peripheral test module initialization function, the peripheral test module exemplarily includes: any one or more of multiple peripheral test modules such as SPI, IIC, CAN, DMA, SCI, etc. That is to say, the test system of some embodiments of the present application can test multiple peripherals such as SPI, IIC, CAN, DMA, SCI, etc. at the same time, and users can add, change, or delete peripheral use cases according to their needs.
[0032] In some embodiments of the present application, there are two global variables in the file of each test task, the first global variable is used to represent the number of rounds of testing currently completed for the corresponding peripheral, and the second global variable is used to represent the number of times the current test of the corresponding peripheral has failed. The first global variable is a parameter corresponding to any peripheral test module, and the second global variable is also a parameter corresponding to any peripheral test module. Exemplary peripheral test modules include: SPI, IIC, CAN, DMA or SCI, etc.
[0033] In some embodiments of the present application, the command line task module is also used to store initialization functions, command processing functions, text display functions, and command lists, corresponding command functions, and command parsing functions related to the serial port communication SCI.
[0034] like Figure 3As shown, some embodiments of the present application provide a method for testing processor peripheral use cases, which is applied in the device as described in the first aspect embodiment above, and the method includes: S101, when the system starts, initializing the μCOS-II real-time operating system, wherein the initialization process includes task creation and resource allocation; S102, creating a start task and a command CMD task; S103, according to the requirements of the peripheral use case, creating a corresponding number of test tasks, and assigning each test task to the μCOS-II real-time operating system for management; S104, starting to execute the test task of the peripheral; S105, real-time feedback of the test results.
[0035] In some embodiments of the present application, the creation of the start task and the command CMD task includes: configuring the serial communication SCI serial port information and initializing the command table.
[0036] In some embodiments of the present application, the initiation of the peripheral test task includes: each test task executes the test of the peripheral use case in parallel, and operates and monitors multiple peripherals at the same time.
[0037] In some embodiments of the present application, the real-time feedback test results include: collecting and displaying the execution status and results of the peripheral use cases in real time through the task scheduling and communication mechanism of the μCOS-II real-time operating system.
[0038] The following describes the method for testing processor peripheral use cases in some embodiments of the present application by taking the peripheral SPI as an example.
[0039] like Figure 4 As shown, the method for testing a processor peripheral use case in some embodiments of the present application exemplarily includes:
[0040] Step one, start.
[0041] The second step is initialization: when the system starts, the μCOS-II real-time operating system is initialized, including task creation, resource allocation, etc.
[0042] For example, Figure 4 The initialization process shown exemplarily includes: device initialization, interrupt initialization, timer initialization, kernel initialization, memory initialization, CPU initialization and real-time operating system RTOS (for example, the real-time operating system is referred to as UCOSii in this article) initialization.
[0043] The second step is to create a starting task.
[0044] For example, Figure 4The task shown includes creating IIC tasks, creating SPI tasks, creating DMA tasks, and creating other peripheral tasks (these peripherals include CAN or SCI, etc.). The corresponding task creation includes: hardware initialization (register configuration) of the corresponding peripherals, driver initialization, task creation, and initialization test parameters. Among them, the creation of SPI tasks includes: LED initialization, SPI initialization cfg, judging whether the SPI representation is equal to 1, if it is equal, starting the SPI test, SPI checking the test results, judging whether the check results are consistent, if it is wrong, the number of errors is increased by one, if it is correct and the number of correct tests is increased by one, delaying 5 milliseconds, and judging whether to continue the SPI test.
[0045] The third step is to create a CMD task, initialize SCI, enable SCI interrupt, monitor whether there is CMD input, and search the command table if there is none.
[0046] It should be noted that in some embodiments of the present application, a start task and a command (CMD) task are created: SCI serial port information is configured, the command table is initialized, etc.; peripheral test task creation: a corresponding number of tasks are created according to the requirements of the peripheral use case, and are assigned to the μCOS-II real-time operating system for management; peripheral task startup execution: each task executes the test of the peripheral use case in parallel, that is, multiple peripherals are operated and monitored at the same time. Real-time feedback: The execution status and results of the peripheral use case are collected in real time through the task scheduling and communication mechanism of the μCOS-II real-time operating system.
[0047] That is to say, in some embodiments of the present application, in the starting task, each peripheral test task (such as: SPI task, IIC task or DMA task, etc.) is created. These tasks will perform specific peripheral test work. In the command line task, configure the serial communication related parameters, enable the SCI interrupt, and register the command table to enter the loop. Once the input is read, the input command is parsed. The command line task layer in the system mainly stores the initialization function, command processing function, text display function, command list, corresponding command function, and command parsing function related to serial communication (SCI). The starting task creates all peripheral test module tasks. The corresponding function of each task is located in the corresponding file under the corresponding peripheral task folder. For example, the SPI test file is mainly responsible for the SPI task function, including the SPI startup test function, the SPI result detection function, the SPI module initialization function, etc. These functions are mainly responsible for the processing of the test results. There are two global variables in each task file. For example, for the SPI peripheral test module, SPITestTime represents how many rounds have been tested, and SPIError represents the current number of test failures.
[0048] The specific peripheral initialization, configuration, sending and receiving operations of some embodiments of the present application are implemented in their own c files, for example, SPI configuration related files. These functions are called by tasks related to SPI testing, which realizes the decoupling of RTOS task functions and peripheral functions, making the code clearer and easier to maintain.
[0049] Finally, the operation process is as follows:
[0050] 1. Connect the development board to the computer
[0051] 2 Open the serial port debugger (such as XCOM, putty, etc.)
[0052] 3. Confirm the serial port corresponding to the development board in the device manager
[0053] 4 Select the corresponding serial port in the serial port debugger and set the bit rate to 9600
[0054] 5Open the serial port and reset the development board
[0055] 6 Input commands to the serial debugging assistant, and the development board returns data through SCI. You can view the current running status of peripheral tasks, start or stop any peripheral task, or reset test results, etc.
[0056] Through the above steps, the peripheral use case test system based on the μCOS-II real-time operating system provided in some embodiments of the present application can complete various functions such as creation of test tasks, reception and processing of test commands, and real-time feedback of test results, thereby more efficiently realizing the integrated testing of various peripherals.
[0057] like Figure 5 As shown, the method for testing a processor peripheral use case for SPI provided by some embodiments of the present application exemplarily includes:
[0058] The user performs a reset, creates a command task and creates a startup task.
[0059] The startup task can be used to initialize the tasks corresponding to various peripheral test modules to be tested, such as the IIC task, the CAN task, and the DMA task. Take the SPI task (this example takes the SPI task as an example, and the test system can simultaneously test the corresponding tasks corresponding to various peripherals such as IIC, CAN, DMA, SCI, etc.): for the initialization of the SPI task: initialize the SPI device and return the initialization operation result to the SPI task (or test task); start the test SPI module and feedback the test result to the SPI test task; send the command to monitor the test result to the device, and the device feedbacks the test result to the SPI test task.
[0060] Used to send CAN information to the command task, the command task processes the interrupt, parses the command, sends instructions to the device to abandon CPU resources and delay, and the device feeds back display information to the user; the user sends a request to stop SPI to the command task, and the command task processes the interrupt request item. The SPI test task provides a parsing command, and the SPI flag can be sent to the SPI test task through the parsing command; the user generates and sends an instruction to start SPI to the command task, the command task receives the start SPI instruction, and the SPI flag is set to 1 or 0.
[0061] It should be noted that Figure 4 and Figure 5 The SPI task provides a method process diagram. It can be understood that the same operation as SPI is performed for different peripheral test modules (for example, IIC, DMA, etc.).
[0062] like Figure 6 As shown, the figure exemplarily illustrates a layered architecture diagram of an apparatus for processor peripheral use case testing in some embodiments of the present invention, which includes: a hardware layer, wherein the hardware layer includes a CPU, a timer, and peripherals (for example, Figure 6 The peripherals include, for example, IIC, SPI or DMA, etc. It can be understood that these peripherals can be used as a tested peripheral in the present application, and all peripherals can be tested in parallel using the embodiments of the present application. Figure 6 The software layers from bottom to top are: processor-related μCOS-II real-time operating system, peripheral test task functions (these functions are independent of the processor and include: spiTask(), iicTask(), PwmTask(), and GpioTask(), etc.). Figure 6 The peripheral initialization function layer is related to the processor and exemplarily includes: spiInit(), iicInit(), PwmInit() and GpioInit(). Figure 6 The command line task layer is independent of the processor. It should be noted that examples of peripheral test task functions related to peripheral SPI include: SpiTask() is a test task for the SPI module, and SpiInit() is an initialization function for the SPI module; examples of peripheral test task functions related to peripheral CAN include: CanTask() is a test task for the CAN module, and CanInit() is an initialization function for the CAN module; examples of peripheral test task functions related to peripheral DMA include: DmaTask() is a test task for the DMA module, and DmaInit() is an initialization function for the DMA module.
[0063] Some embodiments of the present application provide a computer-readable communication medium having a computer program stored thereon. When the computer program is executed by a processor, the method described in any embodiment of the second aspect can be implemented.
[0064] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0065] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0066] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0067] The above description is only an embodiment of the present application and is not intended to limit the scope of protection of the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application. It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings.
[0068] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0069] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
Claims
1. A device for testing processor peripheral use cases, the device using μCOS-II real-time operating system, characterized in that: The device comprises: The command line task module is configured to configure serial port communication parameters, enable SCI interrupts, and register the command table to enter the loop and parse the input command when the input is read; The peripheral test task processing module is configured to create a peripheral test task function through a start task, wherein the peripheral test task function is used to perform peripheral tests of corresponding peripherals, and the peripheral test task function of each test task is stored in a corresponding peripheral task folder, and the peripheral functions for initializing, configuring, sending and receiving data for each peripheral to be tested are implemented in respective C files, and the corresponding test task realizes the decoupling of the task function and the peripheral initialization function by calling the operations in the C file; The peripheral test task processing module further includes: The peripheral program parallel processing submodule is configured to perform multi-port parallel processing so that different test tasks can be run in parallel within the same time period; The serial port debugging assistant submodule is configured to provide real-time feedback on the test status and CPU usage of each port in the multiple ports, start or terminate test cases in real time, and monitor or debug the test tasks of each port in real time; The real-time feedback test results include: collecting and displaying the execution status and results of the peripheral use cases in real time through the task scheduling and communication mechanism of the μCOS-II real-time operating system.
2. The device according to claim 1, characterized in that The peripheral test task function is used to test multiple peripherals, wherein the multiple peripherals include: integrated circuit module IIC, direct memory access unit DMA, digital-to-analog converter ADC, serial peripheral interface SPI, serial communication interface SCI, controller area network CAN or local interconnect network LIN, and the peripheral test task function includes: peripheral test module startup test function, peripheral test module result detection function, and peripheral test module initialization function.
3. The device according to claim 1, characterized in that There are two global variables in the file of each test task. The first global variable is used to represent the number of rounds that have been tested for the corresponding peripheral test module, and the second global variable is used to represent the number of test failures for the corresponding peripheral test module.
4. The device according to claim 1, characterized in that The command line task module is also used to store initialization functions, command processing functions, text display functions, command lists, corresponding command functions and command parsing functions related to the serial port communication SCI.
5. A method for testing a processor peripheral use case, applied to the device according to any one of claims 1 to 4, the method comprising: When the system starts, the μCOS-II real-time operating system is initialized, wherein the initialization includes task creation and resource allocation; Create start tasks and command tasks; According to the requirements of the peripheral use case, a corresponding number of test tasks are created, and each test task is assigned to the μCOS-II real-time operating system for management; Start executing the test task of the peripherals; Real-time feedback of test results.
6. The method according to claim 5, characterized in that The creation of the start task and the command task includes: configuring the serial communication SCI serial port information and initializing the command table.
7. The method according to claim 5, characterized in that The starting and executing of the peripheral test tasks includes: each test task executes the test of the peripheral use case in parallel, and operates and monitors multiple peripherals at the same time.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method described in any one of claims 5 to 7 can be implemented.
Citation Information
Patent Citations
Chip testing device and method, electronic equipment and storage medium
CN116298801A
Peripheral interface testing method and device, equipment and storage medium
CN116701168A