Author Topic: Building u-boot with PetaLinux for ZynqBerry  (Read 131 times)

kampi

  • Active Member
  • *
  • Posts: 15
Building u-boot with PetaLinux for ZynqBerry
« on: January 11, 2021, 11:26:00 PM »
Hello,

I want to build my own u-boot with PetaLinux to use it for the BOOT.bin file. Which options do I have to change in PetaLinux to disable the external script file for the u-boot configuration? Or do I have to integrate the script file for u-boot in my BOOT.bin?

JH

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1502
Re: Building u-boot with PetaLinux for ZynqBerry
« Reply #1 on: January 12, 2021, 07:51:46 AM »
Hi,
I'm not sure what you mean with " Which options do I have to change in PetaLinux to disable the external script file for the u-boot configuration?"

Normally there is nothing to change for u-boot.  Import xsa and generate linux files. but fsbl, bistream and uboot into boot.bin and boot and program flash.
We have reference designs and some general notes:
https://wiki.trenz-electronic.de/display/PD/TE0726+Reference+Designs
https://wiki.trenz-electronic.de/display/PD/PetaLinux+KICKstart

In case you will still change somthing on u-boot, you can change u-boot configuration with petalinux-config -c u-boot. Instead of using predefined u-boot sources from the petalinux installation, it should be also possible to change to other local version of u-boot source code with petalinux config menue.
Which version Xilinx used for different petalinux version did you find on the Xilinx AR, for example 19.2:
https://www.xilinx.com/support/answers/72950.html
https://github.com/Xilinx/u-boot-xlnx

Or build u-boot manually (I would not recommend this, in case you has no experience on this topic) .
For more details see petalinux user guide

br

kampi

  • Active Member
  • *
  • Posts: 15
Re: Building u-boot with PetaLinux for ZynqBerry
« Reply #2 on: January 12, 2021, 09:50:48 AM »
Hello,

I build it in this way with the default settings:

Code: [Select]
$ petalinux-config --get-hw-description ../hardware/System_wrapper.xsa
$ petalinux-build
$ petalinux-package --boot --fsbl  --fpga  --u-boot


I copy the generated "BOOT.bin" into the flash of the ZynqBerry and after powering up I get the following messages.

PetaLinux also generates a "boot.scr" file which I have normally copied, together with u-boot, onto the same SD card. So I think the error comes from the missing file.


« Last Edit: January 12, 2021, 10:12:55 AM by kampi »

JH

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1502
Re: Building u-boot with PetaLinux for ZynqBerry
« Reply #3 on: January 12, 2021, 10:06:45 AM »
Hi,
ZYBO is a digilent board, in this case you should write i´to digilent forum:
https://reference.digilentinc.com/reference/programmable-logic/zybo/start
https://forum.digilentinc.com/


For Zynqberry, we offer reference designs (with prebuilt binaries to test), petalinux templates and additional information how we have setup petalinux build environment:
https://wiki.trenz-electronic.de/display/PD/TE0726+Test+Board
https://wiki.trenz-electronic.de/display/PD/PetaLinux+KICKstart


I think your exported XSA did not match the the real platform. Did you use correct PS configuration in your design where you has exported XSA?

br
John

kampi

  • Active Member
  • *
  • Posts: 15
Re: Building u-boot with PetaLinux for ZynqBerry
« Reply #4 on: January 12, 2021, 10:21:24 AM »
Hi,
ZYBO is a digilent board, in this case you should write i´to digilent forum:

Sorry, it was the wrong board. I have tried it with the ZynqBerry (I fix the wrong post)

JH

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1502
Re: Building u-boot with PetaLinux for ZynqBerry
« Reply #5 on: January 12, 2021, 10:27:41 AM »
Hi,
so please try out the reference design.
At first prebuilt Boot.bin and image.ub. Note: Zynq package from Zynqberry allows only QSPI for primary boot, so configure Flash with Boot.bin and put image.ub only on SD.
If this works, generate linux again with the testboard petalinux template and the provided xsa file. --> Use the same petalinux like we have done.
if this works, create our vivado project and export XSA and use our template.
Later you can start to modify.
What we has changed on petalinux config is described on the Test Board Wiki page, instead you want create the petalinux project from scratch.


br
John

kampi

  • Active Member
  • *
  • Posts: 15
Re: Building u-boot with PetaLinux for ZynqBerry
« Reply #6 on: January 12, 2021, 10:55:41 AM »
Hello,

I have done these steps already. My own PetaLinux base does work very well when I regenerate the "BOOT.bin" file from PetaLinux with my own file, which I generate with the FSBL from the PetaLinux image, the bitstream from the XSA file, and the u-boot from the reference design and I get the above error when I change the u-boot to the u-boot version from PetaLinux.

JH

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1502
Re: Building u-boot with PetaLinux for ZynqBerry
« Reply #7 on: January 12, 2021, 11:07:52 AM »

Which Vivado/Petalinux version did you use?

Did you installed all packages which are required in the petalinux installation guide? Did you use supported OS, which are listed in the petalinux installation guide?

Did you use our petalinux template with prebuilt xsa? this makes the same issue?

br
John

kampi

  • Active Member
  • *
  • Posts: 15
Re: Building u-boot with PetaLinux for ZynqBerry
« Reply #8 on: January 13, 2021, 12:18:36 PM »
Hi,

I use PetaLinux 2020.2 (same for Vivado). The PetaLinux installation works very well because I have successfully generated a Linux image for my ZYBO (same block diagram as for the ZynqBerry, but different SoC). I also have used your template with the same behaviour.

JH

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1502
Re: Building u-boot with PetaLinux for ZynqBerry
« Reply #9 on: January 13, 2021, 01:04:33 PM »
compatibility of the templates depends on the changes from petalinux between the versions.

We test only with 2019.2.

2020.2 updates are planned.


Wen you use  petalinux 2020.2, maybe you can help me. Can you export changes in uboot or kernel to the user layer as receipe?
I mean, change something on on the configuration ("petalinux-config -c kernel" or "petalinux-config -c u-boot"). With 2019.2 you must run "petalinux-build -c kernel -x finish -f " or "petalinux-build -c u-boot -x finish -f" to export changes from developer part into the user layer. This doesn't work with 2020.2, I didn't found a solution until now, excepted to generate the layer manually.

br
John

kampi

  • Active Member
  • *
  • Posts: 15
Re: Building u-boot with PetaLinux for ZynqBerry
« Reply #10 on: January 14, 2021, 04:15:31 PM »
Hello,

sorry, but I´m not so experienced with PetaLinux for now. So I don´t know how to do it...
I checked the documentation for the function of this command but I didn´t found the parameter "finish" in the documentation of PetaLinux 2019.1 (unfortunately I didn´t found the command-line documentation for 2019.2),

https://www.xilinx.com/support/documentation/sw_manuals/xilinx2019_1/ug1157-petalinux-tools-command-line-guide.pdf

so I don´t know exactly what this command is doing. But maybe I can repeat the question in the Xilinx Forum.

JH

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1502
Re: Building u-boot with PetaLinux for ZynqBerry
« Reply #11 on: January 14, 2021, 04:47:44 PM »
Hi,
no problem.
Quote
so I don´t know exactly what this command is doing. But maybe I can repeat the question in the Xilinx Forum.
Is not needed, I can do the same in case I didn't find a solution.

Note 2019.2 works. I would recommend to use Vivado/Vitis/Petalinux 2019.2 at the moment. I will publish 20.2 version, when I get it running.
br
John

kampi

  • Active Member
  • *
  • Posts: 15
Re: Building u-boot with PetaLinux for ZynqBerry
« Reply #12 on: January 14, 2021, 06:19:23 PM »
Ok. Let me know when you have a solution. Until then  I will use the pre-compiled u-boot from your reference project.

kampi

  • Active Member
  • *
  • Posts: 15
Re: Building u-boot with PetaLinux for ZynqBerry
« Reply #13 on: January 17, 2021, 08:12:57 PM »
Hi,

I think I found the "problem":

https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/749142017/Using+Distro+Boot+With+Xilinx+U-Boot

PetaLinux 2020.1+ uses something that is called "Distro boot" with the "boot.scr" method. So I have to place "boot.scr" in the flash memory of the ZynqBerry.

kampi

  • Active Member
  • *
  • Posts: 15
Re: Building u-boot with PetaLinux for ZynqBerry
« Reply #14 on: Today at 12:39:54 AM »
Okay, I got stuck now...

I followed these two guides:

https://tuxengineering.com/blog/2020/09/03/U-Boot-changes-to-distro-boot.html
https://forums.xilinx.com/t5/Embedded-Development-Tools/Unable-to-boot-from-QSPI-using-Petalinux-2020-1-Upgrading-from/td-p/1145107

First I have created a new partition for the "boot.scr" (see screenshot). Then I modify "recipes-bsp/u-boot/files/platform-top.h" with the address

Code: [Select]
CONFIG_BOOT_SCRIPT_OFFSET=0xFA0000

and run

Code: [Select]
petalinux-config -c u-boot

I change the boot script offset to 0xFA0000 (see screenshot) and finish the build

Code: [Select]
petalinux-build

In the next step I try to write the "boot.scr" file into the flash memory by using the following TCL command:

Code: [Select]
program_flash -f .../ZynqBerry/MinimalLinux/flash/boot.scr -offset 0xFA0000 -fsbl .../ZynqBerry/fsbl_flash/fsbl_flash.elf -flash_type qspi-x4-single -verify -target_name jsn-JTAG-ONB4-251633001BB2A -url tcp:localhost:3121

The command exit with the error (but why?)

Code: [Select]
ERROR: Given target do not exist

So I try another way. I use the "zynq_fsbl", "u-boot.elf", "boot.scr" and my bitstream to generate a new "BOOT.bin" with Vitis:

Code: [Select]
//arch = zynq; split = false; format = BIN
the_ROM_image:
{
[bootloader]...\ZynqBerry\MinimalLinux\zynq_fsbl.elf
...\ZynqBerry\MinimalLinux\application\MinimalLinux\hw\System_wrapper.bit
...\ZynqBerry\MinimalLinux\u-boot.elf
[offset = 0xFA0000]...\ZynqBerry\MinimalLinux\boot.scr
}

The resulting file is written into the flash and the ZynqBerry was bootet, but throw this error:

Code: [Select]
U-Boot 2020.01 (Jan 17 2021 - 22:20:11 +0000)

CPU:   Zynq 7z010
Silicon: v3.1
DRAM:  ECC disabled 512 MiB
Flash: 0 Bytes
NAND:  0 MiB
MMC:   mmc@e0101000: 0
Loading Environment from SPI Flash... SF: Detected s25fl128s with page size 256 Bytes, erase size 64 KiB, total 16 MiB
*** Warning - bad CRC, using default environment

In:    serial@e0001000
Out:   serial@e0001000
Err:   serial@e0001000
Net:   No ethernet found.
Hit any key to stop autoboot:  0
SF: Detected s25fl128s with page size 256 Bytes, erase size 64 KiB, total 16 MiB
device 0 offset 0xfa0000, size 0x40000
SF: 262144 bytes @ 0xfa0000 Read: OK
QSPI: Trying to boot script at 0x3000000
## Executing script at 03000000
SF: Detected s25fl128s with page size 256 Bytes, erase size 64 KiB, total 16 MiB
Offset exceeds device limit
sf - SPI flash sub-system

Usage:
sf probe [[bus:]cs] [hz] [mode] - init flash device on given SPI bus
                                  and chip select
sf read addr offset|partition len       - read `len' bytes starting at
                                          `offset' or from start of mtd
                                          `partition'to memory at `addr'
sf write addr offset|partition len      - write `len' bytes from memory
                                          at `addr' to flash at `offset'
                                          or to start of mtd `partition'
sf erase offset|partition [+]len        - erase `len' bytes from `offset'
                                          or from start of mtd `partition'
                                         `+len' round up `len' to block size
sf update addr offset|partition len     - erase and write `len' bytes from memory
                                          at `addr' to flash at `offset'
                                          or to start of mtd `partition'
sf protect lock/unlock sector len       - protect/unprotect 'len' bytes starting
                                          at address 'sector'

Wrong Image Format for bootm command
ERROR: can't get kernel image!
QSPI: SCRIPT FAILED: continuing...
JTAG: Trying to boot script at 0x3000000
## Executing script at 03000000
SF: Detected s25fl128s with page size 256 Bytes, erase size 64 KiB, total 16 MiB
Offset exceeds device limit
sf - SPI flash sub-system

So why does u-boot print out this:

Code: [Select]
Trying to boot script at 0x3000000

This is the wrong address for the boot script.

JH

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1502
Re: Building u-boot with PetaLinux for ZynqBerry
« Reply #15 on: Today at 06:49:06 AM »
Hi, thanks for your note. "boot.scr" is new for me, I will check it.

To your problem. You did not put linux into  flash, you must check and modify "boot.scr" maybe. Did you want to boot linux from flash or from SD? We put image.ub normally on SD (flash is also possible, but you has limit space only), so check boot.scr is set to SD  card for image search.

PS: I think "petalinux-config -c u-boot"  changes will not be used by petalinux build at the moment, because this changes are in the developer space. Export receipt must be done --> that was the problem I've (Which I wrote in a older post). In your case you has done the same changes on platform-top.h with "CONFIG_BOOT_SCRIPT_OFFSET=0xFA000" that's the same like modify on uboot config menu, so you has done 2 times the same changes and I think this  one from platform-top is used and this one from uboot config is ignored during build.

br
John

kampi

  • Active Member
  • *
  • Posts: 15
Re: Building u-boot with PetaLinux for ZynqBerry
« Reply #16 on: Today at 10:33:04 AM »
Hi,

I want to boot the Linux from the SD card, so I have to do some additional research on how I modify the "boot.scr". I have checked "/project-spec/meta-user/recipes-bsp/u-boot/u-boot-zynq-scr" and found the file "boot.cmd.default" which consist the plaintext script:

Code: [Select]
# This is a boot script for U-Boot
# Generate boot.scr:
# mkimage -c none -A arm -T script -d boot.cmd.default boot.scr
#
################
## Please change the kernel_offset and kernel_size if the kernel image size more than
## the 100MB and BOOT.BIN size more than the 30MB
## kernel_offset --> is the address of qspi which you want load the kernel image
## kernel_size --> size of the kernel image in hex
###############
fdt_addr=0x1000
imageub_addr=0x10000000
kernel_addr=0x80000
kernel_offset=0x1E00200
kernel_size=0x7800000
kernel_type=image.ub

for boot_target in ${boot_targets};
do
if test "${boot_target}" = "jtag" ; then
booti ${kernel_addr} - ${fdt_addr};
exit;
fi
if test "${boot_target}" = "mmc0" || test "${boot_target}" = "mmc1" ; then
if test -e ${devtype} ${devnum}:${distro_bootpart} /image.ub; then
fatload ${devtype} ${devnum}:${distro_bootpart} ${imageub_addr} image.ub;
bootm ${imageub_addr};
exit;
fi
if test -e ${devtype} ${devnum}:${distro_bootpart} /Image; then
fatload ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr} Image;
booti ${kernel_addr} - ${fdt_addr};
exit;
fi
booti ${kernel_addr} - ${fdt_addr};
exit;
fi
if test "${boot_target}" = "xspi0"; then
sf probe 0 0 0;
if test "${kernel_type}" = "image.ub"; then
sf read ${imageub_addr} ${kernel_offset} ${kernel_size};
bootm ${imageub_addr};
exit;
fi
if test "${kernel_type}" = "Image"; then
sf read ${kernel_addr} ${kernel_offset} ${kernel_size};
booti ${kernel_addr} - ${fdt_addr};
exit;
fi
exit;
fi
done

I think you are right with your mention that the build system doesn´t use the changes, because the guy from Tux Engineering wrote the same:

"...
Now somewhat redundantly, we need to inform u-boot again, where to find the bootscr partition offset, by modifying the following lines in recipes-bsp/u-boot/u-boot-zynq-scr.bbappend:
..."