[OpenBMC] Build First Image and Modify Repo Using devtool
Build Image
git clone https://github.com/openbmc/openbmc.git
cd openbmc
. setup romulus
bitbake obmc-phosphor-image
Download and Start QEMU Session
Get QEMU
Note
-
So we use the QEMU provided by openbmc and don’t use the upstream QEMU. If you use the QEMU installed with
apt get
, you will get the errornetwork backend 'user' is not compiled into this binary
. -
The ‘user’ networking backend is provided by the ‘slirp’ library; you get above error message when the QEMU binary was built without slirp support compiled in. (Maydell)
-
As noted in the 7.2 changelog, QEMU no longer ships a copy of the slirp module with its sources. Instead you need to make sure you have installed your distro’s libslirp development package (which is probably called libslirp-devel or libslirp-dev or something similar) before configuring and building QEMU. You need at least libslirp 4.7 or better. (Maydell)
wget https://jenkins.openbmc.org/job/latest-qemu-x86/lastSuccessfulBuild/artifact/qemu/build/qemu-system-arm
chmod u+x qemu-system-arm
Copy Image
cp ./tmp/deploy/images/romulus/obmc-phosphor-image-romulus.static.mtd ./
Start QEMU session with Romulus Image
Note
- For REST, SSH and IPMI to work into your QEMU session, you must connect up some host ports to the REST, SSH and IPMI ports in your QEMU session. In this example, it just uses 2222, 2443, 2623. You can use whatever you prefer.
./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
Check Status
# In obmc
obmcutil state
Check ssh
sshpass -p 0penBmc ssh root@172.0.0.1 -p 2222
Check webui
Open the browser and browse http://127.0.0.1:2443
Check IPMI
ipmitool -I lanplus -p 2623 -H 127.0.0.1 -U root -P 0penBmc -C17 mc info
Note
- You need to designate ciphersuite 17 by adding option
-C17
for openbmc, which is assigned in cipher_list.json. The default for ipmitool is 3 which specifies RAKP-HMAC-SHA1 authentication, HMAC-SHA1-96 integrity, and AES-CBC-128 encryption algorightms. ciphersuite 3 is removed by this commit because HMAC-SHA1 is deprecated.
Table 22-19 in the IPMIv2 spec
Exit QEMU Session
press Ctrl+a
and x
Clone a Repo and modify it Locally using devtool
Method One: Clone, Modify, and Rebuild the Whole Image
1. Use devtool to Extract Source Code
. setup romulus
devtool modify phosphor-state-manager
2. Add Hello World
vi workspace/sources/phosphor-state-manager/bmc_state_manager_main.cpp
diff should look like this
+#include <iostream>
int main(int argc, char**)
{
@@ -17,6 +18,8 @@ int main(int argc, char**)
bus.request_name(BMC_BUSNAME);
+ std::cout<<"Hello World" <<std::endl;
+
while (true)
{
3. Rebuild the Image
bitbake obmc-phosphor-image
4. Verify
Start the QEMU session and use journalctl to check the hello world is added.
journalctl | grep "Hello World"
Should see something like this
<date> romulus phosphor-bmc-state-manager[1089]: Hello World
Method Two: Rebuild the Repo Only and Load it Directly into a Running QEMU
1. Repeat Step 1, 2 of Method One
2. Bitbake only the phosphor-state-manger Repo
bitbake phosphor-state-manager
Your new binary will be located at the following location relative to your bitbake directory: ./workspace/sources/phosphor-state-manager/oe-workdir/package/usr/bin/phosphor-bmc-state-manager
3. Create a Safe File System for Your Application
# in obmc
mkdir -p /tmp/persist/usr
mkdir -p /tmp/persist/work/usr
mount -t overlay -o lowerdir=/usr,upperdir=/tmp/persist/usr,workdir=/tmp/persist/work/usr overlay /usr
4. Scp the New Binary onto QEMU Instance
scp -P 2222 ./workspace/sources/phosphor-state-manager/oe-workdir/package/usr/bin/phosphor-bmc-state-manager root@127.0.0.1:/usr/bin/
5. Verify
# in obmc
systemctl restart xyz.openbmc_project.State.BMC.service
journalctl | tail
References
OpenBMC Development Environment
OpenBMC Hello World using devtool
stack overflow: network backend ‘user’ is not compiled into this binary