running uboot 's saveenv damage boot partition and can not boot again on maaxboard

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

running uboot 's saveenv damage boot partition and can not boot again on maaxboard

493 次查看
gonewithwind-peter
Senior Contributor I

Hi all ,

running uboot 's saveenv damage boot partition and can not boot again on maaxboard (from imx8mq_dev)

I am playing rauc  and need  uboot to read environment variable from somewhere that generated by fw_setenv in linux.

I following the guide here :https://community.nxp.com/t5/i-MX-Processors-Knowledge-Base/Linux-fw-printenv-fw-setenv-to-access-U-...

fw_setenv and fw_printenv works well. I use fw_setenv to add  the demo :

uboot_vars

ABC 1

XYZ 2

the fw_printenv can print out it. that means the fw_setenv and fw_printenv  works in user space.

the output:

fw_setenv mmcroot /dev/mmcblk0p3 rootwait rw
-sh-4.4# fw_printenv
bootcmd=run envboot;mmc dev ${mmcdev}; if mmc rescan; then if run loadbootscript; then run bootscript; ei
bootdelay=2
baudrate=115200
ethprime=FEC
loadaddr=0x40480000
mfgtool_args=setenv bootargs console=${console},${baudrate} rdinit=/linuxrc clk_ignore_unused
kboot=booti
bootcmd_mfg=run mfgtool_args;if iminfo ${initrd_addr}; then if test ${tee} = yes; then bootm ${tee_addr};
initrd_addr=0x43800000
initrd_high=0xffffffffffffffff
emmc_dev=0
sd_dev=1
jh_clk=
jh_mmcboot=setenv fdt_file fsl-imx8mq-evk-root.dtb; setenv jh_clk clk_ignore_unused; if run loadimage;
jh_netboot=setenv fdt_file fsl-imx8mq-evk-root.dtb; setenv jh_clk clk_ignore_unused; run netboot;
bootenvfile=uEnv.txt
importbootenv=echo Importing environment from mmc${mmcdev} ...; env import -t ${loadaddr} ${filesize}
loadbootenv=fatload mmc ${mmcdev} ${loadaddr} ${bootenvfile}
envboot=mmc dev ${mmcdev}; if mmc rescan; then echo SD/MMC found on device ${mmcdev};if run loadbootenv;;
script=boot.scr
image=Image
console=ttymxc0,115200 earlycon=ec_imx6q,0x30860000,115200
fdt_addr=0x43000000
fdt_high=0xffffffffffffffff
boot_fdt=try
fdt_file=em-sbc-imx8m.dtb
initrd_addr=0x43800000
initrd_high=0xffffffffffffffff
mmcdev=1
mmcpart=1
mmcautodetect=yes
mmcargs=setenv bootargs ${jh_clk} console=${console} root=${mmcroot}
loadbootscript=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};
bootscript=echo Running bootscript from mmc ...; source
loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}
loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}
mmcboot=echo Booting from mmc ...; run mmcargs; if test ${boot_fdt} = yes || test ${boot_fdt} = try; the;
netargs=setenv bootargs ${jh_clk} console=${console} root=/dev/nfs ip=dhcp nfsroot=${serverip}:${nfsrootp
netboot=echo Booting from net ...; run netargs; if test ${ip_dyn} = yes; then setenv get_cmd dhcp; else;
abc=1
xyz=2

 

 

but the uboot can not read it from user space somewhere. 

and  on uboot command line I run printenv, it is different with upper info from fw_printenv

on uboot command line , I run saveenv, it seems it can save the environment variable. but after reset. it can not boot again. and I use gparted to see my sdcard ,  the boot partition that kernel image and dtb are in here was damaged.

I found someone suggestion here to add  #define CONFIG_SYS_MMC_ENV_PART 0  to my .h file, but same error happened

https://community.nxp.com/t5/i-MX-Processors/unable-to-read-uboot-environment-using-fw-printenv-in-i... 

I posted relative Qz here:

https://community.nxp.com/t5/i-MX-Processors/uboot-environment-variable-should-be-written-in-which-p...

 

any help?

my Qz 1:

I think the issue is about how to define  the environment variable  location  in uboot code. but why I can not set it correctly?

sdcard layout is :    1. u-boot image (not show in gparted and lsblk in linux) 2. mmcblk0p1 (boot partition to save kernel image and dtb, uEnv.txt ..) 3.  mmcblk0p2 (rootfs_a)  3.  mmcblk0p3 (rootfs_b) .

my /etc/fw_env.conf is same as the guide:

/dev/mmcblk0   0x400000  0x1000

 

my Qz 2:

so I think the fw_setenv will write to boot partition,right?  or somewhere? I am not sure.

 

debug info:

u-boot=> printenv
baudrate=115200
boot_fdt=try
bootcmd=run envboot;mmc dev ${mmcdev}; if mmc rescan; then if run loadbootscript; then run bootscript; ei
bootcmd_mfg=run mfgtool_args;if iminfo ${initrd_addr}; then if test ${tee} = yes; then bootm ${tee_addr};
bootdelay=2
bootenvfile=uEnv.txt
bootscript=echo Running bootscript from mmc ...; source
console=ttymxc0,115200 earlycon=ec_imx6q,0x30860000,115200
emmc_dev=0
envboot=mmc dev ${mmcdev}; if mmc rescan; then echo SD/MMC found on device ${mmcdev};if run loadbootenv;;
ethprime=FEC
fastboot_dev=mmc0
fdt_addr=0x43000000
fdt_file=em-sbc-imx8m.dtb
fdt_high=0xffffffffffffffff
fdtcontroladdr=bc92a360
image=Image
importbootenv=echo Importing environment from mmc${mmcdev} ...; env import -t ${loadaddr} ${filesize}
initrd_addr=0x43800000
initrd_high=0xffffffffffffffff
jh_clk=
jh_mmcboot=setenv fdt_file fsl-imx8mq-evk-root.dtb; setenv jh_clk clk_ignore_unused; if run loadimage; t
jh_netboot=setenv fdt_file fsl-imx8mq-evk-root.dtb; setenv jh_clk clk_ignore_unused; run netboot;
kboot=booti
loadaddr=0x40480000
loadbootenv=fatload mmc ${mmcdev} ${loadaddr} ${bootenvfile}
loadbootscript=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};
loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}
loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}
mfgtool_args=setenv bootargs console=${console},${baudrate} rdinit=/linuxrc clk_ignore_unused
mmcargs=setenv bootargs ${jh_clk} console=${console} root=${mmcroot}
mmcautodetect=yes
mmcboot=echo Booting from mmc ...; run mmcargs; if test ${boot_fdt} = yes || test ${boot_fdt} = try; the;
mmcdev=0
mmcpart=1
mmcroot=/dev/mmcblk0p2 rootwait rw
netargs=setenv bootargs ${jh_clk} console=${console} root=/dev/nfs ip=dhcp nfsroot=${serverip}:${nfsrootp
netboot=echo Booting from net ...; run netargs; if test ${ip_dyn} = yes; then setenv get_cmd dhcp; else;
script=boot.scr
sd_dev=1
soc_type=imx8mq

Environment size: 2772/4092 bytes
u-boot=> saveenv
Saving Environment to MMC... Writing to MMC(0)... OK
u-boot=> reset
resetting ...

U-Boot SPL 2018.03- (Sep 08 2022 - 17:04:28 +0000)
DDRINFO: start lpddr4 ddr init
DRAM PHY training for 2400MTS
check ddr4_pmu_train_imem code
check ddr4_pmu_train_imem code pass
check ddr4_pmu_train_dmem code
check ddr4_pmu_train_dmem code pass
Training PASS
DRAM PHY training for 1600MTS
check ddr4_pmu_train_imem code
check ddr4_pmu_train_imem code pass
check ddr4_pmu_train_dmem code
check ddr4_pmu_train_dmem code pass
Training PASS
DRAM PHY training for 1064MTS
check ddr4_pmu_train_imem code
check ddr4_pmu_train_imem code pass
check ddr4_pmu_train_dmem code
check ddr4_pmu_train_dmem code pass
Training PASS
DRAM PHY training for 2400MTS
check ddr4_pmu_train_imem code
check ddr4_pmu_train_imem code pass
check ddr4_pmu_train_dmem code
check ddr4_pmu_train_dmem code pass
Training PASS
DDRINFO:ddrphy calibration done
DDRINFO: ddrmix config done
Normal Boot
Trying to boot from MMC1


U-Boot 2018.03- (Sep 08 2022 - 17:04:28 +0000)

CPU: Freescale i.MX8MQ rev2.0 1300 MHz (running at 800 MHz)
CPU: Industrial temperature grade (-40C to 105C) at 43C
Reset cause: POR
Model: Freescale i.MX8MQ EVK
DRAM: 2 GiB
MMC: FSL_SDHC: 0
Loading Environment from MMC... OK
No panel detected: default to HDMI
Display: HDMI (1280x720)
In: serial
Out: serial
Err: serial

BuildInfo:
- ATF 1cb68fa
- U-Boot 2018.03-

switch to partitions #0, OK
mmc0 is current device
flash target is MMC:0
Net:
Warning: ethernet@30be0000 (eth0) using random MAC address - be:d5:45:e8:61:7a
eth0: ethernet@30be0000
Fastboot: Normal
Normal Boot
Hit any key to stop autoboot: 0
switch to partitions #0, OK
mmc0 is current device
SD/MMC found on device 0
** Unrecognized filesystem type **
switch to partitions #0, OK
mmc0 is current device
** Unrecognized filesystem type **
** Unrecognized filesystem type **
Booting from net ...
ethernet@30be0000 Waiting for PHY auto negotiation to complete......... TIMEOUT !
Could not initialize PHY ethernet@30be0000
BOOTP broadcast 1
BOOTP broadcast 2
BOOTP broadcast 3
BOOTP broadcast 4

Abort
ethernet@30be0000 Waiting for PHY auto negotiation to complete......... TIMEOUT !
Could not initialize PHY ethernet@30be0000
BOOTP broadcast 1
BOOTP broadcast 2
BOOTP broadcast 3
BOOTP broadcast 4
BOOTP broadcast 5
BOOTP broadcast 6

Abort
WARN: Cannot load the DT
u-boot=>

 

 

 

 

 

0 项奖励
0 回复数