The source code on the back-end of PetaLinux for v2021.2 has changed since my previous project, so this project outlines the latest updates since Vitis/PetaLinux v2021.2 was originally released. I discovered this after I did something dumb to blow up my Ubuntu 18.04 VM the other week and had to reinstall Ubuntu from scratch, which meant reinstalling all of the versions of Vivado/Vitis/PetaLinux I was using.
When I got to the point of recreating the PetaLinux project for my Kria KV260 with a freshly downloaded 2021.2 KV260 BSP, I followed the same steps I posted in my original project post I did when 2021.2 was initially released. However, after flashing an SD card with the WIC image and attempting to boot my KV260 I stumbled upon a few issues:
1 - The MMC block number for where the root filesystem is located (the SD card) is incorrect in the kernel boot arguments.
2 - The device tree node for the SD card slot was disabled by default in the device tree overlay.
3 - The hardware settings in the PetaLinux project were not configured to look for the Ethernet port on the KV260 carrier card and its corresponding device tree node was also disabled in the overlay.
I've noticed questions pop up on my original post in the comments that mostly all could be answered with the following updates in this post.
Update Bootargs for SD CardThe 2021.2 BSP by default configures the kernel to look on MMC #0 (mmcblk0) for the root filesystem during the boot process, but the SD card is MMC #1 (mmcblk1) on the Kria KV260.
Note: The optional 16GB eMMC is MMC #0 (even on KV260 boards that don't come with the 16GB eMMC installed).
Source the PetaLinux tools in the environment, change directories into the KV260 PetaLinux project created from the 2021.2 BSP, and launch the system configuration editor:
~$ source /tools/Xilinx/PetaLinux/2021.2/settings.sh
~$ cd ./kria_kv260/xilinx-k26-som-2021.2/
~/kria_kv260/xilinx-k26-som-2021.2$ petalinux-config
Update the kernel boot arguments under DTG Settings > Kernel Bootargs from:
earlycon console=ttyPS1,115200 clk_ignore_unused ext4=/dev/mmcblk0p2:/rootfs init_fatal_sh=1 cma=1000M
to:
earlycon console=ttyPS1,115200 clk_ignore_unused ext4=/dev/mmcblk1p2:/rootfs rw init_fatal_sh=1 cma=1000M
Be sure to leave the generate boot args automatically options not selected. The rw is also added to the boot args to ensure the root filesystem is mounted as read-write capable and not read-only,
Once I was finally able to boot into the root filesystem, I noticed that the kernel wasn't able to find the Ethernet port as an available device to use. This was initially explained when I noticed in the system configuration editor that the primary ethernet interface was set to manual instead of the ethernet interface connected to the Zynq MPSoC via its MIO as configured in Vivado (the configuration/process for the Kria KV260 is the same in 2021.2 as it was in 2021.1 which is why I didn't write a Kria KV260 Vivado 2021.2 post).
After updating the kernel boot arguments in the system configuration editor, navigate to Subsystem AUTO Hardware Settings > Ethernet Settings > Primary Ethernet, and change it from manual to psu_ethernet_3
It's up to you whether you'd like to set a specific MAC address or generate a random one to use at boot, as well as if you want the IP address to be set automatically with DHCP.
At this point, exit the system configuration editor and save this new configuration when prompted.
Disable eMMC Node & Enable SD Card Node in Device TreeAs I indirectly mentioned previously, there are two SD host controller interfaces on the Kria KV260: one for the optional 16GB eMMC and a second one for the SD card.
In the device tree overlay, the optional 16GB eMMC is the sdhci0 node and the SD card is the sdhci1 node. I think the BSP configured by default for a Kria KV260 with the 16GB eMMC installed to look for the root filesystem on the eMMC instead of the SD card. This is because the sdhci0 node is enabled while the sdhci1 node is disabled by default. To enable the sdhci1 node to make the SD card slot available to the kernel, simply add the following node to system-user.dtsi in ./xilinx-k26-som-2021.2/project-spec/meta-user/recipes-bsp/device-tree/files:
&sdhci1{
status = "okay";
disable-wp;
};
The disable-wp option also ensures the filesystem does not mount as read-only by disabling write-protect on the SD card.
I also disabled the sdhci0 node since my Kria KV260 does not have the 16GB eMMC installed on it:
&sdhci0 {
status = "disabled";
};
Then also update the kernel boot arguments in the device tree the same as in the system configuration editor:
/include/ "system-conf.dtsi"
/ {
chosen {
bootargs = "earlycon console=ttyPS1,115200 clk_ignore_unused ext4=/dev/mmcblk1p2:/rootfs rw init_fatal_sh=1 cma=1000M ";
stdout-path = "serial1:115200n8";
};
};
Enable Ethernet Node in Device TreeFinally, the Ethernet device tree node also needs to be enabled, as well as the physical layer protocol specified for the kernel to know which drivers to use. So add the following node also to system-user.dtsi in ./xilinx-k26-som-2021.2/project-spec/meta-user/recipes-bsp/device-tree/files:
&gem3 {
status = "okay";
phy-handle = <&phy0>;
phy-mode = "rgmii-id";
mdio: mdio {
#address-cells = <1>;
#size-cells = <0>;
reset-gpios = <&gpio 38 GPIO_ACTIVE_LOW>;
reset-delay-us = <2>;
phy0: ethernet-phy@1 {
#phy-cells = <1>;
reg = <1>;
ti,rx-internal-delay = <0x8>;
ti,tx-internal-delay = <0xa>;
ti,fifo-depth = <0x1>;
ti,dp83867-rxctrl-strap-quirk;
};
};
};
This also requires a few include files to be called out specifically:
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/net/ti-dp83867.h>
#include <dt-bindings/phy/phy.h>
#include <dt-bindings/pinctrl/pinctrl-zynqmp.h>
Overall the system-user.dtsi file in ./xilinx-k26-som-2021.2/project-spec/meta-user/recipes-bsp/device-tree/files should look like this:
Also enable the Ethernet node in the U-Boot device tree file (system-user.dtsi in ./xilinx-k26-som-2021.2/project-spec/meta-user/recipes-bsp/uboot-device-tree/files) by adding the following node:
&gem3 {
phy-mode = "rgmii-id";
status = "okay";
};
And update the kernel boot arguments the same as in the system configuration editor:
/include/ "system-conf.dtsi"
/ {
chosen {
bootargs = "earlycon console=ttyPS1,115200 clk_ignore_unused ext4=/dev/mmcblk1p2:/rootfs rw init_fatal_sh=1 cma=1000M ";
stdout-path = "serial1:115200n8";
};
};
Overall, the system-user.dtsi file in ./xilinx-k26-som-2021.2/project-spec/meta-user/recipes-bsp/uboot-device-tree/files should look like this:
Save and close both system-user.dtsi files then build the PetaLinux project.
~/kria_kv260/xilinx-k26-som-2021.2$ petalinux-build
Package WIC for SD CardAfter the project has been successfully built, package a new WIC image to flash an SD card with:
~/kria_kv260/xilinx-k26-som-2021.2$ petalinux-package --wic --bootfiles "ramdisk.cpio.gz.u-boot boot.scr Image system.dtb"
Then flash the SD card with a program such as balenaEtcher or using the command line on the host PC:
~$ sudo dd bs=4M if=./kria_kv260/xilinx-k26-som-2021.2/images/linux/petalinux-sdimage.wic of=/dev/sdc status=progress && sync
~$ sudo umount /media/<user>/boot
~$ sudo umount /media/<user>/root
Boot KV260Insert the newly flashed SD card in the SD card slot on the KV260 and connect the microUSB UART cable to the host PC with a serial terminal, an Ethernet cable to your router, and the 12V power supply cable finally to boot the Kria KV260
The UART output on the serial terminal will print out instructions of how to connect to the Jupyter notebook running on the Kria KV260 (a URL to navigate to from a browser on your host PC).
Side note: I did not update the boot binary (BOOT.BIN) on the Kria, nor did I use the one generated by the 2021.2 BSP, I'm still using the 2021.1_update2_BOOT.BIN from the Kria KV260 wiki.
Comments