How to write u-boot environment variables in mmcblk0boot0 instead of mmcblk0p1

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

How to write u-boot environment variables in mmcblk0boot0 instead of mmcblk0p1

4,166 Views
kulbhushankashy
Contributor I

I'm working on board bring-up of a custom iMX6 based board. I'm using the Android package from iMX6 Sabre SD board, and have got most of the things working with booting from eMMC which on on-board, but I'm facing issue with 'saveenv' of u-boot.

Firstly, everytime on boot there is a print :

*** Warning - bad CRC or MMC, using default environment

I search online and found that we have to do 'saveenv' once to let this error go away. So I did saveenv but after that the board doesn't boot completely and got stuck on 'Uncompressing Linux ...' !

I then boot-up the board using SD card and got the hexdump of /dev/block/mmcblk0boot0 and /dev/block/mmcblk0p1 (both are eMMC partitions, SD card is dev/block/mmcblk1)

To my surprise, from hexdump I found that 'saveenv' writes the environment variable data to /dev/block/mmcblk0p1 and not /dev/block/mmcblk0boot0 which was the reason the board didn't boot-up as boot.img is in dev/block/mmcblk0p1 partition was corrupted by u-boot doing saveenv and over-writing the boot.img data.

So, my question is how can I change the u-boot code to modify it to read and save environment variables on /dev/block/mmcblk0boot0 instead of /dev/block/mmcblk0p1

I'm trying to dig into the code and so far I have found that common/env_mmc.c is the file which has all functions to read/write environment variables, and include/configs/mx6solo_sabresd.h includes the configuration of my board.

Labels (6)
0 Kudos
1 Reply

2,194 Views
BiyongSUN
NXP Employee
NXP Employee

boot0, boot1 for emmc is the boot partition.

If you want to write it. you need to change the settings in  the boot config.

You can check the mfg tool to get some idea. How handle the emmc boot partition from linux.

In uboot, mmc command has sub command  mmc partconf for that.

But it is very dangous if your design is to access the boot partition.

Keep it read only is the system level to protect uboot. that is also why emmc has boot partition. SD card doesn't have.

You need to arrage a  layout for your design.

For most of the products design, the environment is fixed in the code.

Better to check the emmc spec for more details.

0 Kudos