/petalinux-configs

Configs & Syntax, MemoryMaps for PetaLinux

Primary LanguageShellMIT LicenseMIT

petalinux-configs

Configs & Syntax, MemoryMaps for PetaLinux.

Included python program that Auto Generating "platform-top.h".

./gen/gen.py


1. Building enviroments

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. Building orders

2.1. First build order

HW Menuconfig

petalinux-config --get-hw-description <user-fpga-directory>
  1. Subsystem AUTO Hardware Settings → Flash Settings

4

  1. u-boot Configuration → u-boot script configuration → QSPI/OSPI image offsets

4

  • 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://./.)

U-Boot Menuconfig

petalinux-config -c u-boot
  1. ARM architecture: Boot script offset

4

  1. Environment: Environment...

  2. Environment: Environment offset

4

  • ext. Command line interface: Shell prompt

Kernel Menuconfig

petalinux-config -c kernel
  1. File systems → Miscellaneous filesystems → [ ] JFFS2 summary support (disable)

  2. File systems → Miscellaneous filesystems → [ ] JFFS2 XATTR support (disable)

Rootfs Menuconfig

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
  1. Image Features -> Init-manager (sysvinit or systemd)
  2. user packages -> (libubootenv, libubootenv-bin)
  • ext. PetaLinux RootFS Settings (enable busybox)

Busybox Menuconfig

petalinux-config -c busybox
  • ext. PetaLinux RootFS busybox Settings (flashcp)

Build

#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

ramdisk

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

JFFS2


2.4. Building u-boot env

Use mkenvimage

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

Use U-Boot tftpput

saveenv
sf probe; sf read 0x100000 <env-offset> <env-size>; tftpput 0x100000 <env-size> ${serverip}:<env-name>

2.5. Packaging

U-Boot only (No fpga, env)

petalinux-package --boot --force --format BIN --u-boot -o uboot.bin

U-Boot only (No env)

petalinux-package --boot --force --format BIN --fpga --u-boot -o uboot.bin

U-Boot only (With env)

petalinux-package --boot --force --format BIN --fpga --u-boot --add uboot.env --offset <env-offset> -o uboot.bin

Booting using Fit image

petalinux-package --boot --force --format BIN --fpga --u-boot --kernel image.ub --offset <kernel-offset> --boot-script --offset <bootsrc-offset>

Booting using Separate images (NOT WORKING)

# 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. Building kernel driver

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)

Command List

petalinux-build -c <user-module-name> -x listtasks

Build

petalinux-build -c <user-module-name>

Rebuild

petalinux-build -c <user-module-name> -x do_clean
petalinux-build -c <user-module-name>

Install

petalinux-build -c <user-module-name> -x do_install

Output Directory

<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