User Tools

Site Tools


hw:zynq:linux:petalinux:boot_kernel

This is an old revision of the document!


Boot and Kernel configure & build with PetaLinux without BSP (board support package)

  1. Create Vivado design and export the hardware with bitstream.
    Default hdf (hardware description file) location is:
    <project_directory>/<project_name>.sdk/

    In case you need it (but usually you shouldn't), default bitstream location is:

    <project_directory>/<project_name>.runs/impl_1/
  2. Setup PetaLinux enviroment (see Install PetaLinux)

  3. Create PetaLinux project:
    petalinux-create --type project --template zynq --name <boot_project_name>
    cd <boot_project_name>
  4. Get hardware description from Vivado project:
    petalinux-config --get-hw-description=<absolute_path_to_vivado_project_directory>/<project_name>.sdk/
  5. Set booting from SD card by navigating through settings tree and choosing the proper options:
    Subsystem AUTO Hardware Settings -> Advanced bootable images storage Settings -> boot image settings  : set ‘image storage media’ option to ‘primary sd’
                                                                                  -> kernel image settings: set ‘image storage media’ option to ‘primary sd’
                                                                                  -> dtb image settings   : set ‘image storage media’ option to ‘primary sd’
    Image Packaging Configurations: set ‘Root filesystem type’ option to ‘SD card’

    Select Exit and write the configuration.
    In case you want to reconfigure boot settings, run:

    petalinux-config
  6. Check whether all required drivers/modules are enabled in kernel config:
    petalinux-config -c kernel

    Hint: you can use vim-like search /<search_string> to list all enabled drivers/modules.
    For example, for axi_gpio the following driver options should be enabled:

    GPIO_SYSFS
    SYSFS
    GPIO_XILINX

    If search result list is empty, the selected driver/module is not enabled.

  7. Fix the u-boot bug – a typo in default boot command.
    The proper boot configure entry:
    default_bootcmd=run uenvboot; run cp_kernel2ram && bootm ${netstart}

    is created by PetaLinux as

    default_bootcmd=run uenvboot; run cp_kernel2ram && run cp_dtb2ram && booti ${netstart} - ${dtbnetstart}

    with the typo in booti instead of bootm command.
    To fix this bug, edit the platform-top.h file (after all other configuration is done):

    vim ./project-spec/meta-user/recipes-bsp/u-boot/files/platform-top.h

    and add the following entry at the end:

    /* Due to a bug where having u-boot load dtb from SD card causes the boot
     * command to default to using booti instead of bootm on Zynq, the defult build
     * fails to boot. This boot command override is a temporary workaround.
    */
    #ifdef CONFIG_BOOTCOMMAND
    #undef CONFIG_BOOTCOMMAND
    #define CONFIG_BOOTCOMMAND	"run uenvboot; run cp_kernel2ram && run cp_dtb2ram && bootm ${netstart} - ${dtbnetstart}"
    #endif
  8. Speed up the boot process by disabling the netboot: edit the platform-top.h file (see previous point) and add the following entries at the end:
    #ifdef CONFIG_BOOTDELAY
    #undef CONFIG_BOOTDELAY
    #endif
    #define CONFIG_BOOTDELAY        0
    
    #ifdef CONFIG_ENV_IS_IN_SPI_FLASH
    #undef CONFIG_ENV_IS_IN_SPI_FLASH
    #endif
    #define CONFIG_ENV_IS_NOWHERE
    
    #undef CONFIG_NETCONSOLE
    #undef CONFIG_CMD_DHCP
    #undef CONFIG_CMD_MII
    #undef CONFIG_CMD_NET
    #undef CONFIG_CMD_PING
    #undef CONFIG_CMD_NFS
    
    /* PREBOOT */
    #ifdef CONFIG_PREBOOT
    #undef CONFIG_PREBOOT
    #endif
    #define CONFIG_PREBOOT  "echo U-BOOT for ${hostname};setenv preboot; echo no-net"
  9. Build the boot and kernel files:
    petalinux-build
  10. Determinate the bit file name in PetaLinux project (it is copied automatically from Vivado design by –get-hw-description):
    ls ./images/linux/*.bin
  11. Create BOOT.BIN image:
    petalinux-package --boot --format BIN --fsbl ./images/linux/zynq_fsbl.elf --fpga ./images/linux/<bit_filename>.bit --u-boot
/services/www/http/wiki/data/attic/hw/zynq/linux/petalinux/boot_kernel.1553083461.txt.gz · Last modified: 2019/03/20 13:04 by jakub.moron