Author: June

  • Building PetaLinux 2024.2 for the Zedboard

    PetaLinux is theoretically the quickest way to get Linux running on a Zynq chip, as it’s the build system officially provided by Xilinx.

    They don’t consider it a distro in and of itself. What Xilinx provides is basically:

    • The PetaLinux build tools which leverage Yocto under the hood to produce a Linux boot image with drivers targeting Xilinx chips and other Xilinx-specific configuration
    • A board support package (BSP) for each of the official dev boards which includes a base FPGA design and device tree corresponding to the board and chip features which the PetaLinux tools can look at in order to configure the Yocto build

    The one small hiccup here is that a BSP is no longer provided for the Zedboard, which means Xilinx wants us to use older versions of the tools where it used to be supported, or else figure out it on our own.

    Thankfully, an open source contributor published a BSP for Zedboard which has been updated to work with the latest PetaLinux tools.

    The steps are:

    1. Get PetaLinux
      For this I am following the installation guide published by Xilinx
    2. Get the BSP
      wget https://github.com/ubfx/zedboard-bsp/releases/download/2024.2/zedboard-2024.2.bsp
    3. Generate a PetaLinux project from the BSP
      petalinux-create project -s zedboard-2024.2.bsp -n zedboard-2024.2
    4. Build the PetaLinux project, generating the required images
      petalinux-build
    5. Create a boot image from the build outputs above
      petalinux-package boot --u-boot --fpga --force
    6. Flash the boot image onto an SD card
      Following the instructions linked by the GitHub repo

    The setup process is pretty easy, you just download the set script from the downloads link in the installation guide, then run it, find out you are missing a bunch of dependencies, then discover there is a list of dependencies in the release notes for that download.

    The dependencies were all a series of sudo apt-gets, 95% of which installed smoothly and some had issues which I had to look up in order to get them installed.

    One thing to note is you have to source petalinux-install-dir/settings.sh in order to be able to run any of the petalinux CLI commands.

    One issue that I found with the BSP provided is that it is initially configured to mount a ramdisk as root filesystem instead of the SD card second partition. To fix this I had to run petalinux-config following step 3 and adjust Image Packaging Configuration > Root filesystem settings:

    From here, I’m able to run all the way through step 4, it builds several hundred items, and exactly one fails due to Ubuntu’s AppArmor intervening. I disable intending that I might turn it back on one day should I happen to remember, and then the build succeeds, providing me with outputs in the images directory.

    I also removed several arguments originally specified for step 5 by the BSP instructions hich were not relevant to Zynq7000.

    Step 4 and 5 leaves us with the following to put onto the SD card.

    My SD card shows up as /dev/sdb, so I can follow the linked instructions for step 6 exactly. Basically the first 3 files get copied into the boot partition, and then the tarball gets extracted into the filesystem of the second partition.

    Formatting leaves me with the following:

    I could just as easily have used Ubuntu’s graphical Disk utility and copied files in Nautilus.

    It seemed curious to me that the boot device has a filesystem, rather than a binary and headers or magic numbers located at 0. Apparently for the special case of SD cards, Zynq’s on-chip BootROM checks a FAT32 filesystem for a file named BOOT.BIN.

    After modifying the Zedboard jumpers to boot from SD, I am able to see Linux boot and access the terminal via the UART.

    23 seconds later…

    The boot takes far too long!

  • Learning Embedded Linux

    For the instrument we’re building at work, I had originally applied an Arria 10 SOC intending to use embedded Linux on the ARM CPU to run the main controller firmware.

    The chip has support in the Yocto ecosystem, but after working with it for a while I found that handling the build and deployment process and interfacing custom components and IPs in the FPGA fabric to the Linux OS to be too much burden to handle on my own with no background and a short timeline.

    So I scaled the design back a little to target a more familiar Cyclone FPGA with a Nios II soft core and bare metal firmware. It ended up being much more manageable and met our needs.

    Now, on my own time I want to learn more about embedded Linux, AXI interfacing, and operating systems in general.

    Picture of a ZedBoard development board, green PCB with connectors and buttons. Board is unplugged, sitting on top of its anti-static bag

    I bought this Zedboard a few years ago, and it’s a little outdated now but I spent ~$500 on it so might as well use it.

    The popular Zynq7000 chip has a dual core ARM9 CPU and a FPGA fabric similar to the Artix 7 series.

    This board has USB OTG and 1G ethernet attached to the ARM processing system, and HDMI connected to the fabric. I would basically like to turn it into a mini PC similar to a Raspberry Pi.

    The FPGA itself is fairly powerful and a large amount of IO including multi-gigabit transceivers. It could serve as a good hardware development platform for projects where tight integration with a powerful CPU is desirable.

    This is mainly a learning experience, the steps I intend to take are something like the following:

    1. Get board set up with bare metal tutorial <- You are here
    2. Learn to deploy PetaLinux to the board, which is the platform and toolchain that Xilinx directly supports.
    3. Learn about Linux’s graphics stack and figure out how to get HDMI working as a video output for XWindows
    4. Get keyboard and mouse working
    5. Figure out how to build the above from scratch (kernel, devicetree, buildroot, uboot, etc) for a minimal deployment

    It turns out that all of the above is not trivial, but I did manage to gather a fair amount of documentation.

    • Getting started with Zedboard – intro to Vivado/Vitis SOC toolchain, bare metal example, up to date with latest Xilinx software
    • Apparently, in the past Xilinx provided a BSP for this board to use with the PetaLinux build tools, but it fell out of date. Thankfully someone released an up to date PetaLinux BSP for ZedBoard by migrating the last supported one.
    • Documentation on building Linux from scratch, available from Xilinx.
    • Also tons of Linux driver info from Xilinx including on DRM/KMS and Framebuffer Read which are potentially useful for video stack.
    • The BSP does not have any HDMI components, so that is clearly not available out of the box, but Analog Devices who makes the on-board HDMI TX chip releases a reference design for Linux with HDMI video output on Zedboard.

    In the default code example for the Getting started tutorial, the LEDs just tracked the buttons, so I added a usleep() to make them more lively.