Booting/rootfs from SD card

In your log, MMC0 and MMC1 decides the boot device.

[2020-09-24 14:37:23] U-Boot 2016.07-g0536cf2a27 (Dec 09 2019 - 22:43:10 -0800)
[2020-09-24 14:37:23]
[2020-09-24 14:37:23] TEGRA186
[2020-09-24 14:37:23] Model: NVIDIA P2771-0000-500
[2020-09-24 14:37:23] DRAM: 7.8 GiB
[2020-09-24 14:37:23] MC: Tegra SD/MMC: 0, Tegra SD/MMC: 1
[2020-09-24 14:37:23] *** Warning - bad CRC, using default environment
[2020-09-24 14:37:23]
[2020-09-24 14:37:23] In: serial
[2020-09-24 14:37:23] Out: serial
[2020-09-24 14:37:23] Err: serial
[2020-09-24 14:37:23] Net: eth0: ethernet@2490000
[2020-09-24 14:37:23] Hit any key to stop autoboot: 2 1 0
[2020-09-24 14:37:25] switch to partitions #0, OK
[2020-09-24 14:37:25] mmc1 is current device
[2020-09-24 14:37:25] Scanning mmc 1:1…
[2020-09-24 14:37:25] Found /boot/extlinux/extlinux.conf

Thanks Wayne.
Need one more clarification.

  1. I flashed the Jetson Tx2 with ./flash.sh mmcblk0p1 (Its using emmc)
  2. Then I created rootfs in SD card
  3. Edited the extlinux.conf file in SD card /boot, to load the rootfs from SD card partition.

In this scenario, Only rootfs is referred from SD card/boot/extlinux/extlinux.conf Is my understanding correct?

The kernel Image file, dtb files are referred from eMMC?

Or rootfs and Image file is from SD card? and dtb settings are all referred from eMMC?

Part of this is just that U-Boot has macros which expand and can search for boot devices. If you change the environment variable, then the search order will differ. You can examine this and alter it in a serial console boot prompt. An example of what it looks like in serial console if you hit a key at the right moment:

[0004.291] I> Kernel EP: 0x84600000, DTB: 0x80000000


U-Boot 2016.07-g0eb73f4 (Mar 13 2019 - 00:20:34 -0700)

TEGRA186
Model: NVIDIA P2771-0000-500
DRAM:  7.8 GiB
MC:   Tegra SD/MMC: 0, Tegra SD/MMC: 1
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   eth0: ethernet@2490000
Hit any key to stop autoboot:  0 
Tegra186 (P2771-0000-500) # 

If you were to then run the command β€œboot” then boot would continue. If you run the command β€œhelp”, then you’ll see many commands explained. In your case you will find the environment handling commands of extra interest, and the β€œecho” command. Try β€œhelp env”. Look at commands β€œprintenv” and β€œsaveenv”.

If you alter something in U-Boot, but do not save, then the change will take effect for only one boot. It is safe to try different settings and then β€œboot”. If you find something you like, then you can β€œsaveenv” to make it permanent.

To see what is in your environment use β€œprintenv”. If you want to see a particular variable, then you can use a number of commands to look at it, but I tend to just use β€œecho $variable”. For example, β€œecho $vendor” should reply β€œnvidia”.

Remember I mentioned using β€œboot” to continue boot? This triggers macro expansion of β€œ$bootcmd”. Check β€œecho $bootcmd”. This becomes β€œrun distro_bootcmd”. If you β€œecho $distro_bootcmd”, then you will see this expands to:
for target in ${boot_targets}; do run bootcmd_${target}; done

You’re now getting close, look at β€œecho $boot_targets”:
mmc1 mmc0 usb0 pxe dhcp

The boot will cycle from β€œmmc1” to β€œmmc0” to β€œusb0” to β€œpxe” to β€œdhcp”. The first one which has the correct trigger condition will become the partition booted. If you have multiple boot devices from that list, then the first one considered β€œacceptable” will boot. I don’t remember what all is used to determine β€œacceptable”, but I think anything β€œext4”, perhaps with a β€œ/boot” directory, is accepted.

If you have just eMMC, but SD is searched for, then eMMC would boot. When SD has the right content, and is searched prior to eMMC, then SD will be used.

A very important but subtle thing to understand is that when you flash a pointer to a device to start with is from the flash command line. Look at the two following manual flash commands for a TX2:

sudo ./flash.sh jetson-tx2 mmcblk0p1
sudo ./flash.sh jetson-tx2 mmcblk1p1

Some boot content will always remain on the Jetson no matter where you tell the flash to look for configuration. In the first case everything will be on the TX2. In the latter case part of the boot information will be on the TX2, and some will now be instead on the SD. If you flash to mmcblk0p1, then the system can boot regardless of whether the is an SD card. If you flash to mmcblk1p1, then no configuration will ever be found if the SD card is missing. Flashing to mmcblk0p1 still allows macro expansion, but it isn’t until boot finds the device configured that the macro expansion even matters. I always recommend flashing to mmcblk0p1 even if you only plan to use SD since you could use the eMMC as a kind of rescue. Once to put that initial pointer in from flash to point at mmcblkp1 there will never again be a boot without that SD card.

Depending on whether search looks at mmcblk0 or mmcblk1 you might find either of two extlinux.conf files. The actual kernel argument for β€œrootfs=” is what determines root device for the Linux kernel even if U-Boot used a different device to find the configuration and U-Boot environment.

1 Like

Hi linuxdev,
thanks for the detailed answer. But if you have explicitly answered my questions, that would be great.

Kindly check my answer and update if needed.

Hi,

Where uboot reads and gets extlinux.conf is the place to get kernel and dtb from.

In your case, uboot tries to extlinux.conf from sdcard slot so the kernel and dtb from all from sd.
Then, based on your device in β€œroot=”, the kernel decides where to read the rootfs.

1 Like

Thanks Wayne/linuxdev.