xref: /openbmc/docs/architecture/code-update/host-code-update.md (revision 692765c2ed9f1dc2e9123a268212b9a981457e7b)
1# Host Code Update
2
3Reference:
4<https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/yaml/xyz/openbmc_project/Software>
5
6Following are the steps to update the host firmware (or "BIOS"). This assumes
7the host is not accessing its firmware.
8
91. Get a squashfs image:
10   - Build op-build: <https://github.com/open-power/op-build>
11   - After building, the image should be a tarball in the output/images
12     directory called `<system type>.pnor.squashfs.tar`
13
142. Transfer the generated squashfs image to the BMC via one of the following
15   methods:
16   - Method 1: Via scp: Copy the generated squashfs image to the `/tmp/images/`
17     directory on the BMC.
18   - Method 2: Via REST Upload:
19     <https://github.com/openbmc/docs/blob/master/rest-api.md#uploading-images>
20   - Method 3: Via TFTP: Perform a POST request to call the `DownloadViaTFTP`
21     method of `/xyz/openbmc_project/software`.
22
23   ```bash
24     curl -b cjar -k -H "Content-Type: application/json" -X POST \
25       -d '{"data": ["<filename>", "<TFTP server IP address"]}' \
26       https://${bmc}/xyz/openbmc_project/software/action/DownloadViaTFTP
27   ```
28
293. Note the version id generated for that image file. The version id is a hash
30   value of 8 hexadecimal numbers, generated by SHA-512 hashing the version
31   string contained in the image and taking the first 8 characters. Get the
32   version id via one of the following methods:
33   - Method 1: From the BMC command line, note the most recent directory name
34     created under `/tmp/images/`, in this example it'd be `2a1022fe`:
35
36   ```bash
37     # ls -l /tmp/images/
38     total 0
39     drwx------    2 root     root            80 Aug 22 07:54 2a1022fe
40     drwx------    2 root     root            80 Aug 22 07:53 488449a2
41   ```
42
43   - Method 2: This method _only_ works if there are no `Ready` images at the
44     start of transferring the image. Using the REST API, note the object that
45     has its Activation property set to Ready, in this example it'd be
46     `2a1022fe`:
47
48   ```json
49     $ curl -b cjar -k https://${bmc}/xyz/openbmc_project/software/enumerate
50     {
51       "data": {
52         "/xyz/openbmc_project/software/2a1022fe": {
53           "Activation": "xyz.openbmc_project.Software.Activation.Activations.Ready",
54   ```
55
56   - Method 3: Calculate the version id beforehand from the image with:
57
58   ```bash
59     tar xfO <squashfs image tar> MANIFEST | sed -ne '/version=/ {s/version=//;p}' | head -n1 | tr -d '\n' | sha512sum | cut -b 1-8
60   ```
61
624. To initiate the update, set the `RequestedActivation` property of the desired
63   image to `Active`, substitute `<id>` with the hash value noted on the
64   previous step, this will write the contents of the image to a UBI volume in
65   the PNOR chip via one of the following methods:
66   - Method 1: From the BMC command line:
67
68   ```bash
69     busctl set-property org.open_power.Software.Host.Updater \
70       /xyz/openbmc_project/software/<id> \
71       xyz.openbmc_project.Software.Activation RequestedActivation s \
72       xyz.openbmc_project.Software.Activation.RequestedActivations.Active
73
74   ```
75
76   - Method 2: Using the REST API:
77
78   ```bash
79     curl -b cjar -k -H "Content-Type: application/json" -X PUT \
80       -d '{"data":
81       "xyz.openbmc_project.Software.Activation.RequestedActivations.Active"}' \
82       https://${bmc}/xyz/openbmc_project/software/<id>/attr/RequestedActivation
83   ```
84
855. (Optional) Check the flash progress. This interface is only available during
86   the activation progress and is not present once the activation is completed
87   via one of the following:
88   - Method 1: From the BMC command line:
89
90   ```bash
91     busctl get-property org.open_power.Software.Host.Updater \
92       /xyz/openbmc_project/software/<id> \
93       xyz.openbmc_project.Software.Activation Progress
94   ```
95
96   - Method 2: Using the REST API:
97
98   ```bash
99     curl -b cjar -k https://${bmc}/xyz/openbmc_project/software/<id>/attr/Progress
100   ```
101
1026. Check the activation is complete by verifying the Activation property is set
103   to Active via one of the following methods:
104   - Method 1: From the BMC command line:
105
106   ```bash
107     busctl get-property org.open_power.Software.Host.Updater \
108       /xyz/openbmc_project/software/<id> \
109       xyz.openbmc_project.Software.Activation Activation
110   ```
111
112   - Method 2: Using the REST API:
113
114   ```bash
115     curl -b cjar -k https://${bmc}/xyz/openbmc_project/software/<id>
116   ```
117
118## Patching the host firmware
119
120Copy the partition binary file to `/usr/local/share/pnor/` on the BMC.
121
122The partition binary file must be named the same as the partition name that
123intends to patch, ex: `ATTR_TMP`.
124
125## Associations, MANIFEST File, Deleting an Image, Software Field Mode, and Software Factory Reset
126
127Information about associations, the MANIFEST file, deleting an image, software
128field mode, and software factory reset can be found at
129[code-update.md#associations](code-update.md#associations)
130
131## Implementation
132
133<https://github.com/openbmc/openpower-pnor-code-mgmt>
134