Environment of u-boot won't save in sd cart when boot from external sd card

I think that the offset of the environment in the image did not match. The ‘Warning’ message appears only on first µSD boot. After ‘saveenv’ command and ‘reset’/second boot with µSD these message did not appear. So it seams that the environment is now written in right place on µSD. After that i boot with eMMC only which may be also did not have the environment in right place?

I try to diff the µSD with the original image and look for the environments…

As i wrote i use:

$ git branch -vv && git status -sb
* bpi-r2-on-lede-v1 f0f934f [origin/bpi-r2-on-lede-v1] Fix an issue in network configuration
## bpi-r2-on-lede-v1...origin/bpi-r2-on-lede-v1

$ ./scripts/feeds list -s
packages   src-git  7f645d9  https://git.lede-project.org/feed/packages.git
luci       src-git  09ea6db  https://git.lede-project.org/project/luci.git
routing    src-git  2f74073  https://git.lede-project.org/feed/routing.git
telephony  src-git  9a034c9  https://git.lede-project.org/feed/telephony.git

In my config i only set:

Target System (MediaTek Ralink ARM)
Target Images ---> ramdisk
Boot Loaders  ---> u-boot-bpi_r2

then i build with

make -j1 V=s

concerning the date in the ‘U-Boot 2014.04-rc1’ line, is that not the last build date? and if you don’t make a ‘make clean’ and/or there are no changes in the branch so the date did not change or i’m wrong?

I’m using uboot from ubuntu-kernel-repo (4.4) not lede. Had thought,that these are the same…

I thought so too. would not it be better to keep this largely the same?

I did the diff now. As you can see in the build images (mkt…) is no environment. Only on the µSD dump. Here i boot from µSD and save the environment via saveenv to µSD.

I comper the files from my build (from your git repo) and Frank’s build with the µSD dump

grafik

the environment is saved to emmc defaultly,maybe we need to modify some uboot configurations,to make the environment to save to sd card,I will have a try. image

image

I came to u-boot-mt,choose to SD,here is the menu image

after choose to SD,the autoconf.h changed like this: image

then I build the uboot,but I met some compile errors,still trying to solve this,or I don’t know is there any other way to save enviroments to SD?

hi Jackzeng can you tell me which source and commit do you use the u-boot build?

Hi,tStone;yes sure,here is the repo:https://github.com/BPI-SINOVOIP/BPI-R2-bsp, use master branch.

uboot path is in “u-boot-mt”,enter this folder,and execute “make menuconfig” you can enter the uboot menu.

you can also use my forked repo, i have fixed some warnings in uboot-code

I was thinking the same thing, it would be interesting to be able to load the image onto the emmc, and then When it boots it could run an overlay file system on the SD card.

cool,thank you frank

I have not chaned this behaviour yet, but if you say what have to be changed i will change it

I want to achieve saving environments to where them boot from,like booting from sd,then save environments to sd,booting from emmc,then save environments to emmc;

R2 Bsp judges where it boot from by macro CONFIG_SYS_MMC_ENV_DEV,but this macro is configured by menuconfig,I wondered whether I could get the state of boot switch to achieve this.

The boot-switch exists only on hw-revision 1.2. It would be nice if older boards also write uboot-settings to right device.

Is this setting fixed or does it read out the boot-device?

It would be best that uboot judge and save environment variables to the boot storage on the fly.

OK, I got it,the SD card priority is higher than emmc,So if the device get two mem devs,it means SD card plug in,then we save envs to sd card,I will have a try.

No, If u-boot behave like that, users may be in trouble when they change a sd-card. There is no Fundamental change between saveing emmc or sd card “Defaultly”. In this case, Why don’t just compile two version of u-boot with different configuration, one flash to emmc, the other one flash to sd card, both hard-code the location to u-boot environment.

Is there more elegant way to do that? Is there a register(or memory) of MTK that contain value tell you where u-boot boot from. For example, when u-boot boot from emmc, the value is true, else it’s false.

Hello weiqi_chen: thanks for your advice,I had tried to compile sd version that could save envs to sd,but I met many errors,and I think make one BIOS that can judge where it boot from will be more convenient.

Actually I have posted this , bsp judge where it boot from by macro CONFIG_SYS_MMC_ENV_DEV,but this macro is configured by menuconfig.

I really would like to know the value of where it boot from. I will check more infos.

i see this when i start my uboot (from 4.4.70-github) direct after uboot-menu:

BPI: SD/eMMC SD=1 eMMC=0 id = 1 (drivers/mmc/mediatek/mtk_mmc.c)

if we know which variables are used here it may help