Mender not working in iMX6 UL

Hey,

I’m building Yocto project from https://source.codeaurora.org/external/imx/imx-manifest/tree/imx-4.19.35-1.1.0.xml?h=imx-linux-warrior with mender for iMX 6UL EVK. Here u-boot consists of two parts (SPL & u-boot.img) and so in local.conf I’ve added,

MENDER_IMAGE_BOOTLOADER_BOOTSECTOR_OFFSET = "2"
MENDER_IMAGE_BOOTLOADER_FILE = "SPL"
MENDER_IMAGE_BOOTLOADER_BOOTSECTOR_OFFSET = "138"
MENDER_IMAGE_BOOTLOADER_FILE = "u-boot.img"

Now the booting is not at all working.

NOTE: If I add only,

MENDER_IMAGE_BOOTLOADER_BOOTSECTOR_OFFSET = "2"
MENDER_IMAGE_BOOTLOADER_FILE = "SPL"

it is looping in the following,

Trying to boot from MMC1
mmc_load_image_raw_sector: mmc block read error
spl_load_image_ext: ext4fs mount err - 0

Any help would much be appreciated.

For me on imx6 the full bootloader image to use is u-boot.imx rather than u-boot.img. I don’t think the u-boot.img has the IVT header in it as the img is smaller than the imx.

Hey @dellgreen,

Thanks for the reply.

Could you please guide me through creating .imx in yocto project! I’m stuck with that.

Looking back over a past project I had to add a yocto bbappend file to my uboot recipe which created the imx file manually. Below are the bitbake append functions i added

do_compile_append() {
    if [ -n "${UBOOT_CONFIG}" ]
    then
        unset i j
        for config in ${UBOOT_MACHINE}; do
            i=$(expr $i + 1);
            for type in ${UBOOT_CONFIG}; do
                j=$(expr $j + 1);
                if [ $j -eq $i ]
                then
                    dd if="${B}/${config}/SPL" of="${B}/${config}/u-boot-${type}.imx"
                    dd if="${B}/${config}/u-boot.img" of="${B}/${config}/u-boot-${type}.imx" obs=1K seek=68
                fi
            done
            unset  j
        done
        unset  i
    else
        dd if="${B}/SPL" of="${B}/u-boot.imx"
        dd if="${B}/u-boot.img" of="${B}/u-boot.imx" obs=1K seek=68
    fi

}



do_deploy_append () {
    if [ -n "${UBOOT_CONFIG}" ]
    then
        for config in ${UBOOT_MACHINE}; do
            i=$(expr $i + 1);
            for type in ${UBOOT_CONFIG}; do
                j=$(expr $j + 1);
                if [ $j -eq $i ]
                then
                    install -d ${DEPLOYDIR}
                    install -m 644 ${B}/${config}/u-boot-${type}.imx ${DEPLOYDIR}/u-boot-${type}-${PV}-${PR}.imx
                    cd ${DEPLOYDIR}
                    ln -sf u-boot-${type}-${PV}-${PR}.imx u-boot-${type}.imx
                    ln -sf u-boot-${type}-${PV}-${PR}.imx u-boot.imx
                fi
            done
            unset  j
        done
        unset  i
    else
        install -d ${DEPLOYDIR}
        install -m 644 ${B}/u-boot.imx ${DEPLOYDIR}/u-boot-${PV}-${PR}.imx
        cd ${DEPLOYDIR}
        rm -f u-boot*.imx
        ln -sf u-boot-${PV}-${PR}.imx u-boot.imx

   fi

}
1 Like

its possible that using just the SPL and the uboot.img could work, but everything i tried failed, which led me to the above solution which comes from the NXP forums.

Thank you. I’ll your solution and let you know the results.

Yes the interface provided by the Mender variables typically only work if there is one file related to the bootloader. I think there is a task to improve this but never prioritized :).

What @dellgreen proposed is what I would recommend as well as a workaround or something like this which I did for another platform,

Hi,

Your reply was helpful in creating u-boot.imx and I’ve created .imx file successfully. However, now it doesn’t load kernel. I edited the local.conf as,

MENDER_IMAGE_BOOTLOADER_BOOTSECTOR_OFFSET = "2"
MENDER_IMAGE_BOOTLOADER_FILE = "u-boot.imx"

The logs are attached for your reference below:

U-Boot SPL 2019.07+fslc+gca0ab15271 (May 19 2020 - 12:56:29 +0000)
Trying to boot from MMC1
hab fuse not enabled


U-Boot 2019.07+fslc+gca0ab15271 (May 19 2020 - 12:18:57 +0000)

CPU:   Freescale i.MX6UL rev1.1 528 MHz (running at 396 MHz)
CPU:   Industrial temperature grade (-40C to 105C) at 39C
Reset cause: POR
Model: Freescale i.MX6 UltraLite 14x14 EVK Board
Board: MX6UL 14x14 EVK
DRAM:  512 MiB
MMC:   FSL_SDHC: 0, FSL_SDHC: 1
Loading Environment from MMC... MMC: no card present
*** Warning - No block device, using default environment

Video: 480x272x24
In:    serial
Out:   serial
Err:   serial
Net:   
Error: ethernet@020b4000 address not set.

Error: ethernet@020b4000 address not set.

Error: ethernet@02188000 address not set.
eth-1: ethernet@020b4000
Error: ethernet@02188000 address not set.
, eth-1: ethernet@02188000
Hit any key to stop autoboot:  0 
Saving Environment to MMC... MMC: no card present
No block device
Failed (1)
MMC: no card present
MMC: no card present
=>

Can you help me in this?

Uboot seems to be trying to work with mmc, I’m guessing your are booting from sdcard?

Also does your uboot have vender support for your evaluation board?

Yes, we’re trying to boot from the SD card using .sdimg

I hope you’re referring to Mender here! iMX 6UL EVK has no support for Mender and we’re currently trying to integrate manually.

I’m more distracted as to why your uboot is trying to work with the MMC and failing. as it looks like its dropping you to a uboot shell prompt, I would use the uboot shell to inspect the uboot variables to see what the mender variables are set to for boot device.

https://www.denx.de/wiki/publish/DULG/to-delete/UBootCmdGroupEnvironment.html
https://docs.mender.io/1.5/devices/partition-layout

The environment variables are as follows (and the mender variables are set here),

U-Boot SPL 2019.07+fslc+gca0ab15271 (May 19 2020 - 12:56:29 +0000)
Trying to boot from MMC1
hab fuse not enabled


U-Boot 2019.07+fslc+gca0ab15271 (May 19 2020 - 12:18:57 +0000)

CPU:   Freescale i.MX6UL rev1.1 528 MHz (running at 396 MHz)
CPU:   Industrial temperature grade (-40C to 105C) at 39C
Reset cause: POR
Model: Freescale i.MX6 UltraLite 14x14 EVK Board
Board: MX6UL 14x14 EVK
DRAM:  512 MiB
MMC:   FSL_SDHC: 0, FSL_SDHC: 1
Loading Environment from MMC... MMC: no card present
*** Warning - No block device, using default environment

Video: 480x272x24
In:    serial
Out:   serial
Err:   serial
Net:   
Error: ethernet@020b4000 address not set.

Error: ethernet@020b4000 address not set.

Error: ethernet@02188000 address not set.
eth-1: ethernet@020b4000
Error: ethernet@02188000 address not set.
, eth-1: ethernet@02188000
Hit any key to stop autoboot:  0 
=> 
=> printenv 
altbootcmd=run mender_altbootcmd; run bootcmd
baudrate=115200
board_name=EVK
board_rev=14X14
boot_fdt=try
bootcmd=run mender_setup; setenv bootargs root=${mender_kernel_root} ${bootargs}
; if test "${fdt_addr_r}" != ""; then load ${mender_uboot_root} ${fdt_addr_r} /b
oot/${mender_dtb_name}; fi; load ${mender_uboot_root} ${kernel_addr_r} /boot/${mender_kernel_name}; ${mender_boot_kernel_type} ${kernel_addr
_r} - ${fdt_addr_r}; run mender_try_to_recover
bootcount=1
bootdelay=2
bootlimit=1
bootscript=echo Running bootscript from mmc ...; source
console=ttymxc0
ethprime=eth1
fdt_addr_r=0x83000000
fdt_file=undefined
fdt_high=0xffffffff
fdtcontroladdr=9ef86a30
findfdt=if test $fdt_file = undefined; then if test $board_name = EVK && test $board_rev = 9X9; then setenv fdt_file imx6ul-9x9-evk.dtb; fi;
 if test $board_name = EVK && test $board_rev = 14X14; then setenv fdt_file imx6ul-14x14-evk.dtb; fi; if test $fdt_file = undefined; then ec
ho WARNING: Could not determine dtb to use; fi; fi;
image=zImage
initrd_high=0xffffffff
ip_dyn=yes
loadaddr=0x82000000
loadbootscript=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};
loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}
loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}
mender_altbootcmd=if test ${mender_boot_part} = 2; then setenv mender_boot_part 3; setenv mender_boot_part_hex 3; else setenv mender_boot_pa
rt 2; setenv mender_boot_part_hex 2; fi; setenv upgrade_available 0; saveenv; run mender_setup
mender_boot_kernel_type=bootz
mender_boot_part=2
mender_boot_part_hex=2
mender_check_saveenv_canary=1
mender_dtb_name=imx6ul-14x14-evk-emmc.dtb
mender_kernel_name=zImage
mender_setup=if test "${mender_saveenv_canary}" != "1"; then setenv mender_saveenv_canary 1; saveenv; fi; if test "${mender_pre_setup_comman
ds}" != ""; then run mender_pre_setup_commands; fi; if test "${mender_systemd_machine_id}" != ""; then setenv bootargs systemd.machine_id=${
mender_systemd_machine_id} ${bootargs}; fi; setenv mender_kernel_root /dev/mmcblk0p${mender_boot_part}; if test ${mender_boot_part} = 2; the
n setenv mender_boot_part_name /dev/mmcblk0p2; else setenv mender_boot_part_name /dev/mmcblk0p3; fi; setenv mender_kernel_root_name ${mender
_boot_part_name}; setenv mender_uboot_root mmc 0:${mender_boot_part_hex}; setenv mender_uboot_root_name ${mender_boot_part_name}; setenv exp
and_bootargs "setenv bootargs \\"${bootargs}\\""; run expand_bootargs; setenv expand_bootargs; if test "${mender_post_setup_commands}" != ""
; then run mender_post_setup_commands; fi
mender_try_to_recover=if test ${upgrade_available} = 1; then reset; fi
mender_uboot_boot=mmc 0:1
mender_uboot_dev=0
mender_uboot_if=mmc
mmcargs=setenv bootargs console=${console},${baudrate} 
mmcautodetect=yes
mmcboot=echo Booting from mmc ...; run mmcargs; if test ${boot_fdt} = yes || test ${boot_fdt} = try; then if run loadfdt; then bootz ${loada
ddr} - ${fdt_addr}; else if test ${boot_fdt} = try; then bootz; else echo WARN: Cannot load the DT; fi; fi; else bootz; fi;
mmcdev=0
mmcpart=1
mmcroot=/dev/mmcblk1p2 rootwait rw
netargs=setenv bootargs console=${console},${baudrate} ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp
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} 
${image}; if test ${boot_fdt} = yes || test ${boot_fdt} = try; then if ${get_cmd} ${fdt_addr} ${fdt_file}; then bootz ${loadaddr} - ${fdt_ad
dr}; else if test ${boot_fdt} = try; then bootz; else echo WARN: Cannot load the DT; fi; fi; else bootz; fi;
script=boot.scr
upgrade_available=0
videomode=video=ctfb:x:480,y:272,depth:24,pclk:108695,le:8,ri:4,up:2,lo:4,hs:41,vs:10,sync:0,vmode:0

Environment size: 3702/131067 bytes
=> 

The SD card layout is in accordance with mender documentation:

Disk /dev/sdc: 7.2 GiB, 7776239616 bytes, 15187968 sectors
/dev/sdc1  *      49152   81919   32768   16M  c W95 FAT32 (LBA)
/dev/sdc2         81920  950271  868352  424M 83 Linux
/dev/sdc3        950272 1818623  868352  424M 83 Linux
/dev/sdc4       1818624 2080767  262144  128M 83 Linux

I’m happy to share more details, if needed. Thanks in advance.

@mirzak any thoughts on this, as its been a while since i hacked on uboot?

Unfortunately I’m not sure the cause of this, where i would start if by using the uboot mmc command from the uboot shell to start investigating which SDHC device is which, and why its complaining about why it cannot find its uboot environment on your SD card. Its almost as if some part of the uboot configuration is still referencing the emmc. Or there is no uboot environment block in your sdcard image.