Petalinux Configuration - bkushal26/ELM_Bring_up_Petalinux GitHub Wiki
note- This page is under development and is known to be incomplete. Reference document from A. Greshilov, UF is used, and modifications are being done as per the progress.
All steps below assume that Vivado and Petalinux tools are already installed and firmware is exported. Important: Use a similar version of Vivado and Petalinux (in our case the versions > 2020.1).
As the firmware is exported including a bitstream, in the root of the Vivado project you can see generated .xsa
package which should be provided to the Petalinux toolchain to generate the corresponding Linux kernel version.
Now we are ready to follow the next steps to create the Petalinux project and to build kernel images:
- Open terminal, go to the Petalinux installation directory, and set petalinux environment by command:
-
source settings.sh
(For Bash as user login shell) -
source settings.csh
(For C shell as user login shell)
-
Verify that the working environment has been set:
echo $PETALINUX
Environment variable$PETALINUX
should point to the installed PetaLinux path. -
Change to the directory under which you want PetaLinux projects to be created. For example, if you want to create projects under /home/user:
cd /home/user
- Run Petalinux-create command on the command console:
petalinux-create --type project --template zynqMP --name <PROJECT_NAME>
- Change into the directory of your PetaLinux project:
cd <plnx_proj_root>
Import the hardware description with the petalinux-config
command, by giving the path of the directory containing the .xsa
file as follows:
petalinux-config --get-hw-description=<path_to_xsa_file>
This will pop up a window(shown in the following figure) to configure the project. There are few things that need to be configured, in this window, in order to point the kernel to a custom root file system.
IMAGE to be added
- Go to
Subsystem AUTO Hardware Settings -> Advanced bootable images storage Settings -> boot image settings
and setimage storage media
option toprimary sd
.
- Go to
Subsystem AUTO Hardware Settings -> Advanced bootable images storage Settings -> kernel image settings
and set theimage storage media
option toprimary sd
. - Go to
Subsystem AUTO Hardware Settings -> Advanced bootable images storage Settings ->dtb image settings
and set theimage storage media
option toprimary sd
. - Go to
Image Packaging Configurations
and set theRoot filesystem type
option toSD card
. - Enable following FPGA Manager by clicking 'Y' button:-
FPGA Manager
- Select Exit and save the new configuration.
Once the system configuration process is complete, run the command below to start the kernel configuration for the embedded OS:
petalinux-config -c kernel
When the initialization is complete, a configuration menu will be shown:
Image to be added
Here you can set all configuration settings you need otherwise you can leave the default settings. For ELM bring up firmware add the following settings:
Configure macb Driver in kernel Configuration. Steps for checking macb driver configuration:-
- Go to
Device Drivers--> Network device support--> Ethernet Driver Support-->
[*] Cadence devices
<*> Cadence MACB/GEM support
(this option is not selected by default, press 'y' to select, 'n' to deselect.)
- use left/right arrow keys to
<Save>
option.
Go to to Device Drivers--> I2C support--> I2C support(I2C[=y])I2C hardware Bus Support-->[*] Cadence I2C controller
(this option is not selected by default, press 'space bar' to select, 'n' to deselect.)
use left/right arrow keys to <Save>
option.
- Enable the following
Power management options
by clicking the 'Y' buttonSuspend to RAM and standby
Userspace wakeup sources interface
Device power management core functionality
- Enable following
Kernel hacking
-
Compile-time checks and compiler options
Debug Filesystem
-
- Enable following
Firmware Drivers
-
Zynq MPSoC Firmware Drivers
Xilinx Zynq MPSoC firmware interface
Xilinx Zynq MPSoC firmware debug APIs
-
- Enable following
Device Drivers
-
FPGA Configuration Framework
Xilinx Zynq UltraScale+ MPSoC FPGA
FPGA debug fs
-
Save and exit the menu. The kernel configuration process will continue and will issue the following message when completed.
Once this process is completed, you can modify the device tree file to allow all required modifications in requested device tree nodes from reserved for this system-user.dtsi
file.
Access the file project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi
and modify it with the following configs:
/include/ "system-conf.dtsi"
/ {
chosen {
bootargs = "console=ttyPS0,115200 earlyprintk root=/dev/mmcblk0p2 rw rootwait";
};
debug_bridge_0: debug_bridge@80010000 {
clock-names = "s_axi_aclk";
clocks = <&zynqmp_clk 71>;
compatible = "xlnx,debug-bridge-3.0", "generic-uio";
reg = <0x0 0x80010000 0x0 0x10000>;
};
};
&sdhci0{
status = "okay";
max-frequency = <50000000>;
disable-wp;
no-1-8-v; /*this makes SD card work*/
};
&i2c0 {
status = "okay";
clock-frequency = <400000>;
bus-id = <0>;
clocks = <&zynqmp_clk 61>;
compatible = "cdns,i2c-r1p14", "cdns,i2c-r1p10";
interrupt-parent = <&gic>;
interrupts = <0 17 4>;
reg = <0x0 0xff020000 0x0 0x1000>;
xlnx,has-interrupt = <0x0>;
eeprom@50 {
compatible = "microchip,24aa02e48";
reg = <0x50>;
};
eeprom@51{
compatible = "at24,24a256";
reg = <0x51>;
};
};
Finally, we are ready to build the complete PetaLinux Image by running the command below:
petalinux-build
The build process can take several minutes and will issue several messages.
This process creates several ELF files in the directory images/linux
. The last step is to consolidate these files into boot files to be saved to an SD Card and inserted into the Ultrascale+ board.
After the project is successfully built, run the following command (This is a single line command):
petalinux-package --boot --format BIN --fsbl images/linux/zynqmp_fsbl.elf --u-boot images/linux/u-boot.elf --pmufw images/linux/pmufw.elf --fpga images/linux/*.bit --force
The process will issue several messages and will successfully end with the following message: INFO: Binary is ready.
Navigate to the directory <plnx_proj_name>/images/linux
and verify that the files BOOT.BIN,image.ub,boot.scr
. We need to copy on the prepared SD Card (BOOT partition) are present.
- This can be easily done with
gparted
application for Linux. In Ubuntu, open a terminal and type the following command to startgparted
:sudo gparted
- If
gparted
is not installed, you can install it using the following command:sudo apt-get install gparted
- Right-click the unallocated space and create a new partition with the following settings:
Free Space Proceeding (MiB): 4,
New Size (MiB) : 512, File System : FAT32, Label : BOOT. Don’t change other settings and clickAdd
to finish. - Right-click the remaining unallocated space and create a new partition with the following settings,
Free Space Proceeding (MiB): 0,
Free Space Following(MiB): 0, File System : ext4, Label : rootfs. Don’t change other settings and clickAdd
to finish. - Apply all changes to create the partitions.
Under Windows, you can do this using the MiniTool Partition Wizard application. You can download it here: https://www.partitionwizard.com/free-partition-manager.html
Now you can copy needed boot files to the prepared SD Card:
- From
<plnx_proj_name>images/linuxcopy BOOT.BIN,image.ub,boot.scr
files to theBOOT
partition of the prepared SD Card. - From transferred files copy to the rootfs partition of the SD card already prepared CentOS 8 root filesystem:
PS: First extract CentOS 8 root filesystem:
sudotar -xvf rootfs.tar.gz
After copy root filesystem to the rootfs partition of the SD card:
sudo cp -a <path/to/root_filesystem>/. <path/to/rootfs_partition>
- Now SD card is ready to be inserted to the board. Make sure the board is configured to boot from SD card:
- Insert SD card to the board. Connect the serial port, set baud rate to 115200 and power on.
Several useful packages have been added to the prepared root file system of CentOS 8::net-tools, i2c-tools, cmake, make, git, htop, g++, boost. Other packages which are required for bring up tests are added using rpm. The extra packages (listed below) are downloaded using this link.
- iperf3 (iperf3-3.5-6.el8.aarch64.rpm)
- lksctp-tools-doc-1.0.18-3.el8.aarch64.rpm
- lksctp-tools-devel-1.0.18-3.el8.aarch64.rpm
- lksctp-tools-1.0.18-3.el8.aarch64.rpm
- devmem (devmem2-1.0-17.43.aarch64.rpm)