From 7aff3df849222805342346b49674bebe32caadef Mon Sep 17 00:00:00 2001 From: duangavin123 Date: Thu, 14 Apr 2022 19:19:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E8=8B=B1=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: duangavin123 --- .../driver/driver-platform-mipicsi-develop.md | 503 +++++++++++++++++ en/device-dev/subsystems/Readme-EN.md | 1 + .../subsystems/subsys-toolchain-hiperf.md | 519 ++++++++++++++++++ .../faqs/faqs-environment-building.md | 205 ------- zh-cn/device-dev/faqs/faqs-porting.md | 39 -- zh-cn/device-dev/faqs/faqs-startup.md | 57 -- .../faqs/faqs-system-applications.md | 211 ------- zh-cn/device-dev/faqs/faqs.md | 19 - 8 files changed, 1023 insertions(+), 531 deletions(-) create mode 100644 en/device-dev/driver/driver-platform-mipicsi-develop.md create mode 100644 en/device-dev/subsystems/subsys-toolchain-hiperf.md delete mode 100644 zh-cn/device-dev/faqs/faqs-environment-building.md delete mode 100644 zh-cn/device-dev/faqs/faqs-porting.md delete mode 100644 zh-cn/device-dev/faqs/faqs-startup.md delete mode 100644 zh-cn/device-dev/faqs/faqs-system-applications.md delete mode 100644 zh-cn/device-dev/faqs/faqs.md diff --git a/en/device-dev/driver/driver-platform-mipicsi-develop.md b/en/device-dev/driver/driver-platform-mipicsi-develop.md new file mode 100644 index 0000000000..f5691e402b --- /dev/null +++ b/en/device-dev/driver/driver-platform-mipicsi-develop.md @@ -0,0 +1,503 @@ +# MIPI CSI + +- [Overview](#section72226945170128) +- [Available APIs](#section735525713405) +- [How to Develop](#section378858277170128) +- [Development Example](#section2049027816170128) + +## Overview + +Defined by the Mobile Industry Processor Interface \(MIPI\) Alliance, the Camera Serial Interface \(CSI\) is a specification that allows data to be transmitted from the camera to the host processor on mobile platforms. In the Hardware Driver Foundation \(HDF\), the MIPI CSI module uses the service-free mode for API adaptation. The service-free mode applies to the devices that do not provide user-mode APIs or the OS that does not distinguish the user mode and the kernel mode. In the service-free mode, DevHandle \(a void pointer\) directly points to the kernel-mode address of the device object. + +**Figure 1** Service-free mode + +![](figures/service-free-mode.png "Service-free mode") + +## Available APIs + +MipiCsiCntlrMethod: + +``` +struct MipiCsiCntlrMethod { + int32_t (*setComboDevAttr)(struct MipiCsiCntlr *cntlr, ComboDevAttr *pAttr); + int32_t (*setPhyCmvmode)(struct MipiCsiCntlr *cntlr, uint8_t devno, PhyCmvMode cmvMode); + int32_t (*setExtDataType)(struct MipiCsiCntlr *cntlr, ExtDataType* dataType); + int32_t (*setHsMode)(struct MipiCsiCntlr *cntlr, LaneDivideMode laneDivideMode); + int32_t (*enableClock)(struct MipiCsiCntlr *cntlr, uint8_t comboDev); + int32_t (*disableClock)(struct MipiCsiCntlr *cntlr, uint8_t comboDev); + int32_t (*resetRx)(struct MipiCsiCntlr *cntlr, uint8_t comboDev); + int32_t (*unresetRx)(struct MipiCsiCntlr *cntlr, uint8_t comboDev); + int32_t (*enableSensorClock)(struct MipiCsiCntlr *cntlr, uint8_t snsClkSource); + int32_t (*disableSensorClock)(struct MipiCsiCntlr *cntlr, uint8_t snsClkSource); + int32_t (*resetSensor)(struct MipiCsiCntlr *cntlr, uint8_t snsResetSource); + int32_t (*unresetSensor)(struct MipiCsiCntlr *cntlr, uint8_t snsResetSource); +}; +``` + +**Table 1** Callbacks for the members in the MipiCsiCntlrMethod structure + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Callback

+

Input Parameter

+

Output Parameter

+

Return Value

+

Description

+

setComboDevAttr

+

cntlr: structure pointer to the MIPI CSI controller.

+

pAttr: structure pointer to the configuration structure of the MIPI CSI.

+

+

HDF_STATUS

+

Sets the MIPI-CSI configuration.

+

setPhyCmvmode

+

cntlr: structure pointer to the MIPI CSI controller.

+

devno: Device ID, which is of the uint8_t type.

+

cmvMode: common-mode voltage (CMV) mode.

+

+

HDF_STATUS

+

Sets the CMV mode.

+

setExtDataType

+

cntlr: structure pointer to the MIPI CSI controller.

+

dataType: structure pointer to the data that defines the YUV, original data formats, and bit depth.

+

+

HDF_STATUS

+

Sets the YUV, RAW data format, and bit depth.

+

setHsMode

+

cntlr: structure pointer to the MIPI CSI controller.

+

laneDivideMode: lane mode.

+

+

HDF_STATUS

+

Sets the MIPI RX lane distribution.

+

enableClock

+

cntlr: structure pointer to the MIPI CSI controller.

+

comboDev: channel ID, which is of the uint8_t type.

+

+

HDF_STATUS

+

Enables the MIPI clock.

+

disableClock

+

cntlr: structure pointer to the MIPI CSI controller.

+

comboDev: channel ID, which is of the uint8_t type.

+

+

HDF_STATUS

+

Disables the MIPI clock.

+

resetRx

+

cntlr: structure pointer to the MIPI CSI controller.

+

comboDev: channel ID, which is of the uint8_t type.

+

+

HDF_STATUS

+

Resets the MIPI RX.

+

unresetRx

+

cntlr: structure pointer to the MIPI CSI controller.

+

comboDev: channel ID, which is of the uint8_t type.

+

+

HDF_STATUS

+

Deasserts the reset of the MIPI RX.

+

enableSensorClock

+

cntlr: structure pointer to the MIPI CSI controller.

+

snsClkSource: number of the clock signal cable of the sensor, which is of the uint8_t type.

+

+

HDF_STATUS

+

Enables the MIPI sensor clock.

+

disableSensorClock

+

cntlr: structure pointer to the MIPI CSI controller.

+

snsClkSource: number of the clock signal cable of the sensor, which is of the uint8_t type.

+

+

HDF_STATUS

+

Disables the MIPI sensor clock.

+

resetSensor

+

cntlr: structure pointer to the MIPI CSI controller.

+

snsClkSource: number of the clock signal cable of the sensor, which is of the uint8_t type.

+

+

HDF_STATUS

+

Resets the sensor.

+

unresetSensor

+

cntlr: structure pointer to the MIPI CSI controller.

+

snsClkSource: number of the clock signal cable of the sensor, which is of the uint8_t type.

+

+

HDF_STATUS

+

Deasserts the reset of a sensor.

+
+ +## How to Develop + +The MIPI CSI module adaptation involves the following steps: + +1. Instantiate the driver entry. + - Instantiate the **HdfDriverEntry** structure. + - Call **HDF\_INIT** to register the **HdfDriverEntry** instance with the HDF. + +2. Configure attribute files. + - Add the **deviceNode** information to the **device\_info.hcs** file. + - \(Optional\) Add the **mipicsi\_config.hcs** file. + +3. Instantiate the MIPI CSI controller object. + - Initialize **MipiCsiCntlr**. + - Instantiate **MipiCsiCntlrMethod** in the **MipiCsiCntlr** object. + + >![](../public_sys-resources/icon-note.gif) **NOTE:** + >For details, see [Available APIs](#section735525713405). + + +4. Debug the driver. + - \(Optional\) For new drivers, verify basic functions, for example, verify the information returned after the connect operation and whether data is successfully transmitted. + + +## Development Example + +The following uses **mipi\_rx\_hi35xx.c** as an example to present the contents that need to be provided by the vendor to implement device functions. + +1. Generally, you need to configure the device attributes in **busxx\_config.hcs** and add the **deviceNode** information to the **device\_info.hcs** file. The device attribute values are closely related to the default values or value range of the **MipiCsiCntlr** members at the core layer. The **deviceNode** information is related to the driver entry registration. + + >![](../public_sys-resources/icon-note.gif) **NOTE:** + >In this example, the MIPI controller attributes are defined in the source file. If required, add the **deviceMatchAttr** information to **deviceNode** in the **device\_info** file and add the** mipicsi\_config.hcs** file. + + **device\_info.hcs** configuration reference: + + ``` + root { + device_info { + match_attr = "hdf_manager"; + platform :: host { + hostName = "platform_host"; + priority = 50; + device_mipi_csi:: device { + device0 :: deviceNode { + policy = 0; + priority = 160; + permission = 0644; + moduleName = "HDF_MIPI_RX"; // (Mandatory) Driver name, which must be the same as the moduleName in the driver entry. + serviceName = "HDF_MIPI_RX";// (Mandatory) Unique name of the service published by the driver. + } + } + } + } + } + ``` + +2. Instantiate the driver entry. The driver entry must be a global variable of the **HdfDriverEntry** type \(defined in **hdf\_device\_desc.h**\), and the value of **moduleName** must be the same as that in **device\_info.hcs**. The function pointer members of the **HdfDriverEntry** structure are filled by the vendors' operation functions. In the HDF, the start address of each **HdfDriverEntry** object of all loaded drivers is collected to form a segment address space similar to an array for the upper layer to invoke. + + Generally, the HDF calls the **Bind** function and then the **Init** function to load a driver. If **Init** fails to be called, the HDF calls **Release** to release driver resources and exit. + + MIPI CSI driver entry reference: + + ``` + struct HdfDriverEntry g_mipiCsiDriverEntry = { + .moduleVersion = 1, + .Init = Hi35xxMipiCsiInit, // See the Init function. + .Release = Hi35xxMipiCsiRelease, //See the Release function. + .moduleName = "HDF_MIPI_RX", // (Mandatory) The value must be the same as that in the device_info.hcs file. + }; + HDF_INIT(g_mipiCsiDriverEntry); // Call HDF_INIT to register the driver entry with the HDF. + ``` + +3. Initialize the **MipiCsiCntlr** object at the core layer, including initializing the vendor custom structure \(passing parameters and data\), instantiating **MipiCsiCntlrMethod** \(used to call underlying functions of the driver\) in **MipiCsiCntlr**, and implementing the **HdfDriverEntry** member functions \(**Bind**, **Init**, and **Release**\). + - Custom structure reference: + + >![](../public_sys-resources/icon-note.gif) **NOTE:** + >To the driver, the custom structure carries parameters and data. The values in the **config** file are used to initialize the structure members. In this example, the MIPI CSI attributes are defined in the source file. Therefore, the basic member structure is similar to that of **MipiCsiCntlr**. + + ``` + typedef struct { + /** Data type: 8-bit, 10-bit, 12-bit, 14-bit, or 16-bit */ + DataType inputDataType; + /** MIPI WDM mode */ + MipiWdrMode wdrMode; + /** laneId: -1 - disabled */ + short laneId[MIPI_LANE_NUM]; + + union { + /** Used for HI_MIPI_WDR_MODE_DT */ + short dataType[WDR_VC_NUM]; + }; + } MipiDevAttr; + + typedef struct { + /** Device number. */ + uint8_t devno; + /** Input mode, which can be MIPI, LVDS, sub-LVDS, HiSPi, or DC. */ + InputMode inputMode; + MipiDataRate dataRate; + /** Crop area of the MIPI RX device (same as the size of the input image of the sensor). */ + ImgRect imgRect; + + union { + MipiDevAttr mipiAttr; + LvdsDevAttr lvdsAttr; + }; + } ComboDevAttr; + + // MipiCsiCntlr is the core layer controller structure. Its members are assigned with values by using the Init function. + struct MipiCsiCntlr { + /** Send the service provided by this controller when the driver is bound to the HDF. */ + struct IDeviceIoService service; + /** Pass the pointer to the device when the driver is bound to the HDF. */ + struct HdfDeviceObject *device; + /** Device number */ + unsigned int devNo; + /** All APIs provided by the controller */ + struct MipiCsiCntlrMethod *ops; + /** All APIs for controller debugging. Set it to null if the driver is not implemented. */ + struct MipiCsiCntlrDebugMethod *debugs; + /** Controller context variable. */ + MipiDevCtx ctx; + /** Spinlock used when the controller context variable is accessed. */ + OsalSpinlock ctxLock; + /** Lock method when the controller is managed */ + struct OsalMutex lock; + /** Pointer to anonymous data, which is used to store the CSI device structure */ + void *priv; + }; + ``` + + - **\(Important\)** Instantiate the callback function structure **MipiCsiCntlrMethod** in **MipiCsiCntlr**. Other members are initialized by using the **Init** function. + + ``` + static struct MipiCsiCntlrMethod g_method = { + .setComboDevAttr = Hi35xxSetComboDevAttr, + .setPhyCmvmode = Hi35xxSetPhyCmvmode, + .setExtDataType = Hi35xxSetExtDataType, + .setHsMode = Hi35xxSetHsMode, + .enableClock = Hi35xxEnableClock, + .disableClock = Hi35xxDisableClock, + .resetRx = Hi35xxResetRx, + .unresetRx = Hi35xxUnresetRx, + .enableSensorClock = Hi35xxEnableSensorClock, + .disableSensorClock = Hi35xxDisableSensorClock, + .resetSensor = Hi35xxResetSensor, + .unresetSensor = Hi35xxUnresetSensor + }; + ``` + + - Init function + + Input parameters: + + **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information. + + Return values: + + HDF\_STATUS \(The following table lists some status. For details about other status, see **HDF\_STATUS** in the **/drivers/framework/include/utils/hdf\_base.h** file.\) + + + + + + + + + + + + + + + + + + + + + + + + + +

Status (Value)

+

Description

+

HDF_ERR_INVALID_OBJECT

+

Invalid object

+

HDF_ERR_MALLOC_FAIL

+

Failed to allocate memory

+

HDF_ERR_INVALID_PARAM

+

Invalid parameter

+

HDF_ERR_IO

+

I/O error

+

HDF_SUCCESS

+

Operation successful

+

HDF_FAILURE

+

Operation failed

+
+ + Function description: + + Connects to the **MipiCsiCntlrMethod** instance, calls **MipiCsiRegisterCntlr**, and performs other vendor-defined initialization operations. + + ``` + static int32_t Hi35xxMipiCsiInit(struct HdfDeviceObject *device) + { + int32_t ret; + + HDF_LOGI("%s: enter!", __func__); + g_mipiCsi.priv = NULL; // g_mipiTx is a global variable defined. + //static struct MipiCsiCntlr g_mipiCsi = { + //.devNo = 0 + //}; + g_mipiCsi.ops = &g_method; // Connect to the MipiCsiCntlrMethod instance. + #ifdef CONFIG_HI_PROC_SHOW_SUPPORT + g_mipiCsi.debugs = &g_debugMethod; + #endif + ret = MipiCsiRegisterCntlr(&g_mipiCsi, device); // (Mandatory) Call the function at the core layer and g_mipiTx to initialize global variables at the core layer. + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: [MipiCsiRegisterCntlr] failed!", __func__); + return ret; + } + + ret = MipiRxDrvInit(); // (Mandatory) Device initialization customized by the vendor. + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: [MipiRxDrvInit] failed.", __func__); + return ret; + } + #ifdef MIPICSI_VFS_SUPPORT + ret = MipiCsiDevModuleInit(g_mipiCsi.devNo); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: [MipiCsiDevModuleInit] failed!", __func__); + return ret; + } + #endif + + OsalSpinInit(&g_mipiCsi.ctxLock); + HDF_LOGI("%s: load mipi csi driver success!", __func__); + + return ret; + } + + // mipi_csi_core.c, core layer file. + int32_t MipiCsiRegisterCntlr(struct MipiCsiCntlr *cntlr, struct HdfDeviceObject *device) + { + ... + // Define the global variable static struct MipiCsiHandle g_mipiCsihandle[MAX_CNTLR_CNT]; + if (g_mipiCsihandle[cntlr->devNo].cntlr == NULL) { + (void)OsalMutexInit(&g_mipiCsihandle[cntlr->devNo].lock); + (void)OsalMutexInit(&(cntlr->lock)); + + g_mipiCsihandle[cntlr->devNo].cntlr = cntlr; // Initialize MipiCsiHandle. + g_mipiCsihandle[cntlr->devNo].priv = NULL; + cntlr->device = device; // Enable conversion between HdfDeviceObject and MipiCsiHandle. + device->service = &(cntlr->service); // Enable conversion between HdfDeviceObject and MipiCsiHandle. + cntlr->priv = NULL; + HDF_LOGI("%s: success.", __func__); + + return HDF_SUCCESS; + } + + HDF_LOGE("%s: cntlr already exists.", __func__); + return HDF_FAILURE; + } + ``` + + - Release function + + Input parameters: + + **HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information. + + Return values: + + – + + Function description: + + Releases the memory and deletes the controller. This function assigns a value to the **Release** API in the driver entry structure. When the HDF fails to call the **Init** function to initialize the driver, the **Release** function can be called to release driver resources. All forced conversion operations for obtaining the corresponding object can be successful only when the **Init** function has the corresponding value assignment operations. + + ``` + static void Hi35xxMipiCsiRelease(struct HdfDeviceObject *device) + { + struct MipiCsiCntlr *cntlr = NULL; + ... + cntlr = MipiCsiCntlrFromDevice(device); // A forced conversion from HdfDeviceObject to MipiCsiCntlr is involved. + //return (device == NULL) ? NULL : (struct MipiCsiCntlr *)device->service; + ... + + OsalSpinDestroy(&cntlr->ctxLock); + #ifdef MIPICSI_VFS_SUPPORT + MipiCsiDevModuleExit(cntlr->devNo); + #endif + MipiRxDrvExit(); // (Mandatory) Release the resources occupied by the vendor's devices. + MipiCsiUnregisterCntlr(&g_mipiCsi); // Null function + g_mipiCsi.priv = NULL; + + HDF_LOGI("%s: unload mipi csi driver success!", __func__); + } + ``` + + + diff --git a/en/device-dev/subsystems/Readme-EN.md b/en/device-dev/subsystems/Readme-EN.md index 9d104caf78..83289e57bc 100644 --- a/en/device-dev/subsystems/Readme-EN.md +++ b/en/device-dev/subsystems/Readme-EN.md @@ -96,4 +96,5 @@ - [R&D Tools](subsys-toolchain.md) - [bytrace Usage Guidelines](subsys-toolchain-bytrace-guide.md) - [hdc\_std Usage Guidelines](subsys-toolchain-hdc-guide.md) + - [hiperf Usage Guidelines](subsys-toolchain-hiperf.md) - [XTS](subsys-xts-guide.md) \ No newline at end of file diff --git a/en/device-dev/subsystems/subsys-toolchain-hiperf.md b/en/device-dev/subsystems/subsys-toolchain-hiperf.md new file mode 100644 index 0000000000..e1bdd06642 --- /dev/null +++ b/en/device-dev/subsystems/subsys-toolchain-hiperf.md @@ -0,0 +1,519 @@ +# hiperf + +hiperf is a performance sampling and analysis tool provided for developers. It extends the user-mode capabilities based on the kernel perf mechanism and can conduct performance sampling of the specified application or the entire system. + +You can run the **hiperf -h** command to display the commands supported by hiperf. + +The following describes the common commands \(**list**, **stat**, **record**, and **report**\) supported by hiperf. + +## list + +### Parameters + +The **list** command lists all the perf events supported by the device. The event names are used for the **-e** and **-g** parameters of the **stat** and **record** commands. + +``` +hiperf list [event type] +``` + + + + + + + + + + + + + + + + + + + + + + +

Parameter

+

Description

+

hw

+

Lists the hardware events supported by the performance monitoring unit (PMU).

+

sw

+

Lists the software events supported.

+

tp

+

Lists the tracepotint events supported.

+

cache

+

Lists the cache events supported by the PMU.

+

raw

+

Lists the raw PMU events supported.

+
+ +### Example + +List the hardware events supported by the PMU. The command also lists the events that are not supported by the PMU. + +``` +hiperf list hw +event not support hw-stalled-cycles-backend +event not support hw-stalled-cycles-frontend +event not support hw-ref-cpu-cycles + +Supported events for hardware: + hw-cpu-cycles + hw-instructions + hw-cache-references + hw-cache-misses + hw-branch-instructions + hw-branch-misses + hw-bus-cycles +``` + +## stat + +### Parameters + +The **stat** command monitors the specified application and periodically prints the values of performance counters. + +``` +hiperf stat [options] + Collect performance counter information. +``` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Parameter

+

Description

+

-a

+

Collects the values of all threads and default performance counters of the system.

+

-c

+

Specifies the IDs of the CPUs to monitor. Use commas (,) to separate multiple CPU IDs, for example 0,1,2.

+

-d <sec>

+

Specifies the monitoring period, in seconds.

+

-i <ms>

+

Specifies the interval for printing the monitored events, in milliseconds.

+

-e

+

Specifies the events to monitor. You can run the list command to list all the events supported. event:u indicates an event in the user space, and event:k indicates an event in the kernel space.

+

-g

+

Specifies a group of events to monitor. The events in the same group are monitored by the same PMU.

+

--no-inherit

+

Leaves the sub-threads of the target thread or process not monitored.

+

-p

+

Specifies the process IDs (PIDs) to monitor.

+

-t

+

Specifies the thread IDs (TIDs) to monitor.

+

--verbose

+

Displays detailed report, including raw time data.

+
+ +### Example + +Monitor the entire system for 3 seconds. + +``` +hiperf stat -d 3 -a +this is root mode, perfEventParanoid assume as -1 +Start Profiling... +Timeout exit (total 3009 ms) + count name | comment | coverage + 132523 hw-branch-instructions | 15.750 M/sec | (100%) + 62554 hw-branch-misses | 47.202372% miss rate | (100%) + 6994768 hw-cpu-cycles | 0.832068 GHz | (100%) + 1237627 hw-instructions | 5.651758 cycles per instruction | (100%) + 248 sw-context-switches | 29.959 K/sec | (100%) + 0 sw-page-faults | 0.000 /sec | (100%) + 9402580 sw-task-clock | 0.002758 cpus used | (100%) +``` + +### Field Description + + + + + + + + + + + + + + + + + + + +

Field

+

Description

+

count

+

Indicates the times that an event occurred.

+

name

+

Indicates the event name. You can run the list command to list all the supported events. hw stands for hardware, and sw stands for software.

+

comment

+

Provides values calculated from those in the Count column for easy understanding. For example, the CPU frequency (hw-cpu-cycles) is converted to 0.832068 GHz from 6994768.

+

coverage

+

Indicates the percentage of PMU resources occupied by the event. The number of events to be monitored by a PMU varies depending on the number of PMUs.

+
+ +## record + +### Parameters + +The **record** command samples the specified application and saves the sampling data to a file \(**perf.data** by default\). + +``` +hiperf record [options] + Collect performance sampling information. +``` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Parameter

+

Description

+

-a

+

Samples all processes and threads in the system.

+

--exclude-hiperf

+

Leaves the hiperf process not sampled.

+

-c

+

Specifies the IDs of the CPUs to sample.

+

--cpu-limit <percent>

+

Specifies the maximum percentage of CPU resources occupied by the sampling.

+

-d <sec>

+

Specifies the sampling duration, in seconds.

+

-f <freq>

+

Specifies how often a sampling event is triggered. The default value is 4000 times/second.

+

Note: A higher value indicates heavier CPU load but more sampling data.

+

--period <num>

+

Specifies the number of occurrence times of an event that triggers a sampling. That is, a sampling is performed once when the event occurs the specified number of times.

+

-e

+

Specifies the events to monitor. You can run the list command to list all the events supported. event:u indicates an event in the user space, and event:k indicates an event in the kernel space.

+

-g

+

Specifies a group of events to monitor. The events in the same group are monitored by the same PMU.

+

--no-inherit

+

Leaves the sub-threads of the target thread or process not monitored.

+

-p

+

Specifies the processes to monitor.

+

-t

+

Specifies the threads to monitor.

+

--offcpu

+

Monitors the CPU scheduling event, which is equivalent to the --period 1 -e sched:sched_switch event.

+

-j <branch_filter1>[,branch_filter2]...

+

Monitors the branch prediction events. Branch prediction tries to predict the next instruction to be executed if there are multiple if else conditions.

+

-s / --call-stack <fp \| dwarf[,size]>

+

Sets the user stack unwinding mode, which can be fp or dwarf. If dwarf is used, you can specify the size of the user stack to be sampled. The default value is 65528.

+

--delay-unwind

+

Delays the stack unwinding till the sampling is complete.

+

--disable-unwind

+

Disables stack unwinding. The user register and stack data is stored in perf.data for offline stack unwinding.

+

--disable-callstack-expend

+

Disables the unwound call stack information from being combined or extended.

+

--clockid <clock type>

+

Sets the clock source for the sampling data. The options are monotonic, boottime, and realtime.

+

--symbol-dir <dir>

+

Specifies the directory of the symbol table. The specified symbol table will be preferentially used in stack unwinding.

+

-m <mmap pages>

+

Specifies the cache size, in pages. The default value is 1024. The parameter value must be a power of 2. The value range is [2 - 1024].

+

Note: A higher value indicates a lower event loss rate but higher memory usage.

+

--app <package name>

+

Specifies the bundle name of the target application to be sampled. The default timeout interval is 10 seconds. If the specified application does not exist, the hiperf process exits after 10 seconds.

+

--data-limit <SIZE[K|M|G]>

+

Specifies the maximum size of the sampling result, in KB, MB, or GB. By default, there is no limit on the size.

+

-o <output file name>

+

Specifies the name of the sampling result file. It is /data/local/tmp/perf.data by default.

+

-z

+

Saves the output file in .gzip format.

+

--verbose

+

Displays detailed log information during sampling.

+
+ +### Example + +- Sample all processes in the system for 3 seconds and display detailed log information during the sampling process. + + ``` + hiperf record -d 3 -a --verbose + ``` + + +- Enable stack unwinding in fp mode. + + ``` + hiperf record -s fp -d 3 -a + ``` + +- Enable stack unwinding in dwarf mode. + + ``` + hiperf record -s dwarf -d 3 -a + ``` + +- Sample offcpu events. + + ``` + hiperf record --offcpu -s dwarf -d 3 -a + ``` + +- Delay stack unwinding. + + ``` + hiperf record -d 3 -s dwarf --delay-unwind -a + ``` + +- Disable stack unwinding. In this case, the stack data is saved to the **perf.data** file. + + ``` + hiperf record -d 3 -s dwarf --disable-unwind -a + ``` + +- Monitor the **com.ohos.launch** application. The hiperf process exits after 10 seconds if the process corresponding to the specified bundle name does not exist. + + ``` + hiperf record -d 3 -s dwarf --app com.ohos.launch + ``` + +- Compress the sampling results. + + ``` + hiperf record -z -s dwarf -d 3 -a + ``` + + +## report + +The **report** command displays the sampling data that is captured by using **record**. + +``` +hiperf report [option] + Report sampling information from perf.data. +``` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Parameter

+

Description

+

--symbol-dir <dir>

+

Specifies the directory of the symbol table.

+

--limit-percent <number>

+

Specifies the minimum percentage of the result to display. The result that is lower than the minimum percentage is not displayed.

+

-s / --call-stack

+

Displays detailed call stack information.

+

--call-stack-limit-percent <number>

+

Specifies the minimum percentage of the call stack to display. The call stack that is lower than the minimum percentage is not displayed.

+

--proto

+

Converts the perf.data file into the proto format. The default file name is perf.proto.

+

--json

+

Converts the perf.data file into the JSON format. The default file name is perf.json.

+

--branch

+

Displays the report based on the branch prediction result address instead of the IP address of the call stack.

+

--<keys> <keyname1>[,keyname2][,...]

+

Filters and displays reports based on the given keywords. keys can be comms, pids, and tids. For example, --comms hiperf,hilog displays only the records whose process or thread name is hiperf or hilog.

+

--sort <key1>[,key2][,...]

+

Sorts and displays information based on specified keywords, such as pid, tid, and comm. Multiple keywords can be specified.

+

-i <filename>

+

Specifies the sampling data (perf.data by default).

+

-o <filename>

+

Specifies the name of the report to output.

+
+ +## Example + +- Output the report of the sampling data \(**perf.data** by default\). + + ``` + hiperf report + ``` + + Output \(example\): + + ``` + Heating count comm pid tid dso func + 5.68% 15073949 hiperf_example_ 1085 1091 /system/lib/ld-musl-arm.so.1 malloc + 2.57% 6834119 hiperf_example_ 1085 1091 [kernel.kallsyms] vector_swi + 2.27% 6013910 hiperf_example_ 1085 1087 /system/lib/ld-musl-arm.so.1 malloc + 2.19% 5805738 hiperf_example_ 1085 1091 /system/lib/ld-musl-arm.so.1 vfprintf + 2.09% 5543362 hiperf_example_ 1085 1091 [kernel.kallsyms] ktime_get_ts64 + report done + ``` + +- Output the call stack report of the sampling data. + + ``` + hiperf report -s + ``` + +- Set the symbol table directory. + + ``` + hiperf report -s --symbol-dir /data/local/tmp + ``` + +- Display only the information containing **libutils.z.so**. + + ``` + hiperf report --dsos libuitls.z.so + ``` + +- Sort the result by **dso**. + + ``` + hiperf report --sort dso + ``` + + diff --git a/zh-cn/device-dev/faqs/faqs-environment-building.md b/zh-cn/device-dev/faqs/faqs-environment-building.md deleted file mode 100644 index 8087e8fdf5..0000000000 --- a/zh-cn/device-dev/faqs/faqs-environment-building.md +++ /dev/null @@ -1,205 +0,0 @@ -# 环境搭建常见问题 - - -## 轻量和小型系统 - - -### hb安装过程中出现乱码、段错误 - -- **现象描述** - 执行“python3 -m pip install --user ohos-build”出现乱码、段错误(segmentation fault)。 - -- **可能原因** - pip版本过低。 - -- **解决办法** - 执行如下命令升级pip。 - - - ``` - python3 -m pip install -U pip - ``` - - -### hb安装过程中提示"cannot import 'sysconfig' from 'distutils'" - -- **现象描述** - 执行“python3 -m pip install --user ohos-build”提示"cannot import 'sysconfig' from 'distutils'" - -- **可能原因** - 缺少distutils模块。 - -- **解决办法** - 执行如下命令安装。 - - - ``` - sudo apt-get install python3.8-distutils - ``` - - -### hb安装过程中提示"module 'platform' has no attribute 'linux_distribution'" - -- **现象描述** - 执行“python3 -m pip install --user ohos-build”提示"module 'platform' has no attribute 'linux_distribution'" - -- **可能原因** - python3 pip安装兼容性问题。 - -- **解决办法** - 执行如下命令重新安装pip。 - - - ``` - sudo apt remove python3-pip - curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py - python get-pip.py - ``` - - -### hb安装过程中提示"Could not find a version that satisfies the requirement ohos-build" - -- **现象描述** - 执行“python3 -m pip install --user ohos-build”提示"Could not find a version that satisfies the requirement ohos-build" - -- **可能原因** - 可能是网络环境较差导致的安装失败。 - -- **解决办法** - 1. 请检查网络连接是否正常。如果网络有问题,请修复网络问题后重新安装。 - 2. 若网络正常,请尝试指定临时pypi源的方式安装: - - ``` - python3 -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple ohos-build - ``` - - -### 安装python3过程中,提示“configure: error: no acceptable C compiler found in $PATH” - -- **现象描述** - 安装python3过程中出现以下错误: - - - ``` - configure: error: no acceptable C compiler found in $PATH. See 'config.log' for more details - ``` - -- **可能原因** - 环境中未安装“gcc”。 - -- **解决办法** - 1. 通过命令“apt-get install gcc”在线安装。 - 2. 完成后,重新安装python3。 - - -### 安装python3过程中,提示“-bash: make: command not found” - -- **现象描述** - 安装python3过程中出现以下错误: - - - ``` - -bash: make: command not found - ``` - -- **可能原因** - 环境中未安装“make”。 - -- **解决办法** - 1. 通过命令“apt-get install make”在线安装。 - 2. 完成后,重新安装python3。 - - -### 安装python3过程中,提示“zlib not available” - -- **现象描述** - 安装python3过程中出现以下错误: - - - ``` - zipimport.ZipImportError: can't decompress data; zlib not available - ``` - -- **可能原因** - 环境中未安装“zlib”。 - -- **解决办法** - 方法1:通过命令“apt-get install zlib”在线安装。 - - 方法2:如果软件源中没有该软件,请从“www.zlib.net”下载版本代码,并离线安装。 - - ![zh-cn_image_0000001198001086](figures/zh-cn_image_0000001198001086.png) - - 完成下载后,通过以下命令安装: - - - ``` - # tar xvf zlib-1.2.11.tar.gz - # cd zlib-1.2.11 - # ./configure - # make && make install - ``` - - 完成后,重新安装python3。 - - -### 编译构建过程中,提示“No module named 'Crypto'” - -- **现象描述** - 编译构建过程中出现以下错误: - - - ``` - ModuleNotFoundError: No module named 'Crypto' - ``` - -- **可能原因** - 环境中未安装“Crypto”。 - -- **解决办法** - 方法1:通过命令“pip3 install Crypto”,在线安装。 - - 方法2:离线安装。 - - 通过网页[https://pypi.org/project/pycrypto/#files](https://pypi.org/project/pycrypto/#files),下载源码。 - - ![zh-cn_image_0000001251196005](figures/zh-cn_image_0000001251196005.png) - - 将源码放置在Linux服务器中,解压,并安装“python3 setup.py install”。 - - 完成上述安装后,重新构建。 - - -### 安装kconfiglib时,遇到lsb_release错误 - -- **现象描述** - 安装kconfiglib过程中遇到如下错误打印: - - - ``` - subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1. - ``` - -- **可能原因** - lsb_release模块基于的python版本与现有python版本不一致。 - -- **解决办法** - 执行"find / -name lsb_release",找到lsb_release位置并删除,如:"sudo rm -rf /usr/bin/lsb_release"。 - - -### Linux编译服务器终端输入不识别的命令时提示“ImportError: No module named apt_pkg” - -- **现象描述** - Linux编译服务器终端输入不识别的命令时,提示"ImportError: No module named apt_pkg" - -- **可能原因** - python3 apt安装兼容性问题。 - -- **解决办法** - 执行如下命令重新安装python3-apt。 - - - ``` - sudo apt-get remove python3-apt - sudo apt-get install python3-apt - ``` diff --git a/zh-cn/device-dev/faqs/faqs-porting.md b/zh-cn/device-dev/faqs/faqs-porting.md deleted file mode 100644 index b481e63e2f..0000000000 --- a/zh-cn/device-dev/faqs/faqs-porting.md +++ /dev/null @@ -1,39 +0,0 @@ -# 移植常见问题 - -- [如何将用户的堆内存挂载进内核](#section21471536184914) - -## 如何将用户的堆内存挂载进内核 - -- 内核堆内存配置的相关宏如下,用户可根据实际情况,在target\_config.h中配置: - -**表 1** 内核堆内存配置相关宏 - - - - - - - - - - - - - - - - -

宏名称

-

描述

-

LOSCFG_SYS_EXTERNAL_HEAP

-

这个宏决定系统是使用内核的内部堆内存还是用户的堆内存,默认为0(即使用内部的堆内存),大小为0x10000;如果用户需要基于外部的堆内存,那么可以将该宏设置为1。

-

LOSCFG_SYS_HEAP_ADDR

-

内核堆内存的起始地址。

-

LOSCFG_SYS_HEAP_SIZE

-

内核堆内存的大小,即LOSCFG_SYS_HEAP_ADDR指定的内存块大小。

-
- -- 注意事项: - -指定的堆内存范围务必保证没有其他模块使用,避免踩内存,破坏堆内存功能。 - diff --git a/zh-cn/device-dev/faqs/faqs-startup.md b/zh-cn/device-dev/faqs/faqs-startup.md deleted file mode 100644 index 5b4350b27f..0000000000 --- a/zh-cn/device-dev/faqs/faqs-startup.md +++ /dev/null @@ -1,57 +0,0 @@ -# 启动恢复常见问题 - -- [系统启动过程中打印“parse failed!”错误后停止启动](#section835662214302) -- [系统启动过程未结束就自动重启,如此反复持续](#section3857921143117) -- [参数正确的情况下调用SetParameter/GetParameter返回失败](#section548818116328) - -## 系统启动过程中打印“parse failed!”错误后停止启动 - -**现象描述** - -系统启动过程中,打印“\[Init\] InitReadCfg, parse failed! please check file /etc/init.cfg format.”错误,启动过程停止,如下图所示: - -**图 1** 运行报错图 -![](figures/运行报错图.png "运行报错图") - -**可能原因** - -修改init.cfg文件时,漏掉或多加了逗号或括号等,导致init.cfg文件的json格式被破坏。 - -**解决办法** - -仔细检查init.cfg文件,确保其格式符合json格式要求。 - -## 系统启动过程未结束就自动重启,如此反复持续 - -**现象描述** - -镜像烧写完成后系统启动,启动过程未完成即自动重新启动,如此反复持续。 - -**可能原因** - -被init启动的服务都有一个叫做“importance”的属性(详见[第2章表3](../subsystems/subsys-boot-init.md)描述)。 - -- 当该属性为0时,表示若当前服务进程退出,init不需要重启单板。 -- 当该属性为1时,表示若当前服务进程退出,init需要重启单板。 - -因此出现上述现象的可能原因:有“importance”属性为1的服务在每次启动的过程中都会退出(可能是进程崩溃或出错自动退出),导致init进程自动重启单板。 - -**解决办法** - -1. 需要通过日志确认崩溃或报错退出的服务,并解决其崩溃/报错的问题,然后重新烧写镜像即可。 -2. 也可以将崩溃/报错退出的服务的“importance”属性改为0,然后重新烧写镜像,这样即使其退出,init也不会重启单板。 - -## 参数正确的情况下调用SetParameter/GetParameter返回失败 - -**现象描述** - -在各参数正确的情况下调用SetParameter/GetParameter返回失败。 - -**可能原因** - -程序对SetParameter/GetParameter这两个接口做了权限校验,在各参数正确的情况下调用SetParameter/GetParameter返回操作失败,很有可能是调用者的uid大于1000,没有调用权限。 - -**解决办法** - -无需处理 - diff --git a/zh-cn/device-dev/faqs/faqs-system-applications.md b/zh-cn/device-dev/faqs/faqs-system-applications.md deleted file mode 100644 index b8f34e907f..0000000000 --- a/zh-cn/device-dev/faqs/faqs-system-applications.md +++ /dev/null @@ -1,211 +0,0 @@ -# 系统应用常见问题 - -- [公共基础库常见问题](#section639433461512) - - [1.LiteOS-A内核\(Hi3516、Hi3518平台\)KV存储路径设置错误,导致KV存储运行失败](#section16520347131511) - -- [视觉应用常见问题](#section787718474161) - - [是否存在一个全局变量,所有的页面都可以访问?](#section187297991718) - - [如何获取dom中的元素](#section1833493719175) - - [如何在页面间传值?](#section184283812183) - - [list如何滚动到某个item?](#section11897734131811) - - [text支持多行吗?](#section5872656121814) - - [为什么控件不显示?](#section7397125317107) - - [如何实现页面滑动?](#section338794422010) - - [Left、Top为什么不生效?](#section2597193611217) - - [动态绑定为什么不生效?](#section6939050172115) - - [如何实现相对定位和绝对定位?](#section5547311192215) - - [如何控制控件的显示与隐藏?](#section16107113352213) - - [使用Margin时,有什么注意事项?](#section1524910142314) - - [使用事件订阅时,有什么注意事项?](#section1537132012231) - - [使用动态绑定时,有什么注意事项?](#section96561452236) - - [swiper loop属性如何生效?](#section690166112414) - - [使用数组时,有什么注意事项?](#section1554552822414) - -- [hdc类问题](#section412357182518) - - [hdc\_std连接不到设备](#section1965012223257) - - [hdc\_std运行不了](#section1157575212515) - - -## 公共基础库常见问题 - -### 1.LiteOS-A内核\(Hi3516、Hi3518平台\)KV存储路径设置错误,导致KV存储运行失败 - -**现象描述** - -LiteOS-A内核\(Hi3516、Hi3518平台\)直接调用KV存储提供的接口,各参数正常的情况下,编译可执行程序运行失败。 - -**可能原因** - -直接运行编译出的可执行文件,没有将程序基于AbilityKit转换成应用,不能由BMS在应用安装时正确设置应用数据存储路径,导致KV存储运行失败。 - -**解决办法** - -显示调用KV存储的UtilsSetEnv接口,设置数据存储路径。 - -``` -UtilsSetEnv("/storage/com.example.kv"); -``` - -## 视觉应用常见问题 - -### 是否存在一个全局变量,所有的页面都可以访问? - -当前框架中不存在所有Page都可以访问的全局变量。 - -### 如何获取dom中的元素 - -如何获取dom中的元素? - -通过ref属性获取dom中的元素,详细示例如下图所示;获取的元素只能使用它的方法,不能改变属性。 - -``` - -
- - -
- -/* index.js */ -export default { - data: { - images:[ - {src:"common/frame1.png"}, - {src:"common/frame2.png"}, - {src:"common/frame3.png"} - ] - }, - handleClick(){ - //通过$refs属性获取对应的组件,在hml中,组件的ref属性要设置为animator - const animator = this.$refs.animator; - const state = animator.getState(); - if(state == "paused"){ - animator.resume(); - }else if(state == "stopped"){ - animator.start(); - }else{ - animator.pause(); - } - } -} -``` - -### 如何在页面间传值? - -通过router.replace方法中的params参数来传递,参考代码如下: - -第一个页面传递数据: - -``` -router.replace({ - uri:'pages/detail/detail', //要跳转的页面uri - params:{transferData:this.data} //传递的数据,数据个数和名称开发者自己定义, -}); -``` - -第二个界面接受数据: - -``` -onInit(){ - const data = this.transferData; //在onInit函数中接受传递的数据 -} -``` - -### list如何滚动到某个item? - -通过list的scrollTo方法滚动到指定的item,参数是目标item的index。Index参数可以通过scrollend事件获取或者开发者指定。 - -### text支持多行吗? - -text支持多行。通过回车键换行或者是不设置text的高度属性,由控件自动根据内容换行。 - -### 为什么控件不显示? - -**现象描述** - -开发者在hml文件中添加的控件无法显示 - -**可能原因** - -- 未设置width和height值; -- 样式设置错误。 - -**处理步骤** - -\(1\)检查是否设置width和height值,组件必须显式设置width和height值; - -\(2\)检查组件的样式设置是否正确。 - -### 如何实现页面滑动? - -实现页面滑动目前有三种方式:scroll(根组件大小超过屏幕的大小即自动实现scroll效果)、list、swiper。开发者可以参考开发文档查看三者的区别,并加以使用。 - -### Left、Top为什么不生效? - -除根节点外,Left、Top配合Stack组件使用才有效果。 - -### 动态绑定为什么不生效? - -在进行绑定时,必须先将要绑定的对象或者对象的属性进行定义,不能先绑定后定义 - -### 如何实现相对定位和绝对定位? - -使用div、stack(top left属性)来实现相对和绝对定位。 - -### 如何控制控件的显示与隐藏? - -通过display、show和if来控制控件的显示与隐藏。区别在于:if为false时,组件会从VDOM中移除,而show仅是渲染时不可见,组件依然存在于VDOM中。 - -### 使用Margin时,有什么注意事项? - -Stack组件不支持其子组件设置margin属性。 - -### 使用事件订阅时,有什么注意事项? - -在应用运行期间只存在一个page,所以router.replace跳转是先销毁前一个页面,然后在新创建一个界面。因此,如果涉及到事件订阅的页面,每次页面创建时要进行事件订阅,跳转离开界面前取消事件订阅。 - -### 使用动态绑定时,有什么注意事项? - -过多的动态绑定会消耗较多的内存,若非业务需要,尽量不要使用太多的动态绑定。 - -### swiper loop属性如何生效? - -去掉第一个组件或者去掉最后一个组件,剩余的长度大于swiper长度,loop生效。 - -### 使用数组时,有什么注意事项? - -数组元素不宜过多,尽量避免对大数组进行频繁操作。 - -## hdc类问题 - -### hdc\_std连接不到设备 - -- **现象描述** - - 执行 "hdc\_std list targets"命令后结果为:\[Empty\] - -- **解决方法** - 1. 设备没有被识别: - - 在设备管理器中查看是否有hdc设备,在通用串行总线设备中会有“HDC Device”信息。如果没有,hdc无法连接。此时需要插拔设备,或者烧写最新的镜像。 - - 2. hdc\_std工作异常: - - 可以执行"hdc kill"或者"hdc start -r"杀掉hdc服务或者重启hdc服务,然后再执行hdc list targets查看是否已经可以获取设备信息。 - - 3. hdc\_std与设备不匹配: - - 如果设备烧写的是最新镜像,hdc\_std也需要使用最新版本。由于hdc\_std会持续更新,请从开源仓developtools\_hdc\_standard中获取,具体位置在该开源仓的prebuilt目录。 - - - -### hdc\_std运行不了 - -- **现象描述** - - 点击hdc\_std.exe文件无法运行。 - -- **解决方法** - - hdc\_std.exe不需要安装,直接放到磁盘上就能使用,也可以添加到环境变量中。通过打开cmd执行hdc\_std命令直接使用。 - - diff --git a/zh-cn/device-dev/faqs/faqs.md b/zh-cn/device-dev/faqs/faqs.md deleted file mode 100644 index a851fcc0fc..0000000000 --- a/zh-cn/device-dev/faqs/faqs.md +++ /dev/null @@ -1,19 +0,0 @@ -# FAQ - - - -- **[常见问题概述](faqs-overview.md)** - -- **[环境搭建常见问题](faqs-environment-building.md)** - -- **[编译构建子系统常见问题](faqs-building.md)** - -- **[烧录常见问题](faqs-burning.md)** - -- **[内核常见问题](faqs-kernel.md)** - -- **[移植常见问题](faqs-transplant.md)** - -- **[启动恢复常见问题](faqs-init.md)** - -- **[系统应用常见问题](faqs-system-using.md)** \ No newline at end of file -- GitLab