Linux and PetaLinux on Zynq
Understand the kernel, user space, Device Tree and safe paths for accessing PL hardware.
Why use an operating system
A standalone, or bare-metal, application directly controls the processor without a complete operating system. Linux adds isolated processes, threads, scheduling, virtual memory, file systems, networking and a driver model.
These services add context-switch, interrupt and memory-management latency. Linux suits rich interfaces, networking, storage and complex applications. A deterministic control loop can remain on the RPU or in the PL.
User space and kernel space
A user program should not freely access every physical register. It requests a service from the kernel, the privileged core of Linux, through a system call. The kernel checks permissions and delegates the operation to a driver.
| Layer | Responsibility |
|---|---|
| Application | Algorithm and product behavior |
| Library | Stable application API |
| Kernel | Processes, memory, interrupts and security |
| Driver | Translation between kernel API and hardware |
| Hardware | Registers, DMA, interrupts and streams |

PetaLinux and the Device Tree
PetaLinux groups AMD tools for building Linux systems for FPGA SoCs. It uses Yocto, cross-compilation tools and the exported hardware description.
The flow creates a project, imports hardware, configures kernel and root file system, builds images, packages boot and deploys to the board. Hardware and software must remain synchronized.
The Device Tree is a structured hardware description read by the Linux kernel at boot. It describes devices the kernel cannot discover automatically. A custom AXI node can provide its address, range, interrupt, clocks and compatible string. This string lets the kernel select the matching driver.
led_controller@a0000000 {
compatible = "fpgapourtous,led-controller-1.0";
reg = <0x0 0xa0010000 0x0 0x1000>;
interrupts = <0 89 4>;
};Exact cells depend on the architecture and interrupt controller. Start from the generated Device Tree for the target.
Accessing hardware
The legacy example uses /sys/class/gpio. It exports a number, reads direction and accesses value. This explains the file model. A recent project should prefer descriptor-based GPIO and libgpiod when supported.
/dev/mem can map a physical address for controlled diagnosis. It does not safely handle interrupts, DMA, clocks or concurrency. UIO fits selected simple peripherals. A kernel driver is better for shared hardware, DMA, power management or a stable product interface.
DMA under Linux
An address returned by malloc is virtual and must not be written directly to a DMA register. A kernel driver uses the DMA API to obtain a buffer and a device-visible address. That API also manages mapping and coherence constraints.
This is a major difference between standalone DMA code and Linux application code.
Zynq UltraScale+ MPSoC can run Linux on the APU and real-time software on the RPU. Shared memory, interprocessor interrupts, remoteproc and RPMsg can connect them. Peripheral and memory ownership must be explicit.
Official references
The PetaLinux Tools Reference Guide UG1144 describes the tools and Yocto integration. The Software Developers Guide UG1137 collects Zynq UltraScale+ MPSoC software resources.
Key points
Linux separates applications from hardware through the kernel and drivers. Device Tree describes platform IP. PetaLinux builds a system matched to the XSA. Historical sysfs examples explain the model, while new designs should use current kernel interfaces.
Test your knowledge - Chapter quiz