How to setenv and update uboot via usb stick

Hello,
I build a custom linux for my colibri board as is described in OpenEmbedded (core) - Toradex System/Computer on Modules.

I customized it to boot from SD-Card in build/local.conf

IMAGE_FSTYPES += “tar.bz2 sdcard cpio.gz”

If I use a new toradex board.

Now I have to update the uboot/system with the easy installer and after this I could change the environment variable serial.

The problem is this is not a practicable way for more than 5 devices.

So is it possible that I update the uboot from the device with changed env variables, without using the serial interface?

After this I would prefer a network boot. So I setup a Ubuntu server in a virtual mashine. I had setup the mashine descripe in How to setup Networking for Embedded Linux Application Development. But I don’t understand which files I have to copy to TFTP and which I have to copy in NFS?

Maybe I don’t understand the openembedded core image really is. Is it equal to https://developer1.toradex.com/files/toradex-dev/uploads/media/Colibri/Linux/Images/Colibri-iMX7_LXDE-Image_2.8b5.156-20181228.tar.bz2 ?

Regards,
hetofs

I build a custom linux for my colibri board as is described in https://developer.toradex.com/knowledge-base/board-support-package/openembedded-(core).

I customized it to boot from SD-Card in build/local.conf

IMAGE_FSTYPES += “tar.bz2 sdcard cpio.gz”

If I use a new Toradex board.

Now I have to update the uboot/system with the easy installer

Note that you may also automatically customise the U-Boot environment (see u_boot_env) during installation:

https://developer.toradex.com/software/toradex-easy-installer#configuration-files

and after this I could change the environment variable serial.

I do not understand what exactly you do want to change the environment variable serial for.

The problem is this is not a practicable way for more than 5 devices.

What exactly is not practicable? Note that the Toradex Easy Installer may install your desired image automatically if autoinstall is set to true.

So is it possible that I update the uboot from the device with changed env variables, without using the serial interface?

Yes, that is exactly what u_boot_env is meant to be used for.

After this I would prefer a network boot. So I setup a Ubuntu server in a virtual mashine. I had setup the mashine descripe in https://developer.toradex.com/knowledge-base/how-to-setup-networking-for-embedded-linux-application-development. But I don’t understand which files I have to copy to TFTP and which I have to copy in NFS?

What exactly is it that you are trying to achieve with such a network boot? Previously, you wanted to boot from an SD card.

Maybe I don’t understand the openembedded core image really is.

There is no such thing as an OpenEmbedded core image. OpenEmbedded is a build system where you may build images like e.g. the LXDE-Image. But you may also build any other image or even build your customised image.

Is it equal to https://developer1.toradex.com/files/toradex-dev/uploads/media/Colibri/Linux/Images/Colibri-iMX7_LXDE-Image_2.8b5.156-20181228.tar.bz2 ?

No, this is just a particular image built off the following image recipe:

http://git.toradex.com/cgit/meta-toradex-demos.git/tree/recipes-images/images/angstrom-lxde-image.bb?h=rocko

My main target is to update the device in the field via server and the opportunities to change the uboot environment variables via USB-Stick.

Unfortunately, non of those two things is integrated out-of-the-box in any of our BSPs.

The USE-CASE1 is not so important anymore. But there was also the question how to change the environment variable via USB-Stick.

USE-CASE1: standalone colibri IMX7-board in the field. The device is boot from the sd-card.

If you anyway boot from an SD card, why don’t you just swap the card then to update?

So I build a custom open embedded core image.

Than I update the device with the easy-installer, because out of box the device could not save the environment variable. After the update I could save the environment variable.

Yes, that is expected behaviour as the Toradex Easy Installer configuration of U-Boot needs to be foolproof in that sense.

Colibri iMX7 # bootcmd=mmc rescan; mmc dev 0; run sdboot

After this the device are booting from the sdcard.

So this way was practicable because I only have 4-8 devices.

With the Toradex Easy Installer’s autoinstall feature this should be practicable for any number of devices.

USE-CASE2

In my second use-case I want to flash the device via LAN. First I have config my ubuntu system decribed here:

https://developer.toradex.com/knowledge-base/how-to-setup-networking-for-embedded-linux-application-development

and load my image to the server describe here: https://developer.toradex.com/knowledge-base//knowlodge-base/flashing-linux-over-ethernet

The target is to update the devices in the field without the usage of the serial console.

While the legacy update procedure is not really meant for unattended installation out-of-the-box you may of course integrate it that way.

Attention: I have build a colibri build described here https://developer.toradex.com/knowledge-base/board-support-package/openembedded-(core) because my custom build did not contain the update.sh script.

If done properly according to our guide you should get the exact same legacy resp. Toradex Easy Installer packages as the pre-build demo images we deploy.

Q: If I changed the uEnv.txt for sdcard boot, what I have to do after this?

uEnv.txt is only meant to be used with the Toradex Easy Installer. The legacy update procedure does not really integrate any such.

Extract the …tar.bz2 to a sdcard and update the device with:

Colibri iMX7 # run setupdate …

Colibri iMX7 # run update

I though, you do want to boot from an SD card. Then, you would just need to dd resp. WIC image to your SD card.

Is this possible or I have to use the toradex easy-installer?

To actually install U-Boot proper with your custom uEnv.txt set to SD card boot I would recommend using the Toradex Easy Installer.

Or is there a simpler way?

For my second use-case.

But what exactly is your 2nd use-case? Updating the SD card you are booting off of? Or what exactly is it that you are trying to achieve?

I have to copy the image to the folder with:

update.sh -c -o /srv/tftp/

https://developer.toradex.com/knowledge-base//knowlodge-base/flashing-linux-over-ethernet

But I don’t understand which files I have to add to the nfs.

What NFS? What exactly are you talking about?

Is it possible to update the device in the field (only via update the server-files). Or is this step:

Colibri iMX7 # run setupdate … Colibri iMX7 # run update

via console, necessary after every update?

You mean after every update of them update files on your sever? No, you may also adjust the U-Boot environment from running Linux using the fw_setenv utility.

Before this step I could change the environment variable of the uboot by editing uEnv.txt?

As mentioned above uEnv.txt integration is solely meant for use with the Toradex Easy Installer.

Now I don’t understand why the update is not possible?

Somehow it does not detect your update files.

(2) Maybe someone could tell me which files I have to upload into tftp and nfs for a network boot?

Now, I believe you are mixing legacy network aka TFTP update being descibed here:

https://developer.toradex.com/knowledge-base//knowlodge-base/flashing-linux-over-ethernet

With NFS network boot described here:

https://developer.toradex.com/knowledge-base/boot-from-a-tftpnfs-server

Which are two completely different things.

(3) If I upload new files to the server with a device anywere in the world but connected to my server: Is it possible to update the device with the server without the usage from uboot serial mode or toradex easy installer?

The legacy update procedure is really not meant for updates accross the Internet. I recommend having a look at our new offerings around Torizon being in the works:

https://labs.toradex.com/projects/torizon

Hello,

thank you for your help. I have to clarify my questions:

My main target is to update the device in the field via server and the opportunities to change the uboot environment variables via USB-Stick.

The USE-CASE1 is not so important anymore. But there was also the question how to change the environment variable via USB-Stick.

USE-CASE1:
standalone colibri IMX7-board in the field. The device is boot from the sd-card. So I build a custom open embedded core image.

custombuild

Than I update the device with the easy-installer, because out of box the device could not save the environment variable.
After the update I could save the environment variable.

Colibri iMX7 # bootcmd=mmc rescan; mmc dev 0; run sdboot

After this the device are booting from the sdcard.

So this way was practicable because I only have 4-8 devices.

USE-CASE2

In my second use-case I want to flash the device via LAN. First I have config my ubuntu system decribed here:

https://developer.toradex.com/knowledge-base/how-to-setup-networking-for-embedded-linux-application-development

and load my image to the server describe here:
https://developer.toradex.com/knowledge-base//knowlodge-base/flashing-linux-over-ethernet

The target is to update the devices in the field without the usage of the serial console.

Attention: I have build a colibri build described here https://developer.toradex.com/knowledge-base/board-support-package/openembedded-(core) because my custom build did not contain the update.sh script.

toradexbuild

Q:

  • If I changed the uEnv.txt for sdcard boot, what I have to do after this? Extract the …tar.bz2 to a sdcard and update the device with:

Colibri iMX7 # run setupdate

Colibri iMX7 # run update

Is this possible or I have to use the toradex easy-installer? Or is there a simpler way?

  • For my second use-case. I have to copy the image to the folder with:

update.sh -c -o /srv/tftp/

https://developer.toradex.com/knowledge-base//knowlodge-base/flashing-linux-over-ethernet

But I don’t understand which files I have to add to the nfs.

  • Is it possible to update the device in the field (only via update the server-files). Or is this step:

Colibri iMX7 # run setupdate

Colibri iMX7 # run update

via console, necessary after every update?

alt text

I think I am understand everything better.

So build a colibri image descriped here:

https://developer.toradex.com/knowledge-base/board-support-package/openembedded-(core)

Extract the tar.bz2 and flash it to a stick:
deploy/images

./update.sh -o /media/KERNEL

Before this step I could change the environment variable of the uboot by editing uEnv.txt?

The stick now contains this:
usbstick
files.

U-Boot 2016.11 (Dec 15 2017 - 12:04:00 +0100)

CPU:   Freescale i.MX7D rev1.2 996 MHz (running at 792 MHz)
CPU:   Extended Commercial temperature grade (-20C to 105C) at 34C
Reset cause: POR
DRAM:  512 MiB
PMIC:  RN5T567 LSIVER=0x01 OTPVER=0x0d
NAND:  512 MiB
MMC:   FSL_SDHC: 0
Video: 640x480x18
In:    serial
Out:   serial
Err:   serial
Model: Toradex Colibri iMX7 Dual 512MB V1.1D, Serial# 03090217
Net:   FEC0
Hit any key to stop autoboot:  0 
Colibri iMX7 # 
Colibri iMX7 # run setupdate
MMC: no card present
starting USB...
USB0:   USB EHCI 1.00
scanning bus 0 for devices... 2 USB Device(s) found
USB1:   USB EHCI 1.00
scanning bus 1 for devices... 1 USB Device(s) found
       scanning usb for storage devices... EHCI timed out on TD - token=0x80008c80
EHCI timed out on TD - token=0x80008d80
EHCI timed out on TD - token=0x80008d80
EHCI timed out on TD - token=0x80008d80
EHCI timed out on TD - token=0x80008d80
EHCI timed out on TD - token=0x80008d80
error in inquiry
0 Storage Device(s) found
** Bad device usb 0 **
FEC0 Waiting for PHY auto negotiation to complete......... TIMEOUT !
Could not initialize PHY FEC0
Using FEC0 device
TFTP from server 192.168.10.1; our IP address is 192.168.10.2
Filename 'colibri_imx7/flash_eth.img'.
Load address: 0x80800000
Loading: *
ARP Retry count exceeded; starting again
Colibri iMX7 # run update
## Error: "update" not defined
Colibri iMX7 # 

Now I don’t understand why the update is not possible?

(2) Maybe someone could tell me which files I have to upload into tftp and nfs for a network boot?

(3) If I upload new files to the server with a device anywere in the world but connected to my server:
Is it possible to update the device with the server without the usage from uboot serial mode or toradex easy installer?

Thank you very much @marcel.tx,

I have two projects. Once the Toradex board is booted with the USB stick and once a project with a Toradex board, which is connected in the field only via LAN. These projects have nothing to do with each other at first. It was a mistake of mine to mix these two projects in this request.

For the ** Project 1 ** my questions were answered. I now understand why it was necessary to make an U-Boot update with the Toradex installer to change the environment variables. I do not need help anymore for project 1.

The ** Project 2 ** I have a device which is only connected to a server. I can only access the device in production. This unit does not use an SD card. I wanted to know if it is possible to update the device in the field via LAN? No other access to the device is possible in the field. So no update by replacing the SD card or by serial access to the device. It should be noted that this is about multiple devices and therefore the update must actually be automated.

What options are there?
alt text

Ok, now I understand. For your Project 2 you may use e.g. fw_setenv to initiate an update without needing any serial console access. E.g. it could be done as follows:

  1. Use fw_setenv bootcmd 'run setethupdate; run update' to set the bootcmd to do an Ethernet update upon next reboot.
  2. Now upon reboot U-Boot will perform the update.
  3. Make sure your U-Boot update script (e.g. flash_eth.img) sets the bootcmd to the regular one again after the update is finished.
  4. Now upon reboot the regular now updated system gets booted again.

Makes sense?