1. Introduction
KV260 and KR260 firmware by default cannot boot the Ubuntu 22.04. Therefore, an update to the firmware is necessary. In this article, I will show you how to update the firmware step by step.
I have the following setup.
- Petalinux bootable microSD card. (2021.1 Petalinux pre-build SD card image: https://www.xilinx.com/member/forms/download/xef.html?filename=petalinux-sdimage-2021.1-update1.wic.xz)
- Connected to Windows 11 using UART (COM port — lower of the available ports)
- Connected to internet through Ethernet.
2. Booting to Petalinux
Inserting the microSD card with a bootable petalinux image will result in the following screen. If this is your first time, the default username is petalinux and you will be prompted for a new password and you will have to set it.
After booting, we can use the following command to check the boot firmware status.
sudo xmutil bootfw_status
This will present you with the following screen (ignore the sudo xmutil bootfw_update -v command for now).
You will see that following parameters are displayed.
Image A: Bootable
Image B: Bootable
Requested Boot Image: Image A
Last Booted Image: Image A
XilinxSom_QspiImage_v1.1_20210422
Let’s understand what the parameters mean.
Kria SOM is configured to boot from two sources: QSPI and microSD. The first boot sequence is done by the firmware located in QSPI and it also has two images: A and B. These are memory locations where the firmware (BOOT.BIN) is stored. And you have to set the source (either A or B) that you want the system to use.
By default, Image A is selected as the firmware to use for bootup sequence. K26 uses a two-source firmware storage method as it provides a failsafe firmware update process (Remember those old days where if the system crashed during the firmware update process — for any reason — you had to say goodbye to the system?). This update process basically allows you to make mistakes (which is a good thing) during the firmware update process.
When you write a new firmware, you will write it in a non-active area of the QSPI memory. Here, the last booted image and requested boot image show that the Image A holds the firmware for doing the boot sequence. Now, we will update the firmware and it will be written in Image B so that even if there is some kind of error, you can always revert back to Image A (which we know works).
However, before we write the new firmware, we will have to find a way to get the new firmware file in the system. Here, I am going follow the on-target method. In short, this is what I am going to do: I am going to upload the boot.bin file to my google drive and then download it into petalinux and then update the system. Now, here’s the long step.
3. Uploading and downloading the BOOT.BIN file
You can get the image file here: 2022.1_update3_BOOT.BIN
You will have to first create a AMD (Xilinx) account and then proceed to download the BOOT_xilinx-k26-starterkit-v2022.1–09152304_update3.BIN file. We are going to use the wget command to download the file, so once you download it, you can go ahead and upload it in your Google drive as shown below.
Then, set the access permission to “Anyone with the link” can be a “Viewer” by selecting “Share” from the right clicking menu and copy the link.
You will get the link that will be something like the following.
Link: https://drive.google.com/file/d/1wACTcpbwLPOH9UUuURk5qcnIYeEverSB/view?usp=sharing
We have to extract the part of the link in between https://drive.google.com/file/d/ and /view?usp=sharing. This part is the File ID of the file that we want to download.
Now, go ahead and replace the FILEID in original command syntax with the File ID of your link and make it as the actual command as shown below.
Original Syntax: wget --no-check-certificate 'https://docs.google.com/uc?export=download&id=FILEID' -O FILENAME
Actual Command: wget --no-check-certificate 'https://docs.google.com/uc?export=download&id=1wACTcpbwLPOH9UUuURk5qcnIYeEverSB' -O k26_update3.BIN
Now, you can go ahead and download the file in any directory inside the /home/petalinux as shown below.
Once you download it, you can quickly verify that you have indeed downloaded the correct file by checking the size of the file. Here, we can see that the file is 2615808 bytes (2.49 MB), which is equal to the original file that we downloaded (NOTE: this is not a reliable way to verify the files, especially files as sensitive as the firmware, if you want to be 100% sure use standard MD5 or other checksums).
4. Updating the firmware
We have the file that we require to update the system and we can go ahead and do just that. We will be using the xmutil command to update the firmware. Use the following command.
Syntax: sudo xmutil bootfw_update -i <path-to-FW.BIN file>
Command: sudo xmutil bootfw_update -i ~/workspace/k26_update3.BIN
Running the command will successfully update the firmware and the following message will be displayed (ignore the filename in the screenshot, I had renamed the file).
Then, you can use the following command to show the current status.
sudo xmutil bootfw_status
This will result in the following message shown in Figure 7.
s you can see, the requested boot image has now been changed to Image B from Image A because the firmware was written to Image B. When you reboot your device, Image B will be used to load all the system devices. One important thing to note is that it is temporary and if you do not save this configuration (which you can do after rebooting once), the booting process will revert back to Image A. So, let’s go ahead and do that.
Use the following command to reboot the system (or you can just press the SW2 — Reset button).
sudo shutdown -r now
The system will reboot, and you can again check the status of the firmware using the bootfw_status command and you will see a screen like Figure 8. The difference between this image and your message will be that your message will say that the requested boot image is Image A. This is because you have to make this change permanent to make sure that the system will boot from Image B. If you do not do that, your system will boot using the Image A.
Now, we will make it a permanent change since we know that it works. Use the following command to do so.
sudo xmutil bootfw_update -v
This command must be run in the immediate reboot and if you reboot without running the command, the system will revert back to Image A. After running the command, you can see with the status check that the requested boot image is B (not A).
5. Conclusion
We went through the steps of updating the KV260/KR260 firmware through the on-target A/B firmware update process. We updated the firmware and verified that the updated firmware works on the device. In the next article, we will use this device to boot the Ubuntu 22.04 image and have some fun by running some applications.
6. References
[1] Kria K26 SOM — Xilinx Wiki — Confluence (atlassian.net): https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/1641152513/Kria+K26+SOM
[2] KV260 Starter Kit User Guide (UG1089): https://docs.xilinx.com/r/en-US/ug1089-kv260-starter-kit/Board-Reset-Firmware-Update-and-Recovery
[3] How to get large file from google drive discussion at Stackoverflow? https://stackoverflow.com/questions/25010369/wget-curl-large-file-from-google-drive