Boot Jetson from mmcblk1p5

Hi everyone.

I’ve installed Ubuntu 14.04.3 system on the SD card and able to boot from it, everything works fine.

Now I’d like to change the partition layout on the SD card. I’ll have some data partitions mmcblk1p{1,2,3,4), and the main file system must be located at mmcblk1p5. How can I achieve that? Yes, I know that I can put the /boot directory into mmcblk1p1 and edit /boot/extlinux/extlinux.conf to point root= option to /dev/mmcblk1p5, but this is not accepted for me for technical reasons. How can I point U-Boot to boot the main system from mmcblk1p5 without moving /boot so a separate partition? Thanks in advance.

For reference, when you say that you installed to the SD card, does this mean you flashed to mmcblk1 instead of mmcblk0? Or is this simply the rootfs on mmcblk1?

I do not know if this actually possible.

Boot is a 3 stage process (after u-boot)

  1. load boot script elinux.conf
  2. load kernel and dtb
  3. load modules from disk (from rootfs)

Your problem is parts 1 & 2. I am not sure u-boot will allow them to be loaded from anything other than the 1st partition.

Try looking at the boot scripting that u-boot does.
It may be possible to boot from a different partition if the script in u-boot tells it to.

I know you can access any mmc device with ls in u-boot, to help you find which partition in u-boot.

I flashed mmcblk0p1 with a new version in order to install U-Boot instead of default “fastboot”. After that I copied all the required files (including the required files from Tegra124_Linux_R21.4.0_armhf.tbz2) to the SD card and inserted in into the SD slot. After reboot Jetson loaded the system from the SD card.

del

In this case the complications of the normally ignored partitions (things used for boot and install but not part of the visible root partition) stick only with eMMC (mmcblk0).

There may be a boot loader limitation to point at root on your SD card or SATA drive first partition (meaning I’m not sure if for example a SATA drive with /dev/sda2 could boot to sda2…it might be limited to sda1 because of u-boot limitations…testing required). The boot loader itself is still on eMMC (because flash was to mmcblk0p1) and the /boot of eMMC (mmcblk0p1) still controls boot (the rest of the files on eMMC outside of its /boot could be removed…but be careful with symbolic links). The /boot of the alternate media will not be referenced by default and could be removed for files used only during u-boot stages (this includes zImage, extlinux.conf, and .dtb files which are loaded into ram by u-boot and not re-loaded during normal operation). Within /dev/sda* partitions other than the rootfs on the first partition, there should not be any limitations of what can be partitioned where.

To point at other partitions for anything loaded by u-boot (other than mmcblk0p1 or mmcblk1p1) u-boot itself will probably need editing. For your purposes, is it acceptable to place u-boot and /boot on the built-in eMMC at mmcblk0p1? Is it also ok to restrict your root partition to either eMMC or to the first partition of an external device (SD card or SATA drive)?

Are sure about that? AFAIK the latest versions of L4K will try boot from the SD card first, including loading the kernel and the DTB files from it. That’s why the SD card should contain everything needed for boot including the kernel and extlinux.conf, and all this stuff must be located on the first SD partition.

Where can I find the U-Boot configuration? U-Boot tries to load the SD card first, and only then eMMC. Where are these configuration values are stored? Or they are compiled into the u-boot.bin and cannot be modified by hand?

“The boot loader itself is still on eMMC”
This is true no matter which device it boots to later.
Someone else has been asking if u-boot can reside in the SPI boot ROM - no answer to that yet.

“and the /boot of eMMC (mmcblk0p1) still controls boot”
Not strictly true. u-boot can be made to look at MMC, SD, USB, PXE or DHCP for the 3 boot items (extlinux.conf, zImage and .dtb)
It is controlled by the ‘boot_targets’ parameter.
So “Are sure about that? AFAIK latest versions of L4K will try boot from SD card first”
is true, u-boot has been configured to do this by default. However, this can be changed.

“Where can I find the U-Boot configuration?”
Type ‘printenv’ on the u-boot command line. The parameter that controls boot order is ‘boot_targets’

“Where are these configuration values are stored?”
They are stored in a hidden partition. I have not managed to find it yet.
The parameter ‘boot_target’ (or any u-boot parameter) can be changed by ‘setenv’
eg
setenv boot_targets usb0 pxe dhcp
changes u-boot to ignore the SD and MMC.
Make sure the parameters are saved with ‘saveenv’

If you look at the u-boot parameters, you will notice the boot for each device is actually a u-boot script. It might be possible to change the script for SD to boot from a different partition.

OK I think I have work out how it might work for you :

boot_targets=mmc1 mmc0 usb0 pxe dhcp

Tell u-boot to work through boot devices in order :
SD MMC USB PXE DHCP

The MMC/SD boot script is :
mmc_boot=if mmc dev ${devnum}; then setenv devtype mmc; run scan_dev_for_boot; fi

Which is going to try and run ‘scan_dev_for_boot’

‘scan_dev_for_boot’ says :
scan_dev_for_boot=echo Scanning {devtype} {devnum}…; for prefix in ${boot_prefixes}; do run scan_dev_for_extlinux; run scan_dev_for_scripts; done

This will run 2 scripts :
scan_dev_for_extlinux
scan_dev_for_scripts

scan_dev_for_extlinux looks like this :
scan_dev_for_extlinux=if test -e {devtype} {devnum}:{bootpart} {prefix}extlinux/extlinux.conf; then echo Found ${prefix}extlinux/extlinux.conf; run boot_extlinux; echo SCRIPT FAILED: continuing…; fi

Notice the “${bootpart}” !

The u-boot parameter bootpart is defaulted to “1”

Change it to 5 and see if it does what you want.

Thanks GE_Chen for this great investigation, I’ll try that

These are U-Boot environment variables related to how U-Boot boot.
‘boot’ command is equal to ‘run bootcmd’.
And ‘run bootcmd’ execute commands in environment variable ‘bootcmd’.

boot_targets=mmc1 mmc0 usb0 pxe dhcp 
bootcmd=setenv usb_need_init; for target in ${boot_targets}; do run bootcmd_${target}; done
bootcmd_mmc0=setenv devnum 0; run mmc_boot
bootcmd_mmc1=setenv devnum 1; run mmc_boot
bootcmd_usb0=setenv devnum 0; run usb_boot
bootpart=1
mmc_boot=if mmc dev ${devnum}; then setenv devtype mmc; run scan_dev_for_boot; fi
scan_dev_for_boot=echo Scanning ${devtype} ${devnum}...; for prefix in ${boot_prefixes}; do run scan_dev_for_extlinux; run scan_dev_for_scripts; done
scan_dev_for_extlinux=if test -e ${devtype} ${devnum}:${bootpart} ${prefix}extlinux/extlinux.conf; then echo Found ${prefix}extlinux/extlinux.conf; run boot_extlinux; echo SCRIPT FAILED: continuing...; fi
boot_extlinux=sysboot ${devtype} ${devnum}:${bootpart} any ${scriptaddr} ${prefix}extlinux/extlinux.conf

There is simple manual of U-Boot commands in “U-Boot Guide/Debugging U-Boot Environment” in this document:
http://developer.download.nvidia.com/embedded/L4T/r21_Release_v4.0/Tegra_Linux_Driver_Package_Documents_R21.4.tar
According to this document, ‘saveenv’ save the modified environment which is preserved in case of resets and reboots.
But I have never tried it.

U-Boot has commands to print/change environment variables from Linux, but these command is not available on Linux 4 Tegra.
http://www.denx.de/wiki/view/DULG/HowCanIAccessUBootEnvironmentVariablesInLinux
If you want fw_setenv and fw_printenv, it might require building U-Boot from source.

So far as the comment on the boot loader remaining on eMMC, it’s restricted to flashing to mmcblk0p1 (and this is the mentioned flash target) and then copying rootfs to the alternate location. You can make alterations later, but this initially puts the boot loader executable itself on eMMC.