Chargement…
Chargement…
Understand the kernel, user space, Device Tree and safe paths for accessing PL hardware.
Linux provides processes, virtual memory, networking, storage, and drivers. These services support rich applications but introduce scheduling, interrupts, and variable latency. Strictly deterministic functions may remain on RPU or in PL.
Applications request kernel services rather than freely owning all physical registers:
| 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 |
Drivers handle access, sharing, and peripheral resources. This boundary limits the effect of application faults on the system.
PetaLinux uses Yocto, cross-compilation, and hardware description. Its flow covers project creation, hardware import, kernel/rootfs configuration, build, packaging, deployment, and serial diagnosis.
After changing addresses, interrupts, or IP, update affected descriptions and drivers. Booting an image made for an old XSA does not establish compatibility.
Device Tree supplies addresses, sizes, interrupts, clocks, and compatibility:
led-controller@a0010000 {
compatible = "fpgapourtous,led-controller-1.0";
reg = <0x0 0xa0010000 0x0 0x1000>;
interrupts = <0 89 4>;
};The name after @ must match the node address. reg cells depend on the parent bus; interrupt cells depend on the controller. This fragment assumes two address and two size cells. A driver must recognize the chosen compatible and receive properties required by its binding.
Historical sysfs exposes /sys/class/gpio:
FILE *fp = fopen("/sys/class/gpio/export", "w");
if (fp == NULL) {
perror("GPIO export");
return -1;
}
int written = fprintf(fp, "%d", gpio_number);
int closed = fclose(fp);
if (written < 0 || closed != 0) {
return -1;
}This fragment only exports a GPIO. Check file opening and writing, then configure direction and value. New projects should prefer the GPIO character-device interface and libgpiod appropriate to kernel and library versions. Global sysfs numbering is fragile.
/dev/mem with mmap can support authorized diagnosis but does not independently manage interrupts, DMA, clocks, or concurrency. UIO suits some simple devices; shared resources and DMA usually warrant kernel drivers.
A malloc address is virtual. Do not write it directly to a DMA register. Drivers use kernel DMA allocation or mapping APIs to obtain a device-usable address and meet synchronization requirements.
Linux on APU can communicate with RPU processing using shared memory, interprocessor interrupts, and supported remoteproc/RPMsg flows. Reserve memory and assign peripherals. Two environments must not reconfigure one resource without a protocol.
UG1144 documents PetaLinux; UG1137 collects MPSoC resources. The Linux GPIO API documents current userspace access.
Test your knowledge - Chapter quiz