I have built a custom board with a iMX6 Processor. Unfortunately i have not stripped out the Bootloader Config pins. They are still unconnected BGA-Balls. I do have access to UART1-3, JTAG and SD-Card interface and also to the BOOT0 and BOOT1 pins.
No i would like to start a U-Boot. Therefore i have ported or added my own board to the configs. I can build U-Boot successfull (not tested on the board yet).
Then i thought, i could download u-boot into the internal RAM of the i.MX6. unfortunately the i.MX got only 68kb RAM. The u-boot is about 160kb.
After some googling i saw that there is a possibility to compile a SP-Loader (SPL) which will first start, then load u-boot from SD-Card into the DDR3 RAM and then start the regular U-Boot from external DDR3 RAM.
I also found this readme: https://github.com/ARM-software/u-boot/blob/master/doc/README.SPL
This is my actual defconfig file:
CONFIG_ARM=y
CONFIG_ARCH_MX6=y
CONFIG_TARGET_EVAL1A=y
CONFIG_MXC_UART=y
CONFIG_DM_MMC=y
CONFIG_SYS_TEXT_BASE=0x87800000
CONFIG_SPL_TEXT_BASE=0x0907000
CONFIG_SPL=y
CONFIG_SPL_BUILD=y
CONFIG_SPL_SERIAL_SUPPORT=y
CONFIG_SPL_FS_FAT=y
CONFIG_SPL=y
Im a little bit confused about SYS_TEXT_BASE and SPL_TEXT_BASE. I think SPL_TEXT_BASE is where my SPL will reside? So 907000 is the start of the internal RAM. SYS_TEXT_BASE should be the start of the external DDR3 RAM right?
Anway, with the above config and the following commands:
make mrproper
make myBoard_config
make
I only get the regular u-boot.bin which is about 160kb in size.
What do i wrong? How can i build the SPL into a separate binary?
Thanks.
Edit: i solved it that way:
If you build linux by your self for your own board of even for an other board then you often get three different files.
U-Boot Bootloader
Linux Kernel (zImage, uImage)
rootfs (debian, ubuntu etc.)
Usually you get some advice how to format your SD-Card properly and copy your files onto them. But normally it is more convenient to have only one single image file which you can flash onto your card using some 3rd party tool like balena etcher.
During my development of the i.MX6 DevBoard i have created a shell script which does exactly this. Combining all these three parts into one image.
I provide this script here for free, without any further comments or instructions. This script was tested with an i.MX6 Controller using mainline U-Boot and Mainline Linux.
The script is provided without any warranty. Use it at your own risk.
#!/bin/bash
# Copyright: C. Hediger, 2019
# databyte.ch
# provided without warranty. use it at your own risk!
echo "-------------------------------------------"
echo "-------- SD-Card image generator ----------"
echo "-------------------------------------------"
echo ""
#echo "Please enter the Size of your Image"
read -p 'Size for *.img [MB] default 512MByte: ' imagesize
if [ -z "$imagesize" ]
then
imagesize="512"
fi
#echo "Please enter the destination of the image"
read -p 'Path to Image default /home/<user>/Desktop/sdcard/sdimage.img: ' imagepath
if [ -z "$imagepath" ]
then
imagepath="/home/"$USER"/Desktop/sdcard/sdimage.img"
fi
#echo "Please enter the path of the u-boot.imx"
read -p 'Path to u-boot default /home/<user>/Desktop/sdcard/u-boot.imx: ' ubootpath
if [ -z "$ubootpath" ]
then
ubootpath="/home/"$USER"/Desktop/sdcard/u-boot.imx"
fi
#echo "Please enter the path of the rootfs.tar.gz"
read -p 'Path to rootfs default /home/<user>/Desktop/sdcard/rootfs.tar.gz: ' rootfspath
if [ -z "$rootfspath" ]
then
rootfspath="/home/"$USER"/Desktop/sdcard/rootfs.tar.gz"
fi
read -p 'Strip output directory? Default 1: ' stripcount
if [ -z "$stripcount" ]
then
stripcount="1"
fi
#echo "Please enter the path of the kernel"
read -p 'Path to kernel default /home/<user>/Desktop/sdcard/zImage: ' kernelpath
if [ -z "$kernelpath" ]
then
kernelpath="/home/"$USER"/Desktop/sdcard/zImage"
fi
#echo "Please enter the path of the device tree blob"
read -p 'Path to *.dtb default /home/<user>/Desktop/sdcard/eval1a.dtb: ' dtbpath
if [ -z "$dtbpath" ]
then
dtbpath="/home/"$USER"/Desktop/sdcard/eval1a.dtb"
fi
ddimagesize=$((imagesize * 2))k
partitionsize=+$((imagesize - 20))M
#echo $imagesize
#echo $imagepath
#echo $partitionsize
dd status=progress if=/dev/zero of=$imagepath bs=512 count=$ddimagesize
(
echo o # Create a new empty DOS partition table
echo p # Add a new partition
#echo u # change units to cylinders
echo x # expert mode
echo h # Partition number
echo 255
echo s
echo 63
echo c
echo
echo r
echo n
echo p
echo 1
echo 4096
echo $partitionsize
echo p
echo w
) | fdisk $imagepath
dd bs=512 seek=2 conv=notrunc if=$ubootpath of=$imagepath
loodevice="$(sudo losetup --partscan --show --find $imagepath)"
loopartition="$loodevice"p1
mountfolder=/mnt/sdcardtmpfolder
echo "Device: "$loodevice
echo "Partition: "$loopartition
sudo mkfs.ext2 $loopartition
sudo mkdir -p $mountfolder
sudo mount $loopartition $mountfolder
sudo cp $rootfspath "$mountfolder"/rootfs.tar.gz
sudo tar xzf "$mountfolder"/rootfs.tar.gz -C $mountfolder --strip-components=$stripcount
sudo cp $kernelpath "$mountfolder"/boot/zImage
sudo cp $dtbpath "$mountfolder"/boot/imx6ull-dtb-eval1a.dtb
sudo rm "$mountfolder"/rootfs.tar.gz
echo " ----- Please extract rootfs -----"
read
sudo umount /mnt/sdcardtmpfolder
sudo fsck.ext4 $loopartition
sudo losetup -d $loodevice
sudo rm -R /mnt/sdcardtmpfolder
sudo gparted $imagepath