Monday, January 29, 2024

RISC-v on ZC706 Evaluation Board - Part V: Running Petalinux

Follow up on RISC-v on ZC706 Evaluation Board - Part IV: petalinux. As mentioned in the previous post, I didn't have tftp setup on my host PC. With 'BOOT.BIN' copied to SD card, when booting up the board, U-Boot will look for tftp server, and trying to download Linux image from there. I guess it is possible to copy the Linux image to the SD card and boot from there. But let's setup the tftp server, then it be more convenience to update the Linux image without the need to transfer image to the SD card, why not? It's also possible to run SCP on the ZC706 EV board to copy image to SD card.

It's very easy to setup tftp (Trivial File Transfer Protocol). Searching Internet may recommend tftp-hpa, which is an enhanced version of the BSD TFTP client and server. It possesses a number of bugfixes and enhancements over the original. May follow this to setup tftp backed by xinetd. If cannot update /etc/xinetd.d/tftp file, and 'sudo kill -HUP pid_of_inetd' doesn't help, then try 'sudo kill -9 pid_of_inetd'. Then restart xinetd with: sudo /etc/init.d/xinetd restart

There might be multiple tftp servers on the same subnet, so may need to specify the server on the ZC706 board. This can be done with cmd:

setenv serverip 192.168.1.117

Somehow, it still try to download from the other tftp server. So I tried to boot the image with QEMU:

 source petalinux/settings.sh
 petalinux-boot --qemu --prebuilt 2

It can boot to Linux, and will ask for login credential, and 'root/root' doesn't work. Per https://docs.xilinx.com/r/en-US/ug1144-petalinux-tools-reference-guide/Login-Changes, the root account is disabled, The default user is petalinux and the password should be set on first boot. For me, using both 2 and 3 for prebuilt option will boot to Linux, but with 2, it will show more information for uboot boot.

Refer to QEMU User Documentation for how to use QEMU, such as:

To quit the emulation, press CTRL+A followed by X. To switch
between the serial port and the monitor, use CTRL+A followed by C.

Now, back to the UBoot with tftp, do a power cycle and press 'space' key within 3 seconds to pause UBoot. printenv shows:

arch=arm
baudrate=115200
board=zynq
board_name=zynq
boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefix}${script}; source ${scriptaddr}
boot_efi_binary=load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} efi/boot/bootarm.efi; if fdt addr ${fdt_addr_r}; i
boot_efi_bootmgr=if fdt addr ${fdt_addr_r}; then bootefi bootmgr ${fdt_addr_r};else bootefi bootmgr;fi
boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}${boot_syslinux_conf}
boot_net_usb_start=usb start
boot_prefixes=/ /boot/
boot_script_dhcp=boot.scr.uimg
boot_scripts=boot.scr.uimg boot.scr
boot_syslinux_conf=extlinux/extlinux.conf
boot_targets=mmc0 jtag mmc0 mmc1 qspi nand nor usb0 usb1 pxe dhcp
bootcmd=run distro_bootcmd
bootcmd_dhcp=devtype=dhcp; run boot_net_usb_start; if dhcp ${scriptaddr} ${boot_script_dhcp}; then source ${scriptaddr}; fi;set;
bootcmd_jtag=echo JTAG: Trying to boot script at ${scriptaddr} && source ${scriptaddr}; echo JTAG: SCRIPT FAILED: continuing...;
bootcmd_mmc0=devnum=0; run mmc_boot
bootcmd_mmc1=devnum=1; run mmc_boot
bootcmd_nand=nand info && nand read ${scriptaddr} ${script_offset_f} ${script_size_f} && echo NAND: Trying to boot script at ${;
bootcmd_nor=cp.b ${script_offset_nor} ${scriptaddr} ${script_size_f} && echo NOR: Trying to boot script at ${scriptaddr} && sou;
bootcmd_pxe=run boot_net_usb_start; dhcp; if pxe get; then pxe boot; fi
bootcmd_qspi=sf probe 0 0 0 && sf read ${scriptaddr} ${script_offset_f} ${script_size_f} && echo QSPI: Trying to boot script at;
bootcmd_usb0=devnum=0; run usb_boot
bootcmd_usb1=devnum=1; run usb_boot
bootcmd_usb_dfu0=setenv dfu_alt_info boot.scr ram $scriptaddr $script_size_f && dfu 0 ram 0 60 && echo DFU0: Trying to boot scr;
bootcmd_usb_dfu1=setenv dfu_alt_info boot.scr ram $scriptaddr $script_size_f && dfu 1 ram 1 60 && echo DFU1: Trying to boot scr;
bootcmd_usb_thor0=setenv dfu_alt_info boot.scr ram $scriptaddr $script_size_f && thordown 0 ram 0 && echo THOR0: Trying to boot;
bootcmd_usb_thor1=setenv dfu_alt_info boot.scr ram $scriptaddr $script_size_f && thordown 1 ram 1 && echo THOR1: Trying to boot;
bootdelay=2
bootfile=pxelinux.0
bootfstype=fat
bootm_low=0
bootm_size=30000000
cpu=armv7
dfu_alt_info=mmc 0:1=boot.bin fat 0 1;u-boot.img fat 0 1
distro_bootcmd=for target in ${boot_targets}; do run bootcmd_${target}; done
efi_dtb_prefixes=/ /dtb/ /dtb/current/
ethact=ethernet@e000b000
ethaddr=??:??:??:??:??:??
fdt_addr_r=0x1f00000
fdtcontroladdr=3eadf220
ipaddr=x.x.x.x
kernel_addr_r=0x2000000
load_efi_dtb=load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${prefix}${efi_fdtfile}
loadaddr=0x0
mmc_boot=if mmc dev ${devnum}; then devtype=mmc; run scan_dev_for_boot_part; fi
modeboot=sdboot
pxefile_addr_r=0x2000000
ramdisk_addr_r=0x3100000
scan_dev_for_boot=echo Scanning ${devtype} ${devnum}:${distro_bootpart}...; for prefix in ${boot_prefixes}; do run scan_dev_for;
scan_dev_for_boot_part=part list ${devtype} ${devnum} -bootable devplist; env exists devplist || setenv devplist 1; for distro_t
scan_dev_for_efi=setenv efi_fdtfile ${fdtfile}; if test -z "${fdtfile}" -a -n "${soc}"; then setenv efi_fdtfile ${soc}-${board}e
scan_dev_for_extlinux=if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${boot_syslinux_conf}; then echo Found ${prefi
scan_dev_for_scripts=for script in ${boot_scripts}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${script}; te
script_offset_f=9c0000
script_offset_nor=0xE2FC0000
script_size_f=0x40000
scriptaddr=3000000
serverip=y.y.y.y
soc=zynq
stderr=serial@e0001000
stdin=serial@e0001000
stdout=serial@e0001000
ubifs_boot=env exists bootubipart || env set bootubipart UBI; env exists bootubivol || env set bootubivol boot; if ubi part ${bi
usb_boot=usb start; if usb dev ${devnum}; then devtype=usb; run scan_dev_for_boot_part; fi
vendor=xilinx
ethaddr, ipaddr and serverip are all set valid value, somehow it will keep trying a different tftp server. With uboot paused, manually issue 'bootcmd' will make it able to load from the desired tftp server. May get lot of network error, but after multiple retries, it should be able to load pxelinux.0, rootfs.cpio.gz.u-boot, zImage, system.dtb, then start the kernel successfully. uname -a =>

Linux xilinx-zc706-2022_2 5.15.36-xilinx-v2022.2 #1 SMP PREEMPT Mon Oct 3 07:50:07 UTC 2022 armv7l GNU/Linux

So it is still running on the ARM core. Still need to figure out how to fix fesvr-zynq issue. Probably need to rebuild fesvr-zynq with petaliux SDK? Need to explore more.