3. Building and Deploying the Image
This page walks you through building the configured project and deploying the resulting images to an SD card for booting on the hardware.
Build the PetaLinux Project
- Run the build command. This process can take a significant amount of time.
petalinux-build
- If you encounter errors, you can perform a clean build:
petalinux-build -x mrproper petalinux-build
- After a successful build, create the boot image:
petalinux-package --boot --fsbl --fpga --u-boot
Prepare the SD Card
You need an SD card with two partitions: a FAT32 partition for boot files and an EXT4 partition for the root filesystem.
Insert the SD card in your computer. If you are using WSL, usbipd
must be used for passthrough (link). Identify the SD card by
dmesg | tail
The necessary partitions can be created with fdisk
:
sudo fdisk /dev/sdX # USE ACTUAL DEVICE ID (DOUBLE CHECK!)
# inside fdisk
# d (delete existing partitions)
# n (new partition)
# p (primary)
# 1 (partition number 1)
# <Enter> (default first sector)
# +256M (size for boot partition)
# n (new partition)
# p (primary)
# 2 (partition number 2)
# <Enter> (default first sector)
# <Enter> (default last sector - uses remaining space)
# w (write changes and exit)
⚠️ Warning: Replace
/dev/sdX
with the actual device identifier for your SD card. Using the wrong identifier can result in data loss.
We must now format the partitions. they should exist in /dev
as /dev/sdX1
and /dev/sdX2
:
sudo mkfs.vfat /dev/sdX1
sudo mkfs.ext4 /dev/sdX2
Copy Files to the SD Card
- Mount the partitions:
sudo mkdir -p /mnt/boot /mnt/rootfs sudo mount /dev/sdX1 /mnt/boot sudo mount /dev/sdX2 /mnt/rootfs
- Copy boot files to the FAT32 partition:
cd ~/fenrir-petalinux/images/linux sudo cp BOOT.BIN boot.scr image.ub /mnt/boot/
- Extract the root filesystem to the EXT4 partition:
sudo tar -xzvf rootfs.tar.gz -C /mnt/rootfs
- Sync and unmount:
sync sudo umount /mnt/boot /mnt/rootfs
Boot the Device
- Insert the prepared SD card into the Zybo board.
- Set the boot mode jumper to SD.
- Connect a USB cable for power and a serial console (Baud rate: 115200).
- Power on the board. You should see boot messages in your serial terminal.