How to modify U-boot configuration in Linux user space

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to modify U-boot configuration in Linux user space

9,208 Views
jiye
Contributor V

I want to change the u-boot variable in the linux userspace instead of the u-boot prompt window before starting kernel.

I am using lsdk1906 and my kernel is 4.19. I am booting from SD card.

I heard there is a way to do that by downloading the u-boot-tools

However,

After I run "apt-get install u-boot-tools"  

then I perform fw_printenv in the linux it tells me that 

Cannot parse config file '/etc/fw_env.config': No such file or directory

I checked this link:

Accessing U-Boot environment variables from Linux - ArmadeusWiki 

I need to know 

# MTD device name       Device offset   Env. size       Flash sector size       Number of sectors

I do not know what is the value of the location of my uboot.

Can anyone help?

Labels (1)
0 Kudos
7 Replies

7,734 Views
Pavel
NXP Employee
NXP Employee

Set the CONFIG_MTD = y.

 

See README and example from LSDK 1906 in the attachment.

Have a great day,
Pavel Chubakov

0 Kudos

7,734 Views
Pavel
NXP Employee
NXP Employee

fw_printenv is built into LSDK1906 Ubuntu rootfs by default. Just need to create /etc/fw_env.config and edit it to:

/dev/mtd0 0x60000000 0x2000 0x100000

See some message example below:

root@localhost:~# fw_printenv
Warning: Bad CRC, using default environment
bootcmd=run distro_bootcmd
bootdelay=2
baudrate=115200
stdin=serial,cros-ec-keyb,usbkbd
stdout=serial,vidconsole
stderr=serial,vidconsole
ethaddr=00:00:11:22:33:44
eth1addr=00:00:11:22:33:45
eth3addr=00:00:11:22:33:46
eth5addr=00:00:11:22:33:47
ipaddr=1.2.3.4
host_boot=if host dev ${devnum}; then setenv devtype host; run scan_dev_for_boot_part; fi
sata_boot=if sata dev ${devnum}; then setenv devtype sata; run scan_dev_for_boot_part; fi
scsi_init=if ${scsi_need_init}; then setenv scsi_need_init false; scsi scan; fi
scsi_boot=run scsi_init; if scsi dev ${devnum}; then setenv devtype scsi; run scan_dev_for_boot_part; fi
boot_prefixes=/ /boot/
boot_scripts=boot.scr.uimg boot.scr
boot_script_dhcp=boot.scr.uimg
boot_targets=host1 host0
boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}extlinux/extlinux.conf
scan_dev_for_extlinux=if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}extlinux/extlinux.conf; then echo Found ${prefix}extlinux/extlinux.conf; run boot_extlinux; echo SCRIPT FAILED: continuing...; fi
boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefix}${script}; source ${scriptaddr}
scan_dev_for_scripts=for script in ${boot_scripts}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${script}; then echo Found U-Boot script ${prefix}${script}; run boot_a_script; echo SCRIPT FAILED: continuing...; fi; done
scan_dev_for_boot=echo Scanning ${devtype} ${devnum}:${distro_bootpart}...; for prefix in ${boot_prefixes}; do run scan_dev_for_extlinux; run scan_dev_for_scripts; done;
scan_dev_for_boot_part=part list ${devtype} ${devnum} -bootable devplist; env exists devplist || setenv devplist 1; for distro_bootpart in ${devplist}; do if fstype ${devtype} ${devnum}:${distro_bootpart} bootfstype; then run scan_dev_for_boot; fi; done
bootcmd_host1=setenv devnum 1; run host_boot
bootcmd_host0=setenv devnum 0; run host_boot
distro_bootcmd=setenv scsi_need_init; for target in ${boot_targets}; do run bootcmd_${target}; done
bootm_size=0x10000000
kernel_addr_r=0x1000000
fdt_addr_r=0xc00000
ramdisk_addr_r=0x2000000
scriptaddr=0x1000
pxefile_addr_r=0x2000
root@localhost:~#

Have a great day,
Pavel Chubakov

0 Kudos

7,734 Views
jiye
Contributor V

yeah but yours showing CRC error which means it’s not access the right location of the u-boot. Which means it’s not taking effective otherwise your eth address should be some real mac addresses. Also my device is booting from SD card and once I am in the userspace I could not find /proc/mtd 

Besides, in the fw_env.config file should it be /dev/mmcblk0 and it’s sector size and offset ?

Also do i need to set CONFIG_MTD = y during the kernel compilation.

0 Kudos

7,734 Views
Pavel
NXP Employee
NXP Employee

See attached file.

This file is available using the following path in LSDK 1906:

/LSDK_1906/flexbuild_lsdk1906/packages/firmware/u-boot/tools/env

Have a great day,
Pavel Chubakov

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

7,734 Views
jiye
Contributor V

Hi Pavel,

(1) I did not see the u-boot folder under /LSDK_1906/flexbuild_lsdk1906/packages/firmware

I could only see 

Makefile pfe_bin uefi_bin

(2) regarding the REDEME file you sent it says 

In order to cross-compile fw_printenv, run
make CROSS_COMPILE=<your cross-compiler prefix> envtools
in the root directory of the U-Boot distribution. For example,
make CROSS_COMPILE=arm-linux- envtools

where should I run this command is that under the flexbuild_lsdk1906/build/linux/linux/arm32/LS/output/LSDK-19.06-V4.19 ?

0 Kudos

7,734 Views
jiye
Contributor V

when I was using  make CROSS_COMPILE=arm-linux-gnueabihf- envtools

under flexbuild_lsdk1906/build/linux/linux/arm32/LS/output/LSDK-19.06-V4.19 

I encountered an error says:

make[2]: *** No rule to make target 'envtools'. Stop.
Makefile:146: recipe for target 'sub-make' failed
make[1]: *** [sub-make] Error 2
Makefile:24: recipe for target '__sub-make' failed
make: *** [__sub-make] Error 2

0 Kudos

2,564 Views
shirishaReddy
Contributor I

Hi, I am using flex-build (ls1046ardb ) in that fw_env.config file was there in u-boot/tool/env but not located in /etc folder all are files are is there related fw_printenv and fw_setenv but when I am giving command fw_printenv and fw_setenv commands I am getting error like fw_printenv command not found .I tried to install sudo apt-get install u-boot-tools its showing already installed u-boot-tools 

can  anybody help me how to enable fw_printenv and fw_setenv commands and it works in target baord

0 Kudos