Configs & Syntax, MemoryMaps for PetaLinux.
Included python program that Auto Generating "platform-top.h".
./gen/gen.py
1.1. First initialize building enviroment
sudo dpkg --add-architecture i386 && sudo apt-get update
sudo apt install tofrodos gawk xvfb git libncurses5-dev tftpd zlib1g-dev zlib1g-dev:i386 libssl-dev flex bison chrpath socat autoconf libtool texinfo gcc-multilib libsdl1.2-dev libglib2.0-dev screen pax xterm bc build-essential
./petalinux-<petalinux-version>-installer.run -d ./petalinux-build/
source ./petalinux-build/settings.sh
petalinux-create --type project --template <template, ex)zynqMP> --name <user-project-name>
1.2. Initialize building enviroment
source ./petalinux-build/settings.sh
cd <user-project-root>
2.1. First build order
petalinux-config --get-hw-description <user-fpga-directory>
- Subsystem AUTO Hardware Settings → Flash Settings
- u-boot Configuration → u-boot script configuration → QSPI/OSPI image offsets
-
ext 1-1. Image Packaging Configuration → (INITRD or JFFS2, if=JFFS2 then=set erase_block)
-
ext 1-2. Image Packaging Configuration → INITRAMFS/INITRD Image name (petalinux-image-minimal) (petalinux-initramfs-image)
-
ext 2. Firmware Version Configuration
-
ext 3-1. Yocto Settings → Add pre-mirror url (/downloads)
-
ext 3-2. Yocto Settings → Local sstate feeds settings (/aarch64) (file://./.)
petalinux-config -c u-boot
- ARM architecture: Boot script offset
-
Environment: Environment...
-
Environment: Environment offset
- ext. Command line interface: Shell prompt
petalinux-config -c kernel
-
File systems → Miscellaneous filesystems → [ ] JFFS2 summary support (disable)
-
File systems → Miscellaneous filesystems → [ ] JFFS2 XATTR support (disable)
petalinux-config -c rootfs
cat >> ./project-spec/meta-user/conf/petalinuxbsp.conf <<-EOF
INIT_MANAGER_DEFAULT:forcevariable = "sysvinit"
EOF
cat >> ./project-spec/meta-user/conf/user-rootfsconfig <<-EOF
CONFIG_libubootenv
CONFIG_libubootenv-bin
CONFIG_updatetools
EOF
- Image Features -> Init-manager (sysvinit or systemd)
- user packages -> (libubootenv, libubootenv-bin)
- ext. PetaLinux RootFS Settings (enable busybox)
petalinux-config -c busybox
- ext. PetaLinux RootFS busybox Settings (flashcp)
#if need
vi ./project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi
vi ./project-spec/meta-user/recipes-bsp/u-boot/files/platform-top.h
petalinux-build
2.2. Build order
petalinux-config --get-hw-description <user-fpga-directory>
petalinux-build
petalinux-config -c <component>
petalinux-build -c <component>
2.3. Customize rootfs
dd bs=64 skip=1 if=rootfs.cpio.gz.u-boot of=rootfs.cpio.gz
gunzip rootfs.cpio.gz
mkdir rootfs && cd rootfs
cpio -i -F ../rootfs.cpio
sudo su <<-EOF
chown -R root:root *
chown -R user:user home/kvim
find . | cpio -o -H newc | gzip -9 > ../rootfs_new.cpio.gz
EOF
cd ../
mkimage -A arm -T ramdisk -C gzip -d rootfs_new.cpio.gz rootfs_new.cpio.gz.u-boot
2.4. Building u-boot env
vi env.txt
The input file is in format:
key1=value1
key2=value2
...
Empty lines are skipped, and lines with a # in the first
column are treated as comments (also skipped).
mkenvimage -s <env-size> -o <env-name> env.txt
saveenv
sf probe; sf read 0x100000 <env-offset> <env-size>; tftpput 0x100000 <env-size> ${serverip}:<env-name>
2.5. Packaging
petalinux-package --boot --force --format BIN --u-boot -o uboot.bin
petalinux-package --boot --force --format BIN --fpga --u-boot -o uboot.bin
petalinux-package --boot --force --format BIN --fpga --u-boot --add uboot.env --offset <env-offset> -o uboot.bin
petalinux-package --boot --force --format BIN --fpga --u-boot --kernel image.ub --offset <kernel-offset> --boot-script --offset <bootsrc-offset>
# Have to use u-boot tftpboot
petalinux-package --boot --force --format BIN --fpga --u-boot --kernel Image.gz --offset <kernel-offset> --boot-script --offset <bootsrc-offset> --add rootfs.cpio.gz.u-boot --offset <rootfs-offset>
3.1. Initialize building kernel driver enviroment
cd <user-project-root>
petalinux-create --type modules --enable --name <user-module-name>
cat >> ./project-spec/meta-user/conf/petalinuxbsp.conf <<-EOF
RM_WORK_EXCLUDE += "<user-module-name>"
EOF
cd ./project-spec/meta-user/recipes-modules/<user-module-name>
vi ./files/<user-module-name>.c
3.2. Build kernel driver (module)
petalinux-build -c <user-module-name> -x listtasks
petalinux-build -c <user-module-name>
petalinux-build -c <user-module-name> -x do_clean
petalinux-build -c <user-module-name>
petalinux-build -c <user-module-name> -x do_install
<user-project-root>/build/tmp/work/<machine-name>-xilinx-linux/<user-module-name>/1.0-r0/sysroot-destdir/lib/modules/<petalinux-version>/extra/<user-module-name>.ko