1.安装openbmc适配的qume
Download and Start QEMU Session
- 下载最新的 QEMU 应用的 openbmc/qemu fork
wget https://jenkins.openbmc.org/job/latest-qemu-x86/lastSuccessfulBuild/artifact/qemu/build/qemu-system-arm
chmod u+x qemu-system-arm
- 下载 Romulus 镜像。
wget https://jenkins.openbmc.org/job/latest-master/label=docker-builder,target=romulus/lastSuccessfulBuild/artifact/openbmc/build/tmp/deploy/images/romulus/obmc-phosphor-image-romulus.static.mtd
- 使用下载的 Romulus 镜像启动 QEMU
** 注** - 要使 REST、SSH 和 IPMI 工作到您的 QEMU 会话中,您必须将一些主机端口连接到 QEMU 会话中的 REST、SSH 和 IPMI 端口。在这个例子中,它只使用 2222、2443、2623。你可以使用任何你喜欢的。
./qemu-system-arm -m 256 -M romulus-bmc -nographic \
-drive file=./obmc-phosphor-image-romulus.static.mtd,format=raw,if=mtd \
-net nic \
-net user,hostfwd=:127.0.0.1:2222-:22,hostfwd=:127.0.0.1:2443-:443,hostfwd=udp:127.0.0.1:2623-:623,hostname=qemu
注- 默认情况下,Jenkins 和 openbmc-test-automation 分别使用 SSH 和 HTTPS 端口 22 和 443。对于 IPMI 端口 623 被使用。使用用户定义的端口 2222 的 SSH 连接可能不会成功。要使用 SSH 端口 22、HTTPS 端口 443 和 IPMI 端口 623:
./qemu-system-arm -m 256 -machine romulus-bmc -nographic \
-drive file=./obmc-phosphor-image-romulus.static.mtd,format=raw,if=mtd \
-net nic \
-net user,hostfwd=:127.0.0.1:22-:22,hostfwd=:127.0.0.1:443-:443,hostfwd=tcp:127.0.0.1:80-:80,hostfwd=tcp:127.0.0.1:2200-:2200,hostfwd=udp:127.0.0.1:623-:623,hostfwd=udp:127.0.0.1:664-:664,hostname=qemu
- 等待基于 QEMU 的 BMC 启动
使用默认的 root/0penBmc 登录登录(注意 0 是零)。
- 检查系统状态
您会在控制台中看到很多服务启动,您可以开始运行 obmcutil 工具来检查 OpenBMC 状态服务的状态。当您看到以下内容时,您已成功启动到“就绪”状态。
root@openbmc:~# obmcutil state
CurrentBMCState : xyz.openbmc_project.State.BMC.BMCState.Ready
CurrentPowerState : xyz.openbmc_project.State.Chassis.PowerState.Off
CurrentHostState : xyz.openbmc_project.State.Host.HostState.Off
Note 要退出(并终止)您的 QEMU 会话,请运行:ctrl+a x
2.启动bmc
使用openbmc官方镜像启动
如果没有编译出镜像,可以先试用openbmc官方提供的lastsuccessbuild镜像测试,先去下载:https://jenkins.openbmc.org/job/latest-master/lastSuccessfulBuild/label=docker-builder,target=romulus/
启动命令:
./qemu-system-arm -m 256 -M romulus-bmc -nographic -drive file=/home/test/Documents/openbmc_ws/obmc-phosphor-image-romulus-20211214025233.static.mtd,format=raw,if=mtd -net nic -net user,hostfwd=:127.0.0.1:2222-:22,hostfwd=:127.0.0.1:2443-:443,hostfwd=udp:127.0.0.1:2623-:623,hostname=qemu
使用自己编译的镜像启动
我这里启动之前的步骤中编译出的ast2600-evb
./qemu-system-arm -m 1024 -M ast2600-evb -nographic -drive file=/home/test/Documents/openbmc_ws/openbmc/build/evb-ast2600/tmp/deploy/images/evb-ast2600/obmc-phosphor-image-evb-ast2600.static.mtd,format=raw,if=mtd -net nic -net user,hostfwd=:127.0.0.1:2222-:22,hostfwd=:127.0.0.1:2443-:443,hostfwd=udp:127.0.0.1:2623-:623,hostname=qemu
3.使用bmc web
3.1 可以看到上一步中的启动方式是用的端口映射方式启动的,如果使用官方的镜像,输入:https://127.0.0.1:2443/
3.2 如果使用ast2600-evb,默认使用redfish:
3.3 如果使用ast2600-evb,启用bmc web的步骤:
phosphor-webui软件包编译所依赖的AngularJS已经停止维护,所以这里使用webui-vue:
修改~/openbmc/build/evb-ast2600/conf/local.conf,添加:
CORE_IMAGE_EXTRA_INSTALL += "webui-vue"
新建文件 ~/openbmc/meta-phosphor/recipes-phosphor/image/obmc-phosphor-image.bbappend,写入配置:
OBMC_IMAGE_EXTRA_INSTALL_${MACHINE} += "webui-vue"
新建文件 ~/openbmc/meta-phosphor/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bbappend,写入配置:
RDEPENDS_${PN}-inventory_${MACHINE} += "webui-vue"
然后重新编译并启动:
bitbake obmc-phosphor-image -c clean
bitbake obmc-phosphor-image
4.使用ssh连接bmc
SSH 端口 22、HTTPS 端口 443 和 IPMI 端口 623
ssh -p 2222 root@127.0.0.1
后记:
附上openbmc文档里的qemu说明:
Using QEMU
QEMU has a palmetto-bmc machine (as of v2.6.0) which implements the core devices
to boot a Linux kernel. OpenBMC also
maintains a tree with patches on their way
upstream or temporary work-arounds that add to QEMU’s capabilities where
appropriate.
qemu-system-arm -m 256 -M palmetto-bmc -nographic \
-drive file=<path>/flash-palmetto,format=raw,if=mtd \
-net nic \
-net user,hostfwd=:127.0.0.1:2222-:22,hostfwd=:127.0.0.1:2443-:443,hostname=qemu
If you get an error you likely need to build QEMU (see the section in this
document). If no error and QEMU starts up just change the port when interacting
with the BMC…
curl -c cjar -b cjar -k -H "Content-Type: application/json" \
-X POST https://localhost:2443/login -d "{\"data\": [ \"root\", \"0penBmc\" ] }"
or
ssh -p 2222 root@localhost
To quit, type Ctrl-a c
to switch to the QEMU monitor, and then quit
to exit.
Building QEMU
git clone https://github.com/openbmc/qemu.git
cd qemu
git submodule update --init dtc
mkdir build
cd build
../configure --target-list=arm-softmmu
make
Built file will be located at: arm-softmmu/qemu-system-arm
Use a bridge device
Using a bridge device requires a bit of root access to set it up. The benefit is
your qemu session runs in the bridges subnet so no port forwarding is needed.
There are packages needed to yourself a virbr0 such as…
apt-get install libvirt libvirt-bin bridge-utils uml-utilities qemu-system-common
qemu-system-arm -m 256 -M palmetto-bmc -nographic \
-drive file=<path>/flash-palmetto,format=raw,if=mtd \
-net nic,macaddr=C0:FF:EE:00:00:02,model=ftgmac100 \
-net bridge,id=net0,helper=/usr/lib/qemu-bridge-helper,br=virbr0
There are some other useful parms like that can redirect the console to another
window. This results in having an easily accessible qemu command session.
-monitor stdio -serial pty -nodefaults