提交 4c198b99 编写于 作者: W wusongqing

updated docs

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 703d07c8
# Burning<a name="EN-US_TOPIC_0000001170009518"></a>
## Mini and Small Systems<a name="section278314413530"></a>
### "Error: Opening COMxx: Access denied" Is Displayed After a Serial Port Is Selected for Burning<a name="section18988185615914"></a>
- **Symptom**
**Error: Opening COMxx: Access denied** is displayed after clicking **Burn** and selecting a serial port.
![](figures/failed-to-open-the-serial-port.png)
- **Possible Causes**
The serial port has been used.
- Solution
The serial port may be in use. Perform the following steps to troubleshoot:
1. Search for the serial port from the drop-down list in the **TERMINAL** panel.
![](figures/terminal-list.png)
2. Click the dustbin for the terminal using the serial port to disable the terminal.
### What should I do when the image failed to be burnt?<a name="section1370982513317"></a>
- **Symptom**
The burning status is not displayed after clicking **Burn** and selecting a serial port.
- **Possible Causes**
The IDE is not restarted after the DevEco plug-in is installed.
- **Solutions**
Restart the IDE.
### What should I do when no command output is displayed?<a name="section183421944953"></a>
- **Symptom**
The serial port shows that the connection has been established. After the board is restarted, nothing is displayed when you press **Enter**.
- **Possible Cause 1**
The serial port is connected incorrectly.
- **Solutions**
Change the serial port number.
Start **Device Manager** to check whether the serial port connected to the board is the same as that connected to the terminal device. If the serial ports are different, perform step 1 in the **Running an Image** section to change the serial port number.
- **Possible Cause 2**
The U-Boot of the board is damaged.
- **Solutions**
Burn the U-Boot.
If the fault persists after you perform the preceding operations, the U-Boot of the board may be damaged. You can burn the U-Boot by performing the following steps:
1. Obtain the U-Boot file.
>![](public_sys-resources/icon-notice.gif) **NOTICE:**
>The U-Boot file of the two boards can be obtained from the following paths, respectively.
>Hi3516D V300: **device\\hisilicon\\hispark\_taurus\\sdk\_liteos\\uboot\\out\\boot\\u-boot-hi3516dv300.bin**
>Hi3518E V300: **device\\hisilicon\\hispark\_aries\\sdk\_liteos\\uboot\\out\\boot\\u-boot-hi3518ev300.bin**
2. Burn the U-Boot file by following the procedures for burning a U-Boot file over USB.
Select the U-Boot files of corresponding development boards for burning by referring to [Programming Flash Memory on the Hi3516](https://device.harmonyos.com/en/docs/ide/user-guides/hi3516_upload-0000001052148681)/[Programming Flash Memory on the Hi3518](https://device.harmonyos.com/en/docs/ide/user-guides/hi3518_upload-0000001057313128)
3. Log in to the serial port after the burning is complete.
**Figure 1** Serial port displayed after the U-Boot is burnt<a name="en-us_topic_0000001128470856_en-us_topic_0000001053466255_fig155914681910"></a>
![](figures/serial-port-displayed-after-the-u-boot-is-burnt.png "serial-port-displayed-after-the-u-boot-is-burnt")
### What should I do when Windows-based PC failed to be connected to the board?<a name="section1215410450215"></a>
- **Symptom**
The file image cannot be obtained after clicking **Burn** and selecting a serial port.
**Figure 2** Failed to obtain the image file due to unavailable connection<a name="en-us_topic_0000001128470856_fig135261439195819"></a>
![](figures/failed-to-obtain-the-image-file-due-to-unavailable-connection.png "failed-to-obtain-the-image-file-due-to-unavailable-connection")
- **Possible Causes**
The board is disconnected from the Windows-based PC.
Windows Firewall does not allow Visual Studio Code to access the network.
- **Solutions**
1. Check whether the network cable is properly connected.
2. Click **Windows Firewall**.
![](figures/hi3516-network-and-firewall-setting.png)
3. Click **Firewall & network protection**, and on the displayed page, click **Allow applications to communicate through Windows Firewall**.
![](figures/hi3516-firewall-and-network-protection.png)
4. Select the Visual Studio Code application.
![](figures/hi3516-selecting-the-visual-studio-code-application.png)
5. Select the **Private** and **Public** network access rights for the Visual Studio Code application.
![](figures/hi3516-allowing-the-visual-studio-code-application-to-access-the-network.png)
# Compilation and Building Subsystem<a name="EN-US_TOPIC_0000001215530845"></a>
## Mini and Small Systems<a name="section78686441462"></a>
### Invalid -- w Option<a name="section67961431372"></a>
- **Symptom**
The build fails, and "usr/sbin/ninja: invalid option -- w" is displayed.
- **Cause**
The Ninja version in the build environment is outdated and does not support the **--w** option.
- **Solution**
Uninstall Ninja and GN and follow the instructions provided in [IDE](../get-code/gettools-ide.md) to install Ninja and GN of the required version.
### Library ncurses Not Found<a name="section199631617371"></a>
- **Symptom**
The build fails, and "/usr/bin/ld: cannot find -lncurses" is displayed.
- **Cause**
The ncurses library is not installed.
- **Solution**
```
sudo apt-get install lib32ncurses5-dev
```
### mcopy not Found<a name="section937435175"></a>
- **Symptom**
The build fails, and "line 77: mcopy: command not found" is displayed.
- **Cause**
mcopy is not installed.
- **Solution**
```
​sudo apt-get install dosfstools mtools
```
### No riscv File or Directory<a name="section1115535018713"></a>
- **Symptom**
The build fails, and the following information is displayed:
riscv32-unknown-elf-gcc: error trying to exec 'cc1': execvp: No such file or directory.
- **Cause**
Permission is required to access files in the **riscv** compiler directory.
- **Solution**
Run the following command to query the directory where **gcc\_riscv32** is located:
```
which riscv32-unknown-elf-gcc
```
Run the **chmod** command to change the directory permission to **755**.
### No Crypto<a name="section17982573813"></a>
- **Symptom**
The build fails, and "No module named 'Crypto'" is displayed.
- **Cause**
Crypto is not installed in Python 3.
- **Solution**
1. Run the following command to query the Python version:
```
python3 --version
```
2. Ensure that Python 3.7 or later is installed, and then run the following command to install pycryptodome:
```
sudo pip3 install pycryptodome
```
### Unexpected Operator<a name="section53663205819"></a>
- **Symptom**
The build fails, and "xx.sh \[: xx unexpected operator" is displayed.
- **Cause**
The build environment is shell, not bash.
- **Solution**
```
sudo rm -rf /bin/sh
sudo ln -s /bin/bash /bin/sh
```
### What should I do when the message **Could not find a version that satisfies the requirement six\>=1.9.0** is displayed during compilation and building?<a name="section1917790845"></a>
- **Symptom**
The following error occurs during compilation and building:
```
Could not find a version that satisfies the requirement six>=1.9.0
```
- **Possible Causes**
**six** is not installed.
- **Solutions**
Solution 1: Run the **pip3 install six** command to install **six** online.
Solution 2: Install **six** offline.
- Download the installation package from [https://pypi.org/project/six/\#files](https://pypi.org/project/six/#files).
![](figures/download-six.png)
- Save the source code to the Linux server and run the **pip3 install six-1.14.0-py2.py3-none-any.whl** command to install **six**.
- Rebuild an environment.
### What should I do when the message **cannot find -lgcc** is displayed during compilation and building?<a name="section141771701647"></a>
- **Symptom**
The following error occurs during compilation and building:
```
riscv32-unknown-elf-ld: cannot find -lgcc
```
- **Possible Causes**
The PATH is incorrectly written by **gcc\_riscv32**. There is an extra slash \(/\).
```
~/gcc_riscv32/bin/:/data/toolchain/
```
- **Solutions**
Modify the PATH by deleting the slash \(/\).
```
~/gcc_riscv32/bin:/data/toolchain/
```
### What should I do when the message indicating Python cannot be found is displayed during compilation and building?<a name="section51781202415"></a>
- **Symptom**
The following error occurs during compilation and building:
```
-bash: /usr/bin/python: No such file or directory
```
- **Possible Cause 1:** Python is not installed.
- **Solutions**
[Install Python](../quick-start/quickstart-lite-env-setup-linux.md).
- **Possible Cause 2:** The soft link that points to the Python does not exist in the **usr/bin** directory.
![](figures/reason-no-python-soft-link.png)
- **Solutions**
Run the following commands to add a soft link:
```
# cd /usr/bin/
# which python3
# ln -s /usr/local/bin/python3 python
# python --version
```
Example:
![](figures/solution-add-soft-link.png)
### What should I do when the message indicating Python 3 cannot be found is displayed during compilation and building?<a name="section1917950148"></a>
- **Symptom**
![](figures/11.png)
- **Possible Causes**
Python 3 is not installed.
- **Solutions**
[Install Python](../quick-start/quickstart-lite-env-setup-linux.md).
# Environment Setup<a name="EN-US_TOPIC_0000001215650793"></a>
## Mini and Small Systems<a name="section1742119306399"></a>
### What should I do if garbled characters and segmentation faults occur during hb installation?<a name="section36351051193919"></a>
- **Symptom**
Garbled characters and segmentation faults occur during the execution of the **python3 -m pip install --user ohos-build** command.
- **Possible Causes**
pip is of an early version.
- **Solutions**
Upgrade pip.
```
python3 -m pip install -U pip
```
### What should I do if the message "cannot import 'sysconfig' from 'distutils'" is displayed during hb installation?<a name="section48221013144011"></a>
- **Symptom**
The message "cannot import 'sysconfig' from 'distutils'" is displayed during the execution of the **python3 -m pip install --user ohos-build** command.
- **Possible Causes**
The **distutils** module is unavailable.
- **Solutions**
Install **distutils**.
```
sudo apt-get install python3.8-distutils
```
### What should I do if the message "module 'platform' has no attribute 'linux\_distribution'" is displayed during hb installation?<a name="section10307193044111"></a>
- **Symptom**
The message "module 'platform' has no attribute 'linux\_distribution'" is displayed during the execution of the **python3 -m pip install --user ohos-build** command.
- **Possible Causes**
There is a compatibility issue of python3-pip.
- **Solutions**
Reinstall pip.
```
sudo apt remove python3-pip
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
```
### What should I do if the message "Could not find a version that satisfies the requirement ohos-build" is displayed during hb installation?<a name="section8692735427"></a>
- **Symptom**
The message "Could not find a version that satisfies the requirement ohos-build" is displayed during the execution of the **python3 -m pip install --user ohos-build** command.
- **Possible Causes**
The installation fails due to poor network connectivity.
- **Solutions**
1. Ensure that your computer has a good network connection. If the network connection is unstable, rectify the network fault and reinstall hb.
2. If the network is functional, run the following commands to install hb by specifying a temporary PyPI source:
```
python3 -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple ohos-build
```
### What should I do when the message **configure: error: no acceptable C compiler found in $PATH** is displayed during Python 3 installation?<a name="section870082884217"></a>
- **Symptom**
The following error occurs during Python 3 installation:
```
configure: error: no acceptable C compiler found in $PATH. See 'config.log' for more details
```
- **Possible Causes**
**GCC** is not installed.
- **Solutions**
1. Run the **apt-get install gcc** command to install **GCC** online.
2. After the installation, reinstall Python 3.
### What should I do when the message **-bash: make: command not found** is displayed during Python 3 installation?<a name="section198707170455"></a>
- **Symptom**
The following error occurs during Python 3 installation:
```
-bash: make: command not found
```
- **Possible Causes**
**Make** is not installed.
- **Solutions**
1. Run the **apt-get install make** command to install **Make** online.
2. After the installation, reinstall Python 3.
### What should I do when the message **zlib not available** is displayed during Python 3 installation?<a name="section85401445204518"></a>
- **Symptom**
The following error occurs during Python 3 installation:
```
zipimport.ZipImportError: can't decompress data; zlib not available
```
- **Possible Causes**
**zlib** is not installed.
- **Solutions**
Solution 1: Run the **apt-get install zlib** command to install **zlib** online.
Solution 2: If the software source does not contain **zlib**, download the source code from https://www.zlib.net/.
![](figures/download-zlib.png)
Then run the following commands to install **zlib** offline:
```
# tar xvf zlib-1.2.11.tar.gz
# cd zlib-1.2.11
# ./configure
# make && make install
```
After the installation, reinstall Python 3.
### What should I do when the message **No module named '\_ctypes'** is displayed during Python 3 installation?<a name="section12202694460"></a>
- **Symptom**
The following error occurs during Python 3 installation:
```
ModuleNotFoundError: No module named '_ctypes'
```
- **Possible Causes**
**libffi** and **libffi-devel** are not installed.
- **Solutions**
1. Run the **apt-get install libffi\* -y** command to install **libffi** and **libffi-devel** online.
2. After the installation, reinstall Python 3.
### What should I do when an error with **lsb\_release** occurs during **kconfiglib** installation?<a name="section5803174135115"></a>
- **Symptom**
The following error occurs during **kconfiglib** installation:
```
subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1.
```
- **Possible Causes**
The Python version matched with the **lsb\_release** module is different from the current Python version.
- **Solutions**
Run the **find / -name lsb\_release** command, for example, **sudo rm -rf /usr/bin/lsb\_release** to locate and delete **lsb\_release**.
### What should I do if the message "ImportError: No module named apt\_pkg" is displayed during the execution of an unidentifiable command?<a name="section510820516515"></a>
- **Symptom**
The message "ImportError: No module named apt\_pkg" is displayed when an unidentifiable command is executed on the Linux server.
- **Possible Causes**
There is a compatibility issue of python3-apt.
- **Solutions**
Reinstall python3-apt.
```
sudo apt-get remove python3-apt
sudo apt-get install python3-apt
```
# Kernel<a name="EN-US_TOPIC_0000001169850498"></a>
## Basic Kernel<a name="section263912372168"></a>
### What are the differences between APIs provided by LiteOS-A and LiteOS-M?<a name="section447571122918"></a>
Basic kernel APIs are different. LiteOS-A provides the standard Portable Operating System Interface \(POSIX\), and LiteOS-M provides standard POSIX and Common Microcontroller Software Interface Standard \(CMSIS\) interfaces. To support cross-platform functions, standard interfaces such as POSIX are recommended for third-party adaptation.
### How do I analyze thread stack overflow?<a name="section8623141711293"></a>
**Symptom**
The system is abnormal, and the message "CURRENT task _ThreadName_ stack overflow!" is displayed.
**Solution**
1. When creating the thread, double the thread stack size. If the problem does not recur after multiple attempts, the task stack size is insufficient and needs to be increased.
2. If the problem persists after the thread stack size is increased, check whether an ultra-large array is defined in the thread or whether recursive invoking exists in the process.
3. If the preceding causes are excluded, check whether memory corruption occurs.
## File System<a name="section098519592162"></a>
### What should I do when the Hi3516 board fails to open the same file in write mode \(LiteOS-A\)?<a name="section517972255311"></a>
When a file is already open, it is not allowed to open the file in write mode again, because the Hi3516 board uses the FAT file system.
### What hardware platforms are supported by the LiteOS kernel?<a name="section868413518533"></a>
LiteOS-A supports the Hi3516 and Hi3518 development boards. LiteOS-M supports the Hi3861 development board, STM32F103, STM32F429IGTb, and Nucleo\_f767zi. For details, see the **README.md** file in the **kernel/liteos\_m** directory.
### What chip architectures are supported by the LiteOS kernel?<a name="section1131661465417"></a>
LiteOS-M supports RISC-V, Cortex-M3, Cortex-M4, Cortex-M7, Cortex-M33, and Arm 9, and will support c-sky and Xtensa. LiteOS-A supports ARMv7-A and will support ARMv8-A. Any new update will be released in the OpenHarmony community.
## Third-party Components<a name="section971818231178"></a>
### What third-party components are supported by OpenHarmony?<a name="section74138185411"></a>
Open-source components \(such as mbedTLS and LwIP\) and third-party libraries have been provided and can be directly used. In addition, standard POSIX is provided for adaptation.
### What should I do if the key length verification fails when OpenSSL is used on OpenHarmony?<a name="section10564614135516"></a>
Check whether the architecture type \(such as ARM and x86\) and the number of system bits \(32-bit and 64-bit\) are correctly selected in OpenSSL compilation options.
### Does setsockopt support SO\_RCVBUF and SO\_SNDBUF?<a name="section2093373215556"></a>
No. It does not support SO\_RCVBUF or SO\_SNDBUF.
## Compilation and Linking<a name="section10955302179"></a>
### How do I run an application developed by ARM Linux on LiteOS-A?<a name="section1164175713557"></a>
The application must be recompiled using the cross-compiler provided in OpenHarmony before it can run.
### What system is used for OpenHarmony compilation? What compiler is used?<a name="section132287223567"></a>
LiteOS-A is compiled in the Linux environment by using the LLVM compiler. LiteOS-M can be compiled in the Linux or Windows environment by using compilers such as IAR, Keil, and GCC.
### For a third-party component that is independently compiled into a static library and used on LiteOS-M, what should I do when the component's global variable value is incorrect or the system is suspended after the component's function is called?<a name="section15189154225619"></a>
Check whether address-irrelevant compilation options, such as **-fPIE**, **-fpie**, **-fPIC**, and **-fpic**, exist in the third-party component compilation options. If yes, delete them and recompile the third-party component into a static library.
### What should I do if the message "use VFP register arguments, xxx.o does not" is displayed when LiteOS-A generates a target executable file?<a name="section193571012578"></a>
Check whether the **-mfloat-abi=xxx**, **-mcpu=xxx**, and **-mfpu=xxx** compilation options are added during the compilation of **xxx.o**. If not, add them.
### What should I do when calling clock\_gettime obtains an incorrect time?<a name="section8973152015717"></a>
In **struct timespec**, **tv\_sec** is **time\_t**, which is of the long long type, and the print control character is **%lld**. Check whether the print control character in use is correct.
# Overview of FAQs<a name="EN-US_TOPIC_0000001169691604"></a>
FAQs are used to help developers solve problems frequently encountered during development. They cover a wide range of topics.
## Environment Setup<a name="section93289248249"></a>
### Mini and Small Systems<a name="section197234983111"></a>
- [What should I do if garbled characters and segmentation faults occur during hb installation?](environment-setup.md#section36351051193919)
- [What should I do if the message "cannot import 'sysconfig' from 'distutils'" is displayed during hb installation?](environment-setup.md#section48221013144011)
- [What should I do if the message "module 'platform' has no attribute 'linux\_distribution'" is displayed during hb installation?](environment-setup.md#section10307193044111)
- [What should I do if the message "Could not find a version that satisfies the requirement ohos-build" is displayed during hb installation?](environment-setup.md#section8692735427)
- [What should I do when the message configure: error: no acceptable C compiler found in $PATH is displayed during Python 3 installation?](environment-setup.md#section870082884217)
- [What should I do when the message -bash: make: command not found is displayed during Python 3 installation?](environment-setup.md#section198707170455)
- [What should I do when the message zlib not available is displayed during Python 3 installation?](environment-setup.md#section85401445204518)
- [What should I do when the message No module named '\_ctypes' is displayed during Python 3 installation?](environment-setup.md#section12202694460)
- [What should I do when an error with lsb\_release occurs during kconfiglib installation?](environment-setup.md#section5803174135115)
- [What should I do if the message "ImportError: No module named apt\_pkg" is displayed during the execution of an unidentifiable command?](environment-setup.md#section510820516515)
## Compilation and Building<a name="section18826114693810"></a>
### Mini and Small Systems<a name="section693410399"></a>
- [Invalid -- w Option](compilation-and-building-subsystem.md#section67961431372)
- [Library ncurses Not Found](compilation-and-building-subsystem.md#section199631617371)
- [mcopy not Found](compilation-and-building-subsystem.md#section937435175)
- [No riscv File or Directory](compilation-and-building-subsystem.md#section1115535018713)
- [No Crypto](compilation-and-building-subsystem.md#section17982573813)
- [Unexpected Operator](compilation-and-building-subsystem.md#section53663205819)
- [What should I do when the message Could not find a version that satisfies the requirement six\>=1.9.0 is displayed during compilation and building?](compilation-and-building-subsystem.md#section1917790845)
- [What should I do when the message cannot find -lgcc is displayed during compilation and building?](compilation-and-building-subsystem.md#section141771701647)
- [What should I do when the message indicating Python cannot be found is displayed during compilation and building?](compilation-and-building-subsystem.md#section51781202415)
- [What should I do when the message indicating Python 3 cannot be found is displayed during compilation and building?](compilation-and-building-subsystem.md#section1917950148)
## Burning<a name="section6556741113712"></a>
### Mini and Small Systems<a name="section1029933713812"></a>
- ["Error: Opening COMxx: Access denied" Is Displayed After a Serial Port Is Selected for Burning](burning.md#section18988185615914)
- [What should I do when the image failed to be burnt?](burning.md#section1370982513317)
- [What should I do when no command output is displayed?](burning.md#section183421944953)
- [What should I do when Windows-based PC failed to be connected to the board?](burning.md#section1215410450215)
## Kernel<a name="section13741125564211"></a>
### Basic Kernel<a name="section1723365191114"></a>
- [What are the differences between APIs provided by LiteOS-A and LiteOS-M?](kernel.md#section447571122918)
- [How do I analyze thread stack overflow?](kernel.md#section8623141711293)
### File System<a name="section14523145918136"></a>
- [What should I do when the Hi3516 board fails to open the same file in write mode \(LiteOS-A\)?](kernel.md#section517972255311)
### Chip Adaptation<a name="section141541939159"></a>
- [What hardware platforms are supported by the LiteOS kernel?](kernel.md#section868413518533)
- [What chip architectures are supported by the LiteOS kernel?](kernel.md#section1131661465417)
### Third-party Components<a name="section4988163321816"></a>
- [What third-party components are supported by OpenHarmony?](kernel.md#section74138185411)
- [What should I do if the key length verification fails when OpenSSL is used on OpenHarmony?](kernel.md#section10564614135516)
- [Does setsockopt support SO\_RCVBUF and SO\_SNDBUF?](kernel.md#section2093373215556)
### Compilation and Linking<a name="section080219574225"></a>
- [How do I run an application developed by ARM Linux on LiteOS-A?](kernel.md#section1164175713557)
- [What system is used for OpenHarmony compilation? What compiler is used?](kernel.md#section132287223567)
- [For a third-party component that is independently compiled into a static library and used on LiteOS-M, what should I do when the component's global variable value is incorrect or the system is suspended after the component's function is called?](kernel.md#section15189154225619)
- [What should I do if the message "use VFP register arguments, xxx.o does not" is displayed when LiteOS-A generates a target executable file?](kernel.md#section193571012578)
- [What should I do when calling clock\_gettime obtains an incorrect time?](kernel.md#section8973152015717)
## Porting<a name="section129331824154313"></a>
- [How Do I Mount the Heap Memory to the Kernel?](porting.md#section21471536184914)
## Startup and Recovery<a name="section83501764443"></a>
- [System startup interrupted due to "parse failed!" error](startup-and-recovery.md#section835662214302)
- [System automatically restarted again and again](startup-and-recovery.md#section3857921143117)
- [Failed to call the SetParameter or GetParameter API with correct parameter values](startup-and-recovery.md#section548818116328)
## System Services<a name="section19567132114455"></a>
### Utils<a name="section3214181711465"></a>
- [1. Failure in running the KV store on the LiteOS-A kernel \(Hi3516 or Hi3518\) due to incorrect path setting for the KV store](system-applications.md#section16520347131511)
### Visual Applications<a name="section295651815466"></a>
- [Is there a global variable that can be accessed by all pages?](system-applications.md#section187297991718)
- [How do I obtain DOM elements?](system-applications.md#section1833493719175)
- [How do I pass values between pages?](system-applications.md#section184283812183)
- [How do I scroll a list to an item?](system-applications.md#section11897734131811)
- [Does the <text\> component support multiple lines?](system-applications.md#section5872656121814)
- [Why is a component not displayed?](system-applications.md#section7397125317107)
- [How do I implement scrolling on a page?](system-applications.md#section338794422010)
- [Why do not the left and top attributes take effect?](system-applications.md#section2597193611217)
- [Why does not dynamic binding take effect?](system-applications.md#section6939050172115)
- [How do I implement relative and absolute positioning?](system-applications.md#section5547311192215)
- [How do I display or hide a component?](system-applications.md#section16107113352213)
- [What are the precautions for using the margin attribute?](system-applications.md#section1524910142314)
- [What are the precautions for event subscription?](system-applications.md#section1537132012231)
- [What are the precautions for using dynamic binding?](system-applications.md#section96561452236)
- [How does the loop attribute take effect for <swiper\>?](system-applications.md#section690166112414)
- [What are the precautions for using an array?](system-applications.md#section1554552822414)
### HDC<a name="section178081876506"></a>
- [hdc\_std Fails to Connect to a Device](system-applications.md#section1965012223257)
- [hdc\_std Fails to Run](system-applications.md#section1157575212515)
# Porting<a name="EN-US_TOPIC_0000001215769367"></a>
## How Do I Mount the Heap Memory to the Kernel?<a name="section21471536184914"></a>
- The following table describes the macros for configuring the kernel heap memory. You can configure them as required in the **target\_config.h** file.
**Table 1** Macros for configuring the kernel heap memory
<a name="en-us_topic_0000001153683024_table04172020563"></a>
<table><thead align="left"><tr id="en-us_topic_0000001153683024_row5462035616"><th class="cellrowborder" valign="top" width="39.12%" id="mcps1.2.3.1.1"><p id="en-us_topic_0000001153683024_p1456204569"><a name="en-us_topic_0000001153683024_p1456204569"></a><a name="en-us_topic_0000001153683024_p1456204569"></a>Macro</p>
</th>
<th class="cellrowborder" valign="top" width="60.88%" id="mcps1.2.3.1.2"><p id="en-us_topic_0000001153683024_p19502005618"><a name="en-us_topic_0000001153683024_p19502005618"></a><a name="en-us_topic_0000001153683024_p19502005618"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="en-us_topic_0000001153683024_row14522018560"><td class="cellrowborder" valign="top" width="39.12%" headers="mcps1.2.3.1.1 "><p id="en-us_topic_0000001153683024_p35112025620"><a name="en-us_topic_0000001153683024_p35112025620"></a><a name="en-us_topic_0000001153683024_p35112025620"></a>LOSCFG_SYS_EXTERNAL_HEAP</p>
</td>
<td class="cellrowborder" valign="top" width="60.88%" headers="mcps1.2.3.1.2 "><p id="en-us_topic_0000001153683024_p5127138175710"><a name="en-us_topic_0000001153683024_p5127138175710"></a><a name="en-us_topic_0000001153683024_p5127138175710"></a>Specifies whether the internal kernel heap memory or the user heap memory will be used. The default value is <strong id="en-us_topic_0000001153683024_b161891157141719"><a name="en-us_topic_0000001153683024_b161891157141719"></a><a name="en-us_topic_0000001153683024_b161891157141719"></a>0</strong> and indicates that the internal heap memory whose size is <strong id="en-us_topic_0000001153683024_b116218121820"><a name="en-us_topic_0000001153683024_b116218121820"></a><a name="en-us_topic_0000001153683024_b116218121820"></a>0x10000</strong> will be used. If you want to use the external heap memory, set this macro to <strong id="en-us_topic_0000001153683024_b2744657141814"><a name="en-us_topic_0000001153683024_b2744657141814"></a><a name="en-us_topic_0000001153683024_b2744657141814"></a>1</strong>.</p>
</td>
</tr>
<tr id="en-us_topic_0000001153683024_row20514209567"><td class="cellrowborder" valign="top" width="39.12%" headers="mcps1.2.3.1.1 "><p id="en-us_topic_0000001153683024_p5532017563"><a name="en-us_topic_0000001153683024_p5532017563"></a><a name="en-us_topic_0000001153683024_p5532017563"></a>LOSCFG_SYS_HEAP_ADDR</p>
</td>
<td class="cellrowborder" valign="top" width="60.88%" headers="mcps1.2.3.1.2 "><p id="en-us_topic_0000001153683024_p65520125619"><a name="en-us_topic_0000001153683024_p65520125619"></a><a name="en-us_topic_0000001153683024_p65520125619"></a>Specifies the start address of the kernel heap memory.</p>
</td>
</tr>
<tr id="en-us_topic_0000001153683024_row15302929115615"><td class="cellrowborder" valign="top" width="39.12%" headers="mcps1.2.3.1.1 "><p id="en-us_topic_0000001153683024_p113021529145612"><a name="en-us_topic_0000001153683024_p113021529145612"></a><a name="en-us_topic_0000001153683024_p113021529145612"></a>LOSCFG_SYS_HEAP_SIZE</p>
</td>
<td class="cellrowborder" valign="top" width="60.88%" headers="mcps1.2.3.1.2 "><p id="en-us_topic_0000001153683024_p1030252965619"><a name="en-us_topic_0000001153683024_p1030252965619"></a><a name="en-us_topic_0000001153683024_p1030252965619"></a>Specifies the size of the kernel heap memory, that is, size of the memory block specified by <strong id="en-us_topic_0000001153683024_b1611815991419"><a name="en-us_topic_0000001153683024_b1611815991419"></a><a name="en-us_topic_0000001153683024_b1611815991419"></a>LOSCFG_SYS_HEAP_ADDR</strong>.</p>
</td>
</tr>
</tbody>
</table>
- Note:
Ensure that the specified heap memory range is not used by other modules. Otherwise, functions of the heap memory will be damaged due to the heap memory corruption.
# Startup and Recovery<a name="EN-US_TOPIC_0000001215449321"></a>
## System startup interrupted due to "parse failed!" error<a name="section835662214302"></a>
**Problem**
During system startup, the error message "\[Init\] InitReadCfg, parse failed! please check file /etc/init.cfg format." is displayed, and the startup is interrupted, as shown in the following figure.
**Figure 1** Error information<a name="en-us_topic_0000001063231870_fig15217111545118"></a>
![](figures/error-information.png "error-information")
**Cause**
During the modification of the **init.cfg** file, required commas \(,\) or parentheses are missing or unnecessary ones are added. As a result, the file's JSON format becomes invalid.
**Solution**
Check the **init.cfg** file and ensure that its format meets the JSON specifications.
## System automatically restarted again and again<a name="section3857921143117"></a>
**Problem**
After the image burning is complete, the system keeps restarting.
**Cause**
Each service started by the init process has the **importance** attribute, as described in Table 3 in init Module.
- If the attribute value is **0**, the init process does not need to restart the development board when the current service process exits.
- If the attribute value is **1**, the init process needs to restart the development board when the current service process exits.
During the startup of a service whose **importance** is **1**, if the service exits due to a process crash or an error, the init process automatically restarts the development board.
**Solution**
1. View logs to identify the service that encounters a process crash or exits due to an error, rectify the issue, and then burn the image again.
2. Alternatively, change the value of **importance** to **0** for the service that exits due to a process crash or an error, and then burn the image again. In this way, the development board will not be restarted even if the service exits.
## Failed to call the **SetParameter** or **GetParameter** API with correct parameter values<a name="section548818116328"></a>
**Problem**
Calling the **SetParameter** or **GetParameter** API fails even if correct values are passed to all input parameters.
**Cause**
Permission verification has been enabled for the **SetParameter** and **GetParameter** APIs. If the UID of the caller is greater than 1000, that is, the caller does not have the permission to call these APIs, API calls will fail even if the parameters are correct.
**Solution**
No action is required.
# System Applications<a name="EN-US_TOPIC_0000001169690992"></a>
## Utils<a name="section639433461512"></a>
### 1. Failure in running the KV store on the LiteOS-A kernel \(Hi3516 or Hi3518\) due to incorrect path setting for the KV store<a name="section16520347131511"></a>
**Problem**
When the LiteOS-A kernel \(Hi3516 or Hi3518 platform\) directly calls the API provided by the KV store, the compiled executable program fails to run.
**Possible Causes**
The compiled executable program is run directly without being converted to an application using **AbilityKit** APIs. In this case, the Bundle Manager Service \(BMS\) cannot correctly set the path for storing application data during application installation. As a result, the KV store fails to run.
**Solution**
Call the **UtilsSetEnv** function of the KV store to set the data storage path.
```
UtilsSetEnv("/storage/com.huawei.kv");
```
## Visual Applications<a name="section787718474161"></a>
### Is there a global variable that can be accessed by all pages?<a name="section187297991718"></a>
There is no such a global variable.
### How do I obtain DOM elements?<a name="section1833493719175"></a>
You can obtain DOM elements via the **ref** attribute. You can use methods of the obtained elements but cannot change their attributes. The sample code is as follows:
```
<!--index.hml-->
<div class="container">
<!-- Set the ref attribute of the component to animator -->.
<image-animator class="image-player" ref="animator" images="{{images}}" duration="1s" onclick="handleClick"></image-animator>
</div>
/* index.js */
export default {
data: {
images:[
{src:"common/frame1.png"},
{src:"common/frame2.png"},
{src:"common/frame3.png"}
]
},
handleClick(){
// Obtain the component through the $refs attribute. (The ref attribute of the component has been set to animator in the HML file.)
const animator = this.$refs.animator;
const state = animator.getState();
if(state == "paused"){
animator.resume();
}else if(state == "stopped"){
animator.start();
}else{
animator.pause();
}
}
}
```
### How do I pass values between pages?<a name="section184283812183"></a>
You can pass values through **params** of the **router.replace** method. The sample code is as follows:
Set **params** to the values to be passed on a page.
```
router.replace({
uri:'pages/detail/detail', // URI of the page to switch to.
params:{transferData:this.data} // Data to be transferred. You need to define the data amount and name.
});
```
Receive the passed values on another page.
```
onInit(){
const data = this.transferData; // Receive the transferred data by the onInit function.
}
```
### How do I scroll a list to an item?<a name="section11897734131811"></a>
Call the **scrollTo** method of the list. The input parameter of this method is the index of the target item. You can specify an item index, or obtain the index through the **scrollend** event.
### Does the **<text\>** component support multiple lines?<a name="section5872656121814"></a>
Yes. You can use the Enter key to start a new line. Alternatively, the component automatically starts a new line based on the content, without the need to set the height attribute of the text.
### Why is a component not displayed?<a name="section7397125317107"></a>
**Description**
The component added to the **.hml** file cannot be displayed.
**Possible Causes**
- The width and height of the component may not be set.
- The style setting may be incorrect.
**Solution**
\(1\) Check whether the width and height values are set explicitly.
\(2\) Check whether the style of the component is set correctly.
### How do I implement scrolling on a page?<a name="section338794422010"></a>
There are three ways to implement page scrolling: **scroll**, **<list\>**, or **<swiper\>**. For a root component with **scroll** set, the scrolling effect is automatically implemented when the component size exceeds the screen size. For details, see the development specifications.
### Why do not the **left** and **top** attributes take effect?<a name="section2597193611217"></a>
**left** and **top** attributes must work with the **<stack\>** component in addition to the root component.
### Why does not dynamic binding take effect?<a name="section6939050172115"></a>
The object or its attributes are not defined before dynamic binding.
### How do I implement relative and absolute positioning?<a name="section5547311192215"></a>
You can use the **<div\>** and **<stack\>** \(with **top** and **left** attributes\) components.
### How do I display or hide a component?<a name="section16107113352213"></a>
You can use **display**, **show**, or **if**. When an **if** clause evaluates to **false**, the corresponding component will be removed from the VDOM. When **show** is set to **false**, the component will be invisible during rendering, but will not be removed from the VDOM.
### What are the precautions for using the **margin** attribute?<a name="section1524910142314"></a>
The **margin** attribute cannot be set for child components of the **<stack\>** component.
### What are the precautions for event subscription?<a name="section1537132012231"></a>
Only one page exists when the application is running. Therefore, the **router.replace** function destroys the previous page and then creates a new one. For pages involving event subscription, an event should be subscribed every time a page is created, and unsubscribed before page switching.
### What are the precautions for using dynamic binding?<a name="section96561452236"></a>
Do not use too many dynamic bindings because they consume too much memory.
### How does the **loop** attribute take effect for **<swiper\>**?<a name="section690166112414"></a>
If the total length of the child components, except for the first and last ones, is greater than the length of **<swiper\>**, the **loop** attribute takes effect.
### What are the precautions for using an array?<a name="section1554552822414"></a>
Do not include too many elements in an array. Avoid frequent operations on a large array.
## HDC<a name="section412357182518"></a>
### hdc\_std Fails to Connect to a Device<a name="section1965012223257"></a>
- **Symptom**
**\[Empty\]** is displayed in the output after the **hdc\_std list targets** command is executed.
- **Solutions**
1. The device cannot be identified.
Check whether **HDC Device** exists in the universal serial bus device of the device manager. If **HDC Device** does not exist, the device cannot be connected. In this case, remove and then insert the device or burn the latest image for the device.
2. hdc\_std works improperly.
Run the **hdc kill** or **hdc start -r** command to kill or restart the hdc service. Then, run the **hdc list targets** command to check whether device information can be obtained.
3. hdc\_std does not match the device.
If the latest image is burnt on the device, the latest hdc\_std version must be used. As hdc\_std is updated continuously, obtain hdc\_std of the latest version from the **developtools\_hdc\_standard** repository in the **prebuilt** directory.
### hdc\_std Fails to Run<a name="section1157575212515"></a>
- **Symptom**
The **hdc\_std.exe** file does not run after being clicked.
- **Solutions**
**hdc\_std.exe** requires no installation. It can be directly used on a disk or added to environment variables. Open the cmd window and run the **hdc\_std** command to use **hdc\_std.exe**.
# 编译构建子系统常见问题<a name="ZH-CN_TOPIC_0000001215530845"></a>
- [轻量和小型系统](#section78686441462)
- [编译构建过程中,提示“usr/sbin/ninja: invalid option -- w”](#section67961431372)
- [编译构建过程中,提示“/usr/bin/ld: cannot find -lncurses”](#section199631617371)
- [编译构建过程中,提示“line 77: mcopy: command not found”](#section937435175)
- [编译构建过程中,提示“riscv32-unknown-elf-gcc: error trying to exec 'cc1': execvp: No such file or directory”](#section1115535018713)
- [编译构建过程中,提示“No module named 'Crypto'”](#section17982573813)
- [编译构建过程中,提示“xx.sh : xx unexpected operator”](#section53663205819)
- [编译构建过程中,提示“Could not find a version that satisfies the requirement six\>=1.9.0”](#section1917790845)
- [编译构建过程中,提示找不到“-lgcc”](#section141771701647)
- [编译构建过程中,提示找不到“python”](#section51781202415)
- [编译构建过程中,提示找不到“python3”](#section1917950148)
## 轻量和小型系统<a name="section78686441462"></a>
### 编译构建过程中,提示“usr/sbin/ninja: invalid option -- w”<a name="section67961431372"></a>
- **现象描述:**
编译失败,提示“usr/sbin/ninja: invalid option -- w”。
- **可能原因:**
编译环境中ninja版本太低,不支持--w选项。
- **解决办法:**
卸载环境中ninja和gn,按照[获取工具](../get-code/gettools-ide.md)。
### 编译构建过程中,提示“/usr/bin/ld: cannot find -lncurses”<a name="section199631617371"></a>
- **现象描述:**
编译失败,提示“/usr/bin/ld: cannot find -lncurses”。
- **可能原因:**
编译环境ncurses库缺失。
- **解决办法:**
```
sudo apt-get install lib32ncurses5-dev
```
### 编译构建过程中,提示“line 77: mcopy: command not found”<a name="section937435175"></a>
- **现象描述:**
​编译失败,提示“line 77: mcopy: command not found”。
- **可能原因:**
编译环境未安装mcopy。
- **解决办法:**
```
​sudo apt-get install dosfstools mtools
```
### 编译构建过程中,提示“riscv32-unknown-elf-gcc: error trying to exec 'cc1': execvp: No such file or directory”<a name="section1115535018713"></a>
- **现象描述:**
编译失败,提示“riscv32-unknown-elf-gcc: error trying to exec 'cc1': execvp: No such file or directory”。
-**可能原因:**
当前用户对riscv编译器路径下的文件访问权限不够。
-**解决办法:**
查询gcc\_riscv32所在目录。
```
which riscv32-unknown-elf-gcc
```
使用chmod命令修改目录权限为755。
### 编译构建过程中,提示“No module named 'Crypto'”<a name="section17982573813"></a>
- **现象描述:**
编译失败,提示“No module named 'Crypto'”。
- **可能原因:**
python3未安装Crypto。
- **解决办法:**
1. 查询Python版本号。
```
python3 --version
```
2. 需使用python3.7以上版本,然后安装pycryptodome。
```
sudo pip3 install pycryptodome
```
### 编译构建过程中,提示“xx.sh : xx unexpected operator”<a name="section53663205819"></a>
- **现象描述:**
编译失败:“xx.sh \[: xx unexpected operator”。
- **可能原因:**
编译环境shell不是bash。
- **解决办法:**
```
sudo rm -rf /bin/sh
sudo ln -s /bin/bash /bin/sh
```
### 编译构建过程中,提示“Could not find a version that satisfies the requirement six\>=1.9.0”<a name="section1917790845"></a>
- **现象描述**
编译构建过程中出现以下错误:
```
Could not find a version that satisfies the requirement six>=1.9.0
```
- **可能原因**
环境中未安装合适的“six”。
- **解决办法**
方法1:通过命令“pip3 install six”,在线安装。
方法2:离线安装
通过网页[https://pypi.org/project/six/\#files](https://pypi.org/project/six/#files),下载安装包。
![](figures/download-six.png)
将源码放置在Linux服务器中,并安装“pip3 install six-1.14.0-py2.py3-none-any.whl”。
完成上述安装后,重新构建。
### 编译构建过程中,提示找不到“-lgcc”<a name="section141771701647"></a>
- **现象描述**
编译构建过程中出现以下错误:
```
riscv32-unknown-elf-ld: cannot find -lgcc
```
- **可能原因**
交叉编译器gcc\_riscv32的PATH添加错误,如下,在"bin"后多添加了一个“/”,应该删除。
```
~/gcc_riscv32/bin/:/data/toolchain/
```
- **解决办法**
重新修改gcc\_riscv32的PATH,将多余的“/”删除。
```
~/gcc_riscv32/bin:/data/toolchain/
```
### 编译构建过程中,提示找不到“python”<a name="section51781202415"></a>
- **现象描述**
编译构建过程中出现以下错误:
```
-bash: /usr/bin/python: No such file or directory
```
- **可能原因**1
没有装python。
- **解决办法**
请使用如下命令安装Python,下方以Python3.8为例。
```
sudo apt-get install python3.8
```
- **可能原因2**
usr/bin目录下没有python软链接
![](figures/reason-no-python-soft-link.png)
- **解决办法**
请运行以下命令添加软链接:
```
# cd /usr/bin/
# which python3
# ln -s /usr/local/bin/python3 python
# python --version
```
例:
![](figures/solution-add-soft-link.png)
### 编译构建过程中,提示找不到“python3”<a name="section1917950148"></a>
- **现象描述**
安装python3过程中出现以下错误:
```
configure: error: no acceptable C compiler found in $PATH. See 'config.log' for more details
```
- **可能原因**
环境中未安装“gcc”。
- **解决办法**
1. 通过命令“apt-get install gcc”在线安装。
2. 完成后,重新安装python3。
# 烧录常见问题<a name="ZH-CN_TOPIC_0000001170009518"></a>
- [轻量和小型系统](#section278314413530)
- [烧写选择串口后,提示“Error: Opening COMxx: Access denied”](#section18988185615914)
- [烧写失败](#section1370982513317)
- [串口无回显](#section183421944953)
- [Windows电脑与单板网络连接失败](#section1215410450215)
## 轻量和小型系统<a name="section278314413530"></a>
### 烧写选择串口后,提示“Error: Opening COMxx: Access denied”<a name="section18988185615914"></a>
- **现象描述**
点击烧写并选择串口后,出现“Error: Opening COMxx: Access denied”。
![](figures/Failed-to-open-the-serial-port.png)
- **可能原因**
串口已经被占用。
- 解决方法
检查主机中可能占用该端口的工具,关闭即可。若是当前工具占用,可按以下步骤排查并关闭:
1. 排查终端窗口列表,检查是否被monitor或其他终端占用。
![](figures/terminal-list.png)
2. 找到占用,点击垃圾桶图标,关闭占用。
### 烧写失败<a name="section1370982513317"></a>
- **现象描述**
点击烧写并选择串口后,出现无法烧写的情况。
- **可能原因**
安装IDE插件DevEco后未重启。
- **解决方法**
重启IDE。
### 串口无回显<a name="section183421944953"></a>
- **现象描述**
串口显示已连接,重启单板后,回车无任何回显。
- **可能原因1**
串口连接错误。
- **解决办法**
修改串口号。
请查看设备管理器,确认连接单板的串口与终端中连接串口是否一致,若不一致,请按镜像运行修改串口号。
- **可能原因2**
单板U-boot被损坏。
- **解决办法**
烧写U-boot。
若上述步骤依旧无法连接串口,可能由于单板U-boot损坏,按下述步骤烧写U-boot。
1. 获取引导文件U-boot。
>![](../public_sys-resources/icon-notice.gif) **须知:**
>单板的U-boot文件请在开源包中获取:
>Hi3516DV300:device\\hisilicon\\hispark\_taurus\\sdk\_liteos\\uboot\\out\\boot\\u-boot-hi3516dv300.bin
>Hi3518EV300:device\\hisilicon\\hispark\_aries\\sdk\_liteos\\uboot\\out\\boot\\u-boot-hi3518ev300.bin
2. 根据USB烧写步骤烧写U-boot文件。
按照[Hi3516系列USB烧写步骤](https://device.harmonyos.com/cn/docs/ide/user-guides/hi3516_upload-0000001052148681)/[Hi3518系列USB烧写步骤](https://device.harmonyos.com/cn/docs/ide/user-guides/hi3518_upload-0000001057313128)中描述的USB烧写方法,选择对应单板的U-boot文件进行烧写。
3. 烧写完成后,登录串口如下图所示。
**图 1** U-boot烧写完成串口显示图<a name="zh-cn_topic_0000001128470856_zh-cn_topic_0000001053466255_fig155914681910"></a>
![](figures/U-boot烧写完成串口显示图.png "U-boot烧写完成串口显示图")
### Windows电脑与单板网络连接失败<a name="section1215410450215"></a>
- **现象描述**
点击烧写并选择串口后,无法获取文件。
**图 2** 网络不通,Hi3516单板无法获取文件<a name="zh-cn_topic_0000001128470856_fig135261439195819"></a>
![](figures/网络不通-Hi3516单板无法获取文件.png "网络不通-Hi3516单板无法获取文件")
- **可能原因**
单板网络与Windows电脑不联通。
Windows电脑防火墙未允许Visual Studio Code联网。
- **解决方法**
1. 检查网线是否连接。
2. 点击Windows防火墙。
![](figures/hi3516-network-and-firewall-setting.png)
3. 点击“允许应用通过防火墙”。
![](figures/hi3516-firewall-and-network-protection.png)
4. 查找Visual Studio Code应用。
![](figures/hi3516-selecting-the-visual-studio-code-application.png)
5. 勾选Visual Studio Code的专用和公用网络的访问权限。
![](figures/hi3516-allowing-the-visual-studio-code-application-to-access-the-network.png)
# 环境搭建常见问题<a name="ZH-CN_TOPIC_0000001215650793"></a>
- [轻量和小型系统](#section1742119306399)
- [安装hb过程中,出现乱码、段错误](#section36351051193919)
- [安装hb过程中,提示"cannot import 'sysconfig' from 'distutils'"](#section48221013144011)
- [安装hb过程中,提示"module 'platform' has no attribute 'linux\_distribution'"](#section10307193044111)
- [安装hb过程中,提示"Could not find a version that satisfies the requirement ohos-build"](#section8692735427)
- [安装python3过程中,提示“configure: error: no acceptable C compiler found in $PATH”](#section870082884217)
- [安装python3过程中,提示“-bash: make: command not found”](#section198707170455)
- [安装python3过程中,提示“zlib not available”](#section85401445204518)
- [安装python3过程中,提示“No module named '\_ctypes'”](#section12202694460)
- [安装 kconfiglib时,遇到lsb\_release错误](#section5803174135115)
- [Linux编译服务器终端输入不识别的命令时提示“ImportError: No module named apt\_pkg”](#section510820516515)
## 轻量和小型系统<a name="section1742119306399"></a>
### 安装hb过程中,出现乱码、段错误<a name="section36351051193919"></a>
- **现象描述**
执行“python3 -m pip install --user ohos-build”出现乱码、段错误(segmentation fault)。
- **可能原因**
pip版本过低。
- **解决办法**
执行如下命令升级pip。
```
python3 -m pip install -U pip
```
### 安装hb过程中,提示"cannot import 'sysconfig' from 'distutils'"<a name="section48221013144011"></a>
- **现象描述**
执行“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'"<a name="section10307193044111"></a>
- **现象描述**
执行“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"<a name="section8692735427"></a>
- **现象描述**
执行“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”<a name="section870082884217"></a>
- **现象描述**
安装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”<a name="section198707170455"></a>
- **现象描述**
安装python3过程中出现以下错误:
```
-bash: make: command not found
```
- **可能原因**
环境中未安装“make”。
- **解决办法**
1、通过命令“apt-get install make”在线安装。
2、完成后,重新安装python3。
### 安装python3过程中,提示“zlib not available”<a name="section85401445204518"></a>
- **现象描述**
安装python3过程中出现以下错误:
```
zipimport.ZipImportError: can't decompress data; zlib not available
```
- **可能原因**
环境中未安装“zlib”。
- **解决办法**
方法1:通过命令“apt-get install zlib”在线安装。
方法2:如果软件源中没有该软件,请从“www.zlib.net”下载版本代码,并离线安装。
![](figures/download-zlib.png)
完成下载后,通过以下命令安装:
```
# tar xvf zlib-1.2.11.tar.gz
# cd zlib-1.2.11
# ./configure
# make && make install
```
完成后,重新安装python3。
### 安装python3过程中,提示“No module named '\_ctypes'”<a name="section12202694460"></a>
- **现象描述**
安装python3过程中出现以下错误:
```
ModuleNotFoundError:No module named ‘_ctypes’
```
- **可能原因**
环境中未安装“libffi”和“libffi-devel”。
- **解决办法**
1、通过命令“apt-get install libffi\* -y”,在线安装。
2、完成后,重新安装python3。
### 安装 kconfiglib时,遇到lsb\_release错误<a name="section5803174135115"></a>
- **现象描述**
安装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”<a name="section510820516515"></a>
- **现象描述**
Linux编译服务器终端输入不识别的命令时,提示"ImportError: No module named apt\_pkg"
- **可能原因**
python3 apt安装兼容性问题。
- **解决办法**
执行如下命令重新安装python3-apt。
```
sudo apt-get remove python3-apt
sudo apt-get install python3-apt
```
# 启动恢复常见问题<a name="ZH-CN_TOPIC_0000001215449321"></a>
- [系统启动过程中打印“parse failed!”错误后停止启动](#section835662214302)
- [系统启动过程未结束就自动重启,如此反复持续](#section3857921143117)
- [参数正确的情况下调用SetParameter/GetParameter返回失败](#section548818116328)
## 系统启动过程中打印“parse failed!”错误后停止启动<a name="section835662214302"></a>
**现象描述**
系统启动过程中,打印“\[Init\] InitReadCfg, parse failed! please check file /etc/init.cfg format.”错误,启动过程停止,如下图所示:
**图 1** 运行报错图<a name="zh-cn_topic_0000001063231870_fig15217111545118"></a>
![](figures/运行报错图.png "运行报错图")
**可能原因**
修改init.cfg文件时,漏掉或多加了逗号或括号等,导致init.cfg文件的json格式被破坏。
**解决办法**
仔细检查init.cfg文件,确保其格式符合json格式要求。
## 系统启动过程未结束就自动重启,如此反复持续<a name="section3857921143117"></a>
**现象描述**
镜像烧写完成后系统启动,启动过程未完成即自动重新启动,如此反复持续。
**可能原因**
被init启动的服务都有一个叫做“importance”的属性(详见[第2章表3](../subsystems/subsys-boot-init.md)描述)。
- 当该属性为0时,表示若当前服务进程退出,init不需要重启单板。
- 当该属性为1时,表示若当前服务进程退出,init需要重启单板。
因此出现上述现象的可能原因:有“importance”属性为1的服务在每次启动的过程中都会退出(可能是进程崩溃或出错自动退出),导致init进程自动重启单板。
**解决办法**
1. 需要通过日志确认崩溃或报错退出的服务,并解决其崩溃/报错的问题,然后重新烧写镜像即可。
2. 也可以将崩溃/报错退出的服务的“importance”属性改为0,然后重新烧写镜像,这样即使其退出,init也不会重启单板。
## 参数正确的情况下调用SetParameter/GetParameter返回失败<a name="section548818116328"></a>
**现象描述**
在各参数正确的情况下调用SetParameter/GetParameter返回失败。
**可能原因**
程序对SetParameter/GetParameter这两个接口做了权限校验,在各参数正确的情况下调用SetParameter/GetParameter返回操作失败,很有可能是调用者的uid大于1000,没有调用权限。
**解决办法**
无需处理
# 内核常见问题<a name="ZH-CN_TOPIC_0000001169850498"></a>
- [基础内核](#section263912372168)
- [LiteOS-A和LiteOS-M内核对外API的差异](#section447571122918)
- [如何分析线程栈溢出](#section8623141711293)
- [文件系统](#section098519592162)
- [Hi3516开源板以写的模式打开同一个文件失败(LiteOS-A)](#section517972255311)
- [LiteOS内核已支持哪些硬件平台](#section868413518533)
- [LiteOS内核已支持哪几款芯片架构](#section1131661465417)
- [三方组件](#section971818231178)
- [OpenHarmony已支持哪些三方组件](#section74138185411)
- [在OpenHarmony上使用OpenSSL,出现秘钥长度校验不正确](#section10564614135516)
- [setsockopt是否支持SO\_RCVBUF和SO\_SNDBUF选项](#section2093373215556)
- [编译链接](#section10955302179)
- [Arm Linux开发的应用程序,OpenHarmony如何在LiteOS-A上运行](#section1164175713557)
- [OpenHarmony在什么系统下编译,使用什么编译器](#section132287223567)
- [LiteOS-M上使用单独编译成静态库的三方组件,出现三方组件中的全局变量值不正确,或调用三方组件的函数后系统卡死](#section15189154225619)
- [LiteOS-A生成目标可执行文件时,提示 use VFP register arguments,xxx.o does not](#section193571012578)
- [clock\_gettime接口获取的时间打印不对](#section8973152015717)
## 基础内核<a name="section263912372168"></a>
### LiteOS-A和LiteOS-M内核对外API的差异<a name="section447571122918"></a>
基础内核API存在差异,但是LiteOS-A提供标准POSIX接口,LiteOS-M提供标准POSIX和CMSIS接口。如果要支持跨平台,三方适配建议使用POSIX等标准接口。
### 如何分析线程栈溢出<a name="section8623141711293"></a>
**问题现象**
系统异常,提示CURRENT task xxx stack overflow!
**解决措施**
1. 创建xxx线程的时候成倍加大栈空间,多次尝试如果问题不复现,则说明任务栈不够,需要调整;
2. 如果成倍加大线程栈,问题依旧复现,则排查xxx线程中是否定义超大数组,或者流程是否存在递归调用;
3. 确认无前述问题,则需要排查是否存在踩内存的情况。
## 文件系统<a name="section098519592162"></a>
### Hi3516开源板以写的模式打开同一个文件失败(LiteOS-A)<a name="section517972255311"></a>
Hi3516开源板使用FAT文件系统,不允许该操作。
### LiteOS内核已支持哪些硬件平台<a name="section868413518533"></a>
开源版本LiteOS-A已支持Hi3516/Hi3518开发板;LiteOS-M已支持Hi3861开发板、STM32F103、野火挑战者STM32F429IGTb、Nucleo\_f767zi等,详细查看kernel/liteos\_m目录下的README\_zh.md文件。
### LiteOS内核已支持哪几款芯片架构<a name="section1131661465417"></a>
LiteOS-M已支持risc-v、Cortex-m3\\m4\\m7\\m33、arm9,待支持c-sky、xtensa;LiteOS-A已支持armv7-a,待支持armv8-a,请关注开源社区更新。
## 三方组件<a name="section971818231178"></a>
### OpenHarmony已支持哪些三方组件<a name="section74138185411"></a>
已提供mbedtls、lwip等开源组件和三方库,可以直接使用;另外提供标准的POSIX接口,可以自行适配。
### 在OpenHarmony上使用OpenSSL,出现秘钥长度校验不正确<a name="section10564614135516"></a>
OpenSSL编译选项中要注意架构类型(ARM,X86等)和系统位数(32、64位)是否选择正确。
### setsockopt是否支持SO\_RCVBUF和SO\_SNDBUF选项<a name="section2093373215556"></a>
不支持。
## 编译链接<a name="section10955302179"></a>
### Arm Linux开发的应用程序,OpenHarmony如何在LiteOS-A上运行<a name="section1164175713557"></a>
需要用开源版本提供的交叉编译器重新编译应用程序,才可以运行。
### OpenHarmony在什么系统下编译,使用什么编译器<a name="section132287223567"></a>
LiteOS-A在linux环境进行编译,使用LLVM编译器;LiteOS-M在Linux或Windows环境进行编译,使用IAR、Keil、GCC等编译工具。
### LiteOS-M上使用单独编译成静态库的三方组件,出现三方组件中的全局变量值不正确,或调用三方组件的函数后系统卡死<a name="section15189154225619"></a>
检查三方组件编译选项中是否有-fPIE -fpie -fPIC -fpic等地址无关编译选项,如果有,则去掉,重新编译成库使用。
### LiteOS-A生成目标可执行文件时,提示 use VFP register arguments,xxx.o does not<a name="section193571012578"></a>
请确认xxx.o编译时是否添加-mfloat-abi=xxx -mcpu=xxx -mfpu=xxx编译选项,若没有,则需要添加。
### clock\_gettime接口获取的时间打印不对<a name="section8973152015717"></a>
struct timespec结构中tv\_sec为time\_t,而time\_t为long long类型,打印控制符为%lld,请确认实际打印控制符是否正确。
# 常见问题概述<a name="ZH-CN_TOPIC_0000001169691604"></a>
- [环境搭建](#section93289248249)
- [轻量和小型系统](#section197234983111)
- [编译构建子系统](#section18826114693810)
- [轻量和小型系统](#section693410399)
- [烧录](#section6556741113712)
- [轻量和小型系统](#section1029933713812)
- [内核](#section13741125564211)
- [基础内核](#section1723365191114)
- [文件系统](#section14523145918136)
- [芯片适配](#section141541939159)
- [三方组件](#section4988163321816)
- [编译链接](#section080219574225)
- [移植](#section129331824154313)
- [启动恢复](#section83501764443)
- [系统服务](#section19567132114455)
- [公共基础库](#section3214181711465)
- [视觉应用常见问题](#section295651815466)
- [hdc](#section178081876506)
常见问题主要用于帮助开发者解决在开发过程中经常出现的一类问题问题。当前提供了如下常见问题供开发者进行查询。
## 环境搭建<a name="section93289248249"></a>
### 轻量和小型系统<a name="section197234983111"></a>
- [安装hb过程中出现乱码、段错误](faqs-environment-building.md#section36351051193919)
- [安装hb过程中,提示"cannot import 'sysconfig' from 'distutils'"](faqs-environment-building.md#section48221013144011)
- [安装hb过程中,提示"module 'platform' has no attribute 'linux\_distribution'"](faqs-environment-building.md#section8692735427)
- [安装hb过程中,提示"Could not find a version that satisfies the requirement ohos-build"](faqs-environment-building.md#section8692735427)
- [安装python3过程中,提示“configure: error: no acceptable C compiler found in $PATH”](faqs-environment-building.md#section870082884217)
- [安装python3过程中,提示“-bash: make: command not found”](faqs-environment-building.md#section198707170455)
- [安装python3过程中,提示“zlib not available”](faqs-environment-building.md#section85401445204518)
- [安装python3过程中,提示“No module named '\_ctypes'”](faqs-environment-building.md#section12202694460)
- [安装 kconfiglib时,遇到lsb\_release错误](faqs-environment-building.md#section5803174135115)
- [Linux编译服务器终端输入不识别的命令时提示“ImportError: No module named apt\_pkg”](faqs-environment-building.md#section510820516515)
## 编译构建子系统<a name="section18826114693810"></a>
### 轻量和小型系统<a name="section693410399"></a>
- [编译构建过程中,提示“usr/sbin/ninja: invalid option -- w”](faqs-building.md#section67961431372)
- [编译构建过程中,提示“/usr/bin/ld: cannot find -lncurses”](faqs-building.md#section199631617371)
- [编译构建过程中,提示“line 77: mcopy: command not found”](faqs-building.md#section937435175)
- [编译构建过程中,提示“riscv32-unknown-elf-gcc: error trying to exec 'cc1': execvp: No such file or directory”](faqs-building.md#section1115535018713)
- [编译构建过程中,提示“No module named 'Crypto'”](faqs-building.md#section17982573813)
- [编译构建过程中,提示“Could not find a version that satisfies the requirement six\>=1.9.0”](faqs-building.md#section1917790845)
- [编译构建过程中,提示“Could not find a version that satisfies the requirement six\>=1.9.0”](faqs-building.md#section1917790845)
- [编译构建过程中,提示找不到“-lgcc”](faqs-building.md#section141771701647)
- [编译构建过程中,提示找不到“python”](faqs-building.md#section51781202415)
- [编译构建过程中,提示找不到“python3”](faqs-building.md#section1917950148)
## 烧录<a name="section6556741113712"></a>
### 轻量和小型系统<a name="section1029933713812"></a>
- [烧写选择串口后,提示“Error: Opening COMxx: Access denied”](faqs-burning.md#section18988185615914)
- [烧写失败](faqs-burning.md#section1370982513317)
- [串口无回显](faqs-burning.md#section183421944953)
- [Windows电脑与单板网络连接失败](faqs-burning.md#section1215410450215)
## 内核<a name="section13741125564211"></a>
### 基础内核<a name="section1723365191114"></a>
- [LiteOS-A和LiteOS-M内核对外API的差异](faqs-kernel.md#section447571122918)
- [如何分析线程栈溢出](faqs-kernel.md#section8623141711293)
### 文件系统<a name="section14523145918136"></a>
- [Hi3516开源板以写的模式打开同一个文件失败(LiteOS-A)](faqs-kernel.md#section517972255311)
### 芯片适配<a name="section141541939159"></a>
- [LiteOS内核已支持哪些硬件平台](faqs-kernel.md#section868413518533)
- [LiteOS内核已支持哪几款芯片架构](faqs-kernel.md#section1131661465417)
### 三方组件<a name="section4988163321816"></a>
- [OpenHarmony已支持哪些三方组件](faqs-kernel.md#section74138185411)
- [在OpenHarmony上使用OpenSSL,出现秘钥长度校验不正确](faqs-kernel.md#section10564614135516)
- [setsockopt是否支持SO\_RCVBUF和SO\_SNDBUF选项](faqs-kernel.md#section2093373215556)
### 编译链接<a name="section080219574225"></a>
- [Arm Linux开发的应用程序,如何在LiteOS-A上运行](faqs-kernel.md#section1164175713557)
- [OpenHarmony在什么系统下编译,使用什么编译器](faqs-kernel.md#section132287223567)
- [LiteOS-M上使用单独编译成静态库的三方组件,出现三方组件中的全局变量值不正确,或调用三方组件的函数后系统卡死](faqs-kernel.md#section15189154225619)
- [LiteOS-A生成目标可执行文件,提示 use VFP register arguments,xxx.o does not](faqs-kernel.md#section193571012578)
- [clock\_gettime接口获取的时间打印不对](faqs-kernel.md#section8973152015717)
## 移植<a name="section129331824154313"></a>
- [如何将用户的堆内存挂载进内核](faqs-transplant.md#section21471536184914)
## 启动恢复<a name="section83501764443"></a>
- [系统启动过程中打印“parse failed!”错误后停止启动](faqs-init.md#section835662214302)
- [系统启动过程未结束就自动重启,如此反复持续](faqs-init.md#section3857921143117)
- [参数正确的情况下调用SetParameter/GetParameter返回失败](faqs-init.md#section548818116328)
## 系统服务<a name="section19567132114455"></a>
### 公共基础库<a name="section3214181711465"></a>
- [LiteOS-A内核\(Hi3516、Hi3518平台\)KV存储路径设置错误,导致KV存储运行失败](faqs-system-using.md#section16520347131511)
### 视觉应用常见问题<a name="section295651815466"></a>
- [是否存在一个全局变量,所有的页面都可以访问?](faqs-system-using.md#section187297991718)
- [如何获取dom中的元素](faqs-system-using.md#section1833493719175)
- [如何在页面间传值?](faqs-system-using.md#section184283812183)
- [list如何滚动到某个item?](faqs-system-using.md#section11897734131811)
- [text支持多行吗?](faqs-system-using.md#section5872656121814)
- [为什么控件不显示?](faqs-system-using.md#section7397125317107)
- [如何实现页面滑动?](faqs-system-using.md#section338794422010)
- [Left、Top为什么不生效?](faqs-system-using.md#section2597193611217)
- [动态绑定为什么不生效?](faqs-system-using.md#section6939050172115)
- [如何实现相对定位和绝对定位?](faqs-system-using.md#section5547311192215)
- [如何控制控件的显示与隐藏?](faqs-system-using.md#section16107113352213)
- [使用Margin时,有什么注意事项?](faqs-system-using.md#section1524910142314)
- [使用事件订阅时,有什么注意事项?](faqs-system-using.md#section1537132012231)
- [使用动态绑定时,有什么注意事项?](faqs-system-using.md#section96561452236)
- [swiper loop属性如何生效?](faqs-system-using.md#section690166112414)
- [使用数组时,有什么注意事项?](faqs-system-using.md#section1554552822414)
### hdc<a name="section178081876506"></a>
- [hdc\_std连接不到设备](faqs-system-using.md#section1965012223257)
- [hdc\_std运行不了](faqs-system-using.md#section1157575212515)
# 移植常见问题<a name="ZH-CN_TOPIC_0000001215769367"></a>
- [如何将用户的堆内存挂载进内核](#section21471536184914)
## 如何将用户的堆内存挂载进内核<a name="section21471536184914"></a>
- 内核堆内存配置的相关宏如下,用户可根据实际情况,在target\_config.h中配置:
**表 1** 内核堆内存配置相关宏
<a name="zh-cn_topic_0000001153683024_table04172020563"></a>
<table><thead align="left"><tr id="zh-cn_topic_0000001153683024_row5462035616"><th class="cellrowborder" valign="top" width="39.12%" id="mcps1.2.3.1.1"><p id="zh-cn_topic_0000001153683024_p1456204569"><a name="zh-cn_topic_0000001153683024_p1456204569"></a><a name="zh-cn_topic_0000001153683024_p1456204569"></a>宏名称</p>
</th>
<th class="cellrowborder" valign="top" width="60.88%" id="mcps1.2.3.1.2"><p id="zh-cn_topic_0000001153683024_p19502005618"><a name="zh-cn_topic_0000001153683024_p19502005618"></a><a name="zh-cn_topic_0000001153683024_p19502005618"></a>描述</p>
</th>
</tr>
</thead>
<tbody><tr id="zh-cn_topic_0000001153683024_row14522018560"><td class="cellrowborder" valign="top" width="39.12%" headers="mcps1.2.3.1.1 "><p id="zh-cn_topic_0000001153683024_p35112025620"><a name="zh-cn_topic_0000001153683024_p35112025620"></a><a name="zh-cn_topic_0000001153683024_p35112025620"></a>LOSCFG_SYS_EXTERNAL_HEAP</p>
</td>
<td class="cellrowborder" valign="top" width="60.88%" headers="mcps1.2.3.1.2 "><p id="zh-cn_topic_0000001153683024_p5127138175710"><a name="zh-cn_topic_0000001153683024_p5127138175710"></a><a name="zh-cn_topic_0000001153683024_p5127138175710"></a>这个宏决定系统是使用内核的内部堆内存还是用户的堆内存,默认为0(即使用内部的堆内存),大小为0x10000;如果用户需要基于外部的堆内存,那么可以将该宏设置为1。</p>
</td>
</tr>
<tr id="zh-cn_topic_0000001153683024_row20514209567"><td class="cellrowborder" valign="top" width="39.12%" headers="mcps1.2.3.1.1 "><p id="zh-cn_topic_0000001153683024_p5532017563"><a name="zh-cn_topic_0000001153683024_p5532017563"></a><a name="zh-cn_topic_0000001153683024_p5532017563"></a>LOSCFG_SYS_HEAP_ADDR</p>
</td>
<td class="cellrowborder" valign="top" width="60.88%" headers="mcps1.2.3.1.2 "><p id="zh-cn_topic_0000001153683024_p65520125619"><a name="zh-cn_topic_0000001153683024_p65520125619"></a><a name="zh-cn_topic_0000001153683024_p65520125619"></a>内核堆内存的起始地址。</p>
</td>
</tr>
<tr id="zh-cn_topic_0000001153683024_row15302929115615"><td class="cellrowborder" valign="top" width="39.12%" headers="mcps1.2.3.1.1 "><p id="zh-cn_topic_0000001153683024_p113021529145612"><a name="zh-cn_topic_0000001153683024_p113021529145612"></a><a name="zh-cn_topic_0000001153683024_p113021529145612"></a>LOSCFG_SYS_HEAP_SIZE</p>
</td>
<td class="cellrowborder" valign="top" width="60.88%" headers="mcps1.2.3.1.2 "><p id="zh-cn_topic_0000001153683024_p1030252965619"><a name="zh-cn_topic_0000001153683024_p1030252965619"></a><a name="zh-cn_topic_0000001153683024_p1030252965619"></a>内核堆内存的大小,即LOSCFG_SYS_HEAP_ADDR指定的内存块大小。</p>
</td>
</tr>
</tbody>
</table>
- 注意事项:
指定的堆内存范围务必保证没有其他模块使用,避免踩内存,破坏堆内存功能。
# 系统应用常见问题<a name="ZH-CN_TOPIC_0000001169690992"></a>
- [公共基础库常见问题](#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)
## 公共基础库常见问题<a name="section639433461512"></a>
### 1.LiteOS-A内核\(Hi3516、Hi3518平台\)KV存储路径设置错误,导致KV存储运行失败<a name="section16520347131511"></a>
**现象描述**
LiteOS-A内核\(Hi3516、Hi3518平台\)直接调用KV存储提供的接口,各参数正常的情况下,编译可执行程序运行失败。
**可能原因**
直接运行编译出的可执行文件,没有将程序基于AbilityKit转换成应用,不能由BMS在应用安装时正确设置应用数据存储路径,导致KV存储运行失败。
**解决办法**
显示调用KV存储的UtilsSetEnv接口,设置数据存储路径。
```
UtilsSetEnv("/storage/com.huawei.kv");
```
## 视觉应用常见问题<a name="section787718474161"></a>
### 是否存在一个全局变量,所有的页面都可以访问?<a name="section187297991718"></a>
当前框架中不存在所有Page都可以访问的全局变量。
### 如何获取dom中的元素<a name="section1833493719175"></a>
如何获取dom中的元素?
通过ref属性获取dom中的元素,详细示例如下图所示;获取的元素只能使用它的方法,不能改变属性。
```
<!--index.hml-->
<div class="container">
<!--指定组件的ref属性为animator-->
<image-animator class="image-player" ref="ainmator" images="{{images}}" duration="1s" onclick="handleClick"></image-animator>
</div>
/* 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();
}
}
}
```
### 如何在页面间传值?<a name="section184283812183"></a>
通过router.replace方法中的params参数来传递,参考代码如下:
第一个页面传递数据:
```
router.replace({
uri:'pages/detail/detail', //要跳转的页面uri
params:{transferData:this.data} //传递的数据,数据个数和名称开发者自己定义,
});
```
第二个界面接受数据:
```
onInit(){
const data = this.transferData; //在onInit函数中接受传递的数据
}
```
### list如何滚动到某个item?<a name="section11897734131811"></a>
通过list的scrollTo方法滚动到指定的item,参数是目标item的index。Index参数可以通过scrollend事件获取或者开发者指定。
### text支持多行吗?<a name="section5872656121814"></a>
text支持多行。通过回车键换行或者是不设置text的高度属性,由控件自动根据内容换行。
### 为什么控件不显示?<a name="section7397125317107"></a>
**现象描述**
开发者在hml文件中添加的控件无法显示
**可能原因**
- 未设置width和height值;
- 样式设置错误。
**处理步骤**
\(1\)检查是否设置width和height值,组件必须显式设置width和height值;
\(2\)检查组件的样式设置是否正确。
### 如何实现页面滑动?<a name="section338794422010"></a>
实现页面滑动目前有三种方式:scroll(根组件大小超过屏幕的大小即自动实现scroll效果)、list、swiper。开发者可以参考开发文档查看三者的区别,并加以使用。
### Left、Top为什么不生效?<a name="section2597193611217"></a>
除根节点外,Left、Top配合Stack组件使用才有效果。
### 动态绑定为什么不生效?<a name="section6939050172115"></a>
在进行绑定时,必须先将要绑定的对象或者对象的属性进行定义,不能先绑定后定义
### 如何实现相对定位和绝对定位?<a name="section5547311192215"></a>
使用div、stack(top left属性)来实现相对和绝对定位。
### 如何控制控件的显示与隐藏?<a name="section16107113352213"></a>
通过display、show和if来控制控件的显示与隐藏。区别在于:if为false时,组件会从VDOM中移除,而show仅是渲染时不可见,组件依然存在于VDOM中。
### 使用Margin时,有什么注意事项?<a name="section1524910142314"></a>
Stack组件不支持其子组件设置margin属性。
### 使用事件订阅时,有什么注意事项?<a name="section1537132012231"></a>
在应用运行期间只存在一个page,所以router.replace跳转是先销毁前一个页面,然后在新创建一个界面。因此,如果涉及到事件订阅的页面,每次页面创建时要进行事件订阅,跳转离开界面前取消事件订阅。
### 使用动态绑定时,有什么注意事项?<a name="section96561452236"></a>
过多的动态绑定会消耗较多的内存,若非业务需要,尽量不要使用太多的动态绑定。
### swiper loop属性如何生效?<a name="section690166112414"></a>
去掉第一个组件或者去掉最后一个组件,剩余的长度大于swiper长度,loop生效。
### 使用数组时,有什么注意事项?<a name="section1554552822414"></a>
数组元素不宜过多,尽量避免对大数组进行频繁操作。
## hdc类问题<a name="section412357182518"></a>
### hdc\_std连接不到设备<a name="section1965012223257"></a>
- **现象描述**
执行 "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运行不了<a name="section1157575212515"></a>
- **现象描述**
点击hdc\_std.exe文件无法运行。
- **解决方法**
hdc\_std.exe不需要安装,直接放到磁盘上就能使用,也可以添加到环境变量中。通过打开cmd执行hdc\_std命令直接使用。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册