FreeRTOS Hello-World on Colibri iMX7 causes boot to hang

So I was working through the FreeRTOS tutorial

http://developer.toradex.com/knowledge-base/freertos-on-the-cortex-m4-of-a-colibri-imx7

got to the end where it says

With that, U-Boot will load and start the firmware just before booting Linux:

...
Read 0 bytes from volume m4firmware to 7f8000
No size specified -> Using max size (20956)
## Starting auxiliary core at 0x007F8000 ...
...

But now it just seems to hang on boot

Booting from NAND...
ubi0: default fastmap pool size: 200
ubi0: default fastmap WL pool size: 100
ubi0: attaching mtd1
ubi0: scanning is finished
ubi0: attached mtd1 (name "mtd=4", size 508 MiB)
ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
ubi0: VID header offset: 2048 (aligned 2048), data offset: 4096
ubi0: good PEBs: 4060, bad PEBs: 4, corrupted PEBs: 0
ubi0: user volume: 4, internal volumes: 1, max. volumes count: 128
ubi0: max/mean erase counter: 4/1, WL threshold: 4096, image sequence number: 0
ubi0: available PEBs: 0, total reserved PEBs: 4060, PEBs reserved for bad PEB handling: 76
Read 0 bytes from volume m4firmware to 7f8000
No size specified -> Using max size (41897)

Can anyone tell me how to get linux to boot again?

Please provide u-boot output for printenv command

Hello World uses UART_B. Did you disable UART_B on the Linux side (e.g. using the fdt_fixup U-Boot environment variable as described here).

I have the same issue. I want to automatically load “blinking_imx_demo.elf” on boot. If I run the demo after disrupting autoboot and type in the commands

Colibri iMX7 # fatload mmc 0:1 ${loadaddr} blinking_imx_demo.elf
Colibri iMX7 # bootaux ${loadaddr}

by myself, it works once.

What command I have to store in variable m4boot to disable M4 auto boot and load Linux just as before?

printenv delivers:

Colibri iMX7 # printenv
arch=arm
baudrate=115200
board=colibri_imx7
board_name=colibri_imx7
boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefix}${script}; source ${scriptaddr}
boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}extlinux/extlinux.conf
boot_net_usb_start=usb start
boot_prefixes=/ /boot/
boot_script_dhcp=boot.scr.uimg
boot_scripts=boot.scr.uimg boot.scr
boot_targets=mmc0 usb0 dhcp
bootcmd=run ubiboot; setenv fdtfile ${soc}-colibri-${fdt_board}.dtb && run distro_bootcmd;
bootcmd_dhcp=if dhcp ${scriptaddr} ${boot_script_dhcp}; then source ${scriptaddr}; fi;
bootcmd_mmc0=setenv devnum 0; run mmc_boot
bootcmd_usb0=setenv devnum 0; run usb_boot
bootdelay=1
bootm_size=0x10000000
console=ttymxc0
cpu=armv7
defargs=clk_ignore_unused
distro_bootcmd=for target in ${boot_targets}; do run bootcmd_${target}; done
eth1addr=00:14:2d:3c:6a:10
ethact=FEC0
ethaddr=00:14:2d:2c:6a:10
ethprime=FEC
fdt_addr_r=0x82000000
fdt_board=eval-v3
fdt_fixup=fdt addr ${fdt_addr_r} && fdt rm /soc/aips-bus@30800000/spba-bus@30800000/serial@30890000
fdt_high=0xffffffff
fdtcontroladdr=9def6978
fileaddr=80800000
filesize=319bf
initrd_high=0xffffffff
ip_dyn=yes
ipaddr=192.168.10.2
kernel_addr_r=0x81000000
kernel_file=zImage
loadaddr=0x80800000
m4boot=ubi read 0x7F8000 m4firmware && dcache flush && bootaux 0x7F8000
mmc_boot=if mmc dev ${devnum}; then setenv devtype mmc; run scan_dev_for_boot_part; fi
mtddevname=mx7-bcb
mtddevnum=0
mtdids=nand0=gpmi-nand
mtdparts=mtdparts=gpmi-nand:512k(mx7-bcb),1536k(u-boot1)ro,1536k(u-boot2)ro,512k(u-boot-env),-(ubi)
netmask=255.255.255.0
nfsargs=ip=:::::eth0: root=/dev/nfs
nfsboot=run setup; setenv bootargs ${defargs} ${nfsargs} ${setupargs} ${vidargs}; echo Booting from NFS...;dhcp ${kernel_addr_r} && tftp ${fdt_addr_r} ${soc}-colibri-${fdt_board}.dtb && run fdt_fixup && bootz ${kernel_addr_r} - ${fdt_addr_r}
partition=nand0,0
pxefile_addr_r=0x87100000
ramdisk_addr_r=0x82100000
scan_dev_for_boot=echo Scanning ${devtype} ${devnum}:${distro_bootpart}...; for prefix in ${boot_prefixes}; do run scan_dev_for_extlinux; run scan_dev_for_scripts; done;
scan_dev_for_boot_part=part list ${devtype} ${devnum} -bootable devplist; env exists devplist || setenv devplist 1; for distro_bootpart in ${devplist}; do if fstype ${devtype} ${devnum}:${distro_bootpart} bootfstype; then run scan_dev_for_boot; fi; done
scan_dev_for_extlinux=if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}extlinux/extlinux.conf; then echo Found ${prefix}extlinux/extlinux.conf; run boot_extlinux; echo SCRIPT FAILED: continuing...; fi
scan_dev_for_scripts=for script in ${boot_scripts}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${script}; then echo Found U-Boot script ${prefix}${script}; run boot_a_script; echo SCRIPT FAILED: continuing...; fi; done
scriptaddr=0x87000000
sdargs=root=/dev/mmcblk0p2 rw rootwait
sdboot=run setup; setenv bootargs ${defargs} ${sdargs} ${setupargs} ${vidargs}; echo Booting from MMC/SD card...; run m4boot && load mmc 0:1 ${kernel_addr_r} ${kernel_file} && load mmc 0:1 ${fdt_addr_r} ${soc}-colibri-${fdt_board}.dtb && run fdt_fixup && bootz ${kernel_addr_r} - ${fdt_addr_r}
serial#=02910736
serverip=192.168.10.1
setethupdate=if env exists ethaddr; then; else setenv ethaddr 00:14:2d:00:00:00; fi; tftpboot ${loadaddr} ${board}/flash_eth.img && source ${loadaddr}
setsdupdate=mmc rescan && setenv interface mmc && fatload ${interface} 0:1 ${loadaddr} ${board}/flash_blk.img && source ${loadaddr}
setup=setenv setupargs console=tty1 console=${console},${baudrate}n8 ${memargs} consoleblank=0
setupdate=run setsdupdate || run setusbupdate || run setethupdate
setusbupdate=usb start && setenv interface usb && fatload ${interface} 0:1 ${loadaddr} ${board}/flash_blk.img && source ${loadaddr}
soc=imx7d
splashpos=m,m
ubiargs=ubi.mtd=ubi root=ubi0:rootfs rootfstype=ubifs ubi.fm_autoconvert=1
ubiboot=run setup; setenv bootargs ${defargs} ${ubiargs} ${setupargs} ${vidargs}; echo Booting from NAND...; ubi part ubi && run m4boot && ubi read ${kernel_addr_r} kernel && ubi read ${fdt_addr_r} dtb && run fdt_fixup && bootz ${kernel_addr_r} - ${fdt_addr_r}
updlevel=2
usb_boot=usb start; if usb dev ${devnum}; then setenv devtype usb; run scan_dev_for_boot_part; fi
vendor=toradex
vidargs=video=mxsfb:640x480M-16@60
videomode=video=ctfb:x:640,y:480,depth:18,pclk:39722,le:48,ri:16,up:33,lo:10,hs:96,vs:2,sync:0,vmode:0

Environment size: 4579/131068 bytes
Colibri iMX7 #

You have to set the m4boot variable to its default ;

setenv m4boot ;
saveenv

Thanks. Do you know why it does not work to automatically boot?

Thanks. Do you know why it does not work to automatically boot?

If you use a elf firmware you cannot load it directly into SRAM since the loader will make sure it gets loaded at the correct location. Just load it to the default load address. Cache flush is also not necessary in this case, so your m4boot command should look like this:

ubi read ${loadaddr} m4firmware && bootaux ${loadaddr}

E.g.

setenv m4boot 'ubi read ${loadaddr} m4firmware && bootaux ${loadaddr}'

Sorry it works now. I ran “env default -a”, “saveenv” and flashed my OS new with “run setupdate” and “run update”. Maybe this hint helps someone.

I had an issue with iMX7d and Colibri evaluation board.

My setup :
** Qt2Boot linux (SD card) on A7 core and hello_world example (which uses UART2) on M4 core.**

Problem: Following the articles I could run the hello_world on M4 or the QT linux on A7 but not both in auto-boot.

Uboot error :

Booting from MMC/SD card…<\r>

Error, no UBI device/partition selected!

What I had to do to get both in auto boot:


Flash Qt2Boot. See QT documentation for iMX.

Colibri iMX7 # run setupdate

Colibri iMX7 # run update


Deactivate UART2 in device tree for linux and copy the changed device tree to SD card (might also be deactivated via uboot).


See Toradex article “FreeRTOS on the Cortex-M4 of a Colibri iMX7” for reference.

Compile “hello_world” to elf and copy to SD card.


Store a Firmware on Flash and Run it on Boot

  1. Colibri iMX7 # ubi part ubi
  2. Colibri iMX7 # fatload mmc 0:1 ${loadaddr} hello_world.elf
  3. Colibri iMX7 # ubi write ${loadaddr} m4firmware ${filesize}
  4. Colibri iMX7 # setenv m4boot ‘ubi part ubi && ubi read ${loadaddr} m4firmware && dcache flush && bootaux ${loadaddr}’
  5. Colibri iMX7 # saveenv

The difference to the documentation is in 4 ‘ubi part ubi’ .
Without it didnt work for me. Not sure if this is the intended solution.

Hm, maybe Boot2Qt is using a different environment? Normally we run m4boot after attaching to UBI, e.g. the ubiboot command executed run m4boot after ubi part ubi:

ubiboot=run setup; setenv bootargs ${defargs} ${ubiargs} ${setupargs} ${vidargs}; echo Booting from NAND...; ubi part ubi && run m4boot && ubi read ${kernel_addr_r} kernel && ubi read ${fdt_addr_r} dtb && run fdt_fixup && bootz ${kernel_addr_r} - ${fdt_addr_r}