Boot from USB

Hi all,

I am trying to boot jetson xavier nx devkit from USB.

Steps followed:

  1. using 32.4.2 L4T
  2. sudo lsblk -p -d | grep sd
  3. sudo parted /dev/sdb mklabel gpt
  4. sudo parted /dev/ mkpart APP 0GB 32GB
  5. sudo mkfs.ext4 /dev/sdb1
    6.sudo mount /dev/sdb1 /mnt
  6. sudo BOOTDEV=sda1 ./flash.sh --no-flash jetson-xavier-nx-devkit-emmc sda1
  7. sudo mkdir tmp_system
  8. sudo mount bootloader/system.img.raw ./tmp_system
  9. sudo rsync -axHAWX --numeric-ids --info=progress2 --exclude=/proc ./tmp_system/ /mnt
  10. sudo umount /mnt
  11. sudo umount ./tmp_system
  12. Plug the flash drive into target device and power on.

But the board boots from the emmc only?
Is there any step that I missed? Could someone please help me on the above issue

Regards,
deepika.s

Hi @WayneWWW
Could you please help me on the above issue…

Regards,
deepika.s

Again, please dump the log first.

Thanks for your response @WayneWWW

I have attached the dmesg, PFA.
dmesg.txt (68.5 KB)

Regards,
deepika.s

If you want to check boot log, you should also share your bootloader log from uart.

In your dmesg, I see the root device is still mmcblk0p1. It means cboot still search the extlinux.conf from your emmc but not external storage.

Thanks for you response @WayneWWW ,

I wrongly tried with 32.4.2. By following https://docs.nvidia.com/jetson/l4t/#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/flashing.html#wwpID0E0HM0HA with L4T 32.5, the board boots from USB on xavier-nx-devkit

I tried the same thing on the custom board with xavier-nx som, but the board was not booting from USB.
I have attached the dmesg and uart logs, PFA
dmesg.txt (60.2 KB)
uart_log.txt (84.2 KB)

Is there any hardware or software dependency that has to be taken care for booting from USB ?
Could you please help me on the above issue…

Regards,
deepika.s

The error log indicates cboot says your root file system is corrupted on usb drive.

[0006.884] I> Fallback: assuming 0th partition is boot partition
[0006.884] I> Detect filesystem
[0006.891] I> ext4_mount:588: Failed to allocate memory for group descriptor
[0006.891] E> Failed to mount file system!!
[0006.892] I> Loading kernel …
[0006.892] E> Cannot open partition kernel
[0006.893] E> USB boot failed, err: 202184205

Thanks for your response @WayneWWW

I followed the steps mentioned in the user guide to prepare the USB drive. The xavier-nx SoM flashed with 32.5 and USB pendrive with 32.5 images as such without any change works fine on the devkit booting from USB. But when used with custom board it is booting from emmc and not from USB.

I tried with both USB 2.0 and USB 3.0 pendrives.
Is there any specific change on either hardware or software side is need?

Regards,
deepika.s

Hi,

You can try below test

  1. Prepare 1 custom board, 1 devkit and the usb drive.
  2. Use your method to prepare the usb drive, plug it into custom board and see if it can boot from it.
  3. If (2) fails, directly move this usb drive from custom board to devkit and see if it can boot from it.

If devkit can boot from it but custom board cannot, then please check if custom board can mount this usb drive after boot from emmc.

Thanks for your response @WayneWWW

As mentioned above I prepared the boards and USB. On the custom board it was not booting USB and on the devkit it was booting from USB. After custom board booted from emmc, I am able to mount the usb drive.

So far I didn’t use HDMI . But when HDMI was connected to custom board with USB drive, it booted from USB. When hdmi is not connected with USB connected, it booted from emmc. So whenever HDMI is connected I observed the custom board booted from USB and whenever hdmi is not connected it booted from emmc.
But in case of devkit there is no need for any HDMI to boot from USB.

I have attached the following logs. PFA

  1. dmesg of devkit booted from USB without hdmi
    devkit_nohdmi_usbboot_dmesg.txt (76.5 KB)

  2. bootloader log of devkit booted from USB without hdmi
    devkit_nohdmi_usbboot_bootloaderlog.txt (26.0 KB)

  3. dmesg log of custom board without hdmi booted from emmc
    custom_nohdmi_usbconnected_but_booted_emmc_dmesg.txt (62.0 KB)

  4. bootloader log of custom board without hdmi booted from emmc
    custom_nohdmi_usbconnected_but_booted_emmc_bootloader_log.txt (84.6 KB)

  5. dmesg log of custom board with hdmi booted from USB
    custom_hdmiconnected_usbconnected_booted_USB_dmesg.txt (67.4 KB)

  6. bootloader log of custom board with hdmi booted from USB
    custom_hdmiconnected_usbconnected_booted_USB_bootloader_log.txt (27.8 KB)

Could you please help me debug this issue.

Regards,
deepika

Hi,

I checked the log. It looks and sounds like not a software issue to me. Do you mean if you connect HDMI on custom board, then cboot is able to detect file system but if HDMI is gone, then it will not find the filesystem over usb drive?

Thanks for your response @WayneWWW ,

Yes, if HDMI is physically connected the custom board boots from USB else it boots from emmc even if the USB drive is connected.

Is there anything I could check on either software or hardware side?

Regards,
deepika.s

Hi,

Please add these 4 patches to cboot and see if it can resolve this issue.
Patch1

diff --git a/drivers/usbh/xhci.c b/drivers/usbh/xhci.c
index aa0547a..40a1aee 100644
--- a/drivers/usbh/xhci.c
+++ b/drivers/usbh/xhci.c
@@ -1774,7 +1774,6 @@
 		}
 		trb->data_buffer_lo = U64_TO_U32_LO(dma);
 		trb->data_buffer_hi = U64_TO_U32_HI(dma);
-		dma += transfer_size;
 		trb->trb_tfr_len = transfer_size;
 		trb->td_size = (total_packets - ((size + transfer_size) / ctx->curr_dev_priv->enum_dev.ep[dir].packet_size));
 		if (count != (need_trbs - 1)) {

Patch2

diff --git a/lib/gpt/tegrabl_gpt.c b/lib/gpt/tegrabl_gpt.c
index a3b3deb..203aeea 100644
--- a/lib/gpt/tegrabl_gpt.c
+++ b/lib/gpt/tegrabl_gpt.c
@@ -118,12 +118,7 @@
 	pr_trace("GPT read: for device %08x\n", dev->device_id);
 
 	size = sizeof(struct tegrabl_gpt_entry) * TEGRABL_GPT_MAX_PARTITION_ENTRIES;
-
-#if defined(CONFIG_OS_IS_L4T)
-	size += (5 * TEGRABL_BLOCKDEV_BLOCK_SIZE(dev));
-#else
 	size += TEGRABL_BLOCKDEV_BLOCK_SIZE(dev);
-#endif
 
 	if ((*buf) == NULL) {
 		buffer = (uint8_t *)tegrabl_alloc_align(TEGRABL_HEAP_DMA, 4096, size);

Patch3

diff --git a/lib/gpt/tegrabl_gpt.c b/lib/gpt/tegrabl_gpt.c
index 8aab6cb..a3b3deb 100644
--- a/lib/gpt/tegrabl_gpt.c
+++ b/lib/gpt/tegrabl_gpt.c
@@ -120,7 +120,7 @@
 	size = sizeof(struct tegrabl_gpt_entry) * TEGRABL_GPT_MAX_PARTITION_ENTRIES;
 
 #if defined(CONFIG_OS_IS_L4T)
-	size += (6 * TEGRABL_BLOCKDEV_BLOCK_SIZE(dev));
+	size += (5 * TEGRABL_BLOCKDEV_BLOCK_SIZE(dev));
 #else
 	size += TEGRABL_BLOCKDEV_BLOCK_SIZE(dev);
 #endif

Patch4

diff --git a/drivers/usbh/xhci.c b/drivers/usbh/xhci.c
index 0613876..aa0547a 100644
--- a/drivers/usbh/xhci.c
+++ b/drivers/usbh/xhci.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018-2020, NVIDIA CORPORATION.  All rights reserved.
+ * Copyright (c) 2018-2021, NVIDIA CORPORATION.  All rights reserved.
  *
  * NVIDIA CORPORATION and its licensors retain all intellectual property
  * and proprietary rights in and to this software, related documentation
@@ -548,7 +548,7 @@
 
 	xusbh_xhci_writel(DB(0), 0);
 	pr_debug("Ding Dong!  @%08x  0x%x\n", DB(0), xusbh_xhci_readl(DB(0)));
-	err = xusbh_wait_irq(ctx, 100);
+	err = xusbh_wait_irq(ctx, 300);
 	set_enq_ptr(&ctx->cmd_ring);
 	return err;
 }
@@ -730,7 +730,7 @@
 	xusbh_xhci_writel(DB(ctx->slot_id), DB_VALUE(ep_index, 0));
 	pr_debug("Ding Dong!!!  Ring EP%d doorbell (%x)\n", ep_index, xusbh_xhci_readl(DB(ctx->slot_id)));
 
-	err = xusbh_wait_irq(ctx, 1000);
+	err = xusbh_wait_irq(ctx, 3000);
 	return err;
 }
 
@@ -924,7 +924,7 @@
 
 	xusbh_xhci_writel(DB(0), 0);
 	pr_debug("Ding Dong!  @%08x  0x%x\n", DB(0), xusbh_xhci_readl(DB(0)));
-	err = xusbh_wait_irq(ctx, 100);
+	err = xusbh_wait_irq(ctx, 300);
 /*
 	xhci_print_slot_ctx(ctx, 0);
 	xhci_print_ep_ctx(ctx, 0, 3, 0);
@@ -990,7 +990,7 @@
 
 	xusbh_xhci_writel(DB(0), 0);
 	pr_debug("Ding Dong!  @%08x  0x%x\n", DB(0), xusbh_xhci_readl(DB(0)));
-	err = xusbh_wait_irq(ctx, 100);
+	err = xusbh_wait_irq(ctx, 300);
 	tegrabl_dma_unmap_buffer(TEGRABL_MODULE_XUSB_HOST, 0, (void *)ctx->curr_dev_priv->dev_context, sizeof(struct EP) * 10,
 							 TEGRABL_DMA_FROM_DEVICE);
 /*

Thanks for your response @WayneWWW ,

I downloaded cboot sources from the link https://developer.nvidia.com/embedded/L4T/r32_Release_v5.0/sources/T186/cboot_src_t19x.tbz2
Tried to apply the patches. I was able to apply patch1 and patch4 but patches 2 & 3 related to lib/gpt/tegrabl_gpt.c, I am not able to apply. I am getting the below error

$git apply patch2.patch
error: patch failed: lib/gpt/tegrabl_gpt.c:118
error: lib/gpt/tegrabl_gpt.c: patch does not apply

Regards,
deepika.s

Hi,

For patch 2,3, please directly add the size+= … to the tegrabl_gpt.c

    pr_trace("GPT read: for device %08x\n", dev->device_id);
 
 	size = sizeof(struct tegrabl_gpt_entry) * TEGRABL_GPT_MAX_PARTITION_ENTRIES;

    +#if defined(CONFIG_OS_IS_L4T)
   	 +    size += (5 * TEGRABL_BLOCKDEV_BLOCK_SIZE(dev));
     +#else
     +    size += TEGRABL_BLOCKDEV_BLOCK_SIZE(dev);
     +#endif

Hi @WayneWWW

  1. I set the cross_compile path following the link: https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/xavier_toolchain.html

  2. Python version used is
    $python --version
    Python 2.7.17

  3. I followed CBoot_Standalone_Readme_t194.txt to build the cboot binary.
    while executing the below command I am facing errors.
    $ make -C ./bootloader/partner/t18x/cboot PROJECT=t194 TOOLCHAIN_PREFIX=“${CROSS_COMPILE}” DEBUG=2 BUILDROOT=“${PWD}”/out NV_TARGET_BOARD=t194ref NV_BUILD_SYSTEM_TYPE=l4t NOECHO=@

    I have attached the error log PFA
    cboot_error (223.8 KB)

Did I miss any step or did I follow something wrong?
Could you please help me solve this…

Regards,
deepika.s

Hi @WayneWWW

Could you please help me on the above query?

Regards,
deepika.s

Hello,

Where did you download your source code?

Thanks for your response @WayneWWW ,

I downloaded it in my laptop in the directory ~/Downloads/cboot and exported cross_compiler and tried to build.

Regards,
deepika.s

I mean which website or URL link did you download this source code tarball from?