i.MX 8M Mini Bootloader
The u-boot bootloader is a GNU GPL licensed open source software that is used on the i.MX 8M Mini based modules to load the operating system. The u-boot input/output is redirected to the module's serial port. In order to get access to the u-boot output, or to the u-boot command-line interface in general, establish a serial connection between the host and target system (RS-232 adapter cable for conga-ARM modules PN 48000023 can be used for the purpose).
The boot behavior can be affected via so called environment variables, which can be managed using the the u-boot command-line interface. They can be printed using command print, edited using editenv, set using env set and deleted using env delete. Variable list can be saved onto the boot media using saveenv, so any changes made persist.
Work with variables - example:
u-boot=> print fdt_file
fdt_file=imx8mm-cgtsx8m.dtb
u-boot=> env set fdt_file imx8mm-cgtsx8m-800x600.dtb
u-boot=> print fdt_file
fdt_file=imx8mm-cgtsx8m-800x600.dtb
u-boot=> env delete fdt_file
u-boot=> print fdt_file
## Error: "fdt_file" not defined
Identification of version of u-boot used in a particular Yocto or Android image is listed together with instructions how to build the image (e.g. here for Yocto 2.5).
The bootloader can be fetched and built standalone. Instructions how to do the build and how to create a complete bootcontainer are present under the respective operating system section (e.g. here and here for GNU/LInux).
Variable listing example (051220 conga-SMX8-Mini module / g4626e2a876 u-boot)
baudrate=115200
boot_fdt=try
bootcmd=if test ${bootdevice} = mmc; then if mmc dev ${mmcdev} && mmc rescan; then if run loadbootscript; then run bootscript; else if run loadimage; then run mmcboot; fi; fi; fi; else if test ${bootdevice} = usb; then if usb stop && usb start && usb storage; then if run usbargs && run loadusbimage && run loadusbfdt; then echo Booting from USB ... ;booti ${loadaddr} - ${fdt_addr}; fi; fi; fi; fi; run netboot
bootdelay=4
bootdevice=usb
bootscript=echo Running bootscript from mmc ...; source
cma_settings=640M@1024M-3072M
console=ttymxc1,115200 earlycon=ec_imx6q,0x30890000,115200
ethaddr=00:13:95:36:8a:eb
ethprime=FEC
fdt_addr=0x43000000
fdt_file=imx8mm-cgtsx8m.dtb
fdt_high=0xffffffffffffffff
fdtcontroladdr=fe8f5f00
image=Image
initrd_addr=0x43800000
initrd_high=0xffffffffffffffff
loadaddr=0x40480000
loadbootscript=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};
loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}
loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}
loadusbfdt=fatload usb ${usbdev}:${usbpart} ${fdt_addr} ${fdt_file}
loadusbimage=fatload usb ${usbdev}:${usbpart} ${loadaddr} ${image}
mmcargs=setenv bootargs ${jh_clk} console=${console} root=${mmcroot} cma=${cma_settings}
mmcautodetect=yes
mmcboot=echo Booting from mmc ...; run mmcargs; if test ${boot_fdt} = yes || test ${boot_fdt} = try; then if run loadfdt; then booti ${loadaddr} - ${fdt_addr}; else echo WARN: Cannot load the DT; fi; else echo wait for boot; fi;
mmcdev=1
mmcpart=1
mmcroot=/dev/mmcblk2p2 rootwait rw
netargs=setenv bootargs ${jh_clk} console=${console} root=/dev/nfs ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp cma=${cma_settings}
netboot=echo Booting from net ...; run netargs; if test ${ip_dyn} = yes; then setenv get_cmd dhcp; else setenv get_cmd tftp; fi; ${get_cmd} ${loadaddr} ${image}; if test ${boot_fdt} = yes || test ${boot_fdt} = try; then if ${get_cmd} ${fdt_addr} ${fdt_file}; then booti ${loadaddr} - ${fdt_addr}; else echo WARN: Cannot load the DT; fi; else booti; fi;
panel=1024x768
script=boot.scr
soc_type=imx8mm
usbargs=setenv bootargs console=${console} root=${usbroot} cma=${cma_settings}
usbdev=0
usbpart=1
usbroot=/dev/sda2 rootwait rw
video_output_type=LVDS
video_tuning=lvds-use-jeida
Environment size: 2357/4092 bytes
Environment variables Linux access
The u-boot environment variables can also be read and written from the Linux OS itself, using utilities fw_printenv and fw_setenv, respectively. The Yocto package u-boot-fw-utils provides the utilities and can be included in the target OS image e.g. by adding the following line into the conf/local.conf file inside the build directory.
IMAGE_INSTALL_append = " u-boot-fw-utils"
Note: This example is valid for Yocto 2.5 (Sumo), whose documentation page can be found here.
Once the utilities have been included in the Linux OS image they need to be provided with information about u-boot environment variables area location and size. By default is this information get from the /etc/fw_env.config file, but a different file can be specified on command line. Depending on the boot device used (either SD card or module's SPI NOR flash) the contents of the file is to be one of the following:
# SD Card
# Block device Device offset Env. size
/dev/mmcblk1 0x400000 0x1000
# SPI NOR Flash
# MTD device name Device offset Env. size Flash sector size
/dev/mtd0 0x400000 0x1000 0x10000
Note: Before the fw_setenv utility is used to set value of a variable, u-boot environment area shall be initialized, e.g. by executing saveenv command in the u-boot command line environment