Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting U-boot's Version from Userspace

Does anyone know of a way to get U-boot version installed from userspace? There is the fw_printenv command that provides access to U-boot's environment variables, but not the version.

like image 633
waffleman Avatar asked Apr 25 '11 18:04

waffleman


People also ask

How do I find my U-Boot version?

A bulletproof way of accomplishing this would be to pass your u-boot version to the kernel (uboot=blah) and then read /proc. If you're want to make sure you know for sure what version you booted with, not just whats on the flash.

What is U-Boot FW utils?

The U-Boot fw-utils is a tool provided by the bootloader that contains the fw_printenv and fw_setenv utilities to read and write U-Boot environment variables from Linux user space. It is supported out-of-the-box in the Yocto compatible Toradex Embedded Linux BSP, which uses the OpenEmbedded build system.

Is U-Boot a second stage bootloader?

U-Boot is both a first-stage and second-stage bootloader. It is loaded by the system's ROM (e.g. onchip ROM of the ARM CPU) from a supported boot device, such as an SD card, SATA drive, NOR flash (e.g. using SPI or I²C), or NAND flash.

Is U-Boot a bootloader?

Das U-Boot ("the Universal Boot Loader" or U-Boot) is an open-source bootloader that can be used on ST boards to initialize the platform and load the Linux® kernel. Read the README file before starting using U-Boot.


2 Answers

If U-boot is located in mtd0, you can get version info as follows:

root@SUPERWIFI:/proc# strings /dev/mtd0 | grep U-Boot    
U-Boot 1.1.4-g1c8343c8-dirty (Feb 28 2014 - 13:56:54)
U-Boot
Now running in RAM - U-Boot at: %08lx
like image 64
SHI Shougang Avatar answered Sep 17 '22 09:09

SHI Shougang


Just an update for this. In our version of U-Boot we changed the code for main_loop() in main.c to this:

#ifdef CONFIG_VERSION_VARIABLE
    char *oldver=getenv("ver");
    if(oldver==0 ||strcmp(oldver,version_string))
    {
        setenv("ver", version_string);  /* set version variable */
        saveenv();
    }
#endif /* CONFIG_VERSION_VARIABLE */

So setenv/saveenv is only called, if needed by an update. In our firmware we added

/sbin/fw_printenv -n ver > /var/config/u-boot.ver

to make the u-boot version public available.

like image 42
bassklampfe Avatar answered Sep 19 '22 09:09

bassklampfe