How to Create Your Own uEnv.txt File for U-Boot for a Microprocessor Device

Beaglebone black board






In this article, we explain how you can create your own uEnv.txt file for use with u-boot to boot a linux kernel for a given microprocessor device such as a BeagleBone board.

The uEnv.txt file is a key file, because it gives important commands and information to U-boot, so that U-boot can successfully load a linux kernel image.

If you are creating your own custom software to run a linux kernel, and you are building it from the ground up using files such as the MLO and U-boot, you will also need a uEnv.txt file, so that U-boot knows things such as where the linux kernel image is located in the file system, along with the device tree binary (.dtb) file for the board in use.

We will walk through all aspects of the uEnv.txt file in this article, to show the most essential and needed parts that are required for U-boot to be able to boot the linux kernel.

As the full name demonstrates, the uEnv.txt file is a simple text file.

Therefore, we can open any basic text software and create it and then use that file, as it, with no needed modifications.

So let's now go over the elements we need to include in a uEnv.txt file for it to work with U-boot to successfully load a linux kernel image.

The uEnv.txt file that we will create is shown below.

Note that this uEnv.txt file will run the linux kernel image from an SD card. Later, we show how to


linuxbootenv=setenv serverip 192.168.1.2
ipaddr=192.168.27.1
bootargs=console=ttyO0,115200 root=/dev/mmcblk0p2 rw
bootcmd=load mc 0:2 0x82000000 /boot/uImage;load mc 0:2 0x88000000 /boot/am335x-boneblack.dtb;bootm 0x82000000 - 0x88000000;



So it is normally advisable to put the serverip and ipaddr information in the uEnv.txt file in case you are booting a linux kernel image or device tree binary file from a network, in which case internet connection would have to be established. So it is common practice to include this information in a uEnv.txt file.

After specifying these values, we proceed to define the environment variable, bootargs. We first specify where debug messages should be sent, which is ttyO0 at a baud rate of 115200. We then specify the location of the root filesystem, which is, /dev/mmcblk0p2. /dev/mmcblk0p2 specifies the second partition of the SD card.

We then must define the bootcmd variable. This variable defines the entire booting process and sequence to boot the linux kernel image file.

First we load from the second partition of the SD card the uImage file found in /boot/uImage to the load address of 0x82000000.

mc 0 signifies the SD card.

mc 0:2 signifies the second partition of the SD card.

We then load also from the second partition of the SD card the dtb file found in the same boot folder to the load address of 0x88000000.

We then boot the linux kernel using the bootm command (boot from memory).

This is one of the simplest uEnv.txt files that we can create.

This will effectively allow U-boot to run the linux kernel image on an SD card.

A modification of this program is if you want U-boot to run the linux kernel image on the eMMC memory of the board.

In this case, the code would be modified to mc 1, which is the eMMC memory on the board.

The complete uEnv.txt file is shown below.


linuxbootenv=setenv serverip 192.168.1.2
ipaddr=192.168.27.1
bootargs=console=ttyO0,115200 root=/dev/mmcblk0p2 rw
bootcmd=load mc 1:2 0x82000000 /boot/uImage;load mc 1:2 0x88000000 /boot/am335x-boneblack.dtb;bootm 0x82000000 - 0x88000000;



So instead of running the linux kernel from the SD card, if you want the linux kernel on the eMMC memory to be run, you would use the above code.

So these uEnv.txt files are adequate for running linux kernel image files from either an SD card or from eMMC memory on the board.

This is a most basic uEnv.txt file. We can add other parameters such as whether there should be autoload. We can also print a message to the console during the booting process.

For example, in the program, we print ****Booting from Memory**** while the device is being booted from the SD card.


linuxbootenv=setenv serverip 192.168.1.2
ipaddr=192.168.27.1
bootargs=console=ttyO0,115200 root=/dev/mmcblk0p2 rw
bootcmd=echo"****Booting from Memory****";load mc 0:2 0x82000000 /boot/uImage;load mc 0:2 0x88000000 /boot/am335x-boneblack.dtb;bootm 0x82000000 - 0x88000000;



Now when we run this program, while U-boot is booting the linux kernel, we will see the message, ****Booting from Memory**** in the console.

So this is how we can create our own uEnv.txt file for U-boot for it to boot the linux kernel disc image on our microprocessor board.



Related Resources





HTML Comment Box is loading comments...