Yocto U-Boot 4.1.15 features

From Variscite Wiki
U-Boot features


Note: The default environment may change between releases/commits.
If you manually upgrade U-Boot, and you have an old environment saved, it is a good idea to reset your environment to the new default (see Environment handling commands).
(There is no need to do that manually if you install U-Boot using our recovery SD card image).

Notable features:

USB Mass Storage gadget

You can use the board as a USB Mass Storage device:
You will be able to access all the partitions of any block device that is on the board or connected to it, from your host PC - You will see them as /dev/sdXX, just like connecting a regular USB storage to your PC, and you'll be able to mount them, and have full read/write access to them. You can even use it to flash a new U-Boot, re-partition the storage, re-format it, etc.
This is especially useful for updating the internal eMMC.

To do this you need to connect a USB cable between the USB Client port of the board and a regular USB Host port on your PC, and use U-Boot's ums command.

General ums usage is:

ums <USB_controller> [<devtype>] <devnum>  e.g. ums 0 mmc 0
    devtype defaults to mmc

devtype can be any block device (e.g. mmc, usb)

To mount the eMMC:

=> ums 0 mmc 2

To mount an SD card:

=> ums 0 mmc 1

Depending on your host PC, it may automatically mount it or not. If not, you can use dmesg to see the names of the device and its partitions (it should be in the form of /dev/sdXX) and mount them yourself.
To exit the ums command and disconnect the USB device press ctrl+c.

Note: You should use a Linux PC host as Windows can't naturally read ext file systems.

USB Ethernet Gadget

The USB Ethernet gadget allows you to make the board act as a USB Ethernet device when connecting its USB Client port to a host PC using a USB cable.
Basically, it allows for "Ethernet over USB".
This is especially useful if you build a custom board without an Ethernet interface and you want to boot via network using TFTP.

This feature is disabled by default. To enable it, you need to un-comment the defines of the following configs in include/configs/imx8mp_var_dart.h in the U-Boot source code:

CONFIG_USB_ETHER
CONFIG_USB_ETH_CDC

Now you should have a new Ethernet interface called usb_ether.

Before actually using it you should get to know the following environment variables:
Variables specific to this gadget:

usbnet_devaddr  - The virtual MAC address of the device (the board side).
usbnet_hostaddr - The virtual MAC address of the host (the PC side).

General network variables:

ethprime - Sets the primary Ethernet interface. This is the interface that will be tried first.
ethact   - Sets the currently active Ethernet interface. Normally, it is modified by the Ethernet driver, but you can change it if you want to override.
ipaddr   - IP address of the device - needed for tftp command.
netmask  - Subnet Mask.
serverip - TFTP server IP address - needed for tftp command.

So, for example:

=> setenv usbnet_devaddr f8:dc:7a:00:00:02
=> setenv usbnet_hostaddr f8:dc:7a:00:00:01
=> setenv ethact usb_ether
=> setenv ipaddr 192.168.0.100
=> setenv netmask 255.255.255.0
=> setenv serverip 192.168.0.101

And now your are ready to use tftpboot over the usb_ether interface.

Notes:

  • Once you run a network command, e.g. tftpboot, the gadget will be connected to your host PC and a new network adapter will be added to it, for the duration of the network interaction.
  • Note that you may need to configure your host PC to use the new network adapter properly - this configuration is OS dependent.



General U-Boot commands

List all supported commands and their description/usage (help command)

List all supported commands with a brief description for each one:

=> help

Print the description and usage of 'command':

=> help command

Environment handling commands

Print the values of all environment variables:

=> printenv

Print value of environment variable 'name':

=> printenv name

Set environment variable 'name' to 'value ...':

=> setenv name value ...

Delete environment variable 'name':

=> setenv name

Reset default environment:

=> env default -a

Save environment variables to persistent storage:

=> saveenv

File System access

List files in a directory (default /):

=> ls <interface> [<dev[:part]>] [directory]

For example:

List files in the BOOT partition of our NAND/eMMC Recovery SD card (after booting from it):
=> ls mmc 0:1
List files in directory /opt/images/Yocto in the rootfs partition of our NAND/eMMC Recovery SD card (after booting from it):
=> ls mmc 0:2 /opt/images/Yocto

Load binary file 'filename' from a partition to RAM address 'addr':

=> load <interface> [<dev[:part]> [<addr> [<filename> [bytes [pos]]]]]



USB sub-system

To use the USB as host (connect a USB Storage or Ethernet Device to the board), you need to use the usb command.
Usage:

usb start - start (scan) USB controller
usb reset - reset (rescan) USB controller
usb stop [f] - stop USB [f]=force stop
usb tree - show USB device tree
usb info [dev] - show available USB devices
usb test [dev] [port] [mode] - set USB 2.0 test mode
    (specify port 0 to indicate the device's upstream port)
    Available modes: J, K, S[E0_NAK], P[acket], F[orce_Enable]
usb storage - show details of USB storage devices
usb dev [dev] - show or set current USB storage device
usb part [dev] - print partition table of one or all USB storage    devices
usb read addr blk# cnt - read `cnt' blocks starting at block `blk#'
    to memory address `addr'
usb write addr blk# cnt - write `cnt' blocks starting at block `blk#'
    from memory address `addr'

First, connect your device to a USB port on the board.
After the device is connected, start the USB controller:

=> usb start

If you connect/disconnect devices after that, before you can access them you need to rescan the USB controller:

=> usb reset


Using a USB Storage Device

Once you connected the device and stated the USB controller, you can now use the regular File System commands mentioned above with it.
The <interface> in this case is 'usb'.