dd'ing u-boot doesn't wipe u-boot variables?

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

dd'ing u-boot doesn't wipe u-boot variables?

357 Views
entropyro
Contributor II

Working with an iMX8M Plus Quad.

Looking at this manual on ~page 11: i.MX_Linux_Users_Guide_Rev_LF6.6.3_1.0.0_2024-03-29.pdf (https://www.nxp.com/docs/en/user-guide/IMX_LINUX_USERS_GUIDE.pdf)

Issuing: dd if=imx-boot of=/dev/mmcblk0 bs=1k seek=32 conv=fsync

Plenty of normal-looking output.

But when I reboot and interrupt to get back into u-boot, my test env variable is still present! Shouldn't it be blown away? What am I doing wrong?

I've also tried with /dev/mmcblk0boot0 and zero'ing it out before the dd and same thing! The only thing that's managed to blow away my test variable is using uuu.exe to blast on u-boot and the .wic image.

I'm sure I'm missing something fundamental here...any thoughts?

Thank you for your time!

Tags (3)
0 Kudos
7 Replies

239 Views
roke
Contributor II

dd if=/dev/zero of=/dev/mmcblk0 bs=16k seek=256 count=1 

190 Views
entropyro
Contributor II

Where are you pulling the 4096000 (16k*256) number?

0 Kudos

184 Views
roke
Contributor II

16k*256 =16*1024*256 = 4194304

https://man7.org/linux/man-pages/man1/dd.1.html

 

 N and BYTES may be followed by the following multiplicative
       suffixes: c=1, w=2, b=512, kB=1000, K=1024, MB=1000*1000,
       M=1024*1024, xM=M, GB=1000*1000*1000, G=1024*1024*1024, and so on
       for T, P, E, Z, Y, R, Q.  Binary prefixes can be used, too:
       KiB=K, MiB=M, and so on.  If N ends in 'B', it counts bytes not
       blocks.

 

185 Views
roke
Contributor II

https://github.com/nxp-imx/uboot-imx/blob/lf-5.15.71-2.2.2/configs/imx8mp_evk_defconfig

CONFIG_ENV_SIZE=0x4000
CONFIG_ENV_OFFSET=0x400000
CONFIG_ENV_SECT_SIZE=0x10000

270 Views
entropyro
Contributor II

@Zhiming_Liu, thank you for your help.  I figured out what was going on - after a saveenv my u-boot environment variables were being written to an area of the disk not touched by re-blasting the u-boot image.  I am actually compiling my own u-boot environment variables into the u-boot image, so I didn't want this feature.  I am working around it by blasting 0s into the section of memory where the u-boot environment variables are stored, then loading the image so that the "default variables" are always from the binary.

 

Thank you!

0 Kudos

291 Views
entropyro
Contributor II

@Zhiming_Liu, OK this is strange, that's basically exactly what we are doing, but our test u-boot variable persists after flashing it and power-cycling the system!  Any idea what I'm missing?

What seek offset should I use for an i.MX8 Plus Quad?  I've tried both with no change, but it'd be good to know.

0 Kudos

308 Views
Zhiming_Liu
NXP TechSupport
NXP TechSupport

Hi @entropyro 

I tested same behavior on i.MX8MM, below steps can work, Uboot 2022 can be replaced by Uboot2023. You can refer it.

echo 0 > /sys/block/mmcblk2boot0/force_ro
dd if=imx-boot-imx8mm-lpddr4-evk-sd.bin-flash_evk of=/dev/mmcblk2boot0 bs=1k seek=33 conv=fsync
echo 1 > /sys/block/mmcblk2boot0/force_ro