====== Petalinux ======
===== Building and Creating a Bootable Image for an SD card =====
# prepare the environment
source /tools/Xilinx/PetaLinux/2021.2/settings.sh
# configure
# [x] admin > sudo
# [x] misc > coreutils
# [x] misc > tiff
# [x] misc > gdb
# [x] libs > libusb-compat
# [x] libs > libusb1
petalinux-config -c rootfs
petalinux-config -c kernel
petalinux-config --get-hw-description=new_design.xsa
# build and package
petalinux-build
petalinux-package --boot --u-boot --fpga new_bitfile.bit --format BIN --force
petalinux-package --wic
# write to sdcard
lsblk
## sdc 7.4G 0 disk
## |_sdc1 2G 0 part /media/sd1/boot
## |_sdc2 4G 0 part /media/sd1/AAAA-BBBB
sudo dd bs=4096 if=images/linux/petalinux-sdimage.wic of=/dev/sdb
sudo sync
===== Backup and Restore =====
# back up bsp
petalinux-package --bsp -p . --clean -o ./new_bsp.bsp --force
# load bsp
petalinux-create -t project -s $PATH_TO_PETALINUX_PROJECT_BSP --tmpdir $TMPDIR PATH
petalinux-config --get-hw-description=new_design.xsa
# load new firmware without re-imaging sd card
scp /tftpboot/BOOT.BIN /tmp
cp /tmp /media/sd1/BOOT.BIN
reboot
===== Custom Kernel Modules =====
Create the kernel module.
Copy the dma-proxy.c file from the [[https://github.com/Xilinx-Wiki-Projects/software-prototypes/blob/master/linux-user-space-dma/Software/Kernel/dma-proxy.c|Xilinx Repo]]
petalinux-create -t modules --name dma-proxy --enable
vi project-spec/meta-user/recipes-modules/dma-proxy/files/dma-proxy.c
vi project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi
/ {
dma_proxy {
compatible ="xlnx,dma_proxy";
dmas = <&axi_dma_0 0 &axi_dma_0 1>;
dma-names = "dma_proxy_tx", "dma_proxy_rx";
};
};
# if overlay enabled
# $ vi project-spec/meta-user/recipes-bsp/device-tree/files/pl-custom.dtsi
# / {
# dma_proxy {
# compatible ="xlnx,dma_proxy";
# dmas = <&axi_dma_0 0 &axi_dma_0 1>;
# dma-names = "dma_proxy_tx", "dma_proxy_rx";
# };
# };
# disable overlay
# Option 1
petalinux-config
DTG Settings
[ ] Devicetree overlay
# OR Option 2
petalinux-config -c kernel
Device Drivers > Device Tree and Open Firmware support
[ ] Device Tree overlays
# enable module
petalinux-config -c rootfs
# verify module is in project-spec/meta-user/conf/user-rootfsconfig and project-spec/configs/rootfs_config
# build module and kernel
petalinux-build -c kernel
petalinux-build -c dma-proxy
petalinux-build -c rootfs
petalinux-build
# insert module (after booting up petalinux on the SoC or FPGA)
ls /dev | grep dma
modinfo dma-proxy
# filename: /lib/modules/5.10.0-xilinx-v2021.2/extra/dma-proxy.ko
# license: GPL v2
# description: DMA Proxy Prototype
# author: Xilinx, Inc.
# depends:
# name: dma_proxy
# vermagic: 5.10.0-xilinx-v2021.2 SMP mod_unload aarch64
# parm: internal_test:int
insmod /lib/modules/5.10.0-xilinx-v2021.2/extra/dma-proxy.ko
ls /dev | grep dma
dma_proxy_rx
dma_proxy_tx