diff --git a/en/readme/startup.md b/en/readme/startup.md index 98c67077d5c1b8cf4d0a59e61492ab90b50c068a..4d1d1780815533373ea44576ea746c119625d80d 100644 --- a/en/readme/startup.md +++ b/en/readme/startup.md @@ -2,32 +2,32 @@ ## Introduction -The Startup subsystem provides the functions of starting key system processes and services after the kernel is started and before applications are started, and restoring the system to factory settings. The subsystem consists of the following modules: +The startup subsystem is responsible for starting key system processes and services after the kernel is started and before applications are started. The subsystem consists of the following modules: -- init\_lite +- init - This module can be used on the Hi3516D V300 and Hi3518E V300 platforms powered by LiteOS Cortex-A. + This module can be used on platforms powered by LiteOS Cortex-A or Linux kernel. - It starts system service processes from the time the kernel loads the first user-space process to the time the first application is started. In addition to loading key system processes, the module needs to configure their permissions during the startup and keep the specified process alive after sub-processes are started. If a process exits abnormally, the module needs to restart it, and to perform system reset for a special process. + The module starts system service processes from the time the kernel loads the first user-space process to the time the first application is started. In addition to loading key system processes, it needs to configure their permissions during the startup and keep the specified process alive after sub-processes are started. If a key process exits abnormally, the module needs to perform a system restart. For details, see [init Module](../device-dev/subsystems/subsys-boot-init.md). -- appspawn\_lite +- appspawn - This module can be used on the Hi3516D V300 and Hi3518E V300 platforms powered by LiteOS Cortex-A. + This module comes with the Lite and Standard editions. The Lite edition can be used on platforms powered by the LiteOS-A kernel, and the Standard edition can be used on platforms powered by the Linux kernel. - This module spawns application processes upon receiving commands from the application framework, configures permissions for new processes, and calls the entry function of the application framework. + The module spawns application processes upon receiving commands from the application framework, configures permissions for new processes, and calls the entry function of the application framework. -- bootstrap\_lite +- bootstrap - This module can be used on the Hi3861 platform powered by LiteOS Cortex-M. + This module can be used on platforms powered by the LiteOS Cortex-M kernel. - This module provides entry identifiers for starting services and features. When Samgr starts, it will call the entry function identified by bootstrap\_lite and start system services. + The module provides entry identifiers for starting services and features. When SAMGR is started, the entry function identified by **bootstrap** is invoked and system services are started. -- syspara\_lite +- syspara This module obtains and sets system attributes. - It can be used on the Hi3861, Hi3516D V300, and Hi3518E V300 platforms powered by LiteOS Cortex-M and LiteOS Cortex-A. Supported system attributes consist of default, OEM-specified, and custom system attributes. OEM-specified system attributes provide only default values. The specific values need to be adjusted as required. For details, see [Usage Guidelines](#section8533192617117). + The module can be used on all platforms. Supported system attributes consist of default, OEM-specified, and custom system attributes. OEM-specified system attributes provide only default values. The specific values need to be adjusted as required. For details, see [syspara Module](../device-dev/subsystems/subsys-boot-syspara.md). ## Directory Structure @@ -35,6 +35,7 @@ The Startup subsystem provides the functions of starting key system processes an **Table 1** Directory structure of the source code for the startup subsystem + - + + + + - - - - - + - - +

Directory

Description

@@ -45,62 +46,64 @@ The Startup subsystem provides the functions of starting key system processes an

base/startup/appspawn_lite

appspawn_lite module for spawning application processes. It receives Ability Manager Service (AMS) messages via IPC, parses the messages, starts application processes based on the parsing result, and grants permissions to them.

+

appspawn module of the Lite edition for spawning application processes. It receives Ability Manager Service (AMS) messages via IPC, parses the messages, starts application processes based on the parsing result, and grants permissions to them.

+
Platforms using the LiteOS Cortex-A kernel +

base/startup/appspawn_standard

+

appspawn module of the Standard version for spawning application processes. It receives Ability Manager Service (AMS) messages via IPC, parses the messages, starts application processes based on the parsing result, and grants permissions to them.

Hi3516D V300

-

Hi3518E V300

+
Platforms using the Linux kernel

base/startup/bootstrap_lite

bootstrap_lite module for starting all services except core system services.

+

bootstrap module for starting all services except core system services.

Hi3861

+
Platforms using the LiteOS Cortex-M kernel

base/startup/init_lite

init_lite module for implementing the init process, which is the first user-space process loaded after the kernel is initialized. Upon startup, the process parses the configuration file in /etc/init.cfg. Based on the parsing result, the process then starts other key system processes and grants required permissions to them.

-

Hi3516D V300

-

Hi3518E V300

+

init_lite module for implementing the init process, which is the first user-space process loaded after the kernel is initialized. Upon startup, the process parses the configuration file in **/etc/init.cfg**. Based on the parsing result, the process then starts other key system processes and grants required permissions to them.

Platforms using the LiteOS Cortex-A or Linux kernel

base/startup/syspara_lite

syspara_lite module that provides APIs to obtain device information, including the product name, brand name, category name, and manufacturer name.

-

Hi3861

-

Hi3516D V300

-

Hi3518E V300

+

syspara module that provides APIs to obtain device information, including the product name, brand name, category name, and manufacturer name.

All platforms
+ ``` base/startup/ -├── appspawn_standard # appspawn_lite module for the standard system +├── appspawn_standard # appspawn module for the standard system │ ├── include # Header files │ ├── parameter # System parameters │ ├── src # Source files │ └── test # Test cases -├── appspawn_lite # appspawn_lite module for the mini system +├── appspawn_lite # appspawn module for the mini system │ └── services │ ├── include # Header files │ ├── src # Source files │ └── test # Test cases -├── bootstrap_lite # bootstrap_lite module +├── bootstrap_lite # bootstrap module │ └── services │ └── source # Source files -├── init_lite # init_lite module +├── init_lite # init module │ ├── initsync # Source files │ ├── interfaces # External APIs │ └── services │ ├── include # Header files │ ├── src # Source files │ └── test # Test cases -└── syspara_lite # syspara_lite module +└── syspara_lite # syspara module ├── adapter # Adaptation code ├── frameworks # Source files ├── hals # Header files for the hardware abstraction layer (HAL) @@ -108,191 +111,16 @@ base/startup/ └── simulator # Simulator adaptation ``` -## Constraints - -OEM-specified system attributes provide only default values. The specific values need to be adjusted as required. - -## Usage Guidelines - -- Configuration file of the init\_lite module - - The configuration file **init.cfg** of the init\_lite module contains service names, executable file paths, permissions, and other attributes of all key system services that need to be started by the init process. The file is stored in **/vendor/hisilicon/hispark\_aries/init\_configs/** under **/etc/**. It is in JSON format, and its size cannot exceed 100 KB. - - After the init process starts, it reads the **/etc/init.cfg** file, parses the JSON content, and loads system services in sequence based on the parsing result. The format and content of the configuration file are described as follows: - - -``` -{ - "jobs" : [{ - "name" : "pre-init", -------- Job executed before the initialization. It can be used to store some operations (for example, creating a directory) performed before the init process is started. - "cmds" : [ -------- Commands supported by the current job. Currently, only start, mkdir, chmod, chown, and mount are currently supported. - -------- The command name and the parameters (128 bytes or less) must be separated by only one space. - "mkdir /testdir", -------- Command for creating a directory. mkdir and the target directory must be separated by only one space. - "chmod 0700 /testdir", -------- Command for modifying the permission. chmod, permission, and the target directory must be separated by only one space. The permission must be in the 0xxx format. - "chown 99 99 /testdir",-------- Command for modifying the owner group. chown, UID, GID, and the target directory must be separated by only one space. - "mkdir /testdir2", - "mount vfat /dev/mmcblk0p0 /testdir2 noexec nosuid" -------- mount command in the following format: mount file system type source target flags data - -------- Supported flags include only nodev, noexec, nosuid, and rdonly, which are separated by a space. - ] - }, { - "name" : "init", -------- Job name, which currently supports only pre-init, init, and post-init. - "cmds" : [ -------- A single job currently supports a maximum of 30 commands. - "start service1", -------- Service startup command 1. - "start service2" -------- Service startup command 2. The sequence of the commands in the array can be adjusted as required. The init process then executes the commands in the same sequence as they are parsed. - ] - }, { - "name" : "post-init", -------- Job executed after the initialization. It can be used to store some operations performed after the init process is started. - "cmds" : [] - } - ], - "services" : [{ -------- Service set (in an array), including all system services that need to be started by the init process. Currently, a maximum of 100 services are supported. - "name" : "service1", -------- Name of the current service. A maximum of 32 bytes must be specified for the name. - "path" : "/bin/process1" -------- Full path of the executable file of the current service. A maximum of 64 bytes must be specified for the path. - "uid" : 1, -------- UID of the current service process. - "gid" : 1, -------- GID of the current service process. - "once" : 0, -------- Whether the current service process is a one-off process. - 0 --- The current service process is not a one-off process. If the process exits for a certain reason, the init_lite module restarts the service process upon receiving the SIGCHLD signal. - non-0 --- The current service process is a one-off process. If the process exits for a certain reason, the init_lite module does not restart the service process. - "importance" : 1, -------- Whether the current service process is a key system process - 0 --- The current service process is not a key system process. If the process exits due to any reason, the init_lite module does not reset the system. - non-0 --- The current service process is a key system process. If the process exits due to any reason, the init_lite module resets and restarts the system upon receiving the SIGCHLD signal. - "caps" : [0, 1, 2, 5] -------- Capabilities required by the current service. They are determined by the capabilities supported by the security subsystem and configured in accordance with the principle of least permission. (Currently, a maximum of 100 values can be configured.) - }, { - "name" : "service2", -------- Next service that needs to be started by the init_lite module. The service sequence is irrelevant to the startup sequence, which is determined by the command sequence in the previous job. - "path" : "/bin/process2", - "uid" : 2, - "gid" : 2, - "once" : 1, - "importance" : 0, - "caps" : [ ] - } - ] -} -``` - -**Table 2** Supported commands - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Syntax

-

Description

-

start

-

start ServiceName (Only one space is allowed.)

-

Starts a service. The service name must be the same as that in the services array in the file.

-

mkdir

-

mkdir /xxxx/xxx (Only one space is allowed.)

-

Creates a directory.

-

chmod

-

chmod 0xxx /xxx/xx (Only one space is allowed.)

-

Changes the permission. The permission value must be in 0xxx format, for example, 0755 or 0600. This configuration must comply with the principle of least permission.

-

chown

-

chown uid gid /xxx/xx (Only one space is allowed.)

-

Changes the owner group.

-

mount

-

mount fileSysType source target flags data (Only one space is allowed.)

-

Mounts data. Currently, flags can only be nodev, noexec, nosuid, or rdonly, and other strings are considered as data.

-
- -It is worth noting that the modified **init.cfg** file must be in JSON format. Otherwise, the init process fails to parse the file, and no service will be started. The configured service permission **uid/gid/capability** must meet the requirements imposed by the security subsystem and comply with the principle of least permission. In addition, if the values of **once** and **importance** of a service are both **0** and the service exits for more than four consecutive times within four minutes, the init process will stop restarting the service. - -- System parameters - - OEM-specific system attributes - - For Hi3516D V300 and Hi3518E V300 development boards, you need to modify the source files in the **vendor/hisilicon/hispark\_aries/hals/utils/sys\_param** directory. - - ``` - static const char HOS_PRODUCT_TYPE[] = {"****"}; - static const char HOS_MANUFACTURE[] = {"****"}; - static const char HOS_BRAND[] = {"****"}; - static const char HOS_MARKET_NAME[] = {"****"}; - static const char HOS_PRODUCT_SERIES[] = {"****"}; - static const char HOS_PRODUCT_MODEL[] = {"****"}; - static const char HOS_SOFTWARE_MODEL[] = {"****"}; - static const char HOS_HARDWARE_MODEL[] = {"****"}; - static const char HOS_HARDWARE_PROFILE[] = {"aout:true,display:true"}; - static const char HOS_BOOTLOADER_VERSION[] = {"bootloader"}; - static const char HOS_SECURE_PATCH_LEVEL[] = {"2020-6-5"}; - static const char HOS_ABI_LIST[] = {"****"}; - ``` - - For Hi3861 development boards, you need to modify the source files in the **vendor/hisilicon/hispark\_pegasus/hals/utils/sys\_param** directory. - - ``` - static const char HOS_PRODUCT_TYPE[] = {"****"}; - static const char HOS_MANUFACTURE[] = {"****"}; - static const char HOS_BRAND[] = {"****"}; - static const char HOS_MARKET_NAME[] = {"****"}; - static const char HOS_PRODUCT_SERIES[] = {"****"}; - static const char HOS_PRODUCT_MODEL[] = {"****"}; - static const char HOS_SOFTWARE_MODEL[] = {"****"}; - static const char HOS_HARDWARE_MODEL[] = {"****"}; - static const char HOS_HARDWARE_PROFILE[] = {"aout:true,display:true"}; - static const char HOS_BOOTLOADER_VERSION[] = {"bootloader"}; - static const char HOS_SECURE_PATCH_LEVEL[] = {"2020-6-5"}; - static const char HOS_ABI_LIST[] = {"****"}; - ``` - - - Obtaining default system attributes - - ``` - const char* value1 = GetProductType(); - printf("Product type =%s\n", value1); - const char* value2 = GetManufacture(); - printf("Manufacture =%s\n", value2); - const char* value3 = GetBrand(); - printf("GetBrand =%s\n", value3); - ``` - - - - Obtaining custom system attributes - - ``` - const char* defSysParam = "data of sys param ***..."; - char key[] = "rw.parameter.key"; - char value[] = "OEM-hisi-10.1.0"; - int ret = SetParameter(key, value); - char valueGet[128] = {0}; - ret = GetParameter(key, defSysParam, valueGet, 128); - printf("value = %s\n", valueGet); - ``` - - - ## Repositories Involved -Startup subsystem +[Startup subsystem](../device-dev/subsystems/subsys-boot-overview.md) -[startup\_init\_lite](https://gitee.com/openharmony/startup_init_lite) +[startup\_appspawn\_lite](https://gitee.com/openharmony/startup_appspawn_lite) -[startup\_syspara\_lite](https://gitee.com/openharmony/startup_syspara_lite) +[startup\_appspawn](https://gitee.com/openharmony/startup_appspawn) [startup\_bootstrap\_lite](https://gitee.com/openharmony/startup_bootstrap_lite) -[startup\_appspawn\_lite](https://gitee.com/openharmony/startup_appspawn_lite) +[startup_init_lite](https://gitee.com/openharmony/startup_init_lite) +[startup\_syspara\_lite](https://gitee.com/openharmony/startup_syspara_lite)