DevEco Device Tool comes with 2.1 Beta1, and the new release has a lot going for it. In the last “DevEco Device Tool 2.1 Beta1 Hi3861 in Windows platform compilation experience” (harmonyos.51cto.com/posts/4027)… HM_Nano development board is used by Haisi Hi3861V100 chip, the BEARPI HM_Nano development board on hand, use it to do experience.

When developing applications on the Hi3861 development board, developers need to pay attention to memory allocation and usage. DevEco Device Tool 2.1 Beta1 added a new visualization analysis function — Profiling visualization analysis, through the visual interface to display the application running on the development board of system resources and memory resources information, help developers to view and analyze the development board of each task heap memory and stack memory usage. In this way, the memory and resource allocation strategies of each task can be adjusted in time.

Start by creating a Profiling visualization task. After the scheduled task of querying system resource information and memory information is added to the original application program, the visualization analysis can be realized. Again, take iothardware as an example. The steps are as follows:

1. Enter the system disk user directory C: \ Users \ \ Administrator \. Deveco device – tool, platforms, hisilicon, profiling \ SRC, Copy the files “app_demo_sysinfo.c” and “app_demo_sysinfo.h” to the directory of the Iothardware application.

2. These two files can periodically query system resource information and memory information. You need to add these two files to the application program, compile and record them in the 3861 development board.

(1) Add and change the following contents to the build. gn file in the iothardware directory:

Sources: Add the app_demo_sysinfo.c source file to compile. Include_dirs: add “app_demo_sysinfo. H” header file relative path “/ / applications/sample/wifi – iot/app/iothardware”,

Note: include_dirs: Should be “/ / base/iot_hardware/interfaces/kits/wifiiot_lite” changed to “/ / base/iot_hardware/peripheral interfaces/kits”, or the subsequent compilation cannot pass, The “iot_gpio.h” file does not exist. This bug will be corrected in future versions.

(2) add header file #include “app_demo_sysinfo.h” to current program “led_example.c”

(3) In the entry functionLedExampleEntryAdd a call toapp_demo_heap_task(); * * * *

(4) As usual, modify app/ build. gn to make Iothardware participate in compilation.

(5) The on-board indicator is GPIO 2, just change the #define LED_TEST_GPIO 2 of “Applications \sample\wifi-iot\app\iothardware\led_example. C” to 2. Meanwhile, the LED_INTERVAL_TIME_US is changed from 3000000 to 6000000, and the flashing frequency is changed to 1.2 seconds once, which is more suitable for human eyes.

3. Save the modification. Directly under Windows compile, burn. Restart the development board and the on-board blue indicator blinks. Open the serial port, a lot of information constantly emerge, there is time, memory, task and other information.

Once you’re ready, you can enjoy the highlights of DevEco Device Tool 2.1 Beta1 visualization analysis.

Click “Profiling” in the sidebar of the homepage Deveco Home, click “Live Capture” on the Profiling page, and the serial port Settings of the development board will pop up. You only need to select the default value without changing it, and then click “Capture” to enter the visual licensing page. Note that the serial port of the development board cannot be occupied, otherwise visual analysis cannot be performed.

**Heap: ** Real-time statistics of the current application Heap memory usage and historical peak, the horizontal axis is time information, accurate to millisecond, data is updated every 150 milliseconds. (Peak Usage: 86172 Usage: 70988)

**Stack: ** Displays the memory usage of each task in an application. You can view the memory usage of a specific task based on the Peak memory ratio (Peak%) to better allocate the memory size of each task. LedTask memory usage ratio controlled by LED lamp is 72.7%. Click the plus sign to the left of each task to show a visualization of the individual task.

**OS Objects: ** Statistics the usage of system resources, such as the number of timers, tasks, queues, etc

**All in One: ** Statistics Heap and Stack usage, real-time dynamic refresh.

Profiling also allows you to export statistics for the current time period in both “Excel” and “Json” formats, which can then be viewed and analyzed in other ways.

Source program and export Excel files for download