How to make fw_printenv and fw_setenv on MX6Q_SABRESD

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

How to make fw_printenv and fw_setenv on MX6Q_SABRESD

Jump to solution
14,686 Views
lqll
Contributor III

Hello

My environment is MX6Q_SABRESD,android 4.4.2,and my uboot stored in eMMC.I want to modify the uboot environment variables from userspace,then I found fw_printenv can do this,but maybe something wrong within my steps.

1.make fw_printenv

pastedImage_0.png

Then,I get fw_printenv.

pastedImage_4.png

2.Modify fw_env.config.

I need MTD device name and Device offset,Env. size,Flash sector size to do this,so I look up uboot-imx/include/configs/mx6q_sabresd.h,and then get Device offset = 0xC0000,Env. size = 0x2000,Flash sector size = 0x2000.

Then,I want to get MTD device name,so I cat /proc/mtd on my board, but I get nothing!

pastedImage_2.png

So that's my first question,Why can't I get the right device name?

3.copy fw_env.config to my board,and put it in /etc

Even though I can't get device name,I just go next.

In order to change /etc from read-only to read-write,I've done this command:

mount -o rw,remount -t ext4 /dev/block/mmcblk0p5

Then copy fw_env.config to /etc

4.Copy fw_printenv to my board,chmod and run

pastedImage_6.png

This is my second question,I can't execute fw_printenv,why?

I think maybe fw_printenv depends on other lib file to execute,so I've done this:

pastedImage_8.png

Then I found it depends on ld-linux.so.3,but my path /lib doesn't have ld-linux.so.3,only have ld-linux.so.2.So my third question,where can I get ld-linux.so.3?

Please help me to handle this 3 questions.

Thank You

Qiulong Li.

Labels (3)
0 Kudos
Reply
1 Solution
7,558 Views
lqll
Contributor III

I know how to make.

1.My cross compiler is wrong.I used android tool chain,and it can't use in this case,the right toolchain is freescale linux bsp toolchain.

CROSS_COMPILE=/opt/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/arm-fsl-linux-gnueabi-

2.After access make,I got fw_printenv,but this file can't work on my borad,because it can't find some libs,so I must do static make

vi uboot-imx/tools/env/Makefile

add -static to CPPFLAGS like follow:

CPPFLAGS := -Wall -static -DUSE_HOSTCC -I$(SRCTREE)/include

View solution in original post

12 Replies
7,559 Views
lqll
Contributor III

I know how to make.

1.My cross compiler is wrong.I used android tool chain,and it can't use in this case,the right toolchain is freescale linux bsp toolchain.

CROSS_COMPILE=/opt/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/arm-fsl-linux-gnueabi-

2.After access make,I got fw_printenv,but this file can't work on my borad,because it can't find some libs,so I must do static make

vi uboot-imx/tools/env/Makefile

add -static to CPPFLAGS like follow:

CPPFLAGS := -Wall -static -DUSE_HOSTCC -I$(SRCTREE)/include

7,558 Views
jimmychan
NXP TechSupport
NXP TechSupport

For your question 1, the u-boot stored in emmc. the device name under /dev/ is mmcblk0, not MTD. If you store the u-boot in NOR or NAND flash, the device name will be /dev/mtdblk.

0 Kudos
Reply
7,558 Views
lqll
Contributor III

Hi jimmy,

Thanks for your reply.

My uboot stored in emmc,I looked up /dev/block,I found many mmcblk device,

pastedImage_0.png

so which one is the device name I need,please tell me.

Thank You

Qiulong Li

0 Kudos
Reply
7,558 Views
jimmychan
NXP TechSupport
NXP TechSupport

mmcblk0 is the emmc. mmcblk0p1 is the partition 1 in emmc.

mmcblk0boot0 is the boot partition.

https://www.kernel.org/doc/Documentation/mmc/mmc-dev-parts.txt

For your reference, this is the part of script of ucl2.xml in MFGTOOL about writing u-boot to emmc. You can see the u-boot is writing to the boot partition. And then re-enable the write protection for boot partition.

    <CMD state="Updater" type="push" body="$ echo 0 > /sys/block/mmcblk0boot0/force_ro">access boot partition 1</CMD>

    <CMD state="Updater" type="push" body="send" file="files/u-boot-mx6q-sabresd.bin">Sending U-Boot</CMD>

    <CMD state="Updater" type="push" body="$ dd if=$FILE of=/dev/mmcblk0boot0 bs=512 seek=2 skip=2">write U-Boot to sd card</CMD>

    <CMD state="Updater" type="push" body="$ echo 1 > /sys/block/mmcblk0boot0/force_ro"> re-enable read-only access </CMD>

    <CMD state="Updater" type="push" body="$ echo 8 > /sys/devices/platform/sdhci-esdhc-imx.3/mmc_host/mmc0/mmc0:0001/boot_config">enable boot partion 1 to boot</CMD>

7,558 Views
lqll
Contributor III

Hi jimmy,

Thanks for your reply.

My uboot boot arguments store in /dev/block/mmcblk0,and I can get boot arguments by this command:

root@sabresd_6dq:/ # dd if=/dev/block/mmcblk0 of=/sata/boot_args bs=512 skip=1536 count=16

and set boot arguments:

root@sabresd_6dq:/ # dd if=/sata/boot_args of=/dev/block/mmcblk0 bs=512 seek=1536 count=16

So,I can modify the uboot environment variables from userspace through this way,but this way is not flexible.I still want to use fw_printenv,but my fw_printenv is fail to run:

root@sabresd_6dq:/sata # ./fw_printenv                                        

/system/bin/sh: ./fw_printenv: No such file or directory

Can you help me to fix this problem?

Thank You

Qiulong Li

0 Kudos
Reply
7,558 Views
yenchao
Contributor IV

Hi Qiulong,

I'm working on fw_printenv with imx6q sabresd too.

I followed your instruction to build fw_printenv seccessfully,

but it show "cannot get MTD information: Invaild argument" error message when I run fw_printenv.

my fw_env.config is

# MTD device nameDevice offsetEnv. sizeFlash sector sizeNumber of sectors
/dev/block/mmcblk00xC00000x20000x2000

Is it the same as your?

Could you please help me how to set this config file.

Any suggestions would be very appreciated.

Thx

Yen

0 Kudos
Reply
7,558 Views
lqll
Contributor III

Hi Yen Chao

Your fw_env.config file is the same as me,plase check if you put this file at /etc/fw_env.config.

BTW,before put this file to /etc,you should make /etc can read and write by this command

mount -o rw,remount -t ext4 /dev/block/mmcblk0p5

0 Kudos
Reply
7,558 Views
yenchao
Contributor IV

Hi Qiulong,

Thanks for your reply.

I have checked the file position and read/write permission.

Finally, I gave up using fw_printenv command.

Maybe the u-boot(android 4.0.4) fw_printenv version is too old to support emmc.

thx

Yen

0 Kudos
Reply
7,558 Views
ajithpv
Contributor V

root@sabresd_6dq:/sata # ./fw_printenv                                       

/system/bin/sh: ./fw_printenv: No such file or directory

Could you please make sure you are using the cross compiled version of fw_printenv? You can check it with 'file' command. If it shows x86 compiler details, then please change it into ARM by cross compile it properly.

0 Kudos
Reply
7,558 Views
lqll
Contributor III

Hi ajithpv

just like you said,I use wrong cross compiler,but when I use the right cross compiler,I can't build,please goto How to set environment for building u-boot's fw_printenv for i.MX6Q and help me again.

Thank You

Qiulong Li

0 Kudos
Reply
7,558 Views
ajithpv
Contributor V

Could you please see the below note from the u-boot source's "tools/env/README" path.

This is a demo implementation of a Linux command line tool to access

the U-Boot's environment variables.

In the current version, there is an issue in cross-compilation.

In order to cross-compile fw_printenv, run

   make HOSTCC=<your CC cross-compiler> env

in the root directory of the U-Boot distribution. For example,

    make HOSTCC=arm-linux-gcc env

Though I used a different procedure for generating the fw_printenv, I hope the below steps may give you some idea (below steps are in Linux but not Android).

1) Go to U-boot source path. Assuming you have a local version of the cross compiler. I used "poky/1.5.1" for my task.

2) Cross compile manually by exporting the environment settings

export ARCH=arm

export PATH=$PATH:/opt/poky/1.5.1/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/

export CROSS_COMPILE=arm-poky-linux-gnueabi-

3) Compile the fw_printenv using below command

make HOSTCC=arm-poky-linux-gnueabi-gcc env

4) Check the 'fw_printenv' using 'file' command and make sure it compiled for ARM platform.

7,558 Views
lqll
Contributor III

Hi ajithpv

Thanks for your fast reply.

My u-boot source's "tools/env/README" doesn't have any info about cross-compilation issue,and my u-boot version is v2009.08.

And I still follow what you said,this are my steps:

export ARCH=arm

export CROSS_COMPILE=~/android-4.4.2_sdi_in/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-

make distclean

make mx6q_sabresd_android_config

make HOSTCC=~/android-4.4.2_sdi_in/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-gcc env

But I get this error and can't build.

make -C tools/env all MTD_VERSION= || exit 1

make[1]: Entering directory `/home/l/android-4.4.2_sdi_in/bootable/bootloader/uboot-imx/tools/env'

/home/l/android-4.4.2_sdi_in/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-gcc -Wall -DUSE_HOSTCC -I/home/l/android-4.4.2_sdi_in/bootable/bootloader/uboot-imx/include crc32.c  fw_env.c  fw_env_main.c -o fw_printenv

In file included from crc32.c:14:0:

/home/l/android-4.4.2_sdi_in/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/../lib/gcc/arm-eabi/4.6.x-google/include/stdint.h:3:26: fatal error: stdint.h: No such file or directory

compilation terminated.

fw_env.c:27:19: fatal error: errno.h: No such file or directory

compilation terminated.

fw_env_main.c:42:19: fatal error: stdio.h: No such file or directory

compilation terminated.

make[1]: *** [fw_printenv] Error 1

make[1]: Leaving directory `/home/l/android-4.4.2_sdi_in/bootable/bootloader/uboot-imx/tools/env'

make: *** [env] Error 1

What can I do?please help me.

Thank You

Qiulong Li

0 Kudos
Reply