How to build Petalinux Kernel for Ultra96 V2 based on Avnet BSP 2021.1
Updated: Apr 28

Build Steps
PetaLinux Tools Build Guide for Ultra96-V2 Avnet out of box BSP 2021.1
Build Platform Management Unit firmware PMUFW) for Ultra96 V2
Petalinux Kernel source code location
u96v2_sbc_base_2021_1/build/tmp/work/u96v2_sbc-xilinx-linux/linux-xlnx
# Setup PetaLinux Environment
cd ~petalinux-install-directory
source peta/settings.sh
source peta/settings.sh PetaLinux environment set to '/home/jimmy/petalinux/2021.1/peta' INFO: Checking free disk space INFO: Checking installed tools INFO: Checking installed development libraries INFO: Checking network and other services |
# go to BSP source code directory
cd u96v2_sbc_base_2021_1
# In order to clean up build temp files By running following command:
petalinux-build -c kernel -x distclean
# You should see following debug messages:
petalinux-build -c kernel -x distclean [INFO] Sourcing buildtools [INFO] Building kernel [INFO] Sourcing build environment [INFO] Generating workspace directory INFO: bitbake virtual/kernel -c cleansstate NOTE: Started PRServer with DBfile: /home/jimmy/petalinux/2021.1/u96v2_sbc_base_2021_1/build/cache/prserv.sqlite3, IP: 127.0.0.1, PORT: 35933, PID: 5802 Loading cache: 100% |########################################################################################################################################################################| Time: 0:00:06 Loaded 5139 entries from dependency cache. Parsing recipes: 100% |######################################################################################################################################################################| Time: 0:00:02 Parsing of 3514 .bb files complete (3504 cached, 10 parsed). 5149 targets, 227 skipped, 0 masked, 0 errors. NOTE: Resolving any missing task queue dependencies Initialising tasks: 100% |###################################################################################################################################################################| Time: 0:00:00 Sstate summary: Wanted 0 Found 0 Missed 0 Current 0 (0% match, 0% complete) NOTE: No setscene tasks NOTE: Executing Tasks NOTE: Tasks Summary: Attempted 3 tasks of which 0 didn't need to be rerun and all succeeded. [INFO] Successfully built kernel |
# In order to fetch source ode, please run following command:
petalinux-build -c kernel -x fetch
# You should see following debug messages:
petalinux-build -c kernel -x fetch [INFO] Sourcing buildtools [INFO] Building kernel [INFO] Sourcing build environment [INFO] Generating workspace directory INFO: bitbake virtual/kernel -c fetch NOTE: Started PRServer with DBfile: /home/jimmy/petalinux/2021.1/u96v2_sbc_base_2021_1/build/cache/prserv.sqlite3, IP: 127.0.0.1, PORT: 37681, PID: 6700 Loading cache: 100% |########################################################################################################################################################################| Time: 0:00:01 Loaded 5139 entries from dependency cache. Parsing recipes: 100% |######################################################################################################################################################################| Time: 0:00:01 Parsing of 3514 .bb files complete (3504 cached, 10 parsed). 5149 targets, 227 skipped, 0 masked, 0 errors. NOTE: Resolving any missing task queue dependencies Initialising tasks: 100% |###################################################################################################################################################################| Time: 0:00:00 Sstate summary: Wanted 0 Found 0 Missed 0 Current 0 (0% match, 0% complete) NOTE: No setscene tasks NOTE: Executing Tasks NOTE: Tasks Summary: Attempted 1 tasks of which 0 didn't need to be rerun and all succeeded. INFO: Successfully copied built images to tftp dir: /tftpboot [INFO] Successfully built kernel |
# In order to unpack source ode, please run following command:
petalinux-build -c kernel -x unpack
# You will see following debug messages:
petalinux-build -c kernel -x unpack [INFO] Sourcing buildtools [INFO] Building kernel [INFO] Sourcing build environment [INFO] Generating workspace directory INFO: bitbake virtual/kernel -c unpack NOTE: Started PRServer with DBfile: /home/jimmy/petalinux/2021.1/u96v2_sbc_base_2021_1/build/cache/prserv.sqlite3, IP: 127.0.0.1, PORT: 34785, PID: 7646 Loading cache: 100% |########################################################################################################################################################################| Time: 0:00:01 Loaded 5139 entries from dependency cache. Parsing recipes: 100% |######################################################################################################################################################################| Time: 0:00:01 Parsing of 3514 .bb files complete (3504 cached, 10 parsed). 5149 targets, 227 skipped, 0 masked, 0 errors. NOTE: Resolving any missing task queue dependencies Initialising tasks: 100% |###################################################################################################################################################################| Time: 0:00:00 Sstate summary: Wanted 0 Found 0 Missed 0 Current 0 (0% match, 0% complete) NOTE: No setscene tasks NOTE: Executing Tasks NOTE: Tasks Summary: Attempted 2 tasks of which 1 didn't need to be rerun and all succeeded. INFO: Successfully copied built images to tftp dir: /tftpboot [INFO] Successfully built kernel |
# In order to rebuild source ode, please run following command:
petalinux-build -c kernel -x build
petalinux-build -c kernel -x build [INFO] Sourcing buildtools [INFO] Building kernel [INFO] Sourcing build environment [INFO] Generating workspace directory INFO: bitbake virtual/kernel -c build NOTE: Started PRServer with DBfile: /home/jimmy/petalinux/2021.1/u96v2_sbc_base_2021_1/build/cache/prserv.sqlite3, IP: 127.0.0.1, PORT: 44981, PID: 8709 Loading cache: 100% |########################################################################################################################################################################| Time: 0:00:06 Loaded 5139 entries from dependency cache. Parsing recipes: 100% |######################################################################################################################################################################| Time: 0:00:01 Parsing of 3514 .bb files complete (3504 cached, 10 parsed). 5149 targets, 227 skipped, 0 masked, 0 errors. NOTE: Resolving any missing task queue dependencies Initialising tasks: 100% |###################################################################################################################################################################| Time: 0:00:01 Sstate summary: Wanted 16 Found 4 Missed 12 Current 208 (25% match, 94% complete) NOTE: Executing Tasks NOTE: Tasks Summary: Attempted 793 tasks of which 761 didn't need to be rerun and all succeeded. INFO: Successfully copied built images to tftp dir: /tftpboot [INFO] Successfully built kernel |
How to load and debug over JTAG
# We need set device board boot switch to 00, which is booting from JTAG
# start xilinx hardware server
/home/jimmy/petalinux/2021.1/peta/tools/xsct/bin/xsct
# you will see following debug message
/home/jimmy/petalinux/2021.1/peta/tools/xsct/bin/xsct rlwrap: warning: your $TERM is 'xterm-256color' but rlwrap couldn't find it in the terminfo database. Expect some problems.
****** Xilinx Software Commandline Tool (XSCT) v2021.1 **** SW Build 3240477 on 2021-06-05-19:57:09 ** Copyright 1986-2021 Xilinx, Inc. All Rights Reserved. xsct% |
# run connect command to start hardware server
xsct% connect attempting to launch hw_server
****** Xilinx hw_server v2021.1.0 **** Build date : Jun 5 2021 at 17:46:51 ** Copyright 1986-2021 Xilinx, Inc. All Rights Reserved. INFO: hw_server application started INFO: Use Ctrl-C to exit hw_server application INFO: To connect to this hw_server instance use url: TCP:127.0.0.1:3121 tcfchan#0 xsct% |
# Run targets command to get targets
# You will see following debug message from host
xsct% targets 1 PS TAP 2 PMU 3 PL 5 PSU 6 RPU (Reset) 7 Cortex-R5 #0 (RPU Reset) 8 Cortex-R5 #1 (RPU Reset) 9 APU (L2 Cache Reset) 10 Cortex-A53 #0 (APU Reset) 11 Cortex-A53 #1 (APU Reset) 12 Cortex-A53 #2 (APU Reset) 13 Cortex-A53 #3 (APU Reset) xsct% |
# You
# Power on the device, and then run following commands
petalinux-boot --jtag --u-boot --hw_server-url TCP:127.0.0.1:3121 -v
# You will see following debug message from host
petalinux-boot --jtag --u-boot --hw_server-url TCP:127.0.0.1:3121 -v [INFO] Sourcing buildtools XSDB Script: INFO: Launching XSDB for file download and boot. INFO: This may take a few minutes, depending on the size of your image. connect -url TCP:127.0.0.1:3121 for {set i 0} {$i < 20} {incr i} { if { [ta] != "" } break; after 50 } targets -set -nocase -filter {name =~ "*PSU*"} mask_write 0xFFCA0038 0x1C0 0x1C0 targets -set -nocase -filter {name =~ "*MicroBlaze PMU*"} puts stderr "INFO: Downloading ELF file: /home/jimmy/petalinux/2021.1/u96v2_sbc_base_2021_1/images/linux/pmufw.elf to the target." dow "/home/jimmy/petalinux/2021.1/u96v2_sbc_base_2021_1/images/linux/pmufw.elf" after 2000 con targets -set -nocase -filter {name =~ "*APU*"} mwr 0xffff0000 0x14000000 mask_write 0xFD1A0104 0x501 0x0 after 5000 targets -set -nocase -filter {name =~ "*A53*#0"} source /home/jimmy/petalinux/2021.1/u96v2_sbc_base_2021_1/project-spec/hw-description/psu_init.tcl puts stderr "INFO: Downloading ELF file: /home/jimmy/petalinux/2021.1/u96v2_sbc_base_2021_1/images/linux/zynqmp_fsbl.elf to the target." dow "/home/jimmy/petalinux/2021.1/u96v2_sbc_base_2021_1/images/linux/zynqmp_fsbl.elf" after 2000 con after 4000; stop; catch {stop}; psu_ps_pl_isolation_removal; psu_ps_pl_reset_config targets -set -nocase -filter {name =~ "*A53*#0"} puts stderr "INFO: Loading image: /home/jimmy/petalinux/2021.1/u96v2_sbc_base_2021_1/images/linux/system.dtb at 0x00100000" dow -data "/home/jimmy/petalinux/2021.1/u96v2_sbc_base_2021_1/images/linux/system.dtb" 0x00100000 after 2000 targets -set -nocase -filter {name =~ "*A53*#0"} puts stderr "INFO: Downloading ELF file: /home/jimmy/petalinux/2021.1/u96v2_sbc_base_2021_1/images/linux/u-boot.elf to the target." dow "/home/jimmy/petalinux/2021.1/u96v2_sbc_base_2021_1/images/linux/u-boot.elf" after 2000 targets -set -nocase -filter {name =~ "*A53*#0"} puts stderr "INFO: Downloading ELF file: /home/jimmy/petalinux/2021.1/u96v2_sbc_base_2021_1/images/linux/bl31.elf to the target." dow "/home/jimmy/petalinux/2021.1/u96v2_sbc_base_2021_1/images/linux/bl31.elf" after 2000 con exit rlwrap: warning: your $TERM is 'xterm-256color' but rlwrap couldn't find it in the terminfo database. Expect some problems.: Inappropriate ioctl for device INFO: Downloading ELF file: /home/jimmy/petalinux/2021.1/u96v2_sbc_base_2021_1/images/linux/pmufw.elf to the target. INFO: Downloading ELF file: /home/jimmy/petalinux/2021.1/u96v2_sbc_base_2021_1/images/linux/zynqmp_fsbl.elf to the target. INFO: Loading image: /home/jimmy/petalinux/2021.1/u96v2_sbc_base_2021_1/images/linux/system.dtb at 0x00100000 INFO: Downloading ELF file: /home/jimmy/petalinux/2021.1/u96v2_sbc_base_2021_1/images/linux/u-boot.elf to the target. INFO: Downloading ELF file: /home/jimmy/petalinux/2021.1/u96v2_sbc_base_2021_1/images/linux/bl31.elf to the target. |
# You will see following debug message from minicom/hyperterminal
Xilinx Zynq MP First Stage Boot Loader Release 2021.1 Jun 6 2021 - 07:07:32 NOTICE: ATF running on XCZU3EG/silicon v4/RTL5.1 at 0xfffea000 NOTICE: BL31: v2.4(release):v1.1-7609-g851523ea2 NOTICE: BL31: Built : 08:27:07, Apr 28 2021
U-Boot 2021.01 (Jun 01 2021 - 11:54:06 +0000)
Board: Xilinx ZynqMP DRAM: 2 GiB PMUFW: v1.1 Jimmy EL Level: EL2 Chip ID: zu3eg NAND: 0 MiB MMC: mmc@ff160000: 0, mmc@ff170000: 1 In: serial Out: serial Err: serial Bootmode: JTAG_MODE Reset reason: EXTERNAL Net: No ethernet found. Hit any key to stop autoboot: 0 JTAG: Trying to boot script at 20000000 ## Executing script at 20000000 Wrong image format for "source" command JTAG: SCRIPT FAILED: continuing... starting USB... Bus dwc3@fe300000: Register 2000440 NbrPorts 2 Starting the controller USB XHCI 1.00 scanning bus dwc3@fe300000 for devices... 4 USB Device(s) found scanning usb for storage devices... 0 Storage Device(s) found |