How to build First Stage Bootloader (FSBL) for ultra96 V2 Based on Avnet BSP 2018.3

Updated: Apr 27



Build Steps

First Stage Boot Loader (FSBL)

# Source code location

./ultra96v2_oob_2018_3/build/tmp/work/ultra96_zynqmp-xilinx-linux/fsbl


# Setup PetaLinux Environment

cd ~petalinux-install-directory

source peta/settings.sh

# You should see following debug messages:

​PetaLinux environment set to '/home/jimmy/petalinux/2018.3/peta'

INFO: Checking free disk space

INFO: Checking installed tools

INFO: Checking installed development libraries

INFO: Checking network and other services

# Original fsbl debug message


Xilinx Zynq MP First Stage Boot Loader

Release 2018.3 Apr 8 2022 - 02:15:41 PMUFW: v1.1 U-Boot 2018.01 (Apr 10 2022 - 22:20:21 +0000)

# In order to clean up build temp files By running following command:

petalinux-build -c fsbl -x distclean


# You should see following debug messages:

​petalinux-build -c fsbl -x distclean

[INFO] building fsbl

[INFO] sourcing bitbake

INFO: bitbake fsbl -c cleansstate Loading cache: 100% |##################################################################################################################################################| Time: 0:00:51 Loaded 3468 entries from dependency cache. Parsing recipes: 100% |################################################################################################################################################| Time: 0:01:54 Parsing of 2577 .bb files complete (2542 cached, 35 parsed). 3469 targets, 133 skipped, 0 masked, 0 errors. NOTE: Resolving any missing task queue dependencies Initialising tasks: 100% |#############################################################################################################################################| Time: 0:00:00 NOTE: Executing RunQueue Tasks NOTE: Tasks Summary: Attempted 2 tasks of which 0 didn't need to be rerun and all succeeded. [INFO] successfully built fsbl

# In order to fetch source ode, please run following command:

petalinux-build -c fsbl -x fetch


# You will see following debug messages:

​petalinux-build -c fsbl -x fetch

[INFO] building fsbl

[INFO] sourcing bitbake

INFO: bitbake fsbl -c fetch Loading cache: 100% |##################################################################################################################################################| Time: 0:00:00 Loaded 3468 entries from dependency cache. Parsing recipes: 100% |################################################################################################################################################| Time: 0:01:10 Parsing of 2577 .bb files complete (2542 cached, 35 parsed). 3469 targets, 133 skipped, 0 masked, 0 errors. NOTE: Resolving any missing task queue dependencies Initialising tasks: 100% |#############################################################################################################################################| Time: 0:00:00 NOTE: Executing RunQueue Tasks NOTE: Tasks Summary: Attempted 1 tasks of which 0 didn't need to be rerun and all succeeded.

INFO: Copying Images from deploy to images

[INFO] successfully built fsbl

# In order to unpack source ode, please run following command:

petalinux-build -c fsbl -x unpack

# You will see following debug messages:

​petalinux-build -c fsbl -x unpack

[INFO] building fsbl

[INFO] sourcing bitbake

INFO: bitbake fsbl -c unpack Loading cache: 100% |##################################################################################################################################################| Time: 0:00:00 Loaded 3468 entries from dependency cache. Parsing recipes: 100% |################################################################################################################################################| Time: 0:00:03 Parsing of 2577 .bb files complete (2542 cached, 35 parsed). 3469 targets, 133 skipped, 0 masked, 0 errors. NOTE: Resolving any missing task queue dependencies Initialising tasks: 100% |#############################################################################################################################################| Time: 0:00:00 NOTE: Executing RunQueue Tasks NOTE: Tasks Summary: Attempted 2 tasks of which 1 didn't need to be rerun and all succeeded.

INFO: Copying Images from deploy to images

[INFO] successfully built fsbl


Modify the source code and Change debug output

The source code location:

./2018.3+gitAUTOINC+56f3da2afb-r0/build/fsbl/xfsbl_main.c


Open this file and locate the following line of code.

​XFsbl_Printf(DEBUG_PRINT_ALWAYS, "Xilinx Zynq MP First Stage Boot Loader \n\r");

Add “changed by Jimmy” at the end of debug message

​XFsbl_Printf(DEBUG_PRINT_ALWAYS, "Xilinx Zynq MP First Stage Boot Loader Changed By Jimmy \n\r");

# In order to rebuild source ode, please run following command:

petalinux-build -c fsbl -x build


# You will see following debug messages:


This command will rebuild fsbl component and generates new zynqmp_fsbl.elf in folder ultra96v2_oob_2018_3/images/linux


​petalinux-build -c fsbl -x build

[INFO] building fsbl

[INFO] sourcing bitbake

INFO: bitbake fsbl -c build Loading cache: 100% |##################################################################################################################################################| Time: 0:00:00 Loaded 3468 entries from dependency cache. Parsing recipes: 100% |################################################################################################################################################| Time: 0:00:18 Parsing of 2577 .bb files complete (2542 cached, 35 parsed). 3469 targets, 133 skipped, 0 masked, 0 errors. NOTE: Resolving any missing task queue dependencies Initialising tasks: 100% |#############################################################################################################################################| Time: 0:00:01 Checking sstate mirror object availability: 100% |#####################################################################################################################| Time: 0:00:01 NOTE: Executing SetScene Tasks NOTE: Executing RunQueue Tasks NOTE: Tasks Summary: Attempted 631 tasks of which 615 didn't need to be rerun and all succeeded.

INFO: Copying Images from deploy to images

[INFO] successfully built fsbl


# Generate new BOOT.bin file

# Before run the command, we should delete old BOOT.bin in folder images/linux

rm images/linux/BOOT.bin


petalinux-package --boot --fsbl images/linux/zynqmp_fsbl.elf --fpga images/linux/system.bit --pmufw images/linux/pmufw.elf --u-boot


​petalinux-package --boot --fsbl images/linux/zynqmp_fsbl.elf --fpga images/linux/system.bit --pmufw images/linux/pmufw.elf --u-boot INFO: File in BOOT BIN: "/home/jimmy/petalinux/2018.3/ultra96v2_oob_2018_3/images/linux/zynqmp_fsbl.elf" INFO: File in BOOT BIN: "/home/jimmy/petalinux/2018.3/ultra96v2_oob_2018_3/images/linux/pmufw.elf"

INFO: File in BOOT BIN: "/home/jimmy/petalinux/2018.3/ultra96v2_oob_2018_3/images/linux/system.bit"

INFO: File in BOOT BIN: "/home/jimmy/petalinux/2018.3/ultra96v2_oob_2018_3/images/linux/bl31.elf"

INFO: File in BOOT BIN: "/home/jimmy/petalinux/2018.3/ultra96v2_oob_2018_3/images/linux/u-boot.elf"

INFO: Generating ZynqMP binary package BOOT.BIN... ****** Xilinx Bootgen v2018.3 **** Build date : Nov 15 2018-19:22:29 ** Copyright 1986-2018 Xilinx, Inc. All Rights Reserved.

INFO: Binary is ready.

# Insert into SD card, and then copy BOOT.bin to sd card boot partition

cp images/linux/BOOT.bin /media/jimmy/boot/


Run new BOOT.bin in the device, it will generate a new debug message with “changed by Jimmy”.


# You will see following debug messages:

Xilinx Zynq MP First Stage Boot Loader changed by Jimmy

Release 2018.3 Apr 11 2022 - 23:12:08

PMUFW: v1.1

U-Boot 2018.01 (Apr 01 2022 - 22:20:21 +0000)

Model: Avnet Ultra96 Rev1

Board: Xilinx ZynqMP I2C: ready

DRAM: 2 GiB EL

Level: EL2

Chip ID: zu3eg

Watchdog: Started MMC: mmc@ff160000: 0 (SD), mmc@ff170000: 1





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/2018.3/peta/tools/xsct/SDK/2018.3/bin/xsct

# you will see following debug message

​****** Xilinx Software Commandline Tool (XSCT) v2018.3

**** SW Build 2390844 on Thu Nov 15 19:17:20 MST 2018

** Copyright 1986-2018 Xilinx, Inc. All Rights Reserved.



xsct%

# run connect command to start hardware server


​xsct% connect

attempting to launch hw_server

****** Xilinx hw_server v2018.3

**** Build date : Nov 15 2018-19:35:59

** Copyright 1986-2018 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%


# 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

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

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/2018.3/ultra96v2_oob_2018_3/images/linux/pmufw.elf to the target."

dow "/home/jimmy/petalinux/2018.3/ultra96v2_oob_2018_3/images/linux/pmufw.elf"

after 2000

con

targets -set -nocase -filter {name =~ "*APU*"}

mwr 0xffff0000 0x14000000

mask_write 0xFD1A0104 0x501 0x0

targets -set -nocase -filter {name =~ "*A53*#0"}


source /home/jimmy/petalinux/2018.3/ultra96v2_oob_2018_3/project-spec/hw-description/psu_init.tcl

puts stderr "INFO: Downloading ELF file: /home/jimmy/petalinux/2018.3/ultra96v2_oob_2018_3/images/linux/zynqmp_fsbl.elf to the target."

dow "/home/jimmy/petalinux/2018.3/ultra96v2_oob_2018_3/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: Downloading ELF file: /home/jimmy/petalinux/2018.3/ultra96v2_oob_2018_3/images/linux/u-boot.elf to the target."

dow "/home/jimmy/petalinux/2018.3/ultra96v2_oob_2018_3/images/linux/u-boot.elf"

after 2000

targets -set -nocase -filter {name =~ "*A53*#0"}

puts stderr "INFO: Downloading ELF file: /home/jimmy/petalinux/2018.3/ultra96v2_oob_2018_3/images/linux/bl31.elf to the target."

dow "/home/jimmy/petalinux/2018.3/ultra96v2_oob_2018_3/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/2018.3/ultra96v2_oob_2018_3/images/linux/pmufw.elf to the target.

Downloading Program -- /home/jimmy/petalinux/2018.3/ultra96v2_oob_2018_3/images/linux/pmufw.elf

section, .vectors.reset: 0xffdc0000 - 0xffdc0007

section, .vectors.sw_exception: 0xffdc0008 - 0xffdc000f

section, .vectors.interrupt: 0xffdc0010 - 0xffdc0017

section, .vectors.hw_exception: 0xffdc0020 - 0xffdc0027

section, .text: 0xffdc0050 - 0xffdd0527

section, .rodata: 0xffdd0528 - 0xffdd266f

section, .data: 0xffdd2670 - 0xffdd66e7

section, .sdata2: 0xffdd66e8 - 0xffdd66e7

section, .sdata: 0xffdd66e8 - 0xffdd66e7

section, .sbss: 0xffdd66e8 - 0xffdd66e7

section, .bss: 0xffdd6700 - 0xffdda78f

section, .srdata: 0xffdda790 - 0xffddb09f

section, .stack: 0xffddb0a0 - 0xffddc09f

section, .xpbr_serv_ext_tbl: 0xffddf6e0 - 0xffddfadf

100% 0MB 0.2MB/s 00:00

Setting PC to Program Start Address 0xffdcfa7c

Successfully downloaded /home/jimmy/petalinux/2018.3/ultra96v2_oob_2018_3/images/linux/pmufw.elf

INFO: Downloading ELF file: /home/jimmy/petalinux/2018.3/ultra96v2_oob_2018_3/images/linux/zynqmp_fsbl.elf to the target.

Downloading Program -- /home/jimmy/petalinux/2018.3/ultra96v2_oob_2018_3/images/linux/zynqmp_fsbl.elf

section, .text: 0xfffc0000 - 0xfffce13b

section, .init: 0xfffce140 - 0xfffce173

section, .fini: 0xfffce180 - 0xfffce1b3

section, .note.gnu.build-id: 0xfffce1b4 - 0xfffce1d7

section, .rodata: 0xfffce200 - 0xfffce63f

section, .sys_cfg_data: 0xfffce640 - 0xfffcee07

section, .mmu_tbl0: 0xfffcf000 - 0xfffcf00f

section, .mmu_tbl1: 0xfffd0000 - 0xfffd1fff

section, .mmu_tbl2: 0xfffd2000 - 0xfffd5fff

section, .data: 0xfffd6000 - 0xfffd71a7

section, .sbss: 0xfffd71a8 - 0xfffd71bf

section, .bss: 0xfffd71c0 - 0xfffd91bf

section, .heap: 0xfffd91c0 - 0xfffd95bf

section, .stack: 0xfffd95c0 - 0xfffdb5bf

section, .dup_data: 0xfffdb5c0 - 0xfffdc767

section, .handoff_params: 0xfffe9e00 - 0xfffe9e87

section, .bitstream_buffer: 0xffff0040 - 0xfffffc3f

100% 0MB 0.1MB/s 00:00

Setting PC to Program Start Address 0xfffc0000

Successfully downloaded /home/jimmy/petalinux/2018.3/ultra96v2_oob_2018_3/images/linux/zynqmp_fsbl.elf

INFO: Downloading ELF file: /home/jimmy/petalinux/2018.3/ultra96v2_oob_2018_3/images/linux/u-boot.elf to the target.

Downloading Program -- /home/jimmy/petalinux/2018.3/ultra96v2_oob_2018_3/images/linux/u-boot.elf

section, .data: 0x08000000 - 0x0808a567

100% 0MB 0.2MB/s 00:03

Setting PC to Program Start Address 0x08000000

Successfully downloaded /home/jimmy/petalinux/2018.3/ultra96v2_oob_2018_3/images/linux/u-boot.elf

INFO: Downloading ELF file: /home/jimmy/petalinux/2018.3/ultra96v2_oob_2018_3/images/linux/bl31.elf to the target.

Downloading Program -- /home/jimmy/petalinux/2018.3/ultra96v2_oob_2018_3/images/linux/bl31.elf

section, .text: 0xfffea000 - 0xffff1fff

section, .rodata: 0xffff2000 - 0xffff2fff

section, .data: 0xffff3000 - 0xffff6a1f

section, stacks: 0xffff6a40 - 0xffff7b3f

section, .bss: 0xffff7b40 - 0xffff88d3

section, xlat_table: 0xffff9000 - 0xffffdfff

section, coherent_ram: 0xffffe000 - 0xffffefff

100% 0MB 0.2MB/s 00:00

Setting PC to Program Start Address 0xfffea000

Successfully downloaded /home/jimmy/petalinux/2018.3/ultra96v2_oob_2018_3/images/linux/bl31.elf




# You will see following debug message from minicom/hyperterminal


Xilinx Zynq MP First Stage Boot Loader changed by Jimmy

Release 2018.3 Apr 11 2022 - 23:12:08

PMUFW: v1.1

U-Boot 2018.01 (Apr 12 2022 - 01:35:13 +0000)

Model: Avnet Ultra96 Rev1

Board: Xilinx ZynqMP

I2C: ready

DRAM: 2 GiB

EL Level: EL2

Chip ID: zu3eg

Watchdog: Started By Jimmy

MMC: mmc@ff160000: 0 (SD), mmc@ff170000: 1

*** Warning - bad CRC, using default environment


In: serial@ff010000

Out: serial@ff010000

Err: serial@ff010000

Model: Avnet Ultra96 Rev1

Board: Xilinx ZynqMP

Bootmode: JTAG_MODE

Net: Net Initialization Skipped

No ethernet found.

U-BOOT for ultra96v2-oob-2018-3


Hit any key to stop autoboot: 0

Device: mmc@ff160000

Manufacturer ID: 95

OEM: 5355

Name:

Tran Speed: 50000000

Rd Block Len: 512

SD version 3.0

High Capacity: Yes

Capacity: 29.8 GiB

Bus Width: 4-bit

Erase Group Size: 512 Bytes

reading image.ub

9520292 bytes read in 747 ms (12.2 MiB/s)

## Loading kernel from FIT Image at 10000000 ...

Using 'conf-system-top.dtb' configuration



35 views0 comments