1cdfa8079SJeremy Kerr 2cdfa8079SJeremy Kerr# OpenBMC cheatsheet 3cdfa8079SJeremy Kerr 4cdfa8079SJeremy KerrThis document is intended to provide a set of recipes for common OpenBMC 5cdfa8079SJeremy Kerrcustomisation tasks, without having to know the full yocto build process. 6cdfa8079SJeremy Kerr 7cdfa8079SJeremy Kerr## Using a local kernel build 8cdfa8079SJeremy Kerr 9cdfa8079SJeremy KerrThe kernel recipe is in: 10cdfa8079SJeremy Kerr 11cdfa8079SJeremy Kerr``` 12cdfa8079SJeremy Kerr meta-phosphor/common/recipes-kernel/linux/linux-obmc_4.2.bb 13cdfa8079SJeremy Kerr``` 14cdfa8079SJeremy Kerr 15cdfa8079SJeremy KerrTo use a local git tree, change the `SRC_URI` to a git:// URL without 16cdfa8079SJeremy Kerra hostname. For example: 17cdfa8079SJeremy Kerr 18cdfa8079SJeremy Kerr``` 19cdfa8079SJeremy KerrSRC_URI = "git:///home/jk/devel/linux;protocol=git;branch=${KBRANCH}" 20cdfa8079SJeremy Kerr``` 21cdfa8079SJeremy Kerr 22cdfa8079SJeremy KerrThe `SRCREV` variable can be used to set an explicit git commit. The 23cdfa8079SJeremy Kerrdefault (`${AUTOREV}`) will use the latest commit in `KBRANCH`. 24cdfa8079SJeremy Kerr 257b22067aSJoel Stanley## Building for Palmetto 26cdfa8079SJeremy Kerr 277b22067aSJoel StanleyThe Palmetto target is `palmetto`. 287b22067aSJoel Stanley 297b22067aSJoel StanleyIf you are starting from scratch without a `build/conf` directory you can just: 307b22067aSJoel Stanley``` 317b22067aSJoel Stanley$ cd openbmc 327b22067aSJoel Stanley$ TEMPLATECONF=meta-openbmc-machines/meta-openpower/meta-ibm/meta-palmetto/conf . oe-init-build-env 3335abff5fSJeremy Kerr$ bitbake obmc-phosphor-image 347b22067aSJoel Stanley``` 357b22067aSJoel Stanley 3657812c89SAdi Gangidi## Building for Barreleye 3757812c89SAdi Gangidi 3857812c89SAdi GangidiThe Barreleye target is `barreleye`. 3957812c89SAdi Gangidi 4057812c89SAdi GangidiIf you are starting from scratch without a `build/conf` directory you can just: 4157812c89SAdi Gangidi``` 4257812c89SAdi Gangidi$ cd openbmc 4357812c89SAdi Gangidi$ TEMPLATECONF=meta-openbmc-machines/meta-openpower/meta-rackspace/meta-barreleye/conf . oe-init-build-env 4457812c89SAdi Gangidi$ bitbake obmc-phosphor-image 4557812c89SAdi Gangidi``` 4657812c89SAdi Gangidi 470ea78f3aSChris Austen## Building the OpenBMC SDK 480ea78f3aSChris AustenLooking for a way to compile your programs for 'ARM' but you happen to be running on a 'PPC' or 'x86' system? You can build the sdk receive a fakeroot environment. 490ea78f3aSChris Austen``` 500ea78f3aSChris Austen$ bitbake -c populate_sdk obmc-phosphor-image 510ea78f3aSChris Austen$ ./tmp/deploy/sdk/openbmc-phosphor-glibc-x86_64-obmc-phosphor-image-armv5e-toolchain-1.8+snapshot.sh 520ea78f3aSChris Austen``` 530ea78f3aSChris AustenFollow the prompts. After it has been installed the default to setup your env will be similar to this command 540ea78f3aSChris Austen``` 550ea78f3aSChris Austen. /opt/openbmc-phosphor/1.8+snapshot/environment-setup-armv5e-openbmc-linux-gnueabi 560ea78f3aSChris Austen``` 570ea78f3aSChris Austen 587b22067aSJoel Stanley## Rebuilds & Reconfiguration 597b22067aSJoel Stanley 607b22067aSJoel StanleyYou can reconfigure your build by removing the build/conf dir: 617b22067aSJoel Stanley``` 627b22067aSJoel Stanleyrm -rf build/conf 637b22067aSJoel Stanley``` 64a91308a9SJoel Stanleyand running `oe-init-build-env` again (possibly with `TEMPLATECONF` set). 658196be3eSJeremy Kerr 668196be3eSJeremy Kerr## Useful dbus CLI tools 678196be3eSJeremy Kerr 688196be3eSJeremy Kerr## `busctl` 698196be3eSJeremy Kerr 708196be3eSJeremy Kerrhttp://www.freedesktop.org/software/systemd/man/busctl.html 718196be3eSJeremy Kerr 72111325b5SBrad BishopGreat tool to issue dbus commands via cli. That way you don't have to wait for 738196be3eSJeremy Kerrthe code to hit the path on the system. Great for running commands with QEMU 748196be3eSJeremy Kerrtoo! 758196be3eSJeremy Kerr 768196be3eSJeremy KerrRun as: 778196be3eSJeremy Kerr 788196be3eSJeremy Kerr``` 798196be3eSJeremy Kerrbusctl call <path> <interface> <object> <method> <parameters> 808196be3eSJeremy Kerr``` 818196be3eSJeremy Kerr 828196be3eSJeremy Kerr* \<parameters\> example : sssay "t1" "t2" "t3" 2 2 3 83dd7e9997SAndrew Jeffery 84dd7e9997SAndrew Jeffery## Using QEMU 85dd7e9997SAndrew Jeffery 86dd7e9997SAndrew JefferyQEMU has a palmetto-bmc machine (as of v2.6.0) which implements the core 87dd7e9997SAndrew Jefferydevices to boot a Linux kernel. OpenBMC also [maintains a 88dd7e9997SAndrew Jefferytree](https://github.com/openbmc/qemu) with patches on their way upstream or 89dd7e9997SAndrew Jefferytemporary work-arounds that add to QEMU's capabilities where appropriate. 90dd7e9997SAndrew Jeffery 91*81db7dbaSChris Austen``` 92*81db7dbaSChris Austenqemu-system-arm -m 256 -M palmetto-bmc -nographic \ 93*81db7dbaSChris Austen-drive file=<path>/flash-palmetto,format=raw,if=mtd \ 94*81db7dbaSChris Austen-net nic \ 95*81db7dbaSChris Austen-net user,hostfwd=:127.0.0.1:2222-:22,hostfwd=:127.0.0.1:2443-:443,hostname=qemu \ 96*81db7dbaSChris Austen``` 97*81db7dbaSChris AustenIf 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... 98dd7e9997SAndrew Jeffery 99dd7e9997SAndrew Jeffery``` 100*81db7dbaSChris Austencurl -c cjar -b cjar -k -H "Content-Type: application/json" \ 101*81db7dbaSChris Austen-X POST https://localhost:2443/login -d "{\"data\": [ \"root\", \"0penBmc\" ] }" 102*81db7dbaSChris Austen``` 103*81db7dbaSChris Austenor 104*81db7dbaSChris Austen 105*81db7dbaSChris Austen``` 106*81db7dbaSChris Austenssh -p 2222 root@localhost 107dd7e9997SAndrew Jeffery``` 108dd7e9997SAndrew Jeffery 109dd7e9997SAndrew JefferyTo quit, type `Ctrl-a c` to switch to the QEMU monitor, and then `quit` to exit. 110ae88254cSJoel Stanley 111*81db7dbaSChris Austen## Building QEMU 112*81db7dbaSChris Austen 113*81db7dbaSChris Austen``` 114*81db7dbaSChris Austengit clone https://github.com/openbmc/qemu.git 115*81db7dbaSChris Austencd qemu 116*81db7dbaSChris Austengit submodule update --init dtc 117*81db7dbaSChris Austenmkdir build 118*81db7dbaSChris Austencd build 119*81db7dbaSChris Austen../configure --target-list=arm-softmmu 120*81db7dbaSChris Austenmake 121*81db7dbaSChris Austen``` 122*81db7dbaSChris AustenBuilt file will be located at: ```arm-softmmu/qemu-system-arm``` 123*81db7dbaSChris Austen 124*81db7dbaSChris Austen### Use a bridge device 125*81db7dbaSChris AustenUsing a bridge device requires a bit of root access to set it up. The benefit 126*81db7dbaSChris Austenis your qemu session runs in the bridges subnet so no port forwarding is needed. 127*81db7dbaSChris AustenThere are packages needed to yourself a virbr0 such as... 128*81db7dbaSChris Austen 129*81db7dbaSChris Austen``` 130*81db7dbaSChris Austenapt-get install libvirt libvirt-bin bridge-utils uml-utilities qemu-system-common 131*81db7dbaSChris Austen 132*81db7dbaSChris Austenqemu-system-arm -m 256 -M palmetto-bmc -nographic \ 133*81db7dbaSChris Austen-drive file=<path>/flash-palmetto,format=raw,if=mtd \ 134*81db7dbaSChris Austen-net nic,macaddr=C0:FF:EE:00:00:02,model=ftgmac100 \ 135*81db7dbaSChris Austen-net bridge,id=net0,helper=/usr/lib/qemu-bridge-helper,br=virbr0 136*81db7dbaSChris Austen``` 137*81db7dbaSChris Austen 138*81db7dbaSChris AustenThere are some other useful parms like that can redirect the console to another 139*81db7dbaSChris Austenwindow. This results in having an easily accessible qemu command session. 140*81db7dbaSChris Austen```-monitor stdio -serial pty -nodefaults``` 141*81db7dbaSChris Austen 142*81db7dbaSChris Austen 143ae88254cSJoel Stanley## Booting the host 144ae88254cSJoel Stanley 145ae88254cSJoel StanleyLogin: 146ae88254cSJoel Stanley``` 147ae88254cSJoel Stanleycurl -c cjar -k -X POST -H "Content-Type: application/json" -d '{"data": [ "root", "0penBmc" ] }' https://palm5-bmc/login 148ae88254cSJoel Stanley``` 149ae88254cSJoel Stanley 150ae88254cSJoel StanleyConnect to host console: 151ae88254cSJoel Stanley``` 152ae88254cSJoel Stanleyssh -p 2200 root@bmc 153ae88254cSJoel Stanley``` 154ae88254cSJoel Stanley 155ae88254cSJoel StanleyPower on: 156ae88254cSJoel Stanley``` 157ae88254cSJoel Stanleycurl -c cjar -b cjar -k -H "Content-Type: application/json" -X POST -d '{"data": []}' https://palm5-bmc/org/openbmc/control/chassis0/action/powerOn 158ae88254cSJoel Stanley``` 159