Project

General

Profile

How to boot FPGA from U-Boot without having the uboot.env file in my SD card

Added by Shahad Alrawi about 1 year ago

Hello,

As a follow up from this question:https://support.criticallink.com/redmine/boards/45/topics/6501

Luckily, I was able to compile U-Boot 2019 from your CriticalLink repo and compile the Linux kernal and Yocto Rootfs as specified in: https://www.rocketboards.org/foswiki/Documentation/BuildingBootloaderCycloneVAndArria10#Building_Linux_Kernel

Everything worked fine-ish :)
except for FPGA loading from U-Boot. After digging and trying to use the U-Boot environment variables uBootMMCEnv.txt, it seems that I need to know exactly where is everything stored in the SD card partition in order to make it work and therefore I left it and continued without it in the moment. I will just use the default method that uses extlinux.conf in FAT partition as specified in the instruction:

cd $TOP_FOLDER/sd_card
mkdir sdfs &&  cd sdfs
cp $LINUX_BIN/a9/zImage .
cp $LINUX_BIN/a9/socfpga_cyclone5_socdk.dtb .
mkdir extlinux
echo "LABEL Linux Default" > extlinux/extlinux.conf
echo "    KERNEL ../zImage" >> extlinux/extlinux.conf
echo "    FDT ../socfpga_cyclone5_socdk.dtb" >> extlinux/extlinux.conf
echo "    APPEND root=/dev/mmcblk0p2 rw rootwait earlyprintk console=ttyS0,115200n8" >> extlinux/extlinux.conf

So it booted but stopped here: FPGA_not_loaded.png

What I did afterwards, is I tried manually to load FPGA to see if this is indeed the problem. Therefore I did that by copying the commands from uBootMMCEnv.txt.
Mainly these two commands with all variables as specified.
=> setenv mmcloadfpga "${mmcloadcmd} mmc 0:${mmcloadpart} ${loadfpgaaddr} ${mmcfpgaloc}"
=> setenv fpgaload "bridge disable; fpga load 0 ${loadfpgaaddr} ${loadfpgasize}; bridge enable"

MitySOM-5CSx # printenv mmcloadfpga
mmcloadfpga=ext2load mmc 0:2 0x2000000 /home/root/soc_system.rbf
MitySOM-5CSx # run mmcloadfpga
MitySOM-5CSx # printenv fpgaload
fpgaload=bridge disable; fpga load 0 0x2000000 0x700000; bridge enable
MitySOM-5CSx # run fpgaload

and yoho it booted successfully after a boot command :)

My question is how can I write these into U-Boot if I don't have uboot.env file written to this SD card?
And I think I'm using some default environment variables with this extlinux.conf for all other booting options that for me it seems hidden.

For reference, I will append the console and the default environment variables of U-Boot of my Linux image (that doesn't boot FPGA automatically) in the attachment.

Thank you.


Replies (2)

RE: How to boot FPGA from U-Boot without having the uboot.env file in my SD card - Added by Shahad Alrawi about 1 year ago

Hello,

I was wondering, I found in u-boot-socfpga/include/configs

#ifndef CONFIG_EXTRA_ENV_SETTINGS
#define CONFIG_EXTRA_ENV_SETTINGS \
        "fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \
        "bootm_size=0xa000000\0" \
        "kernel_addr_r="__stringify(CONFIG_SYS_LOAD_ADDR)"\0" \
        "fdt_addr_r=0x02000000\0" \
        "scriptaddr=0x02100000\0" \
        "scriptfile=u-boot.scr\0" \
        "fatscript=if fatload mmc 0:1 ${scriptaddr} ${scriptfile};" \
                        "then source ${scriptaddr}; fi\0" \
        "pxefile_addr_r=0x02200000\0" \
        "ramdisk_addr_r=0x02300000\0" \
        "socfpga_legacy_reset_compat=1\0" \
        "prog_core=if load mmc 0:1 ${loadaddr} fit_spl_fpga.itb;" \
                   "then fpga loadmk 0 ${loadaddr}:fpga-core-1; fi\0" \
        SOCFPGA_BOOT_SETTINGS \
        BOOTENV
#endif

This prog_core could be responsible about fpga loading?

In other boards I found more clear settings in which the rbf file name is specified. This is taken from u-boot-socfpga/include/configs/u-boot-socfpga/include/configs

        "load_fpga="            /* Load FPGA bitstream */               \
                "if tftp ${fpga_filename} ; then "                      \
                "fpga load 0 $loadaddr $filesize ; "                    \
                "bridge enable ; "                                      \
                "fi\0" 

All these source code are from the repo: https://support.criticallink.com/gitweb/?p=u-boot-socfpga.git;a=shortlog;h=refs/heads/socfpga_v2019.10

RE: How to boot FPGA from U-Boot without having the uboot.env file in my SD card - Added by Shahad Alrawi about 1 year ago

Hi everyone,

For anyone who is reading, I have figured it out and I hope this will help you.
The U-Boot is running a script, see the bootcmd below

bootcmd= *run fatscrip*  ; bridge enable; run distro_bootcmd
fatscript=if fatload mmc 0:1 ${scriptaddr} ${scriptfile};then source ${scriptaddr}; fi
scriptaddr=0x02100000
scriptfile=u-boot.scr

Therefore, I just needed to write the commands for loading FPGA into the u-boot.script file and then compile it using mkimage tool in U-Boot.
The u-boot.script file contains

# compile with: mkimage -T script -C none -n "boot" -d u-boot.script u-boot.scr
setenv fpga 0
setenv fpga_data 0x2000000
setenv fpga_size 7007204
setenv fpga_image /home/root/soc_system.rbf

# load FPGA config
bridge disable
ext4load mmc 0:2 ${fpga_data} ${fpga_image}
fpga load 0 ${fpga_data} ${fpga_size}

Note: I deleted the command "bridge enable" at the end since it is already done in bootcmd.

Then compile it using the command:

u-boot-socfpga/tools/mkimage -T script -C none -n "boot" -d u-boot.script u-boot.scr

Note: mkimage tool will only be shown after you compile your U-Boot.

Then write the u-boot.scr file into the FAT partition with the other files such as the zImage and .dtb file.
This workaround solution is based on this thread: https://forum.rocketboards.org/t/cyclone-v-uboot-socfpga-with-spl-fpga-load/2309/4

    (1-2/2)
    Go to top
    Add picture from clipboard (Maximum size: 1 GB)