From 8240522bf4b2c2cd27ff7fce7e5fa7915842be08 Mon Sep 17 00:00:00 2001 From: Wanming Hu Date: Fri, 14 Nov 2025 15:18:18 +0800 Subject: [PATCH 1/3] mcs: update mcs to support mica set with xen * update mcs to the latest commit, to support mica set with xen * pack uniproton xen bin demo to /lib/firmware in rootfs Signed-off-by: Wanming Hu --- .oebuild/manifest.yaml | 2 +- meta-openeuler/recipes-mcs/mcs-linux/mcsctl.bb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.oebuild/manifest.yaml b/.oebuild/manifest.yaml index 7ac0791cc2a..bfc55b1dc7a 100644 --- a/.oebuild/manifest.yaml +++ b/.oebuild/manifest.yaml @@ -989,7 +989,7 @@ manifest_list: version: 80744f17a0ec0300e9bc4e140c35120460a05a8a mcs: remote_url: https://gitee.com/openeuler/mcs.git - version: 2c2449e53784552868cda427e0ec1b9add0622e9 + version: 10f2b20e893ab516d1886a37482c6977ff35d9ba mcs-x86: remote_url: https://gitee.com/openeuler/mcs.git version: e1a51d29fb09c3fb35f1666fbe7138840e8f26f8 diff --git a/meta-openeuler/recipes-mcs/mcs-linux/mcsctl.bb b/meta-openeuler/recipes-mcs/mcs-linux/mcsctl.bb index 212d0fd8e7f..0c2ec5a4f3d 100644 --- a/meta-openeuler/recipes-mcs/mcs-linux/mcsctl.bb +++ b/meta-openeuler/recipes-mcs/mcs-linux/mcsctl.bb @@ -46,6 +46,12 @@ do_install:append () { install -d "${D}/lib/firmware" cp -- "$@" "${D}/lib/firmware/" fi + + # install rtos bin for xen + set -- "${S}/rtos/arm64/${RTOS_IMGS}"*.bin + if [ -f "$1" ]; then + cp -- "$@" "${D}/lib/firmware/" + fi } FILES:${PN} += "/usr/bin/mica" -- Gitee From 6d99e0243f5425c71bbd2474976d1e87f56385bd Mon Sep 17 00:00:00 2001 From: Wanming Hu Date: Fri, 14 Nov 2025 15:19:41 +0800 Subject: [PATCH 2/3] mcs: add docs of mica with xen Update supported list, build, mica ctl usage instruction in mica docs, with the new support of xen. Signed-off-by: Wanming Hu --- docs/source/features/mica/build.rst | 10 +- docs/source/features/mica/instruction.rst | 118 +++++++++++++++++- docs/source/features/mica/mica_ctl.rst | 104 +++++++++++---- docs/source/features/mica/supported_lists.rst | 8 +- 4 files changed, 212 insertions(+), 28 deletions(-) diff --git a/docs/source/features/mica/build.rst b/docs/source/features/mica/build.rst index 612988e905d..c755cc5256d 100644 --- a/docs/source/features/mica/build.rst +++ b/docs/source/features/mica/build.rst @@ -7,7 +7,7 @@ 混合关键性部署框架作为 openEuler Embedded 的特性,可以按需集成到 openEuler Embedded 镜像中。 - 请参考 :ref:`南向支持章节 ` 构建不同平台的镜像,只需要在使用 ``oebuild generate`` 时选择 ``openeuler-mcs`` 即可。 + 请参考 :ref:`南向支持章节 ` 构建不同平台的镜像,只需要在使用 ``oebuild generate`` 时选择 ``mcs`` 即可。 以下为 qemu-aarch64 平台的构建步骤,其它平台的构建步骤与之类似: @@ -23,21 +23,23 @@ .. code-block:: console - $ oebuild generate -p -f openeuler-mcs -d + $ oebuild generate -p -f mcs -d # 以 qemu-arm64 为例,platform 可以指定为 qemu-aarch64 # 其它平台请运行 oebuild generate -l 查看 - $ oebuild generate -p qemu-aarch64 -f openeuler-mcs -d + $ oebuild generate -p qemu-aarch64 -f mcs -d 之后,在 ```` 目录下,会生成编译配置文件 ``compile.yaml``。 .. note:: - MICA 支持在 `bare-metal` 和 `jailhouse` 两种不同的环境上运行,默认构建 `bare-metal`。 + MICA 支持在 `bare-metal`、`jailhouse`、`xen` 三种不同的环境上运行,默认构建 `bare-metal`。 若需要支持 `jailhouse`,请修改编译配置文件 ``compile.yaml``,把 **MCS_FEATURES 中的 openamp 改成 jailhouse**。 + 若需要支持 `xen`,请在oebuild generate时额外添加 -f xen,无需修改 ``compile.yaml``。 + 3. 进入 ```` 目录,编译 openeuler-image 或 openeuler-image-mcs,两个镜像都会安装 mcs 组件,但 openeuler-image-mcs 仅包含少量的基础软件包: .. code-block:: shell diff --git a/docs/source/features/mica/instruction.rst b/docs/source/features/mica/instruction.rst index 961cd09fc59..7af0bb562ef 100644 --- a/docs/source/features/mica/instruction.rst +++ b/docs/source/features/mica/instruction.rst @@ -38,13 +38,17 @@ ____ jailhouse 通过 cell 文件进行资源的预留和分配,无需单独配置设备树。 + .. tab:: xen部署 + + xen 给Client OS使用的保留内存是动态申请和释放的,无需通过dts静态预留保留内存,使用可正常部署xen dom0的dtb即可。 + 2. 启动 QEMU .. note:: 下文的QEMU启动命令默认使能 ``virtio-net``,请先阅读 :ref:`QEMU 使用指导 ` 了解如何开启网络。 - 使用生成出来的 dtb,按照以下命令启动 QEMU,注意,bare-metal 部署和 jailhouse 部署所依赖的 QEMU 命令略有不同: + 使用生成出来的 dtb,按照以下命令启动 QEMU,注意,bare-metal、jailhouse、xen 部署所依赖的 QEMU 命令略有不同: .. tabs:: @@ -82,6 +86,27 @@ ____ -kernel zImage \ -initrd openeuler-image-*.cpio.gz + .. tab:: xen部署 + + | 按照以下命令启动 QEMU,注意: + | 1. **低版本qemu存在影响xen的bug,会造成RTOS xen镜像卡死,建议使用高版本qemu。** 可参考 `qemu.org — Build instructions `_ 。 + | 2. 构建-f mcs -f xen的镜像后,生成的 ``*.qemuboot.dtb`` 已带有 `multiboot,module xen,linux-zimage` 节点,可直接用于部署xen dom0。 + | 3. 启动参数 ``mem=1024M`` 是预留给xen总共的内存,dom0 Linux的内存请通过dts ``xen,xen-bootargs`` 的 ``dom0_mem`` 进行配置。 + + .. code-block:: console + + $ sudo /home/user/qemu-10.1.2/build/qemu-system-aarch64 -device virtio-net-pci,netdev=net0 \ + -netdev tap,id=net0,ifname=tap0,script=/etc/qemu-ifup \ + -initrd openeuler-image-*.cpio.gz\ + -device loader,file=Image,addr=0x45000000 \ + -machine virt,gic-version=3 \ + -machine virtualization=true \ + -cpu cortex-a53 -smp 4 -m 4096 \ + -serial mon:stdio -nographic \ + -kernel xen-qemu-aarch64 \ + -append 'root=/dev/ram0 rw debugshell mem=1024M console=ttyAMA0,115200' \ + -dtb openeuler-image-mcs-qemu-aarch64-*.qemuboot.dtb + 3. 部署 Client OS 用户首先需要创建配置文件来关联实时OS以及指定部署方式,之后可以通过 ``mica`` 命令基于配置文件部署 client OS。 @@ -257,6 +282,97 @@ ____ 销毁实例后,可以执行 ``mica create qemu-zephyr-ivshmem.conf`` 重新创建实例。 + .. tab:: xen部署 + + (1) 调整内核打印等级: + + .. code-block:: console + + # 为了不影响shell的使用,先屏蔽内核打印: + qemu-aarch64:~$ echo "1 4 1 7" > /proc/sys/kernel/printk + + (2) 启动 client OS: + + | 镜像启动时默认会根据 `/etc/mica/qemu-uniproton-xen.conf` 和 `/etc/mica/qemu-zephyr-xen.conf` 创建 client OS 实例。 + | 通过 ``mica status`` 查看该实例状态: + + .. code-block:: console + + qemu-aarch64 ~ # mica status + Name Assigned CPU State Service + qemu-uniproton-xen 1-3 Offline + qemu-zephyr-xen 1-3 Offline + + | 可以看到实例的名称为 qemu-uniproton-xen 和 qemu-zephyr-xen,关联的 CPU ID 为1-3,状态为 Offline。 + | 通过 ``mica start `` 启动实例,以 qemu-uniproton-xen 为例: + + .. code-block:: console + + qemu-aarch64:~$ mica start qemu-uniproton-xen + starting qemu-uniproton-xen... + start qemu-uniproton-xen successfully! + + 启动成功后,执行 ``mica status`` 查询状态: + + .. code-block:: console + + qemu-aarch64:~$ mica status + Name Assigned CPU State Service + qemu-uniproton-xen 1-3 Running rpmsg-tty(/dev/ttyRPMSG0) rpmsg-rpc rpmsg-umt + qemu-zephyr-xen 1-3 Offline + + 状态更新为 Running,并且能观察到该实例提供了服务:rpmsg-tty。 + + rpmsg-tty 绑定了 uniproton 的 shell,因此可以通过 screen 打开 tty 设备 ``/dev/ttyRPMSG0`` 来访问 uniproton 的 shell: + + .. code-block:: console + + # 打开 Client OS 的 shell + qemu-aarch64:~$ screen /dev/ttyRPMSG0 + + ... ... + # 回车后可以连上 shell,并执行 uniproton 的 shell 命令 + openEuler UniProton # taskInfo + Pid Name Status + ---------------- ---------------- ---------------- + 1 IdleTask 0x41 + 3 pthread 0x41 + 4 pthread 0x9 + 6 SerialShellTask 0xc1 + 0 0x1 + + + 之后,可以通过 ``Ctrl-a k`` 或 ``Ctrl-a Ctrl-k`` 组合键退出shell,参考 `screen(1) — Linux manual page `_ 。 + + (3) 停止 client OS: + + 通过 ``mica stop `` 停止实例: + + .. code-block:: console + + qemu-aarch64:~$ mica stop qemu-uniproton-xen + stopping qemu-uniproton-xen... + stop qemu-uniproton-xen successfully! + qemu-aarch64:~$ mica status + Name Assigned CPU State Service + qemu-uniproton-xen 1-3 Offline + qemu-zephyr-xen 1-3 Offline + + (4) 销毁 client OS: + + 通过 ``mica rm `` 销毁实例: + + .. code-block:: console + + qemu-aarch64:~$ mica rm qemu-uniproton-xen + removing qemu-uniproton-xen... + rm qemu-uniproton-xen successfully! + qemu-aarch64:~$ mica status + Name Assigned CPU State Service + qemu-zephyr-xen 1-3 Offline + + 销毁实例后,可以执行 ``mica create qemu-uniproton-xen.conf`` 重新创建实例。 + ____ 在树莓派4B上运行 diff --git a/docs/source/features/mica/mica_ctl.rst b/docs/source/features/mica/mica_ctl.rst index 4ec117c2ece..2be0bbdbb5c 100644 --- a/docs/source/features/mica/mica_ctl.rst +++ b/docs/source/features/mica/mica_ctl.rst @@ -9,18 +9,20 @@ mica命令介绍 .. code-block:: console qemu-aarch64:~$ mica --help - usage: mica [-h] {create,start,stop,rm,status} ... + usage: mica [-h] {create,start,stop,rm,set,status,gdb} ... Query or send control commands to the micad. positional arguments: - {create,start,stop,rm,status...} + {create,start,stop,rm,set,status,gdb} the command to execute create Create a new mica client start Start a client stop Stop a client rm Remove a client + set Update settings for a client status query the mica client status + gdb Start GDB client ... options: @@ -44,33 +46,76 @@ mica命令介绍 ``mica gdb `` 如果名字为 的实例支持调试,可以通过该命令启动 GDB Client 开始调试。 -____ +``mica set `` + 在线更新名字为 的实例的 。 -实例配置文件介绍 -**************** + 当前仅支持xen部署时配置CPU、VCPU、CPUWeight、CPUCapacity、Memory资源项,和实例配置文件的入参要求保持一致。 -配置文件用于创建实例,通过不同的选项参数承载该实例对应的实时OS、CPU 等信息。**所有的选项需要放在** ``[Mica]`` **段中配置**: + 例如: -``Name=`` - 实例名称,必须唯一。 + ``mica set qemu-uniproton-xen Memory 1024`` 表示将名字为 ``qemu-uniproton-xen`` 的实例的内存更新为1024MB。 -``CPU=`` - 为实时OS分配的核号,范围:0 到 nproc - 1。 + ``mica set qemu-uniproton-xen CPUCapacity 100`` 表示将名字为 ``qemu-uniproton-xen`` 的实例的CPU算力更新为1个物理CPU。 -``ClientPath=`` - 实时OS的镜像路径,需要配置为绝对路径,且仅支持 elf 格式的镜像。 - -``AutoBoot=`` - 是否在 micad 启动时自动拉起该实例,默认为 no。 +____ -``Pedestal=`` - 指定部署底座,默认为 bare-metal,即在裸核上运行 RTOS。当前支持在 QEMU 上配置为 jailhouse,以使用 jailhouse 部署。 +实例配置文件介绍 +**************** -``PedestalConf=`` - 指定部署底座关联的配置文件。例如 Jailhouse 部署时,需要通过 PedestalConf 指定 RTOS 所需的 Non-Root Cell 配置文件。 +配置文件用于创建实例,通过不同的选项参数承载该实例对应的实时OS、CPU 等信息。**所有的选项需要放在** ``[Mica]`` **段中配置**: -``Debug=`` - bool类型,表示OS二进制是否支持调试,默认为 no。如果支持调试,可以通过 mica gdb 命令启动 GDB Client 开始调试。 + +--------------------+----------------------------------------+------------------------------+----------+ + | 配置项 | 配置内容 | 入参要求 | 底座支持 | + +====================+========================================+==============================+==========+ + |``Name=`` |实例名称,必须唯一 |str(长度<32) |ALL | + +--------------------+----------------------------------------+------------------------------+----------+ + |``CPU=`` |为实时OS分配的核号,范围 0 ~ nproc - 1 |str(长度<128) | ALL | + | | bare-metal:仅支持单核 | | | + | | | | | + | | jailhouse:实际由cell文件配置 | | | + | | | | | + | | xen:支持多核 | | | + +--------------------+----------------------------------------+------------------------------+----------+ + |``ClientPath=`` |实时OS的镜像路径,需要配置为绝对路径, |str(长度<128) |ALL | + | |且仅支持elf | | | + +--------------------+----------------------------------------+------------------------------+----------+ + |``AutoBoot=`` |是否在micad启动时自动拉起该实例, |yes/no |ALL | + | |默认为no | | | + +--------------------+----------------------------------------+------------------------------+----------+ + |``Pedestal=`` |指定部署底座,默认为baremetal,即在裸核 |str(长度<128) |ALL | + | |运行RTOS;支持配置为jailhouse/xen | | | + +--------------------+----------------------------------------+------------------------------+----------+ + |``PedestalConf=`` |指定部署底座关联的配置文件 |str(长度<128) |ALL | + | | bare-metal:不涉及 | | | + | | | | | + | | jailhouse:指定RTOS所需的 | | | + | | Non-Root Cell配置文件 | | | + | | | | | + | | xen:指定用于引导RTOS的bin文件 | | | + +--------------------+----------------------------------------+------------------------------+----------+ + |``Debug=`` |表示OS二进制是否支持调试,默认为no |yes/no |ALL | + | | | | | + | |如果支持调试,可以通过mica gdb命令启动 | | | + | |GDB Client开始调试 | | | + +--------------------+----------------------------------------+------------------------------+----------+ + |``VCPU=`` |为实时OS分配的虚拟CPU数量 |int(范围1~nproc) |xen | + +--------------------+----------------------------------------+------------------------------+----------+ + |``MaxVCPU=`` |在线扩容时可为实时OS分配 |int(范围1~nproc) |xen | + | |的最大虚拟CPU数量,默认和VCPU一致 | | | + +--------------------+----------------------------------------+------------------------------+----------+ + |``CPUWeight=`` |为实时OS分配的CPU算力权重, |int(范围1~65535) |xen | + | |默认256 | | | + +--------------------+----------------------------------------+------------------------------+----------+ + |``CPUCapacity=`` |为实时OS分配的CPU算力(百分比) |int(范围0~100*nproc) |xen | + | | | | | + | |例如100表示1个物理CPU,50表示 | | | + | |半个物理CPU,默认0即不限制 | | | + +--------------------+----------------------------------------+------------------------------+----------+ + |``Memory=`` |为实时OS分配的内存大小(MB) |int |xen | + +--------------------+----------------------------------------+------------------------------+----------+ + |``MaxMemory=`` |在线扩容时可为实时OS分配 |int(>= Memory) |xen | + | |的最大内存大小(MB),默认等于Memory | | | + +--------------------+----------------------------------------+------------------------------+----------+ 以下为一些配置文件样例: @@ -112,3 +157,20 @@ ____ Debug=yes 该配置文件定义了一个名为 rpi4-uniproton-debug 的实例,并指定该实例实现了GDB stub,支持调试。 + +示例四: + + .. code-block:: console + + [Mica] + Name=qemu-uniproton-xen + CPU=1-3 + ClientPath=/lib/firmware/qemu-uniproton-xen.elf + AutoBoot=no + Pedestal=xen + PedestalConf=/lib/firmware/qemu-uniproton-xen.bin + Memory=1024 + VCPU=1 + CPUCapacity=50 + + 该配置文件定义了一个名为 qemu-uniproton-xen 的实例,并指定使用 xen 作为部署底座,同时该实例使用的 xen 引导文件为 `/lib/firmware/qemu-uniproton-xen.bin`,RTOS运行在核1、2、3。 \ No newline at end of file diff --git a/docs/source/features/mica/supported_lists.rst b/docs/source/features/mica/supported_lists.rst index 98a00d4cbd9..73ef51f52d7 100644 --- a/docs/source/features/mica/supported_lists.rst +++ b/docs/source/features/mica/supported_lists.rst @@ -5,14 +5,18 @@ | 架构 | 南向平台 | 部署模式 | 实时OS | +============+========================+=======================+======================+ | | | Jailhouse | zephyr | - | | qemu-aarch64 +-----------------------+----------------------+ - | | | bare-metal | zephyr | + | | +-----------------------+----------------------+ + | | qemu-aarch64 | bare-metal | zephyr | + | | +-----------------------+----------------------+ + | | | Xen | zephyr,UniProton | | +------------------------+-----------------------+----------------------+ | ARM64 | | Jailhouse | zephyr | | | 树莓派4B +-----------------------+----------------------+ | | | bare-metal | zephyr,UniProton | | +------------------------+-----------------------+----------------------+ | | Hi3093 | bare-metal | UniProton | + | +------------------------+-----------------------+----------------------+ + | | hieulerpi | bare-metal | UniProton | +------------+------------------------+-----------------------+----------------------+ | | qemu-x86_64 | bare-metal | UniProton | + x86_64 +------------------------+-----------------------+----------------------+ -- Gitee From 4e52292940ae0abc00276e2e98c7da1e5c1c349e Mon Sep 17 00:00:00 2001 From: Wanming Hu Date: Fri, 14 Nov 2025 16:20:28 +0800 Subject: [PATCH 3/3] mcs: install firmware path for xen bin image Just in case, install firmware path for xen bin image. Usually elf files will exist for aarch64 image. Signed-off-by: Wanming Hu --- meta-openeuler/recipes-mcs/mcs-linux/mcsctl.bb | 1 + 1 file changed, 1 insertion(+) diff --git a/meta-openeuler/recipes-mcs/mcs-linux/mcsctl.bb b/meta-openeuler/recipes-mcs/mcs-linux/mcsctl.bb index 0c2ec5a4f3d..af5e8d97ff9 100644 --- a/meta-openeuler/recipes-mcs/mcs-linux/mcsctl.bb +++ b/meta-openeuler/recipes-mcs/mcs-linux/mcsctl.bb @@ -50,6 +50,7 @@ do_install:append () { # install rtos bin for xen set -- "${S}/rtos/arm64/${RTOS_IMGS}"*.bin if [ -f "$1" ]; then + install -d "${D}/lib/firmware" cp -- "$@" "${D}/lib/firmware/" fi } -- Gitee