Last active
July 25, 2023 08:26
-
-
Save gabonator/a805c77c1fcb464a767098aae9f0d8e0 to your computer and use it in GitHub Desktop.
bmc entity manager setup script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install BMC entity manager and activates some randomly chosen configuration | |
# Adds fake temperature sensor | |
# setup for Ubuntu 23 with GCC-13 | |
# | |
set -e -x | |
sudo apt-get -y update | |
sudo apt-get -y upgrade | |
sudo apt-get install -y libpam0g-dev libsystemd-dev python3 python3-pip python3-inflection python3-mako python3-yaml g++-13 gcc-13 libi2c-dev libboost-all-dev libdbus-1-dev ninja-build cmake libssl-dev libtinyxml2-dev | |
sudo apt-get install -y libgtest-dev | |
sudo apt-get install -y pipx | |
pipx install meson | |
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 50 | |
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 50 | |
export CCACHE_DISABLE=1 | |
# instal sdbusplus (required by entity manager) | |
git clone https://github.com/openbmc/sdbusplus.git | |
cd sdbusplus | |
pipx run meson build -Dprefix=/usr | |
cd build | |
ninja | |
ninja install | |
cd ../.. | |
# object mapper (required by entity manager, shows "Error communicating to mapper." in journal) | |
git clone https://github.com/openbmc/phosphor-objmgr | |
cd phosphor-objmgr | |
pipx run meson build -Dprefix=/usr | |
cd build | |
ninja | |
ninja install | |
cd ../.. | |
# dbus-sensors | |
git clone https://github.com/openbmc/dbus-sensors.git | |
cd dbus-sensors | |
cat > dbus-sensors-fakefs.patch <<- EOM | |
diff --git a/src/HwmonTempMain.cpp b/src/HwmonTempMain.cpp | |
index 9c3e473..2cd8c3f 100644 | |
--- a/src/HwmonTempMain.cpp | |
+++ b/src/HwmonTempMain.cpp | |
@@ -354,6 +354,7 @@ void createSensors( | |
findFiles(root, R"(in_pressure\d*_(input|raw))", paths); | |
findFiles(root, R"(in_humidityrelative\d*_(input|raw))", paths); | |
findFiles(fs::path("/sys/class/hwmon"), R"(temp\d+_input)", paths); | |
+ findFiles(fs::path("/tmp/bmcfs/sys/bus/iio/devices"), R"(temp\d+_input)", paths); | |
// iterate through all found temp and pressure sensors, | |
// and try to match them with configuration | |
@@ -365,7 +366,7 @@ void createSensors( | |
fs::path device; | |
std::string deviceName; | |
- if (pathStr.starts_with("/sys/bus/iio/devices")) | |
+ if (pathStr.find("/sys/bus/iio/devices") != std::string::npos) | |
{ | |
device = fs::canonical(directory); | |
deviceName = device.parent_path().stem(); | |
@@ -495,7 +496,7 @@ void createSensors( | |
} | |
auto hwmonFile = getFullHwmonFilePath(directory.string(), "temp1", | |
permitSet); | |
- if (pathStr.starts_with("/sys/bus/iio/devices")) | |
+ if (pathStr.find("/sys/bus/iio/devices") != std::string::npos) | |
{ | |
hwmonFile = pathStr; | |
} | |
@@ -534,7 +535,7 @@ void createSensors( | |
hwmonFile = getFullHwmonFilePath(directory.string(), | |
"temp" + std::to_string(i + 1), | |
permitSet); | |
- if (pathStr.starts_with("/sys/bus/iio/devices")) | |
+ if (pathStr.find("/sys/bus/iio/devices") != std::string::npos) | |
{ | |
continue; | |
} | |
EOM | |
git apply dbus-sensors-fakefs.patch | |
pipx run meson build -Dprefix=/usr | |
cd build | |
ninja | |
ninja install | |
cd ../.. | |
FAKEFS=/tmp/bmcfs | |
mkdir -p ${FAKEFS}/sys/bus/iio/devices | |
mkdir -p ${FAKEFS}/sys/devices/platform/i2c-0/10-40/iio\:device0 | |
echo 45678 > ${FAKEFS}/sys/devices/platform/i2c-0/10-40/iio\:device0/temp1_input | |
ln -s ${FAKEFS}/\sys/devices/platform/i2c-0/10-40/iio\:device0 ${FAKEFS}/sys/bus/iio/devices/iio:device0 | |
# install entity manager | |
git clone https://github.com/openbmc/entity-manager | |
cd entity-manager | |
pipx run meson build -Dprefix=/usr | |
cd build | |
ninja | |
ninja install | |
cd ../.. | |
ldd `which entity-manager` | |
cat > xyz.openbmc_project.EntityManager.conf <<- EOM | |
<!DOCTYPE busconfig PUBLIC | |
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN" | |
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> | |
<busconfig> | |
<policy user="root"> | |
<allow own="xyz.openbmc_project.EntityManager"/> | |
</policy> | |
</busconfig> | |
EOM | |
cat > org.openbmc.conf <<- EOM | |
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN" | |
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> | |
<busconfig> | |
<policy context="default"> | |
<allow own="*"/> | |
<allow send_destination="*"/> | |
</policy> | |
</busconfig> | |
EOM | |
sudo cp xyz.openbmc_project.EntityManager.conf /usr/share/dbus-1/system.d/xyz.openbmc_project.EntityManager.conf | |
sudo cp org.openbmc.conf /usr/share/dbus-1/system.d/org.openbmc.conf | |
# set probe to true to force entity manager to use this configuration | |
cat > bletchley_frontpanel.patch <<- EOM | |
diff --git a/bletchley_frontpanel.json b/bletchley_frontpanel1.json | |
index a6c7f34..df576ae 100644 | |
--- a/bletchley_frontpanel.json | |
+++ b/bletchley_frontpanel1.json | |
@@ -88,11 +88,7 @@ | |
} | |
], | |
"Name": "Bletchley Front Panel Board", | |
- "Probe": [ | |
- "FOUND('Bletchley Baseboard')", | |
- "AND", | |
- "xyz.openbmc_project.Inventory.Decorator.Asset({'Model': 'Bletchley_FPB_SI7021'})" | |
- ], | |
+ "Probe": "TRUE", | |
"Type": "Board" | |
} | |
] | |
EOM | |
sudo patch /usr/share/entity-manager/configurations/bletchley_frontpanel.json bletchley_frontpanel.patch | |
# bmcweb | |
git clone https://github.com/openbmc/bmcweb | |
cd bmcweb | |
cat > bmcweb-service.patch <<- EOM | |
diff --git a/config/bmcweb.service.in b/config/bmcweb.service.in | |
index a0b6777c..0355edb9 100644 | |
--- a/config/bmcweb.service.in | |
+++ b/config/bmcweb.service.in | |
@@ -8,7 +8,6 @@ After=network.target | |
ExecReload=kill -s HUP \$MAINPID | |
ExecStart=@MESON_INSTALL_PREFIX@/bin/bmcweb | |
Type=simple | |
-WorkingDirectory=/home/root | |
[Install] | |
WantedBy=network.target | |
EOM | |
git apply bmcweb-service.patch | |
pipx run meson build -Dprefix=/usr -Dinsecure-enable-redfish-query=enabled -Dinsecure-disable-auth=enabled | |
cd build | |
ninja | |
ninja install | |
cd ../.. | |
# run services | |
sudo systemctl start xyz.openbmc_project.ObjectMapper | |
sudo systemctl start xyz.openbmc_project.EntityManager | |
sudo systemctl start xyz.openbmc_project.hwmontempsensor | |
sudo systemctl start bmcweb | |
echo waiting 10 seconds... | |
sleep 10 | |
# show log | |
sudo journalctl --no-pager -xeu xyz.openbmc_project.EntityManager | |
sudo journalctl --no-pager -xeu xyz.openbmc_project.hwmontempsensor | |
sudo journalctl --no-pager -xeu bmcweb | |
busctl tree xyz.openbmc_project.EntityManager | |
# redfish test | |
curl -k https://localhost:18080/redfish/v1/Chassis/Bletchley_Front_Panel_Board/Thermal | |
echo 22000 > /tmp/bmcfs/sys/devices/platform/i2c-0/10-40/iio\:device0/temp1_input | |
sleep 2 | |
curl -k https://localhost:18080/redfish/v1/Chassis/Bletchley_Front_Panel_Board/Thermal | |
exit 0 | |
busctl tree xyz.openbmc_project.EntityManager | |
# Jul 14 08:16:02 xx-xxxxxxx-vm entity-manager[14842]: Inventory Added: Bletchley Front Panel Board | |
sudo journalctl --no-pager -xeu xyz.openbmc_project.EntityManager.service | |
# should show | |
# Jul 14 08:16:02 xx-xxxxxxx-vm entity-manager[14842]: Inventory Added: Bletchley Front Panel Board | |
busctl tree xyz.openbmc_project.EntityManager | |
# should show | |
# $ busctl tree xyz.openbmc_project.EntityManager | |
# └─/xyz | |
# └─/xyz/openbmc_project | |
# ├─/xyz/openbmc_project/EntityManager | |
# └─/xyz/openbmc_project/inventory | |
# └─/xyz/openbmc_project/inventory/system | |
# └─/xyz/openbmc_project/inventory/system/board | |
# └─/xyz/openbmc_project/inventory/system/board/Bletchley_Front_Panel_Board | |
# └─/xyz/openbmc_project/inventory/system/board/Bletchley_Front_Panel_Board/FRONT_PANEL_TEMP | |
# | |
busctl introspect xyz.openbmc_project.EntityManager /xyz/openbmc_project/inventory/system/board/Bletchley_Front_Panel_Board/FRONT_PANEL_TEMP | |
# should show | |
# $ busctl introspect xyz.openbmc_project.EntityManager /xyz/openbmc_project/inventory/system/board/Bletchley_Front_Panel_Board/FRONT_PANEL_TEMP | |
# NAME TYPE SIGNATURE RESULT/VALUE FLAGS | |
# org.freedesktop.DBus.Introspectable interface - - - | |
# .Introspect method - s - | |
# org.freedesktop.DBus.Peer interface - - - | |
# .GetMachineId method - s - | |
# .Ping method - - - | |
# org.freedesktop.DBus.Properties interface - - - | |
# .Get method ss v - | |
# .GetAll method s a{sv} - | |
# .Set method ssv - - | |
# .PropertiesChanged signal sa{sv}as - - | |
# xyz.openbmc_project.Configuration.SI7020 interface - - - | |
# .Address property t 64 emits-change | |
# .Bus property t 10 emits-change | |
# .Name property s "FRONT_PANEL_TEMP" emits-change | |
# .Name1 property s "FRONT_PANEL_HUMIDTY" emits-change | |
# .Type property s "SI7020" emits-change | |
# ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment