赞
踩
如果使用ipmitool
发送命令:
# ipmitool -U root -P 0penBmc -H 10.245.27.93 -I lanplus -C 17 chassis power status
Get Chassis Power Status failed: Unspecified error
从BMC
端可以在串口下使用journalctl -p err
看到打印:
尝试修改build/ast2500-default/workspace/sources/phosphor-ipmi-host/chassishandler.cpp
代码:
然后使用ipmitool
命令,可以获取到返回。
# ipmitool -U root -P 0penBmc -H 10.245.27.22 -I lanplus -C 17 chassis power status
Chassis Power is on
因此,目前对于power
的控制是不支持的。
busctl
的使用参考链接: https://www.freedesktop.org/software/systemd/man/latest/busctl.html
sensor
的信息,使用命令:busctl | grep Sensor
busctl tree xyz.openbmc_project.ADCSensor
busctl introspect xyz.openbmc_project.ADCSensor
可以看到interfaces
有如下:
busctl
从代码端分析在文件:build/ast2500-default/workspace/sources/phosphor-ipmi-host/chassishandler.cpp
中,可以看到如下代码:
std::optional<bool> getPowerStatus() { bool powerGood = false; std::shared_ptr<sdbusplus::asio::connection> busp = getSdBus(); try { constexpr const char* chassisStatePath = "/xyz/openbmc_project/state/chassis0"; constexpr const char* chassisStateIntf = "xyz.openbmc_project.State.Chassis"; auto service = ipmi::getService(*busp, chassisStateIntf, chassisStatePath); ipmi::Value powerState = ipmi::getDbusProperty(*busp, service, chassisStatePath, chassisStateIntf, "CurrentPowerState"); powerGood = std::get<std::string>(powerState) == "xyz.openbmc_project.State.Chassis.PowerState.On"; } catch (const std::exception& e) { try { // FIXME: some legacy modules use the older path; try that next constexpr const char* legacyPwrCtrlObj = "/org/openbmc/control/power0"; constexpr const char* legacyPwrCtrlIntf = "org.openbmc.control.Power"; auto service = ipmi::getService(*busp, legacyPwrCtrlIntf, legacyPwrCtrlObj); ipmi::Value variant = ipmi::getDbusProperty( *busp, service, legacyPwrCtrlObj, legacyPwrCtrlIntf, "pgood"); powerGood = static_cast<bool>(std::get<int>(variant)); } catch (const std::exception& e) { log<level::ERR>("Failed to fetch pgood property", entry("ERROR=%s", e.what())); return std::nullopt; } } return std::make_optional(powerGood); }
当前使用的sdbus
结构非legacy
模式,因此,需要查询"xyz.openbmc_project.State.Chassis"
是否存在。
可以发现,我们并未注册该service
到系统中。
meta-aspeed-sdk/meta-ast2500-sdk/conf/machine/ast2500-default.conf
中的内容:require conf/machine/include/ast2500-sdk.inc require conf/machine/include/obmc-bsp-common.inc # Overwrite flash layout FLASH_SIZE = "65535" FLASH_UBOOT_OFFSET = "0" FLASH_KERNEL_OFFSET = "1024" FLASH_ROFS_OFFSET = "10240" FLASH_RWFS_OFFSET = "47104" RWFS_SIZE = "18874368" # U-Boot Build Settings UBOOT_MACHINE = "evb-ast2500_defconfig" UBOOT_DEVICETREE = "ast2500-evb" # Kernel Build Settings KERNEL_DEVICETREE = "aspeed-ast2500-evb.dtb" KBUILD_DEFCONFIG = "aspeed_g5_defconfig" # MACHINE_FEATURES += "\ # obmc-phosphor-fan-mgmt \ # obmc-phosphor-chassis-mgmt \ # obmc-phosphor-flash-mgmt \ # obmc-host-ipmi \ # obmc-host-state-mgmt \ # obmc-chassis-state-mgmt \ # obmc-bmc-state-mgmt \ # " MACHINE_FEATURES += "\ obmc-phosphor-fan-mgmt \ obmc-phosphor-flash-mgmt \ obmc-host-ipmi \ " PREFERRED_PROVIDER_virtual/obmc-system-mgmt = "packagegroup-aspeed-obmc" PREFERRED_PROVIDER_virtual/obmc-host-ipmi-hw = "phosphor-ipmi-kcs" VIRTUAL-RUNTIME_obmc-host-state-manager ?= "x86-power-control" VIRTUAL-RUNTIME_obmc-chassis-state-manager ?= "x86-power-control"
使用以上的配置后,编译系统,烧录程序:
使用busctl
查看系统State service
,可以看到(注意需要修改json
文件和x86-power-control
代码以及相关文件,后面的内容有简单说明):
如此也不会再报错了,只是返回错误的系统状态,这需要具体函数里面添加GPIO
的适配即可:
注意:
x86-power-control
与phosphor-state-manager
是不能共存的,可以看到它们有相同的service
.
build/ast2500-default/workspace/sources/phosphor-gpio-monitor/phosphor-multi-gpio-monitor.json
io
配置。可以查看链接: https://github.com/openbmc/phosphor-gpio-monitor/blob/master/README.md
与链接: https://gitee.com/mirrors_openbmc/x86-power-control
相关文件:
meta-phosphor/conf/distro/include/phosphor-defaults.inc
meta-aspeed-sdk/meta-ast2500-sdk/conf/machine/ast2500-default.conf
meta-phosphor/conf/distro/openbmc-phosphor.conf
需要修改: meta-phosphor/conf/distro/include/phosphor-defaults.inc
文件,选择:x86-power-control
与phosphor-state-manager
的一个包。
将:aspeed/openbmc/meta-phosphor/conf/distro/include/phosphor-defaults.inc
中注释掉内容:
#VIRTUAL-RUNTIME_obmc-chassis-state-manager ?= "phosphor-state-manager-chassis"
#VIRTUAL-RUNTIME_obmc-host-state-manager ?= "phosphor-state-manager-host"
添加包:x86-power-control
之后,可以从BMC
端看到如下内容(前提是修改好json
文件和x86-power-control
的代码):
修改文件:build/ast2500-default/workspace/sources/x86-power-control/config/power-config-host0.json
中的内容:
{ "gpio_configs": [ { "Name": "IdButton", "LineName": "ID_BUTTON", "Type": "GPIO", "Polarity": "ActiveLow" }, { "Name": "PowerOut", "LineName": "POWER_BUTTON", "Type": "GPIO", "Polarity": "ActiveLow" }, { "Name": "PowerOk", "LineName": "PS_PWROK", "Type": "GPIO", "Polarity": "ActiveLow" } ], "timing_configs": { "PowerPulseMs": 1000, "ForceOffPulseMs": 15000, "ResetPulseMs": 500, "PowerCycleMs": 5000, "SioPowerGoodWatchdogMs": 1000, "PsPowerOKWatchdogMs": 8000, "GracefulPowerOffS": 300, "WarmResetCheckMs": 500, "PowerOffSaveMs": 7000 } }
实际上x86-power-control
中将Button
类认为GPIO
是输入的。
配置:build/ast2500-default/workspace/sources/linux-aspeed/arch/arm/boot/dts/aspeed-ast2500-evb.dts
内容:
&gpio {
gpio-line-names =
/*A0~A7*/"A0","A1","A2","","","","","",
/*B0~B7*/"B0","B1","B2","","","","","ID_BUTTON",
/*C0~C7*/"C0","C1","C2","","","","","",
/*D0~D7*/"D0","D1","D2","","","","","",
/*E0~E7*/"E0","E1","E2","","","","","",
/*F0~F7*/"F0","F1","F2","","","","","",
/*G0~G7*/"G0","G1","G2","","","","","",
/*H0~H7*/"H0","H1","H2","","","","","PS_PWROK",
/*I0~I7*/"I0","POWER_BUTTON","I2","","","","","",
/*J0~J7*/"J0","J1","RESET_BUTTON","","","","","";
};
实际上,只需要关注:PS_PWROK
与POWER_BUTTON
。
如此,可以执行开关机动作后,能使用ipmitool
查看到当前os
的开机状态。
本节暂不说如何修改:x86-power-control
的代码。
总之:
openbmc
的代码整体架构还是比较清晰的。 从新手来的角度来说,架构清晰基本上功能的添加还是没有什么太大的难度的。 后面需要的是继续深挖dbus
与c++
语言的知识了。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。