1*f4febd00SPatrick Williams# Host Code Update
231de159fSAdriana Kobylak
331de159fSAdriana KobylakReference:
42bc8dac0SKonstantin Aladyshevhttps://github.com/openbmc/phosphor-dbus-interfaces/blob/master/yaml/xyz/openbmc_project/Software
531de159fSAdriana Kobylak
631de159fSAdriana KobylakFollowing are the steps to update the host firmware (or "BIOS"). This assumes
731de159fSAdriana Kobylakthe host is not accessing its firmware.
831de159fSAdriana Kobylak
931de159fSAdriana Kobylak1. Get a squashfs image:
10*f4febd00SPatrick Williams
11*f4febd00SPatrick Williams- Build op-build: https://github.com/open-power/op-build
12*f4febd00SPatrick Williams- After building, the image should be a tarball in the output/images directory
13*f4febd00SPatrick Williams  called <system type>.pnor.squashfs.tar
1431de159fSAdriana Kobylak
1531de159fSAdriana Kobylak2. Transfer the generated squashfs image to the BMC via one of the following
1631de159fSAdriana Kobylak   methods:
17*f4febd00SPatrick Williams
18*f4febd00SPatrick Williams- Method 1: Via scp: Copy the generated squashfs image to the `/tmp/images/`
1931de159fSAdriana Kobylak  directory on the BMC.
20*f4febd00SPatrick Williams- Method 2: Via REST Upload:
2131de159fSAdriana Kobylak  https://github.com/openbmc/docs/blob/master/rest-api.md#uploading-images
22*f4febd00SPatrick Williams- Method 3: Via TFTP: Perform a POST request to call the `DownloadViaTFTP`
2331de159fSAdriana Kobylak  method of `/xyz/openbmc_project/software`.
2431de159fSAdriana Kobylak
2531de159fSAdriana Kobylak  ```
2631de159fSAdriana Kobylak  curl -b cjar -k -H "Content-Type: application/json" -X POST \
2731de159fSAdriana Kobylak    -d '{"data": ["<filename>", "<TFTP server IP address"]}' \
2831de159fSAdriana Kobylak    https://${bmc}/xyz/openbmc_project/software/action/DownloadViaTFTP
2931de159fSAdriana Kobylak  ```
3031de159fSAdriana Kobylak
3131de159fSAdriana Kobylak3. Note the version id generated for that image file. The version id is a hash
3231de159fSAdriana Kobylak   value of 8 hexadecimal numbers, generated by SHA-512 hashing the version
3331de159fSAdriana Kobylak   string contained in the image and taking the first 8 characters. Get the
3431de159fSAdriana Kobylak   version id via one of the following methods:
3531de159fSAdriana Kobylak
36*f4febd00SPatrick Williams- Method 1: From the BMC command line, note the most recent directory name
3731de159fSAdriana Kobylak  created under `/tmp/images/`, in this example it'd be `2a1022fe`:
3831de159fSAdriana Kobylak
3931de159fSAdriana Kobylak  ```
4031de159fSAdriana Kobylak  # ls -l /tmp/images/
4131de159fSAdriana Kobylak  total 0
4231de159fSAdriana Kobylak  drwx------    2 root     root            80 Aug 22 07:54 2a1022fe
4331de159fSAdriana Kobylak  drwx------    2 root     root            80 Aug 22 07:53 488449a2
4431de159fSAdriana Kobylak  ```
4531de159fSAdriana Kobylak
46*f4febd00SPatrick Williams- Method 2: This method _only_ works if there are no `Ready` images at the start
47*f4febd00SPatrick Williams  of transferring the image. Using the REST API, note the object that has its
48*f4febd00SPatrick Williams  Activation property set to Ready, in this example it'd be `2a1022fe`:
4931de159fSAdriana Kobylak
5031de159fSAdriana Kobylak  ```
5131de159fSAdriana Kobylak  $ curl -b cjar -k https://${bmc}/xyz/openbmc_project/software/enumerate
5231de159fSAdriana Kobylak  {
5331de159fSAdriana Kobylak    "data": {
5431de159fSAdriana Kobylak      "/xyz/openbmc_project/software/2a1022fe": {
5531de159fSAdriana Kobylak        "Activation": "xyz.openbmc_project.Software.Activation.Activations.Ready",
5631de159fSAdriana Kobylak  ```
5731de159fSAdriana Kobylak
58*f4febd00SPatrick Williams- Method 3: Calculate the version id beforehand from the image with:
5931de159fSAdriana Kobylak
6031de159fSAdriana Kobylak  ```
6131de159fSAdriana Kobylak  tar xfO <squashfs image tar> MANIFEST | sed -ne '/version=/ {s/version=//;p}' | head -n1 | tr -d '\n' | sha512sum | cut -b 1-8
6231de159fSAdriana Kobylak  ```
6331de159fSAdriana Kobylak
6431de159fSAdriana Kobylak4. To initiate the update, set the `RequestedActivation` property of the desired
65*f4febd00SPatrick Williams   image to `Active`, substitute `<id>` with the hash value noted on the
66*f4febd00SPatrick Williams   previous step, this will write the contents of the image to a UBI volume in
67*f4febd00SPatrick Williams   the PNOR chip via one of the following methods:
6831de159fSAdriana Kobylak
69*f4febd00SPatrick Williams- Method 1: From the BMC command line:
7031de159fSAdriana Kobylak
7131de159fSAdriana Kobylak  ```
7231de159fSAdriana Kobylak  busctl set-property org.open_power.Software.Host.Updater \
7331de159fSAdriana Kobylak    /xyz/openbmc_project/software/<id> \
7431de159fSAdriana Kobylak    xyz.openbmc_project.Software.Activation RequestedActivation s \
7531de159fSAdriana Kobylak    xyz.openbmc_project.Software.Activation.RequestedActivations.Active
7631de159fSAdriana Kobylak
7731de159fSAdriana Kobylak  ```
7831de159fSAdriana Kobylak
79*f4febd00SPatrick Williams- Method 2: Using the REST API:
8031de159fSAdriana Kobylak
8131de159fSAdriana Kobylak  ```
8231de159fSAdriana Kobylak  curl -b cjar -k -H "Content-Type: application/json" -X PUT \
8331de159fSAdriana Kobylak    -d '{"data":
8431de159fSAdriana Kobylak    "xyz.openbmc_project.Software.Activation.RequestedActivations.Active"}' \
8531de159fSAdriana Kobylak    https://${bmc}/xyz/openbmc_project/software/<id>/attr/RequestedActivation
8631de159fSAdriana Kobylak  ```
8731de159fSAdriana Kobylak
8831de159fSAdriana Kobylak5. (Optional) Check the flash progress. This interface is only available during
8931de159fSAdriana Kobylak   the activation progress and is not present once the activation is completed
9031de159fSAdriana Kobylak   via one of the following:
9131de159fSAdriana Kobylak
92*f4febd00SPatrick Williams- Method 1: From the BMC command line:
9331de159fSAdriana Kobylak
9431de159fSAdriana Kobylak  ```
9531de159fSAdriana Kobylak  busctl get-property org.open_power.Software.Host.Updater \
9631de159fSAdriana Kobylak    /xyz/openbmc_project/software/<id> \
9731de159fSAdriana Kobylak    xyz.openbmc_project.Software.Activation Progress
9831de159fSAdriana Kobylak  ```
9931de159fSAdriana Kobylak
100*f4febd00SPatrick Williams- Method 2: Using the REST API:
10131de159fSAdriana Kobylak
10231de159fSAdriana Kobylak  ```
10331de159fSAdriana Kobylak  curl -b cjar -k https://${bmc}/xyz/openbmc_project/software/<id>/attr/Progress
10431de159fSAdriana Kobylak  ```
10531de159fSAdriana Kobylak
10631de159fSAdriana Kobylak6. Check the activation is complete by verifying the Activation property is set
10731de159fSAdriana Kobylak   to Active via one of the following methods:
10831de159fSAdriana Kobylak
109*f4febd00SPatrick Williams- Method 1: From the BMC command line:
11031de159fSAdriana Kobylak
11131de159fSAdriana Kobylak  ```
11231de159fSAdriana Kobylak  busctl get-property org.open_power.Software.Host.Updater \
11331de159fSAdriana Kobylak    /xyz/openbmc_project/software/<id> \
11431de159fSAdriana Kobylak    xyz.openbmc_project.Software.Activation Activation
11531de159fSAdriana Kobylak  ```
11631de159fSAdriana Kobylak
117*f4febd00SPatrick Williams- Method 2: Using the REST API:
11831de159fSAdriana Kobylak
11931de159fSAdriana Kobylak  ```
12031de159fSAdriana Kobylak  curl -b cjar -k https://${bmc}/xyz/openbmc_project/software/<id>
12131de159fSAdriana Kobylak  ```
12231de159fSAdriana Kobylak
12331de159fSAdriana Kobylak### Patching the host firmware
12431de159fSAdriana Kobylak
12531de159fSAdriana KobylakCopy the partition binary file to `/usr/local/share/pnor/` on the BMC.
12631de159fSAdriana Kobylak
12731de159fSAdriana KobylakThe partition binary file must be named the same as the partition name that
12831de159fSAdriana Kobylakintends to patch, ex: `ATTR_TMP`.
12931de159fSAdriana Kobylak
13031de159fSAdriana Kobylak### Associations, MANIFEST File, Deleting an Image, Software Field Mode, and Software Factory Reset
13131de159fSAdriana Kobylak
13231de159fSAdriana KobylakInformation about associations, the MANIFEST file, deleting an image, software
13331de159fSAdriana Kobylakfield mode, and software factory reset can be found at
13431de159fSAdriana Kobylak[code-update.md#associations](code-update.md#associations)
13531de159fSAdriana Kobylak
13631de159fSAdriana Kobylak### Implementation
13731de159fSAdriana Kobylak
13831de159fSAdriana Kobylakhttps://github.com/openbmc/openpower-pnor-code-mgmt
139