提交 9a1d62df 编写于 作者: W wusongqing

updated docs

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 4c198b99
# 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).
# 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)
# 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
```
# 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.
# 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.
# 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**.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册