OpenHarmony 的启动子系统startup与init组件

1. rk3568的startup配置

配上init component以后,系统就会编译集成这个组件。

vendor/hihope/rk3568/config.json

    {
      "subsystem": "startup",
      "components": [
        {
          "component": "init",
          "features": [
            "enable_ohos_startup_init_feature_ab_partition = true",
            "enable_ohos_startup_init_feature_loader = true"
          ]
        }
      ]
    },

2. startup子系统在 build/subsystem_config.json 的信息

  "startup": {
    "path": "base/startup",
    "name": "startup"
  },

可以看到,startup 子系统的代码保存在 base/startup

3. init组件的详细信息

源码目录:

base/startup/init

代码仓库:直达

https://gitee.com/openharmony/startup_init

4. init组件的源码如何组织编译

代码的组织编译由组件源码目录下面的 bundle文件决定

base/startup/init/bundle.json
https://gitee.com/openharmony/startup_init/blob/master/bundle.json
{
    "name": "@ohos/init",
    "description": "ohos init process",
    "homePage": "https://gitee.com/openharmony",
    "version": "4.0.2",
    "license": "Apache License 2.0",
    "repository": "https://gitee.com/openharmony/startup_init",
    "supplier": "Organization: OpenHarmony",
    "publishAs": "code-segment",
    "segment": {
        "destPath": "base/startup/init"
    },
    "dirs": {},
    "scripts": {},
    "component": {
        "name": "init",
        "subsystem": "startup",
        "syscap": [
            "SystemCapability.Startup.SystemInfo",
            "SystemCapability.Startup.SystemInfo.Lite",
            "SystemCapability.Base"
        ],
        "features": [
            "init_feature_begetctl_liteos",
            "init_lite_use_posix_file_api",
            "init_feature_ab_partition",
            "init_feature_loader",
            "init_lite_use_thirdparty_mbedtls",
            "init_appspawn_client_module"
        ],
        "adapted_system_type": [
            "mini",
            "small",
            "standard"
        ],
        "rom": "3.9MB",
        "ram": "8356KB",
        "hisysevent_config": [
            "//base/startup/init/services/modules/sysevent/init_events.yaml"
        ],
        "deps": {
            "components": [
                "appspawn",
                "safwk",
                "c_utils",
                "napi",
                "ipc",
                "config_policy",
                "hilog",
                ... ...
            ],
            "third_party": [
                "mksh",
                "e2fsprogs",
                "f2fs-tools"
            ]
        },
        "build": {
            "group_type": {
                "base_group": [
                ],
                "fwk_group": [
                    "//base/startup/init/services:startup_init",
                    "//base/startup/init/services/begetctl:begetctl_cmd",
                    "//base/startup/init/services/loopevent:loopeventgroup",
                    "//base/startup/init/services/modules:modulesgroup",
                    "//base/startup/init/services/param:parameter",
                    "//base/startup/init/interfaces/innerkits:innergroup",
                    "//base/startup/init/device_info:device_info_group",
                    "//base/startup/init/interfaces/kits:kitsgroup"
                ],
                "service_group": [
                    "//base/startup/init/watchdog:watchdog",
                    "//base/startup/init/remount:overlayremount",
                    "//base/startup/init/ueventd:startup_ueventd"
                ]
              },

 5. 目录下的 begetd.gni 展示了该module提供哪些编译 feature

base/startup/init/begetd.gni
https://gitee.com/openharmony/startup_init/blob/master/begetd.gni
declare_args() {
  enable_ohos_startup_init_feature_watcher = true
  enable_ohos_startup_init_feature_deviceinfo = true

  # only for test
  param_test = true
  param_base_log = false
  enable_ohos_startup_init_feature_ab_partition = false

  # init begetctl support liteos
  enable_ohos_startup_init_feature_begetctl_liteos = false

  # only support mbedtls for hash
  enable_ohos_startup_init_lite_use_thirdparty_mbedtls = true
  enable_ohos_startup_init_lite_use_posix_file_api = false
  config_ohos_startup_init_lite_data_path = "/"

  # config memory size for liteos-m
  config_ohos_startup_init_lite_memory_size = 5120

  startup_init_feature_decode_group_file = false

  startup_init_test_performance = true

  # log display control
  config_ohos_startup_init_lite_no_log = false

  startup_init_with_param_base = false
  if (!use_musl) {
    startup_init_with_param_base = true
    startup_init_feature_decode_group_file = true
  }

  # begetutil extension module
  startup_begetutil_extra_modules = ""
  startup_init_extra_static_modules = ""
}

这些都是编译时可以选择的配置选项,也就是组件的feature,可以在配置的时候进行选择。

posted @ 2024-09-24 17:33  秦舒云  阅读(41)  评论(0编辑  收藏  举报