Boot TEZI from ethernet

Tried to boot and run TEZI using bootcmd_dhcp command.
TEZI files placed in the root directory of TFTP server which running on the host machine. TFTP server is bounded to host machine IP and env serverip value changed to the same host machine IP.
After run bootcmd_dhcp files 'boot.scr and overlays.txt are successfully loaded from host and then process stop. What is wrong with that?
Please refer to the attached:
Colibri iMX8X # run bootcmd_dhcp
BOOTP broadcast 1
BOOTP broadcast 2
DHCP client bound to address 192.168.8.20 (255 ms)
Using ethernet@5b040000 device
TFTP from server 192.168.9.153; our IP address is 192.168.8.20
Filename ‘boot.scr’.
Load address: 0x83200000
Loading: ################################################## 3.1 KiB

  •     340.8 KiB/s*
    

done
Bytes transferred = 3141 (c45 hex)
## Executing script at 83200000
BOOTP broadcast 1
BOOTP broadcast 2
DHCP client bound to address 192.168.8.20 (255 ms)
Using ethernet@5b040000 device
TFTP from server 192.168.9.153; our IP address is 192.168.8.20
Filename ‘overlays.txt’.
Load address: 0x87000000
Loading: ################################################## 112 Bytes

  •     6.8 KiB/s*
    

done
Bytes transferred = 112 (70 hex)
*** Bad device specification dhcp ***
Colibri iMX8X #

Hi @Serghey , our default boot-tezi.scr only supports loading tezi.itb from mmc or usb device.

 env set bootcmd_tezi 'load ${devtype} ${devnum}:${distro_bootpart} ${ramdisk_addr_r} ${tezi_image}'

For tftp loading, bootcmd_tezi needs change.

env set bootcmd_tezi 'tftp ${ramdisk_addr_r} ${tezi_image}'

boot.cmd (3.0 KB)
is the source file of boot-tezi.scr. And compile it by the following command.

mkimage -T script -C none -n "Distro boot script" -d boot.cmd boot.scr

You can also quickly test with this
boot.scr (3.0 KB).

In U-boot, run bootcmd_dhcp still works. bootcmd_tftp skips usb initialization and saves a few seconds.

env set bootcmd_tftp 'setenv devtype tftp; tftp ${scriptaddr} ${boot_script_dhcp}; source ${scriptaddr}'

Hi Benjamin.
thank you for the reply.
I compiled boot.cmd provided and got boot.scr (3.0 KB) file, then copied it to TFTP root of the PC.
Then the following was done:
Colibri iMX8X # env default -a
## Resetting to default environment
Colibri iMX8X # setenv serverip 192.168.9.153
Colibri iMX8X # env set bootcmd_tezi ‘tftp ${ramdisk_addr_r} ${tezi_image}’
Colibri iMX8X # saveenv
Saving Environment to MMC… Writing to MMC(0)… OK
Colibri iMX8X # run bootcmd_tezi
**** Warning: no boot file name; using ‘C0A80A02.img’*
Using ethernet@5b040000 device
TFTP from server 192.168.9.153; our IP address is 192.168.10.2
Filename ‘C0A80A02.img’.
Load address: 0x8a000000
Loading: ## Warning: gatewayip needed but not set

TFTP error: ‘Could not find file ‘C:\TFTP-Root\C0A80A02.img’.’ (1)
Not retrying…
Colibri iMX8X #
Colibri iMX8X #

The proposed quick test provides the following messages:

Colibri iMX8X # env set bootcmd_tftp ‘setenv devtype tftp; tftp ${scriptaddr} ${boot_script_dhcp}; source ${scriptaddr}’
Colibri iMX8X # saveenv
Saving Environment to MMC… Writing to MMC(0)… OK
Colibri iMX8X # run bootcmd_tftp
Using ethernet@5b040000 device
TFTP from server 192.168.9.153; our IP address is 192.168.10.2
Filename ‘boot.scr’.
Load address: 0x83200000
Loading: ## Warning: gatewayip needed but not set
################################################## 3 KiB

  •     216.8 KiB/s*
    

done
Bytes transferred = 3116 (c2c hex)
## Executing script at 83200000
Using ethernet@5b040000 device
TFTP from server 192.168.9.153; our IP address is 192.168.10.2
Filename ‘overlays.txt’.
Load address: 0x87000000
Loading: ## Warning: gatewayip needed but not set
################################################## 112 Bytes

  •     6.8 KiB/s*
    

done
Bytes transferred = 112 (70 hex)
Using ethernet@5b040000 device
TFTP from server 192.168.9.153; our IP address is 192.168.10.2
Filename ‘tezi.itb’.
Load address: 0x8a000000
Loading: ## Warning: gatewayip needed but not set
################################################## 45.6 MiB

  •     3.5 MiB/s*
    

done
Bytes transferred = 47772008 (2d8f168 hex)
Bootargs: quiet video=DPI-1:640x480-16@60D initcall_blacklist=vpu_driver_init rootfstype=squashfs root=/dev/ram autoinstall clk_ignore_unused pci=nomsi
## Loading kernel from FIT Image at 8a000000 …
Could not find configuration node
ERROR: can’t get kernel image!
Colibri iMX8X #

Could you please help to determine what wrong was done?
Thank you,
Serghey.

This parameter will load nothing as tezi_image is not defined in default u-boot environment. It is only define by boot.scr env set tezi_image ${prefix}tezi.itb. So boot.scr should be loade and executed and let boot.scr to load tezi .itb later.

What is the version of U-boot on Colibri iMX8X? And what is the Toradex Easy Installer version where tezi.itb comes from?

U-Boot 2020.04-5.7.0+git.33bb8e968332 (Jan 01 1970 - 00:00:00 +0000)

Colibri-iMX8X_ToradexEasyInstaller_5.7.0+build.12

The versions should be fine. Before seting bootcmd_tftp, ipaddr and serverip, it is better to clean u-boot environment by env default -fa.

Hi Bedjamin,
It still not successful, this is what I got:

Colibri iMX8X # env default -fa
## Resetting to default environment
Colibri iMX8X # setenv serverip 192.168.9.153
Colibri iMX8X # env set bootcmd_tftp ‘setenv devtype tftp; tftp ${scriptaddr} ${boot_script_dhcp}; source ${scriptaddr}’
Colibri iMX8X # run bootcmd_tftp
Using ethernet@5b040000 device
TFTP from server 192.168.9.153; our IP address is 192.168.10.2
Filename ‘boot.scr’.
Load address: 0x83200000
Loading: ## Warning: gatewayip needed but not set
################################################## 3 KiB

  •     202.1 KiB/s*
    

done
Bytes transferred = 3116 (c2c hex)
## Executing script at 83200000
Using ethernet@5b040000 device
TFTP from server 192.168.9.153; our IP address is 192.168.10.2
Filename ‘overlays.txt’.
Load address: 0x87000000
Loading: ## Warning: gatewayip needed but not set
################################################## 112 Bytes

  •     8.8 KiB/s*
    

done
Bytes transferred = 112 (70 hex)
Using ethernet@5b040000 device
TFTP from server 192.168.9.153; our IP address is 192.168.10.2
Filename ‘tezi.itb’.
Load address: 0x8a000000
Loading: ## Warning: gatewayip needed but not set
################################################## 45.6 MiB

  •     3.6 MiB/s*
    

done
Bytes transferred = 47772008 (2d8f168 hex)
Bootargs: quiet video=DPI-1:640x480-16@60D initcall_blacklist=vpu_driver_init rootfstype=squashfs root=/dev/ram autoinstall clk_ignore_unused pci=nomsi
## Loading kernel from FIT Image at 8a000000 …
Could not find configuration node
ERROR: can’t get kernel image!
Colibri iMX8X #

Hi Bedjamin,
Please ignore the previous post. We found the mistake an can run TEZI from tftp server.
Could you please help with one more question:
Is it possible to include tftp in the targets for distro_bootcmd and if so how to do that?
The purpose is to make module to boot from mmc0 if TFTP boot fail.
Thank you very much for your help.

Hi @Serghey , the boot scrip was changed a little bit between v5.6 and v5.7.

--- boot-5.6.cmd	2022-08-05 07:34:51.010881180 +0800
+++ boot-5.7.cmd	2022-08-05 07:33:47.492094520 +0800
@@ -57,9 +57,9 @@
        env set set_load_overlays_file 'env set load_overlays_file "env import -t 0x82e10000 0x200"'
 fi
 
-env set set_apply_overlays 'env set apply_overlays "for overlay_file in \"\\${fdt_overlays}\"; do env set fitconf_fdt_overlays \"\\"\\${fitconf_fdt_overlays}#config@\\${overlay_file}\\"\"; env set overlay_file; done; true"'
+env set set_apply_overlays 'env set apply_overlays "for overlay_file in \"\\${fdt_overlays}\"; do env set fitconf_fdt_overlays \"\\"\\${fitconf_fdt_overlays}#conf-\\${overlay_file}\\"\"; env set overlay_file; done; true"'
 
-env set bootcmd_run 'echo "Bootargs: \${bootargs}" && bootm ${ramdisk_addr_r}#config@freescale_\${fdtfile}\${fitconf_fdt_overlays}'
+env set bootcmd_run 'echo "Bootargs: \${bootargs}" && bootm ${ramdisk_addr_r}#conf-\${fdtfile}\${fitconf_fdt_overlays}'
 
 run set_load_overlays_file
 run set_apply_overlays

boot.scr (3.0 KB)
boot-5.7.cmd (3.0 KB)
The above files should load Toradex Easy Installer v5.7 successfully on Colibri iMX8X. I just tested it.

Hi Benjamin,
Thank you, it works great.
Now we need to provide the following boot sequence:
1.Try boot from TFTP and if fail try to boot from USB.
2.If both ,TFTP and USB boot fail, run firmware from mmc0.
What changes should be done in environment to implement algorithm above?

Hi @Serghey , this is can be done by prioritizing boot_targets in u-boot.

Colibri iMX8X # print distro_bootcmd
distro_bootcmd=for target in ${boot_targets}; do run bootcmd_${target}; done
Colibri iMX8X # print boot_targets
boot_targets=mmc1 mmc0 usb0 dhcp

Hi Benjamin,
This is what I tried to do;
boot_targets=usb0 tftp mmc0
bootcmd=run distro_bootcmd
I works fine : when usb plugged in, module boots from usb and when usb unplugged module boots from tftp. But when unplug usb and stop tftp server booting does not reach mmc0. It got stock on tftp:
Using ethernet@5b040000 device
TFTP from server 192.168.9.153; our IP address is 192.168.10.2
Filename ‘boot.scr’.
Load address: 0x83200000
Loading: ## Warning: gatewayip needed but not set
T T T T T T T T T T
Retry count exceeded; starting again
## Executing script at 83200000
Wrong image format for “source” command
switch to partitions #0, OK
mmc0(part 0) is current device
*** Bad device specification tftp 0 ***
Colibri iMX8X #
How i can boot from mmc0 when both usb and tftp not available?

Hi @Serghey , please try the following config in u-boot.

setenv usb_boot 'usb start; if usb dev ${devnum}; then setenv devtype usb; run scan_dev_for_boot_part; fi'
setenv bootcmd_tftp 'if tftp ${scriptaddr} ${boot_script_dhcp}; then setenv devtype tftp; source ${scriptaddr}; fi'
setenv mmc_boot 'if mmc dev ${devnum}; then setenv devtype mmc; run scan_dev_for_boot_part; fi'
setenv boot_targets 'tftp usb0 mmc0'
saveenv

Thank you, Benjamin,
It works fine.
One more question: Is it possible to decrease tftp retry count?

Hi @Serghey,

I’ll let @benjamin.tx comment on the tftp retry count; I don’t know the answer off-hand.
However, I did want to touch base to understand what your use case was for loading TEZI in this way. One of my colleagues mentioned that you might be doing this to implement an offline update method for Torizon devices which do not have a network connection. If that is the case, I encourage you to checkout our Secure Offline Update feature which was recently released. This adds the ability to do USB- or SD- based updates but retaining all the robustness and data integrity that is part of our standard online OTA mechanism. It is designed for just this use case. Please take a look and let me know if I can help.

Drew

1 Like

Hi @Serghey , you may try to set netretry in u-boot to no or once.

Thank you again, Benjamin.
setnetretry to no did not solve the problem, but setenv tftptimeout to 1000 improved.
It still additional 10 seconds delay, but acceptable.
One more issue;
if device does not have network access boot process delayed :
ethernet@5b040000 Waiting for PHY auto negotiation to complete… TIMEOUT
Is it any way do disable/decrease this TIMEOUT?
Best regards,
Serghey.

Hi Drew,
Thank you for join.
Some customers may have many units connected to the internal server, some may use standalone device without any connection. Internal server itself may have internet access or not. We are trying to cover all cases without firmware customization. Update should be initiated by the customer, and procedure must be as simple as possible (we choose reset by power circle). Currently with Benjamin’s help we release update from USB (trying first) TFTP (Can download TEZI but for standalone units some delay taking place on TFTP attempt).
If both USB and TFTP not work our application is start.

Hi @Serghey , it is not easy to change PHY negotiation time as this value is hard coded here and referenced here.
If this value were to be changed, you would validate it carefully. Leave enough margin before timeout when Colibri iMX8X has network access.

Hi Benjamin,
This boot delay is not very important and case out of network is not typical.
For now I will be not touch it. Everything works great.
Thank you very much for your support!
Serghey.