(OSD3358) copy uboot environment during commissioning

OSD3358 custom board based upon Beaglebone Black rev-c with microSD card and eMMC. I boot from microSD card and stop uboot. I created a new variable, changed the environment ‘bootdelay=1’ and run saveenv.

U-Boot SPL 2019.04 (May 05 2020 - 23:45:56 -0500)                                                                                   
Trying to boot from MMC2                                                                                                            
Loading Environment from EXT4... OK                                                                                                 
U-Boot 2019.04 (May 05 2020 - 23:45:56 -0500)                                                                                       
CPU  : AM335X-GP rev 2.1                                                                                                            
I2C:   ready                                                                                                                        
DRAM:  512 MiB                                                                                                                      
No match for driver 'omap_hsmmc'                                                                                                    
No match for driver 'omap_hsmmc'                                                                                                    
Some drivers were not found                                                                                                         
Reset Source: Global external warm reset has occurred.                                                                              
Reset Source: Power-on reset has occurred.                                                                                          
RTC 32KCLK Source: External.                                                                                                        
MMC:   OMAP SD/MMC: 0, OMAP SD/MMC: 1                                                                                               
Loading Environment from EXT4... OK                                                                                                 
Board: BeagleBone Black                                                                                                             
BeagleBone Black:                                                                                                                   
BeagleBone: cape eeprom: i2c_probe: 0x54:                                                                                           
BeagleBone: cape eeprom: i2c_probe: 0x55:                                                                                           
BeagleBone: cape eeprom: i2c_probe: 0x56:                                                                                           
BeagleBone: cape eeprom: i2c_probe: 0x57:                                                                                           
Net:   eth0: MII MODE                                                                                                               
cpsw, usb_ether                                                                                                                     
Press SPACE to abort autoboot in 0 seconds                                                                                          
=> setenv bootdelay_orig ${bootdelay}                                                                                               
=> pri bootdelay_orig                                                                                                               
=> setenv bootdelay '1'                                                                                                             
=> pri bootdelay                                                                                                                    
=> saveenv                                                                                                                          
Saving Environment to EXT4... File System is consistent                                                                             
file found, deleting                                                                                                                
update journal finished                                                                                                             
File System is consistent                                                                                                           
update journal finished                                                                                                             

The SD and eMMC has the same partitioning, uboot, kernel and rootfs, but the uboot environments are different because of the above changes. I want to copy the saved environment file from the SD card to the eMMC.

I press reset, boot from SD, login to linux (4.19.106) and cd to the /boot folder. I have not tried copying the /boot/uboot.env file because the date of the file is ‘1970’ and the file size did not increase with the added variable.

root@arm:/boot# ls -a -l                                                                                                            
total 39988                                                                                                                         
drwxr-xr-x  4 root root    4096 May 13  2020 .                                                                                      
drwxr-xr-x 21 root root    4096 Feb 11 03:36 ..                                                                                     
drwxr-xr-x  5 root root    4096 Jul 17  2020 dtbs                                                                                   
drwxr-xr-x  2 root root    4096 Feb 10 16:30 uboot                                                                                  
-rwxr-xr-x  1 root root  131072 Jan  1  1970 uboot.env                                                                              
-rw-r--r--  1 root root     980 Jul 17  2020 uEnv.txt                                                                               
-rwxr-xr-x  1 root root 8069632 Jul 29  2020 vmlinuz-4.19.106-bone49

After booting from the SD, I can mount the eMMC and change to eMMC’s boot directory.

Is the /boot/uboot.env file the correct file to copy from /boot on the SD to /boot on the eMMC?

If it is the file I want then why didn’t the file size change?
Why is the date wrong?

In the future, I want to copy the production uboot.env to my embedded custom board during the commissioning process.

Thank you,

HI @jakthree

Sadly u-boot is only hardcoded for one interface:

# CONFIG_ENV_IS_IN_FAT is not set

So to use the same, /boot/uboot.env on the eMMC, you’ll need to change:




But since you need to rebuild u-boot, you might as well set all your parameters.

No battery backed rtc, so it defaults to the 1970… Check the sha256sum, the contents probably changed, just not the size. (Side note, i’m not sure if u-boot would even use the RTC time if a battery was in place on the AM335x family…)


Your reply raised some questions,

This may answer a problem I have when booting. I built uboot with the above settings. I followed your instructions to put MLO and u-boot.img onto the SD card.

export DISK=/dev/sdb
sudo dd if =./u-boot/MLO of=${DISK} count=1 seek=1 bs=128k
sudo dd if =./u-boot/u-boot.img of=${DISK} count=2 seek=1 bs=384k

I booted the SD card and logged into linux. I then used your same instructions to partition the eMMC, install bootloader, kernel and rootfs tarball onto the eMMC.
I ‘dd’ the SD card’s /opt/backup/uboot/ MLO and u-boot.img to the eMMC.

I removed the SD card and booted from the eMMC to the login prompt. Now the problem. I powered off, inserted the SD card and did not press the boot select switch-2. The board should have loaded uEnv.txt, kernel and rootfs from the eMMC but instead loads from the SD card.

Does it boot from SD because I need to rebuild uboot with ???

One variable I changed and would like to set is
findfdt=echo board_name=[$board_name] …; setenv fdtfile am335x-boneblack.dtb;

Is there a file that uboot uses during build to set these and other vars?

Thank you,

Our u-boot automatically searches the microSD first for the “uEnv.txt” file, if found it it runs it…

Just specify:




How do I change ‘our u-boot’ to boot from microSD or eMMC based upon state of boot select inputs?

Thank you,

That’s actually a neat idea. So, the boot button is tied to the pins the BOOTROM reads on startup, so ‘down’ must always be the microSD, when you read it back… We have the gpio functions avalible in u-boot, this is how the 4 led’s are done:

	"gpio clear 56; " \
	"gpio clear 55; " \
	"gpio clear 54; " \
	"gpio set 53; " \

So looking at the boot order in u-boot:

 	func(MMC, mmc, 0) \
	func(LEGACY_MMC, legacy_mmc, 0) \
 	func(MMC, mmc, 1) \
 	func(LEGACY_MMC, legacy_mmc, 1) \

couldn’t we do a gpio read:

if test gpio input XY = 1;
 	func(MMC, mmc, 0) \
	func(LEGACY_MMC, legacy_mmc, 0) \
 	func(MMC, mmc, 1) \
 	func(LEGACY_MMC, legacy_mmc, 1) \
 	func(MMC, mmc, 1) \
	func(LEGACY_MMC, legacy_mmc, 1) \
 	func(MMC, mmc, 0) \
 	func(LEGACY_MMC, legacy_mmc, 0) \

That ^ won’t exactly work, as i’ve never used the gpio input, and the “func” are defines, but yeah, something like that hacked in…


I understand the state of the SYSBOOT pins are latched at power up. The boot order of the ROM bootloader (BOOTROM) is determined by checking the latched state of the SYSBOOT pins. The ‘test’ should be against the latched state and not the current state. I don’t know the variable name of the latched value. If switch-1 reset is pressed (warm reset) then the beaglebone black boot order remains the same as it was last powered up.

I am missing some history here. What was the intention of always booting from microSD card instead of SYSBOOT boot order?

Thank you,

The original BeagleBone, didn’t have an eMMC.

Once the BeagleBone Black came out, the idea was to always boot from eMMC unless a microSD was plugged in…

Eventually we needed U-Boot Overlays as Kernel Overlays became a dead end, so having an old version of U-Boot in the eMMC just got in the way.

With the follow up BeagleBone-AI design, microSD is first, eMMC only loads if the microSD isn’t installed.



I am not an expert. My custom board is based on Beaglebone Black using an Octavo OSD3358-BAS.
When switch-2 (S2) is not pressed (up) then the SYSBOOT boot sequence is

  1. MMC1 (eMMC)
  2. MMC0 (microSD)
  3. UART0 (console ‘CCCC…’)
  4. USB0

When S2 is pressed (down) then the SYSBOOT boot sequence is

  1. SPI0
  2. MMC0 (microSD)
  3. USB0
  4. UART0 (console ‘CCCC…’)

Now some background that I’m sure has been discussed many times.
If S2 is up the BOOTROM searches the eMMC for MLO.
If S2 is down the BOOTROM searches the microSD for MLO.
MLO then loads uboot.img (i.e. U-Boot proper).
U-Boot proper loads uboot.env and uEnv.txt.

I removed the microSD card, booted from the eMMC, aborted uboot and changed the boot_targets order so that mmc1 (eMMC) is checked first.

setenv boot_targets ‘mmc1 legacy_mmc1 mmc0 legacy_mmc0 pxe dhcp’

I did not change boot_targets on the microSD card. I turn power off, inserted the SD card and turned on power while S2 is up. The board loads MLO, U-Boot proper and uboot.env from the eMMC. The kernel and rootfs are loaded from the eMMC because the boot order of boot_targets now searches mmc1 legacy_mmc1 first.
Now turn power off, turn power on while S2 is down. The board loads MLO, U-Boot proper and uboot.env from the microSD. The kernel and rootfs are loaded from the microSD because the boot order of boot_targets was not changed.

I don’t know how (or where) to edit the U-Boot source to target either microSD or eMMC.

The end result is changing u-boot boot order by editing the eMMC environment works for me.

Thank you,