在本篇博文中,我们将演示如何在 Versal AI Core 系列 VCK190 评估套件上从 USB 辅助启动模式启动 Linux。
为此,我们将修改启动镜像格式 (BIF),使用 Vivado 2020.2 通过 USB 来加载第二个可编程器件镜像 (PDI)。
【资料图】
我们将使用 JTAG 作为第一个启动器件来加载 Platform Loader and Manager (PLM),使用 USB 作为第二个启动器件来加载其他分区(A72、u-boot 和 Linux)。
硬件设置:
使用 USB 线将 VCK190 上的 J308 连接到 PC 主机。将 SW1 跳线设置为 JTAG 模式。
请参阅以下截屏,查找 JTAG 启动模式设置:
模块框图:
注释:默认情况下,在 PetaLinux BSP 中启用 USB 控制器。
修改 Bootgen 和 BIF 文件以创建启动镜像
我们将基于 Vivado/PetaLinux 生成的 BIF 文件来创建 2 个 BIF 文件。
1. 第一个 BIF 用于生成 PDI,用于从主启动器件启动 PLM。在此示例中,使用的是 JTAG。
我们将第一个 BIF 命名为 A72_primary.bif
有两点值得注意:
必须将“boot_device {usb}”添加到 BIF 中。这样 PLM 即可明确 USB 为辅助启动器件。
使用 plm.elf 代替 executable.elf。executable.elf 供 Vivado 用于生成 PDI,但它不支持使用 USB 作为辅助启动器件。因此,我们需要使用 Vitis/PetaLinux 中生成的 plm.elf。
A72_primary.bif:
2. 第二个 BIF 用于生成 PDI,其中包含 u-boot 并通过 USB 器件固件升级 (DFU) 来加载。
我们将第二个 BIF 命名为 A72_secondary.bif
A72_secondary.bif:
A72_secondary.bif
3. 使用 Bootgen 通过以下命令生成主启动镜像和辅助启动镜像。
主启动镜像:
bootgen -arch versal -image a72_primary.bif -w -o boot_primary.bin****** Xilinx Bootgen v2020.2**** Build date : Nov 18 2020-09:50:31** Copyright 1986-2020 Xilinx, Inc. All Rights Reserved.bootgen -arch versal -image a72_primary.bif -w -o boot_primary.bin****** Xilinx Bootgen v2020.2**** Build date : Nov 18 2020-09:50:31** Copyright 1986-2020 Xilinx, Inc. All Rights Reserved.
[WARNING]: BOOTGEN_POST_PROCESSING is enabled, CDOs will be post processed
[INFO] : Bootimage generated successfully
辅助启动镜像:bootgen -arch versal -image a72_secondary.bif -w -o boot_secondary.bin****** Xilinx Bootgen v2020.2**** Build date : Nov 18 2020-09:50:31** Copyright 1986-2020 Xilinx, Inc. All Rights Reserved.
[WARNING]: BOOTGEN_POST_PROCESSING is enabled, CDOs will be post processed
[INFO] : Bootimage generated successfully
将镜像下载至开发板
1.在目标器件上使用 JTAG 加载 boot_primary.bin 镜像
2. 打印以下消息后,PLM 应等待辅助镜像。[7.667278]Xilinx Versal Platform Loader and Manager[12.376881]Release 2020.2 Aug 31 2020 - 09:50:03[17.085931]Platform Version: v1.0 PMC: v1.0, PS: v1.0[21.881875]STDOUT: PS UART[24.324281]****************************************[28.985971] 24.515056 ms for PrtnNum: 1, Size: 2432 Bytes[34.094090]-------Loading Prtn No: 0x2[38.309037] 0.692037 ms for PrtnNum: 2, Size: 48 Bytes[42.467100]-------Loading Prtn No: 0x3[96.268506] 50.276421 ms for PrtnNum: 3, Size: 56912 Bytes[98.652475]-------Loading Prtn No: 0x4[102.562750] 0.388331 ms for PrtnNum: 4, Size: 2512 Bytes[107.286018]-------Loading Prtn No: 0x5[110.907934] 0.013368 ms for PrtnNum: 5, Size: 3424 Bytes[116.006421]-------Loading Prtn No: 0x6[119.620971] 0.004568 ms for PrtnNum: 6, Size: 80 Bytes[124.622246]+++++++Loading Image No: 0x2, Name: pl_cfi, Id: 0x18700000[130.830893]-------Loading Prtn No: 0x7[5791.450975] 5657.002021 ms for PrtnNum: 7, Size: 8407952 Bytes[5794.366281]-------Loading Prtn No: 0x8[6174.214668] 376.148515 ms for PrtnNum: 8, Size: 539520 Bytes[6176.999787]+++++++Loading Image No: 0x3, Name: aie_subsys, Id: 0x0421C005[6183.671081]-------Loading Prtn No: 0x9[6190.315521] 2.944596 ms for PrtnNum: 9, Size: 352 Bytes[6192.665846]+++++++Loading Image No: 0x4, Name: fpd, Id: 0x0420C003[6198.726037]-------Loading Prtn No: 0xA[6203.102859] 0.679168 ms for PrtnNum: 10, Size: 1136 Bytes[6207.766790]Loading PDI from USB[6210.762365]Monolithic/Master Device
3. 检查确认 DFU 能否检测到 USB 目标。$ sudo dfu-util -lUSB 器件应使用 VendorId : ProductId(即 03fd:0050)进行枚举。
您应看到如下输出:Found DFU: [03fd:0050] devnum=0, cfg=1, intf=0, alt=1, name="Xilinx DFU Downloader
注释:如果您未看到“Found DFU”消息,请验证连接,然后重试。
4. 在 PC 主机上运行以下命令以使用 dfu-util 将辅助镜像 boot_secondary.bin 下载到 VCK190。sudo dfu-util d 03fd:0050 -D boot_secondary.bin
检查 UART 0 终端,等待至 U-Boot 加载完成。这样将显示 u-boot 控制台。
5. 出现 U-Boot 提示后,输入 Enter 以终止自动启动。在 UART1 控制台中验证应用是否已加载成功。
6. 在 U-Boot 控制台中,启动 DFU_RAM 以启用 Linux 镜像下载:U-boot> run dfu_ram
7. 使用以下命令从“Host Machine Terminal”(主机终端)下载 Linux 镜像和 system.dtb:$ sudo dfu-util -l
以上命令显示了 DFU RAM 的 alt 信息,如下所示:Found DFU: [03fd:0300] devnum=0, cfg=1, intf=0, alt=0, name="Image"Found DFU: [03fd:0300] devnum=0, cfg=1, intf=0, alt=1, name="system.dtb"Found DFU: [03fd:0300] devnum=0, cfg=1, intf=0, alt=0, name="Image"Found DFU: [03fd:0300] devnum=0, cfg=1, intf=0, alt=1, name="system.dtb"1. dfu-util -d 03fd:0300 -D ./Image -a 02. dfu-util -d 03fd:0300 -D ./system.dtb -a 1
8. 在 U-Boot 上看到 DOWNLOAD 消息后,请在 U-Boot 控制台上使用 Ctrl+C 停止 dfu_ram。##DOWNLOAD ... OK
按 Ctrl+C 退出。
9. 从 U-Boot 控制台运行 booti 命令以运行 Linux。U-boot> booti 0x18000000 - 0x40000000(请在 U-Boot 环境内检查此地址)
10. 验证在目标器件上是否已成功加载 Linux。
主机侧日志root@machine_id:~# dfu-util -ldfu-util 0.5
(C) 2005-2008 by Weston Schmidt, Harald Welte and OpenMoko Inc.(C) 2010-2011 Tormod Volden (DfuSe support)This program is Free Software and has ABSOLUTELY NO WARRANTY
dfu-util does currently only support DFU version 1.0
Found DFU: [03fd:0050] devnum=0, cfg=1, intf=0, alt=1, name="Xilinx DFU Downloader"
root@machine_id:~# dfu-util -D boot_secondary.bindfu-util 0.5
(C) 2005-2008 by Weston Schmidt, Harald Welte and OpenMoko Inc.(C) 2010-2011 Tormod Volden (DfuSe support)This program is Free Software and has ABSOLUTELY NO WARRANTY
dfu-util does currently only support DFU version 1.0
Opening DFU USB device... ID 03fd:0050Run-time device DFU version 0110Found DFU: [03fd:0050] devnum=0, cfg=1, intf=0, alt=1, name="Xilinx DFU Downloader"Claiming USB DFU Interface...Setting Alternate Setting #1 ...Determining device status: state = dfuIDLE, status = 0dfuIDLE, continuingDFU mode device DFU version 0110Device returned transfer size 1024No valid DFU suffix signatureWarning: File has no DFU suffixbytes_per_hash=19961Copying data from PC to DFU deviceStarting download: [##################################################] finished!state(2) = dfuIDLE, status(0) = No error condition is presentDone!
root@machine_id:~# dfu-util -ldfu-util 0.5
(C) 2005-2008 by Weston Schmidt, Harald Welte and OpenMoko Inc.(C) 2010-2011 Tormod Volden (DfuSe support)This program is Free Software and has ABSOLUTELY NO WARRANTY
dfu-util does currently only support DFU version 1.0
Found DFU: [03fd:0300] devnum=0, cfg=1, intf=0, alt=0, name="Image"Found DFU: [03fd:0300] devnum=0, cfg=1, intf=0, alt=1, name="system.dtb"root@machine_id:~#root@machine_id:~#root@machine_id:~# cp -rf /proj/css/Aravind_babu/Image .root@machine_id:~# cp -rf /proj/css/Aravind_babu/system.dtb .root@machine_id:~#
root@machine_id:~# dfu-util -d 03fd:0300 -D Image -a 0dfu-util 0.5
(C) 2005-2008 by Weston Schmidt, Harald Welte and OpenMoko Inc.(C) 2010-2011 Tormod Volden (DfuSe support)This program is Free Software and has ABSOLUTELY NO WARRANTY
dfu-util does currently only support DFU version 1.0
Filter on vendor = 0x03fd product = 0x0300Opening DFU USB device... ID 03fd:0300Run-time device DFU version 0110Found DFU: [03fd:0300] devnum=0, cfg=1, intf=0, alt=0, name="Image"Claiming USB DFU Interface...Setting Alternate Setting #0 ...Determining device status: state = dfuIDLE, status = 0dfuIDLE, continuingDFU mode device DFU version 0110Device returned transfer size 4096No valid DFU suffix signatureWarning: File has no DFU suffixbytes_per_hash=347678Copying data from PC to DFU deviceStarting download: [##################################################] finished!state(7) = dfuMANIFEST, status(0) = No error condition is presentstate(2) = dfuIDLE, status(0) = No error condition is presentDone!
root@machine_id:~# dfu-util -d 03fd:0300 -D system.dtb -a 1dfu-util 0.5
(C) 2005-2008 by Weston Schmidt, Harald Welte and OpenMoko Inc.(C) 2010-2011 Tormod Volden (DfuSe support)This program is Free Software and has ABSOLUTELY NO WARRANTY
dfu-util does currently only support DFU version 1.0
Filter on vendor = 0x03fd product = 0x0300Opening DFU USB device... ID 03fd:0300Run-time device DFU version 0110Found DFU: [03fd:0300] devnum=0, cfg=1, intf=0, alt=1, name="system.dtb"Claiming USB DFU Interface...Setting Alternate Setting #1 ...Determining device status: state = dfuIDLE, status = 0dfuIDLE, continuingDFU mode device DFU version 0110Device returned transfer size 4096No valid DFU suffix signatureWarning: File has no DFU suffixbytes_per_hash=832Copying data from PC to DFU deviceStarting download: [##################################################] finished!state(7) = dfuMANIFEST, status(0) = No error condition is presentstate(2) = dfuIDLE, status(0) = No error condition is presentDone!
log 日志
[7.667278]Xilinx Versal Platform Loader and Manager[12.376881]Release 2020.2 Aug 31 2020 - 09:50:03[17.085931]Platform Version: v1.0 PMC: v1.0, PS: v1.0[21.881875]STDOUT: PS UART[24.324281]****************************************[28.985971] 24.515056 ms for PrtnNum: 1, Size: 2432 Bytes[34.094090]-------Loading Prtn No: 0x2[38.309037] 0.692037 ms for PrtnNum: 2, Size: 48 Bytes[42.467100]-------Loading Prtn No: 0x3[96.268506] 50.276421 ms for PrtnNum: 3, Size: 56912 Bytes[98.652475]-------Loading Prtn No: 0x4[102.562750] 0.388331 ms for PrtnNum: 4, Size: 2512 Bytes[107.286018]-------Loading Prtn No: 0x5[110.907934] 0.013368 ms for PrtnNum: 5, Size: 3424 Bytes[116.006421]-------Loading Prtn No: 0x6[119.620971] 0.004568 ms for PrtnNum: 6, Size: 80 Bytes[124.622246]+++++++Loading Image No: 0x2, Name: pl_cfi, Id: 0x18700000[130.830893]-------Loading Prtn No: 0x7[5791.450975] 5657.002021 ms for PrtnNum: 7, Size: 8407952 Bytes[5794.366281]-------Loading Prtn No: 0x8[6174.214668] 376.148515 ms for PrtnNum: 8, Size: 539520 Bytes[6176.999787]+++++++Loading Image No: 0x3, Name: aie_subsys, Id: 0x0421C005[6183.671081]-------Loading Prtn No: 0x9[6190.315521] 2.944596 ms for PrtnNum: 9, Size: 352 Bytes[6192.665846]+++++++Loading Image No: 0x4, Name: fpd, Id: 0x0420C003[6198.726037]-------Loading Prtn No: 0xA[6203.102859] 0.679168 ms for PrtnNum: 10, Size: 1136 Bytes[6207.766790]Loading PDI from USB[6210.762365]Monolithic/Master Device[14602.209878]8394.398825 ms: PDI initialization time[14604.323262]+++++++Loading Image No: 0x0, Name: apu_subsyste, Id: 0x1C000000[14611.146703]-------Loading Prtn No: 0x0[14614.942668] 0.012150 ms for PrtnNum: 0, Size: 41632 Bytes[14620.302859]-------Loading Prtn No: 0x1[14624.102159] 0.015812 ms for PrtnNum: 1, Size: 59360 Bytes[14629.458853]-------Loading Prtn No: 0x2[14633.428109] 0.185400 ms for PrtnNum: 2, Size: 896512 Bytes[14638.786881]***********Boot PDI Load: Done*************[14643.873331]765870.806637 ms: ROM Time[14647.508740]Total PLM Boot TimeNOTICE: ATF running on Xilinx Versal SiliconWARNING: BL31: invalid exception level (3)NOTICE: BL31: Secure code at 0x0NOTICE: BL31: Non secure code at 0x8000000NOTICE: BL31: v2.2(debug):rel-v2020.2_SAM_EA2-1-g3e90bb84fNOTICE: BL31: Built : 13:22:27, Aug 28 2020INFO: GICv3 with legacy support detected. ARM GICv3 driver initialized in EL3INFO: BL31: Initializing runtime servicesWARNING: BL31: cortex_a72: CPU workaround for 859971 was missing!INFO: BL31: cortex_a72: CPU workaround for cve_2017_5715 was appliedINFO: BL31: cortex_a72: CPU workaround for cve_2018_3639 was appliedINFO: BL31: Preparing for EL3 exit to normal worldINFO: Entry point address = 0x8000000INFO: SPSR = 0x3c9
U-Boot 2020.01 (Sep 02 2020 - 08:11:32 +0000)
Model: Xilinx Versal vck190 Eval board revA (QSPI)DRAM: 6 GiBEL Level: EL2MMC: sdhci@f1050000: 0In: serial@ff000000Out: serial@ff000000Err: serial@ff000000Bootmode: JTAG_MODENet:ZYNQ GEM: ff0c0000, mdio bus ff0c0000, phyaddr 1, interface rgmii-id
Warning: ethernet@ff0c0000 (eth0) using random MAC address - 86:d3:1d:bd:e8:8eeth0: ethernet@ff0c0000ZYNQ GEM: ff0d0000, mdio bus ff0c0000, phyaddr 2, interface rgmii-id
Warning: ethernet@ff0d0000 (eth1) using random MAC address - 76:8d:63:c4:fe:17, eth1: ethernet@ff0d0000Hit any key to stop autoboot: 0Versal>Versal> run dfu_ram#DOWNLOAD ... OKCtrl+C to exit ...#DOWNLOAD ... OKCtrl+C to exit ...Versal>Versal> priarch=armbaudrate=115200board=versalboard_name=versalboot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefix}${script}; source ${scriptaddr}boot_efi_binary=if fdt addr ${fdt_addr_r}; then bootefi bootmgr ${fdt_addr_r};else bootefi bootmgr ${fdtcontroladdr};fi;load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} efi/boot/bootaa64.efi; if fdt addr ${fdt_addr_r}; then bootefi ${kernel_addr_r} ${fdt_addr_r};else bootefi ${kernel_addr_r} ${fdtcontroladdr};fiboot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}${boot_syslinux_conf}boot_net_usb_start=usb startboot_prefixes=/ /boot/boot_script_dhcp=boot.scr.uimgboot_scripts=boot.scr.uimg boot.scrboot_syslinux_conf=extlinux/extlinux.confboot_targets=jtag pxe dhcp jtag mmc0 mmc1 xspi0 dfu_usb pxe dhcpbootcmd=run distro_bootcmdbootcmd_dfu_usb=setenv dfu_alt_info boot.scr ram $scriptaddr $script_size_f; dfu 0 ram 0 && echo DFU: Trying to boot script at ${scriptaddr} && source ${scriptaddr}; echo DFU: SCRIPT FAILED: continuing...;bootcmd_dhcp=run boot_net_usb_start; if dhcp ${scriptaddr} ${boot_script_dhcp}; then source ${scriptaddr}; fi;setenv efi_fdtfile ${fdtfile}; setenv efi_old_vci ${bootp_vci};setenv efi_old_arch ${bootp_arch};setenv bootp_vci PXEClient:Arch:00011:UNDI:003000;setenv bootp_arch 0xb;if dhcp ${kernel_addr_r}; then tftpboot ${fdt_addr_r} dtb/${efi_fdtfile};if fdt addr ${fdt_addr_r}; then bootefi ${kernel_addr_r} ${fdt_addr_r}; else bootefi ${kernel_addr_r} ${fdtcontroladdr};fi;fi;setenv bootp_vci ${efi_old_vci};setenv bootp_arch ${efi_old_arch};setenv efi_fdtfile;setenv efi_old_arch;setenv efi_old_vci;bootcmd_jtag=echo JTAG: Trying to boot script at ${scriptaddr} && source ${scriptaddr}; echo JTAG: SCRIPT FAILED: continuing...;bootcmd_mmc0=devnum=0; run mmc_bootbootcmd_mmc1=devnum=1; run mmc_bootbootcmd_pxe=run boot_net_usb_start; dhcp; if pxe get; then pxe boot; fibootcmd_xspi0=sf probe 0 0 0 && sf read $scriptaddr $script_offset_f $script_size_f && echo XSPI: Trying to boot script at ${scriptaddr} && source ${scriptaddr}; echo XSPI: SCRIPT FAILED: continuing...;bootdelay=5bootm_low=0bootm_size=80000000cpu=armv8dfu_alt_info=Image ram 0x18000000 0x10000000;system.dtb ram 0x40000000 0x400000dfu_ram=run dfu_ram_info && dfu 0 ram 0dfu_ram_info=setenv dfu_alt_info Image ram $kernel_addr_r $kernel_size_r\\;system.dtb ram $fdt_addr_r $fdt_size_rdistro_bootcmd=for target in ${boot_targets}; do run bootcmd_${target}; doneefi_dtb_prefixes=/ /dtb/ /dtb/current/fdt_addr_r=0x40000000fdt_high=10000000fdt_size_r=0x400000fdtcontroladdr=7ded9b20initrd_high=79000000kernel_addr_r=0x18000000kernel_size_r=0x10000000load_efi_dtb=load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${prefix}${efi_fdtfile}mmc_boot=if mmc dev ${devnum}; then devtype=mmc; run scan_dev_for_boot_part; fipxefile_addr_r=0x10000000ramdisk_addr_r=0x02100000scan_dev_for_boot=echo Scanning ${devtype} ${devnum}:${distro_bootpart}...; for prefix in ${boot_prefixes}; do run scan_dev_for_extlinux; run scan_dev_for_scripts; done;run scan_dev_for_efi;scan_dev_for_boot_part=part list ${devtype} ${devnum} -bootable devplist; env exists devplist || setenv devplist 1; for distro_bootpart in ${devplist}; do if fstype ${devtype} ${devnum}:${distro_bootpart} bootfstype; then run scan_dev_for_boot; fi; done; setenv devplistscan_dev_for_efi=setenv efi_fdtfile ${fdtfile}; for prefix in ${efi_dtb_prefixes}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${efi_fdtfile}; then run load_efi_dtb; fi;done;if test -e ${devtype} ${devnum}:${distro_bootpart} efi/boot/bootaa64.efi; then echo Found EFI removable media binary efi/boot/bootaa64.efi; run boot_efi_binary; echo EFI LOAD FAILED: continuing...; fi; setenv efi_fdtfilescan_dev_for_extlinux=if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${boot_syslinux_conf}; then echo Found ${prefix}${boot_syslinux_conf}; run boot_extlinux; echo SCRIPT FAILED: continuing...; fiscan_dev_for_scripts=for script in ${boot_scripts}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${script}; then echo Found U-Boot script ${prefix}${script}; run boot_a_script; echo SCRIPT FAILED: continuing...; fi; donescript_offset_f=7f80000script_size_f=0x80000scriptaddr=0x20000000soc=versalstderr=serial@ff000000stdin=serial@ff000000stdout=serial@ff000000thor_ram=run dfu_ram_info && thordown 0 ram 0ubifs_boot=env exists bootubipart || env set bootubipart UBI; env exists bootubivol || env set bootubivol boot; if ubi part ${bootubipart} && ubifsmount ubi${devnum}:${bootubivol}; then devtype=ubi; run scan_dev_for_boot; fiusb_boot=usb start; if usb dev ${devnum}; then devtype=usb; run scan_dev_for_boot_part; fivendor=xilinx
Environment size: 4783/32764 bytes
Versal> booti 0x18000000 - 0x40000000## Flattened Device Tree blob at 40000000Booting using the fdt blob at 0x40000000Loading Device Tree to 000000000fff2000, end 000000000ffff294 ... OK
Starting kernel ...
[ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd083][ 0.000000] Linux version 5.4.0-xilinx-v2020.1 (oe-user@oe-host) (gcc version 9.2.0 (GCC)) #1 SMP Wed Sep 2 08:07:18 UTC 2020[ 0.000000] Machine model: Xilinx Versal vck190 Eval board revA (QSPI)[ 0.000000] earlycon: pl11 at MMIO32 0x00000000ff000000 (options "115200n8")[ 0.000000] printk: bootconsole [pl11] enabled[ 0.000000] efi: Getting EFI parameters from FDT:[ 0.000000] efi: UEFI not found.[ 0.000000] cma: Reserved 256 MiB at 0x0000000070000000[ 0.000000] psci: probing for conduit method from DT.[ 0.000000] psci: PSCIv1.1 detected in firmware.[ 0.000000] psci: Using standard PSCI v0.2 function IDs[ 0.000000] psci: MIGRATE_INFO_TYPE not supported.[ 0.000000] psci: SMC Calling Convention v1.1[ 0.000000] percpu: Embedded 22 pages/cpu s49880 r8192 d32040 u90112[ 0.000000] Detected PIPT I-cache on CPU0[ 0.000000] CPU features: detected: GIC system register CPU interface
....
root@xilinx-vck190-es1-2020_2:~#
注释:请在启动镜像和 log 日志中找到随附的 BIF 文件。
关键词: