1e41f4b71Sopenharmony_ci# Startup
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci## System Startup
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci### Device Startup Interrupted Due to "parse failed!" Error
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ci**Symptom**
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ciDuring device 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.
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci  **Figure 1** Error information
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci  ![en-us_image_0000001200053087](figures/en-us_image_0000001200053087.png)
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ci**Possible Cause**
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ciThe content of the **init.cfg** file does not comply with the JSON specifications.
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci**Solution**
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ciCheck the **init.cfg** file and ensure that its format meets the JSON specifications.
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci
24e41f4b71Sopenharmony_ci### Device Restarted Repeatedly
25e41f4b71Sopenharmony_ci
26e41f4b71Sopenharmony_ci**Symptom**
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ciThe device restarts over and over again upon startup. 
29e41f4b71Sopenharmony_ci
30e41f4b71Sopenharmony_ci**Possible Cause**
31e41f4b71Sopenharmony_ci
32e41f4b71Sopenharmony_ciEach service started by the init process has the **importance** attribute, as described in [Parameters](../subsystems/subsys-boot-init-service.md#description-of-service-process-configuration-files).
33e41f4b71Sopenharmony_ci
34e41f4b71Sopenharmony_ci- If the attribute value is **0**, the init process does not need to restart the device when the current service process exits.
35e41f4b71Sopenharmony_ci
36e41f4b71Sopenharmony_ci- If the attribute value is **1**, the init process needs to restart the device when the current service process exits.
37e41f4b71Sopenharmony_ci
38e41f4b71Sopenharmony_ci**Solution**
39e41f4b71Sopenharmony_ci
40e41f4b71Sopenharmony_ci1. 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.
41e41f4b71Sopenharmony_ci
42e41f4b71Sopenharmony_ci2. 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.
43e41f4b71Sopenharmony_ci
44e41f4b71Sopenharmony_ci
45e41f4b71Sopenharmony_ci### **SetParameter** or **GetParameter** Failed with Correct Parameters Passed
46e41f4b71Sopenharmony_ci
47e41f4b71Sopenharmony_ci**Symptom**
48e41f4b71Sopenharmony_ci
49e41f4b71Sopenharmony_ciCalling **SetParameter** or **GetParameter** fails when correct parameters are passed.
50e41f4b71Sopenharmony_ci
51e41f4b71Sopenharmony_ci**System Type**
52e41f4b71Sopenharmony_ci
53e41f4b71Sopenharmony_ciliteos-a
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_ci**Possible Cause**
56e41f4b71Sopenharmony_ci
57e41f4b71Sopenharmony_ciPermission verification has been enabled for **SetParameter** and **GetParameter**. If the UID of the caller is greater than **1000**, that is, the caller does not have the API call permission, calling an API will fail even if correct parameters are passed.
58e41f4b71Sopenharmony_ci
59e41f4b71Sopenharmony_ci**Solution**
60e41f4b71Sopenharmony_ci
61e41f4b71Sopenharmony_ciNo action is required.
62e41f4b71Sopenharmony_ci
63e41f4b71Sopenharmony_ci### ueventd Service Failed to Obtain a Socket upon Startup
64e41f4b71Sopenharmony_ci
65e41f4b71Sopenharmony_ci**Symptom**
66e41f4b71Sopenharmony_ci
67e41f4b71Sopenharmony_ciAfter the ueventd service is started, the error message "Failed to get uevent socket, try to create" is displayed, and the error information as shown in the following figure is logged.
68e41f4b71Sopenharmony_ci
69e41f4b71Sopenharmony_ci  **Figure 2** Failure to obtain a socket
70e41f4b71Sopenharmony_ci
71e41f4b71Sopenharmony_ci  ![ueventd_socket](figures/ueventd_socket.png)
72e41f4b71Sopenharmony_ci
73e41f4b71Sopenharmony_ci**Possible Cause**
74e41f4b71Sopenharmony_ci
75e41f4b71Sopenharmony_ci The ueventd service is started on demand. Upon startup, it first needs to check the environment variables for **fd** of the socket created by the init process. The preceding error information will be displayed if the ueventd service fails to obtain environment variables. The possible causes are as follows:
76e41f4b71Sopenharmony_ci1. No socket has been configured for the ueventd service in the **.cfg** file. As a result, the init process does not create a socket for the ueventd service, and no socket ID is present in environment variables.
77e41f4b71Sopenharmony_ci2. If a socket has been configured for the ueventd service in the **.cfg** file, it is probable that the ueventd service is also configured in another **.cfg** file but no socket is designated for it.
78e41f4b71Sopenharmony_ci
79e41f4b71Sopenharmony_ci**Solution**
80e41f4b71Sopenharmony_ci
81e41f4b71Sopenharmony_ci1. For case 1, configure a socket for the ueventd service in the **.cfg** file. For details, see [Socket Configuration for the ueventd Service](../subsystems/subsys-boot-init-service.md#description-of-service-process-configuration-files).
82e41f4b71Sopenharmony_ci2. For case 2, check all **.cfg** files for any duplicate ueventd service and delete it. Retain only one ueventd service with valid configuration.
83e41f4b71Sopenharmony_ci
84e41f4b71Sopenharmony_ci### ueventd Service Exits Because of a Socket Polling Timeout
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ci**Symptom**
87e41f4b71Sopenharmony_ci
88e41f4b71Sopenharmony_ciAfter the ueventd service is started for a period of time, the error message "poll ueventd socket timeout, ueventd exit" is displayed and the ueventd service automatically exits.
89e41f4b71Sopenharmony_ci
90e41f4b71Sopenharmony_ci**Possible Cause**
91e41f4b71Sopenharmony_ci
92e41f4b71Sopenharmony_ciThe ueventd service is started on demand. When a uevent is reported, the init process receives a socket message and starts the ueventd service to process the message. After processing the message, the ueventd service polls the corresponding socket handle for 30s. If a new socket message is reported within this period of time, the ueventd service continues to process the message. After processing the message, the ueventd service polls the socket handle for 30s once again. If no new socket message is reported within this period of time, the ueventd service exits and returns the socket to the init process for polling. In this case, the preceding error message is displayed.
93e41f4b71Sopenharmony_ci
94e41f4b71Sopenharmony_ci**Solution**
95e41f4b71Sopenharmony_ci
96e41f4b71Sopenharmony_ciThis is a normal phenomenon and no action is required.
97e41f4b71Sopenharmony_ci
98e41f4b71Sopenharmony_ci### Service with the ondemand Attribute Failed to Start Because of a Configuration Parsing Error
99e41f4b71Sopenharmony_ci
100e41f4b71Sopenharmony_ci**Symptom**
101e41f4b71Sopenharmony_ci
102e41f4b71Sopenharmony_ciThe service configuration in JSON format cannot be correctly parsed, and the error message "Service is invalid which has both critical and ondemand attribute" is displayed. When the service is started, the error message "Cannot find service" is displayed.
103e41f4b71Sopenharmony_ci
104e41f4b71Sopenharmony_ci**Possible Cause**
105e41f4b71Sopenharmony_ci
106e41f4b71Sopenharmony_ciWhen the **ondemand** attribute is configured, a service is started on demand by default. This attribute, however, is mutually exclusive with the **critical** attribute. If both of them are configured, a conflict will occur, resulting in a failure to resolve the service.
107e41f4b71Sopenharmony_ci
108e41f4b71Sopenharmony_ci**Solution**
109e41f4b71Sopenharmony_ci
110e41f4b71Sopenharmony_ci1. If a service does not need to be started on demand, leave the **ondemand** attribute unspecified.
111e41f4b71Sopenharmony_ci2. If a service needs to be started on demand, leave the **critical** attribute unspecified or disable the **critical** attribute after you configure the **ondemand** attribute.
112e41f4b71Sopenharmony_ci
113e41f4b71Sopenharmony_ci### Parallel Startup Is Not Effective for Services Configured with the ondemand Attribute
114e41f4b71Sopenharmony_ci
115e41f4b71Sopenharmony_ci**Symptom**
116e41f4b71Sopenharmony_ci
117e41f4b71Sopenharmony_ciServices configured with the **ondemand** attribute are not started in the parallel startup phase, regardless of the **start-mode** settings.
118e41f4b71Sopenharmony_ci
119e41f4b71Sopenharmony_ci**Possible Cause**
120e41f4b71Sopenharmony_ci
121e41f4b71Sopenharmony_ciServices configured with the **ondemand** attribute are started only when the startup conditions are met. Therefore, parallel startup is not effective for these services.
122e41f4b71Sopenharmony_ci
123e41f4b71Sopenharmony_ci**Solution**
124e41f4b71Sopenharmony_ci
125e41f4b71Sopenharmony_ciIf you want to add a service to parallel startup, do not configure the **ondemand** attribute for it.
126e41f4b71Sopenharmony_ci
127e41f4b71Sopenharmony_ci### SA Services Cannot Be Started on Demand
128e41f4b71Sopenharmony_ci
129e41f4b71Sopenharmony_ci**Symptom**
130e41f4b71Sopenharmony_ci
131e41f4b71Sopenharmony_ciWhen an SA service is configured with the **ondemand** attribute, the samgr process does not start the SA service after the SA client sends a request.
132e41f4b71Sopenharmony_ci
133e41f4b71Sopenharmony_ci**Possible Cause**
134e41f4b71Sopenharmony_ci
135e41f4b71Sopenharmony_ciAt the initial implementation of on-demand startup for SA services, **SystemAbilityManager::CheckSystemAbility(int32_t systemAbilityId)** is used for all SA services. To distinguish SA services that are started on demand, **LoadSystemAbility(int32_t systemAbilityId, const sptr& callback)** provided by the samgr process is added. If an SA service is not started on demand, it is probable that the original API is used by mistake.
136e41f4b71Sopenharmony_ci
137e41f4b71Sopenharmony_ci**Solution**
138e41f4b71Sopenharmony_ci
139e41f4b71Sopenharmony_ciUse **LoadSystemAbility(int32_t systemAbilityId, const sptr& callback)** for any SA service that needs to be started on demand.
140e41f4b71Sopenharmony_ci
141e41f4b71Sopenharmony_ci### Improper caps Configuration
142e41f4b71Sopenharmony_ci
143e41f4b71Sopenharmony_ci**Symptom**
144e41f4b71Sopenharmony_ci
145e41f4b71Sopenharmony_ciImproper caps configuration leads to a configuration error. The error information is as follows:
146e41f4b71Sopenharmony_ci ```
147e41f4b71Sopenharmony_ci4.619955] [pid=1 0][Init][ERROR][init_capability.c:119]service=multimodalinput not support caps = CAP_DC_OVERRIDE caps 41
148e41f4b71Sopenharmony_ci[ 4.620014] [pid=1 0][Init][ERROR][init_service_manager.c:818]GetServiceSecon secon section not found, skip
149e41f4b71Sopenharmony_ci[ 4.620216] [pid=1 0][Init][ERROR][init_service_manager.c:818]GetServiceSecon secon section not found, skip
150e41f4b71Sopenharmony_ci[ 4.620608] [pid=1 0][Init][ERROR][init_capability.c:119]service=mmi_uinput_service  not support caps = CAP_DC_OVERRIDE caps 41
151e41f4b71Sopenharmony_ci ```
152e41f4b71Sopenharmony_ci**Possible Cause**
153e41f4b71Sopenharmony_ci
154e41f4b71Sopenharmony_ci1. The caps configuration is not supported by the kernel.
155e41f4b71Sopenharmony_ci2. The configuration in the **.cfg** file is incorrect.
156e41f4b71Sopenharmony_ci
157e41f4b71Sopenharmony_ci**System Version**
158e41f4b71Sopenharmony_ci
159e41f4b71Sopenharmony_ciOpenHarmony-3.0-LTS
160e41f4b71Sopenharmony_ci
161e41f4b71Sopenharmony_ci**Solution**
162e41f4b71Sopenharmony_ci
163e41f4b71Sopenharmony_ci1. For case 1, leave **caps** unspecified.
164e41f4b71Sopenharmony_ci2. For case 2, correctly configure **caps** by referring to the definition of the **capStrCapNum** data structure in **base/startup/init/services/init/init_capability.c**.
165e41f4b71Sopenharmony_ci
166e41f4b71Sopenharmony_ci### Sandbox Not Enabled
167e41f4b71Sopenharmony_ci
168e41f4b71Sopenharmony_ci**Symptom**
169e41f4b71Sopenharmony_ci
170e41f4b71Sopenharmony_ciAfter **hdc shell param get const.sandbox** is run, it is found that the value of **const.sandbox** is not **enable**.
171e41f4b71Sopenharmony_ci
172e41f4b71Sopenharmony_ci**Possible Cause**
173e41f4b71Sopenharmony_ci
174e41f4b71Sopenharmony_ciNone.
175e41f4b71Sopenharmony_ci
176e41f4b71Sopenharmony_ci**Solution**
177e41f4b71Sopenharmony_ci
178e41f4b71Sopenharmony_ciSet **const.sandbox** to **enable** in **base/startup/init/services/etc/param/ohos.para**. For details, see [Sandbox Management](../subsystems/subsys-boot-init-sandbox.md).
179e41f4b71Sopenharmony_ci
180e41f4b71Sopenharmony_ci### How to Check the Sandbox Mounting Status
181e41f4b71Sopenharmony_ci
182e41f4b71Sopenharmony_ci**Symptom**
183e41f4b71Sopenharmony_ci
184e41f4b71Sopenharmony_ciNone.
185e41f4b71Sopenharmony_ci
186e41f4b71Sopenharmony_ci**Possible Cause**
187e41f4b71Sopenharmony_ci
188e41f4b71Sopenharmony_ciNone.
189e41f4b71Sopenharmony_ci
190e41f4b71Sopenharmony_ci**Solution**
191e41f4b71Sopenharmony_ci
192e41f4b71Sopenharmony_ciEnter the hdc shell mode on the device. Then, run the **sandbox -s service_name** command to move the current service to the sandbox, and run shell commands such as **ls** to view the sandbox directory. For details, see the [sandbox command description](../subsystems/subsys-boot-init-plugin.md).
193e41f4b71Sopenharmony_ci
194e41f4b71Sopenharmony_ci### Timestamp in the Ready Phase of Some Bootevent Events Is 0
195e41f4b71Sopenharmony_ci
196e41f4b71Sopenharmony_ci**Symptom**
197e41f4b71Sopenharmony_ci
198e41f4b71Sopenharmony_ciIn manual bootevent mode, after device startup is completed and the **dump_service all bootevent** command is executed, the timestamps in the ready phase of some events are 0.
199e41f4b71Sopenharmony_ci
200e41f4b71Sopenharmony_ci**Possible Cause**
201e41f4b71Sopenharmony_ci
202e41f4b71Sopenharmony_ci1. The service does not send the bootevent event.
203e41f4b71Sopenharmony_ci2. The service sends the bootevent event, but does not have the related permission.
204e41f4b71Sopenharmony_ci
205e41f4b71Sopenharmony_ci**Solution**
206e41f4b71Sopenharmony_ci
207e41f4b71Sopenharmony_ci1. For case 1, make sure the related service sends the bootevent in the code.
208e41f4b71Sopenharmony_ci2. For case 2, make sure the service has the permission to set the bootevent parameter.
209e41f4b71Sopenharmony_ci
210e41f4b71Sopenharmony_ci### Failed to Boot from Partition A/B
211e41f4b71Sopenharmony_ci
212e41f4b71Sopenharmony_ci**Symptom**
213e41f4b71Sopenharmony_ci
214e41f4b71Sopenharmony_ciAfter the image is burnt, the system cannot be started, and information similar to the following can be found in the serial port log:
215e41f4b71Sopenharmony_ci
216e41f4b71Sopenharmony_ci```
217e41f4b71Sopenharmony_ciwait for file:/dev/block/platform/fe310000.sdhci/by-name/system_b failed after 5 second.
218e41f4b71Sopenharmony_ciMount /dev/block/platform/fe310000.sdhci/by-name/system_b to /usr failed 2
219e41f4b71Sopenharmony_ci```
220e41f4b71Sopenharmony_ci
221e41f4b71Sopenharmony_ci**Possible Cause**
222e41f4b71Sopenharmony_ci
223e41f4b71Sopenharmony_ciAs indicated by the log, partition B is used as the boot partition. However, it is not found during startup, resulting in the startup failure. This issue occurs because the active slot value in the misc partition is set to 2 (partition B), but partition B is not burnt.
224e41f4b71Sopenharmony_ci
225e41f4b71Sopenharmony_ci**Solution**
226e41f4b71Sopenharmony_ci
227e41f4b71Sopenharmony_ci1. Clear the misc partition by burning the corresponding partition with an empty misc image, erase the active slot value, and restart the system from the default partition.
228e41f4b71Sopenharmony_ci2. Burn the **system_b** and **vendor_b** images to the development board by using the partition table configured with partition B. Then, the development board can boot from partition B.
229e41f4b71Sopenharmony_ci
230e41f4b71Sopenharmony_ci## Application Spawning
231e41f4b71Sopenharmony_ci
232e41f4b71Sopenharmony_ci### Failed to Start appspawn
233e41f4b71Sopenharmony_ci
234e41f4b71Sopenharmony_ci**Symptom**
235e41f4b71Sopenharmony_ci
236e41f4b71Sopenharmony_ciDuring system startup, the system stops at the startup animation and fails to launch the appspawn process.
237e41f4b71Sopenharmony_ci
238e41f4b71Sopenharmony_ci**Possible Cause**
239e41f4b71Sopenharmony_ci
240e41f4b71Sopenharmony_ci1. The startup animation does not exit properly.
241e41f4b71Sopenharmony_ci2. The attempt to start system applications has failed, resulting in a failure to start the appspawn process.
242e41f4b71Sopenharmony_ci
243e41f4b71Sopenharmony_ci**Solution**
244e41f4b71Sopenharmony_ci
245e41f4b71Sopenharmony_ciView 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.
246e41f4b71Sopenharmony_ci
247e41f4b71Sopenharmony_ci### Cold Start of Applications Failed
248e41f4b71Sopenharmony_ci
249e41f4b71Sopenharmony_ci**Symptom**
250e41f4b71Sopenharmony_ci
251e41f4b71Sopenharmony_ciApplications fail to be started by running the cold start command.
252e41f4b71Sopenharmony_ci  ```
253e41f4b71Sopenharmony_ci  aa start -d 12345 -a $name -b $package -C
254e41f4b71Sopenharmony_ci  ```
255e41f4b71Sopenharmony_ci
256e41f4b71Sopenharmony_ci**Possible Cause**
257e41f4b71Sopenharmony_ci
258e41f4b71Sopenharmony_ci1. Cold start is not enabled.
259e41f4b71Sopenharmony_ci2. The parameter of the cold start command is incorrect.
260e41f4b71Sopenharmony_ci3. The socket request times out.
261e41f4b71Sopenharmony_ci4. SELinux is enabled.
262e41f4b71Sopenharmony_ci
263e41f4b71Sopenharmony_ci**Solution**
264e41f4b71Sopenharmony_ci
265e41f4b71Sopenharmony_ci1. For case 1, run **param get startup.appspawn.cold.boot** to check the cold start switch and run **param set startup.appspawn.cold.boot 1** to enable cold start.
266e41f4b71Sopenharmony_ci2. For case 2, correct the parameter of the cold start command.
267e41f4b71Sopenharmony_ci3. For case 3, run the **param set persist.appspawn.client.timeout 5** command to set the timeout period to 5.
268e41f4b71Sopenharmony_ci4. For case 4, run the **setenforce 0** command to disable SELinux.
269e41f4b71Sopenharmony_ci
270e41f4b71Sopenharmony_ci### Failed to Create the Application Sandbox
271e41f4b71Sopenharmony_ci
272e41f4b71Sopenharmony_ci**Symptom**
273e41f4b71Sopenharmony_ci
274e41f4b71Sopenharmony_ciThe system UI freezes at the OpenHarmony startup animation, the calculator application does not respond after being touched, or the font is not displayed properly. The error information in the hilog file is as follows:
275e41f4b71Sopenharmony_ci - bind mount `<src-path>` to `<sandbox-path>` failed errno `<errorCode>`
276e41f4b71Sopenharmony_ci - private mount to `<sandbox-path>`  failed errno `<errorCode>`
277e41f4b71Sopenharmony_ci - symlink failed, `<link-name>`, errno is `<errorCode>`
278e41f4b71Sopenharmony_ci
279e41f4b71Sopenharmony_ci**Possible Cause**
280e41f4b71Sopenharmony_ci
281e41f4b71Sopenharmony_ci1. The sandbox creation process is incorrect.
282e41f4b71Sopenharmony_ci2. The **com.ohos.systemui** sandbox fails to be created.
283e41f4b71Sopenharmony_ci3. The file on which the application sandbox depends is not configured correctly.
284e41f4b71Sopenharmony_ci
285e41f4b71Sopenharmony_ci**Solution**
286e41f4b71Sopenharmony_ci
287e41f4b71Sopenharmony_ci1. Check the error information in the hilog file, and correct the corresponding JSON files.
288e41f4b71Sopenharmony_ci2. Verify the PID of the application, the code logic of the sandbox creation process, and the JSON configuration.
289e41f4b71Sopenharmony_ci
290e41f4b71Sopenharmony_ciFor details, see How to Develop in [Application Sandbox Development Procedure](../subsystems/subsys-boot-appspawn.md).
291