当前位置: 首页 > article >正文

Ubuntu下用QEMU模拟运行OpenBMC

1、前言

        在调试过程中,安装了很多依赖库,具体没有记录。关于kvm,也没理清具体有什么作用。本文仅记录,用QEMU成功的将OpenBMC跑起来的过程,做备忘,也供大家参考。

2、环境信息

VMware® Workstation 15 Pro

sunny@ubuntu:~$ uname -a
Linux ubuntu 5.4.0-150-generic #167~18.04.1-Ubuntu SMP Wed May 24 00:51:42 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

3、虚拟化设置

进入虚拟机:

1、查看是否支持虚拟化
   sunny@ubuntu:~$ LC_ALL=C lscpu | grep Virtualization
   Virtualization:      VT-x
   Virtualization type: full

2、查看核心数,应该大于0
   sunny@ubuntu:~$ egrep -c '(vmx|svm)' /proc/cpuinfo
   4

3、安装KVM,已经安装过
   sunny@ubuntu:~$ sudo apt install qemu qemu-kvm virt-manager bridge-utils
   [sudo] password for sunny: 
   Reading package lists... Done
   Building dependency tree       
   Reading state information... Done
   bridge-utils is already the newest version (1.5-15ubuntu1).
   qemu-kvm is already the newest version (1:2.11+dfsg-1ubuntu7.42).
   qemu is already the newest version (1:2.11+dfsg-1ubuntu7.42).
   virt-manager is already the newest version (1:1.5.1-0ubuntu1.2).
   The following packages were automatically installed and are no longer required:
     gir1.2-goa-1.0 gir1.2-snapd-1
   Use 'sudo apt autoremove' to remove them.
     0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

3、重启虚拟机
    sunny@ubuntu:~$ reboot

4、虚拟机起来后,将用户添加到适当的组中,启用并启动libvirt服务
    sunny@ubuntu:~$ sudo useradd -g $USER libvirt
    sunny@ubuntu:~$ sudo useradd -g $USER libvirt-kvm
    sunny@ubuntu:~$ sudo systemctl enable libvirtd.service
    sunny@ubuntu:~$ sudo systemctl start libvirtd.service
      Synchronizing state of libvirtd.service with SysV service script with         
      /lib/systemd/systemd-sysv-install.
      Executing: /lib/systemd/systemd-sysv-install enable libvirtd

4、安装QENU

1、下载源码
   sunny@ubuntu:~$ wget https://download.qemu.org/qemu-6.2.0.tar.xz

2、解压
   sunny@ubuntu:~$ tar xvJf qemu-6.2.0.tar.xz

3、在下载目录新建文件夹build
   sunny@ubuntu:~$ cd qemu-6.2.0
   sunny@ubuntu:~$ mkdir build 
   sunny@ubuntu:~$ cd build  

4、配置
   sunny@ubuntu:~$ ../configure --enable-kvm  --target-list=arm-softmmu

5、编译
   sunny@ubuntu:~$ make

6、安装
   sunny@ubuntu:~$ make install

7、查看是否安装成功
  sunny@ubuntu:~$ qemu-system-arm --version
    QEMU emulator version 6.2.0
    Copyright (c) 2003-2021 Fabrice Bellard and the QEMU Project developers

5、启动OpenBMC

官方OpenBMC镜像下载:
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

启动并登录:(用户名/密码:root/0penBmc ,0penBmc 首字母是零)

./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
sunny@ubuntu:~$ 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
qemu-system-arm: warning: nic ftgmac100.1 has no peer


U-Boot 2019.04 (Jan 28 2025 - 06:31:57 +0000)

SOC : AST2500-A1 
RST : Power On 
2nd Boot : Enable
LPC Mode : SIO:Enable : SuperIO-2e
Eth : MAC0: RMII/NCSI, , MAC1: RMII/NCSI, 
Model: Romulus BMC
DRAM:  192 MiB (capacity:256 MiB, VGA:64 MiB, ECC:off)
MMC:   
Loading Environment from SPI Flash... SF: Detected n25q256a with page size 256 Bytes, erase size 4 KiB, total 32 MiB
*** Warning - bad CRC, using default environment

In:    serial@1e784000
Out:   serial@1e784000
Err:   serial@1e784000
Net:   ftgmac100_probe - NCSI detected

Warning: ethernet@1e660000 (eth0) using random MAC address - be:b0:c8:9a:8c:85
eth0: ethernet@1e660000
Hit any key to stop autoboot:  0 

...

romulus login: [  OK  ] Started Hostname Service.
[  OK  ] Finished Phosphor Sysfs - Add LED.
[  OK  ] Finished Phosphor Sysfs - Add LED.
[  OK  ] Finished Phosphor Sysfs - Add LED.
[  OK  ] Finished Wait for /org/openbmc/control/power0.
[  OK  ] Finished Wait for /xyz/openbmc_project/control/host0/auto_reboot.
[  OK  ] Finished Wait for /xyz/openbmc_project/control/host0/boot/one_time.
[  OK  ] Finished Wait for /xyz/openbmc_project/control/host0/boot.
[  OK  ] Finished Wait for /xyz/openbmc_pro…control/host0/power_restore_policy.
[  OK  ] Finished Wait for /xyz/openbmc_project/control/host0/restriction_mode.
[  OK  ] Finished Wait for /xyz/openbmc_project/time/sync_method.

romulus login: root
Password: 
root@romulus:~# pwd
/home/root
root@romulus:~# ps
  PID USER       VSZ STAT COMMAND
    1 root     10896 S    {systemd} /sbin/init
    2 root         0 SW   [kthreadd]
    3 root         0 SW   [pool_workqueue_]
    4 root         0 IW<  [kworker/R-slub_]
    5 root         0 IW<  [kworker/R-netns]
    6 root         0 IW   [kworker/0:0-dev]
    7 root         0 IW<  [kworker/0:0H-kb]
    8 root         0 IW   [kworker/u2:0-ev]
    9 root         0 IW<  [kworker/R-mm_pe]
   10 root         0 IW   [rcu_tasks_rude_]
   11 root         0 IW   [rcu_tasks_trace]
   12 root         0 SW   [ksoftirqd/0]
   13 root         0 SW   [kdevtmpfs]
   14 root         0 IW<  [kworker/R-inet_]
   15 root         0 SW   [oom_reaper]
   16 root         0 IW   [kworker/u2:1-ev]
   17 root         0 IW<  [kworker/R-write]
   18 root         0 IW<  [kworker/R-kbloc]
   19 root         0 SW   [watchdogd]
   20 root         0 IW   [kworker/0:1-dev]
   21 root         0 SW   [kswapd0]
   22 root         0 IW   [kworker/0:2-dev]
   23 root         0 IW   [kworker/0:3-eve]
   24 root         0 IW   [kworker/0:4-eve]
   25 root         0 SW   [hwrng]
   26 root         0 SW   [card0-crtc0]
   27 root         0 IW<  [kworker/u3:0]
   28 root         0 IW   [kworker/u2:2-ev]
   29 root         0 IW<  [kworker/R-nbd0-]
   30 root         0 IW<  [kworker/R-nbd1-]
   31 root         0 IW<  [kworker/R-nbd2-]
   32 root         0 IW<  [kworker/R-nbd3-]
   33 root         0 IW<  [kworker/R-nbd4-]
   34 root         0 IW<  [kworker/R-nbd5-]
   35 root         0 IW<  [kworker/R-nbd6-]
   36 root         0 IW<  [kworker/R-nbd7-]
   37 root         0 IW<  [kworker/R-nbd8-]
   38 root         0 IW<  [kworker/R-nbd9-]
   39 root         0 IW<  [kworker/R-nbd10]
   40 root         0 IW<  [kworker/R-nbd11]
   41 root         0 IW<  [kworker/R-nbd12]
   42 root         0 IW<  [kworker/R-nbd13]
   43 root         0 IW<  [kworker/R-nbd14]
   44 root         0 IW<  [kworker/R-nbd15]
   45 root         0 SW   [irq/38-aspeed-v]
   46 root         0 IW<  [kworker/R-mld]
   47 root         0 IW<  [kworker/R-ipv6_]
   89 root         0 SWN  [jffs2_gcd_mtd5]
   99 root         0 IW<  [kworker/0:1H]
  120 root     15644 S    /usr/lib/systemd/systemd-journald
  156 systemd-  7536 S    /usr/lib/systemd/systemd-resolved
  157 systemd- 16348 S    /usr/lib/systemd/systemd-timesyncd
  167 root      3844 S    /usr/lib/systemd/systemd-udevd
  174 systemd-  8800 S    /usr/lib/systemd/systemd-networkd
  220 messageb  6324 S    /usr/bin/dbus-broker-launch --scope system --audit
  222 messageb  2884 S    dbus-broker --log 4 --controller 9 --machine-id d21f666aea624a3b8a37ba09a2631ee3 --max-bytes 536870912 --max-fds 40
  223 avahi     4764 S    avahi-daemon: running [romulus.local]
  224 root     15296 S    /usr/libexec/bmcwebd
  225 root      2980 S    /usr/sbin/klogd -n
  226 root      2980 S    /usr/sbin/syslogd -n
  231 root      3820 S    /usr/sbin/obmc-console-server --config /etc/obmc-console/server.ttyVUART0.conf ttyVUART0
  233 root      6016 S    phosphor-dump-monitor
  235 root     13148 S    /usr/bin/openpower-update-manager
  236 root      3620 S    btbridged
  238 root     41696 S    power_control.exe 3000 10
  239 root     15044 S    /usr/sbin/nscd
  240 root     13828 S    /usr/bin/phosphor-certificate-manager --endpoint truststore --path /etc/ssl/certs/authority --type authority --unit
  242 root     14224 S    /usr/bin/phosphor-certificate-manager --endpoint https --path /etc/ssl/certs/https/server.pem --type server --unit
  245 root     14092 S    /usr/bin/phosphor-certificate-manager --endpoint ldap --path /etc/nslcd/certs/cert.pem --type client --unit
  248 root      6020 S    /usr/bin/phosphor-gpio-monitor --path=/dev/input/by-path/platform-gpio-keys-event --key=135 --polarity=1 --target=i
  260 root     18948 S    /usr/bin/health-monitor
  262 root      9448 S    /usr/libexec/phosphor-led-sysfs/phosphor-ledcontroller
  263 root      5512 S    /usr/sbin/slpd
  265 root      6584 S    /usr/bin/phosphor-srvcfg-manager

6、登录WEB

https://127.0.0.1:2443/

7、SSH登录

sunny@ubuntu:~$ ssh -p 2222 root@127.0.0.1
    The authenticity of host '[127.0.0.1]:2222 ([127.0.0.1]:2222)' can't be established.
    ECDSA key fingerprint is SHA256:1qMjJ+TbkvpF17Y8y/R9d+xVUE4lu0nN7YxZHNaQwhU.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added '[127.0.0.1]:2222' (ECDSA) to the list of known hosts.
    root@127.0.0.1's password: 

root@romulus:~# pwd
    /home/root

原文地址:https://blog.csdn.net/qq_18854309/article/details/146462975
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.kler.cn/a/611535.html

相关文章:

  • 解决Jenkins中Vue前端打包时package.json文件冲突的两种常见问题
  • 实力认证|“AORO M6-Pro在危急特场景的应用”被评为AI标杆产品典型案例
  • Qt QPainter使用方法
  • Qt事件处理(处理鼠标事件、键盘事件、定时器事件、窗口移动和大小变化事件)
  • Postman下载安装(Windows 11 专业版)
  • 【递归与动态规划(DP) C/C++】(1)递归 与 动态规划(DP)
  • 数据结构5(初):续写排序
  • 手搓全自动文章多平台发布系统:2、重要模块的设计
  • 国产化适配 - YashanDB、达梦数据库与MySQL 的兼容性及技术选型对比分析
  • R语言交互项-formula
  • 【C++】STL库_list 的模拟实现
  • 大数据学习栈记——HBase操作(shell java)
  • Couchbase存储引擎Magma和Couchstore
  • Stable Diffusion绘画插件(ControlNet )
  • Eclipse Debug 调试
  • 汇编(六)——汇编语言程序格式及MASM
  • OpenGL绘制文本
  • Vue的实例
  • Three.js 快速入门教程【十八】射线拾取模型——鼠标点击屏幕选中模型或物体
  • 【AI大模型】搭建本地大模型GPT-J:详细步骤及常见问题