Each component's recipe can be changed to either include the build time compilation flags or to include patches for custom code modification/addition. PetaLinux provides meta-user Yocto based layer for user specific modifications. The layer can be found in project directory project-spec/meta-user/ location.
PMU Firmware
User specific recipe for PMU firmware can be found in the following location:
dir:project-spec/meta-user/recipes-bsp/pmu/pmu-firmware_%.bbappend (if doesn't exist please create this file at this path).
The PMU firmware code can be modified by patches against embeddedsw GitHub repo. Location for the source code is embeddedsw/tree/master/lib/sw_apps/zynqmp_pmufw. The patches should be copied to project-spec/meta-user/recipes-bsp/pmu/files directory and the same patch names should be added pmu-firmware_%.bbappend file.
Example:
If my_changes.patch (against PMU firmware source) is to be added and all the flags explained in the Build Time Flags in Building Software are to be enabled (set), then project-spec/meta-user/recipes-bsp/pmu/pmu-firmware_%.bbappend may look like the following file:
YAML_COMPILER_FLAGS_append = " -O2 -DENABLE_EM -DENABLE_RECOVERY
-DENABLE_ESCALATION -DENABLE_NODE_IDLING -DREMOVE_GPIO_FROM_NODE_RESET_INFO
-DCHECK_HEALTHY_BOOT -DIDLE_PERIPHERALS"
FILESEXTRAPATHS_prepend := "${THISDIR}/files:" SRC_URI_append = " file://my_changes.patch"
FSBL
User specific recipe for the FSBL can be found in the following location:
dir:project-spec/meta-user/recipes-bsp/fsbl/fsbl_%.bbappend (if does not exist, please create this file at this path). The FSBL code can be modified by patches against embeddedsw GitHub repo. Location for the source code is as follows:
embeddedsw/tree/master/lib/sw_apps/zynqmp_fsblThe patches should be copied to project-spec/meta-user/recipes-bsp/fsbl/files directory and the same patch names should be added to fsbl_%.bbappend file.
Example:
If my_changes.patch (against the FSBL source) is to be added and all the flags explained in the Build Time Flags in Building Software are to be enabled (set), then the modified project-spec/meta-user/recipes-bsp/fsbl/fsbl_%.bbappend file will look like the following file (XPS_BOARD_ZCU102 flag was already existing):
YAML_COMPILER_FLAGS_append = " -DXPS_BOARD_ZCU102 -DFSBL_PROT_BYPASS"
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
SRC_URI_append = " file://my_changes.patch"
TF-A
User specific recipe for TF-A can be found in the following location:
dirproject-spec/meta-user/recipes-bsp/arm-trusted-firmware/arm-trusted-firmware_%.bbappend file (if it doesn't exist, create this file in this path). You can find the ATF files in Git repository for arm trusted firmware.
Example:
To add warm restart flag to TF-A, project-spec/meta-user/recipes-bsp/arm-trusted-firmware/arm-trusted-firmware_%.bbappend will look like the following file:
#
# Enabling warm restart feature
#
EXTRA_OEMAKE_append = " ZYNQMP_WARM_RESTART=1"
Linux
There are many ways to add /modify Linux configuration. See PetaLinux Tools Documentation: Reference Guide (UG1144) for the same.
User specific recipe for Linux kernel can be found in the following location:
project-spec/meta-user/recipes-kernel/linux/linux-xlnx_%.bbappend (if it doesn't exist, create this file at this path).
You can find the Linux files at Git Repository for Linux Example:
To add SRAM config to Linux, create the following bsp.cfg file:
CONFIG_SRAM=y
Add this file in the following bbapend file of Linux:
SRC_URI += "file://bsp.cfg"
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
Modifying Device Tree
User specific recipe for device tree can be found in the following location:
project-spec/meta-user/recipes-bsp/device-tree/device-tree-generation_%.bbappend. This file contains the following contents:
SRC_URI_append ="\ file://system-user.dtsi \
"
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
The content of system-user.dtsi in project-spec/meta-user/recipes-bsp/device-tree/files directory is as follows:
/include/ "system-conf.dtsi"
/ {
};
This file can be modified to extend the device tree functionality by adding, removing, or modifying the DTS nodes.
Example: Adding DT node(s) [ remoteproc RPU split mode]
The overlay dtsi(s) can be added in files/ directory (remember to update bbappend file accordingly) and included in system-user.dtsi. For adding remoteproc related entries to enable RPU subsystem to load, unload, or restart, add a new overlay file called remoteproc.dtsi.
File: remoteproc.dtsi
/ {
reserved-memory {
#address-cells = <2>;
#size-cells = <2>; ranges;
rproc_0_reserved: rproc:dir3ed000000 { no-map;
reg = <0x0 0x3ed00000 0x0 0x1000000>;
};
};
power-domains {
pd_r5_0: pd_r5_0 {
#power-domain-cells = <0x0>; pd-id = <0x7>;
};
pd_r5_1: pd_r5_1 {
#power-domain-cells = <0x0>; pd-id = <0x8>;
};
pd_tcm_0_a: pd_tcm_0_a {
#power-domain-cells = <0x0>; pd-id = <0xf>;
};
pd_tcm_0_b: pd_tcm_0_b {
#power-domain-cells = <0x0>; pd-id = <0x10>;
};
pd_tcm_1_a: pd_tcm_1_a {
#power-domain-cells = <0x0>;
pd-id = <0x11>;
};
pd_tcm_1_b: pd_tcm_1_b {
#power-domain-cells = <0x0>; pd-id = <0x12>;
};
};
amba {
r5_0_tcm_a: tcm:dirffe00000 { compatible = "mmio-sram";
reg = <0x0 0xFFE00000 0x0 0x10000>;
pd-handle = <&pd_tcm_0_a>;
};
r5_0_tcm_b: tcm:dirffe20000 { compatible = "mmio-sram";
reg = <0x0 0xFFE20000 0x0 0x10000>;
pd-handle = <&pd_tcm_0_b>;
};
r5_1_tcm_a: tcm:dirffe90000 { compatible = "mmio-sram";
reg = <0x0 0xFFE90000 0x0 0x10000>;
pd-handle = <&pd_tcm_1_a>;
};
r5_1_tcm_b: tcm:dirffeb0000 { compatible = "mmio-sram";
reg = <0x0 0xFFEB0000 0x0 0x10000>;
pd-handle = <&pd_tcm_1_b>;
};
elf_ddr_0: ddr:dir3ed00000 { compatible = "mmio-sram";
reg = <0x0 0x3ed00000 0x0 0x40000>;
};
elf_ddr_1: ddr:dir3ed40000 { compatible = "mmio-sram";
reg = <0x0 0x3ed40000 0x0 0x40000>;
};
test_r50: zynqmp_r5_rproc:dir0 {
compatible = "xlnx,zynqmp-r5-remoteproc-1.0";
reg = <0x0 0xff9a0100 0x0 0x100>, <0x0 0xff340000 0x0 0x100>, <0x0 0xff9a0000 0x0 0x100>;
reg-names = "rpu_base", "ipi", "rpu_glbl_base"; dma-ranges;
core_conf = "split0"; sram_0 = <&r5_0_tcm_a>; sram_1 = <&r5_0_tcm_b>; sram_2 = <&elf_ddr_0>; pd-handle = <&pd_r5_0>;
interrupt-parent = <&gic>; interrupts = <0 29 4>;
} ;
test_r51: zynqmp_r5_rproc:dir1 {
compatible = "xlnx,zynqmp-r5-remoteproc-1.0";
reg =<0x0 0xff9a0200 0x0 0x100>, <0x0 0xff340000 0x0 0x100>, <0x0 0xff9a0000 0x0 0x100>;
reg-names = "rpu_base", "ipi", "rpu_glbl_base"; dma-ranges;
core_conf = "split1"; sram_0 = <&r5_1_tcm_a>; sram_1 = <&r5_1_tcm_b>; sram_2 = <&elf_ddr_1>; pd-handle = <&pd_r5_1>;
interrupt-parent = <&gic>; interrupts = <0 29 4>;
} ;
};
};
Now include this node in system-user.dtsi:
/include/ "system-conf.dtsi"
/include/ "remoteproc.dtsi"
/ {
};
For information on OpenAMP and remoteproc, see the OpenAmp wiki page.
Example: Removing DT node(s) [ PL node]
It is necessary to remove PL nodes, which are not accessed or dependent on APU subsystem, from the device tree. Again, you can modify system-user.dtsi in project-spec/meta-user/recipes-bsp/device-tree/files to remove specific node or property.
For example, you can modify the system-user.dtsi as following, if you are willing to remove AXI DMA node from the dts:
/include/ "system-conf.dtsi"
/include/ "remoteproc.dtsi"
/ {
/delete-node/axi-dma;
};