3.1.2 Build U-Boot from Sources
Perform the following steps to build the u-boot.
Note: Make sure to install the mkenvimage tool on the Linux machine.
- Export the cross compiler toolchain path,
using the following
command:
export CROSS_COMPILER=arm-linux-gnueabi- - Clone the Linux4sam GitHub U-Boot
repository, enter in to the cloned directory using the following
command:
$ git clone git://github.com/linux4sam/u-boot-at91.git - Move to the u-boot-at91 directory, using
the following command:
$ cd u-boot-at91 - Switch to a new branch
u-boot-2018.07-at91, using the following commands:$ git branch -r $ git checkout origin/u-boot-2018.07-at91 -b u-boot-2018.07-at91 - The configs/ directory lists many
defconfig files. Use the
sama5d2_xplained_mmc_defconfigfile to configure the u-boot by using the following command:$make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- sama5d2_xplained_mmc_defconfig - Open the
u-boot-at91/include/configs/sama5d2_xplained.hfile and modify the definitions forFAT_ENV_DEVICE_AND_PARTandCONFIG_BOOTCOMMAND, using the following commands:/*bootstrap + u-boot + env in sd card */ #undef FAT_ENV_DEVICE_AND_PART #undef CONFIG_BOOTCOMMAND #define FAT_ENV_DEVICE_AND_PART "0" #define CONFIG_BOOTCOMMAND "fatload mmc 0:1 0x21000000 at91-sama5d2_xplained.dtb; " \ "fatload mmc 0:1 0x22000000 zImage; " \ "bootz 0x22000000 - 0x21000000" #undef CONFIG_BOOTARGS #define CONFIG_BOOTARGS "console=ttyS0,115200 earlyprintk root=/dev/mmcblk0p2 rw rootwait" #elif CONFIG_SPI_BOOT - Build the u-boot binary, using the
following
command:
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-- The result of these operations is a fresh U-Boot binary called
u-boot.bincorresponding to the binary ELF fileu-boot.u-boot.binfile will be created inu-boot-at91directory.u-bootis the ELF format binary file can be used to debug U-Boot through a JTag link.
- The result of these operations is a fresh U-Boot binary called
- Create a text file named
u-boot-env.txtin any directory with the u-boot environment variables mentioned below:bootargs=console=ttyS0,115200 root=/dev/mmcblk0p2 rw rootfstype=ext4 rootwait bootcmd=fatload mmc 0:1 0x21000000 at91-sama5d2_xplained.dtb; fatload mmc 0:1 0x22000000 zImage; bootz 0x22000000 - 0x21000000 bootdelay=1 ethact=gmac0 stderr=serial stdin=serial stdout=serial - Move to the direcrory and enter the
following command to generate
uboot.envfile from the previously createdu-boot-env.txtfile.$ mkenvimage -s 0x2000 -o uboot.env u-boot-env.txt
