Orin NX USB issue

                            Hello.

I will describe issue about of USB3 functionality.

We’ve developed our custom carrier board.
At first, we used it with Xavier NX.

The difference between Nvidia carrier board and our is what we use USB0 as companion for USB3.
For Xavier NX we use Jetson Linux R32.6.1 Release.
I modified tegra194-p3668-common.dtsi file:

                ports {
                        usb2-0 {
                                mode = "otg"; 
                                status = "okay";
                        };
                        usb2-1 {
                                mode = "host";
                                status = "okay";
                        };
                        usb2-2 {
                                mode = "host";
                                vbus-supply = <&battery_reg>;
                                status = "okay";
                        };
                        usb3-2 {
                                nvidia,usb2-companion = <1>;
                                nvidia,usb3-gen1-only = <1>;
                                status = "okay";
                        };
                };
        };

mode = “otg”; was replaced on mode = “host”;
After this change, USB works fine as USB3 and USB2.

Now I want to use Orin NX. Carrier board is the same.
Jetson Linux 35.2.1
But device tree is different a lot.

                ports {
                        usb2-0 {
                                mode = "otg";
                                status = "okay";
                                vbus-supply = <&p3509_vdd_5v_sys>;
#if TEGRA_XUSB_DT_VERSION >= DT_VERSION_3
                                usb-role-switch;
                                connector {
                                        compatible = "usb-b-connector", "gpio-usb-b-connector";
                                        label = "micro-USB";
                                        type = "micro";
                                        vbus-gpio = <&tegra_main_gpio TEGRA234_MAIN_GPIO(Z, 1) GPIO_ACTIVE_LOW>;
                                };
#endif
                        };
                        usb2-1 {
                                mode = "host";
                                vbus-supply = <&p3509_vdd_av10_hub>;
                                status = "okay";
                        };
                        usb2-2 {/* Goes to M2.E */
                                mode = "host";
                                vbus-supply = <&p3509_vdd_5v_sys>;
                                status = "okay";
                        };
                        usb3-0 {
                                nvidia,usb2-companion = <1>;
                                status = "okay";
                        };
                };
        };

If I change mode from otg to host, flashing of device fails.

[    8.688283] tegra_actmon d230000.actmon: in actmon_register()...
[    8.693639] tegra_actmon d230000.actmon: bwmgr_disable = 1
[    8.699517] tegra_actmon d230000.actmon: initialization Completed for the device mc_all
[    8.706960] tegra-xudc 3550000.xudc: failed to get usbphy-0: -517
[    8.712735] hvc_sysfs: hypervisor is not present
[    8.753431] ALSA device list:
[    8.753511]   No soundcards found.
[    8.754280] Freeing unused kernel memory: 3968K
[    8.754463] Run /init as init process
[    8.767417] Root device found: initrd
[    8.767887] Mount initrd as rootfs and enter recovery mode
enable_remote_access
enable remote access
insmod /lib/modules/5.10.104-tegra/kernel/drivers/mtd/mtd.ko 
insmod /lib/modules/5.10.104-tegra/kernel/drivers/mtd/devices/qspi_mtd.ko 
[    8.792064] qspi_mtd spi6.0: MX25U51279G (65536 Kbytes)
[    8.792206] qspi_mtd spi6.0: mtd .name = spi6.0, .size = 0x4000000 (64MiB) .erasesize = 0x00010000
 (64KiB) .numeraseregions = 0
[    8.799615] 1 fixed-partitions partitions found on MTD device spi6.0
[    8.799770] Creating 1 MTD partitions on "spi6.0":
[    8.799902] 0x000000000000-0x000004000000 : "Whole_flash0"
[    8.800479] tegra-xudc 3550000.xudc: failed to get usbphy-0: -517
insmod /lib/modules/5.10.104-tegra/kernel/drivers/spi/spi-tegra210-qspi.ko 
insmod /lib/modules/5.10.104-tegra/kernel/drivers/hwmon/pwm-fan.ko 
[    8.815351] tegra-xudc 3550000.xudc: failed to get usbphy-0: -517
[    9.344738] mmc1: SDHCI controller on 3400000.sdhci [3400000.sdhci] using ADMA 64-bit
No known UDC device found
bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell

Could you please help me, how to correctly switch mode for USB0 from otg to host?

Hi,

Sorry. I am not sure if this is English speaking issue or something else… but what you are talking about seems totally not related to what you want to ask.

I will describe issue about of USB3 functionality.

You told us this is related to usb3. But your question is totally not related to USB3.

The difference between Nvidia carrier board and our is what we use USB0 as companion for USB3.

But your device tree in rel-32.6.1 is also wrong. Your USB0 is not companion for any USB3 port…

Now I want to use Orin NX. Carrier board is the same.

Is your hardware a type A port or a micro B port?

Hi.

Indeed, you are right.
But in rel-32.6.1 with Xavier NX USB works as USB3.0 and USB2.0. It is strange. It seems, than parameter nvidia,usb2-companion is skipped while processing USB driver.

We have custom connector, and it works with Xavier NX.

My issue is.
Release 35.2.1
When I change mode for USB2-0 from otg to host:

                ports {
                        usb2-0 {
                                mode = "otg";
                                status = "okay";
                                vbus-supply = <&p3509_vdd_5v_sys>;
#if TEGRA_XUSB_DT_VERSION >= DT_VERSION_3
                                usb-role-switch;
                                connector {
                                        compatible = "usb-b-connector", "gpio-usb-b-connector";
                                        label = "micro-USB";
                                        type = "micro";
                                        vbus-gpio = <&tegra_main_gpio TEGRA234_MAIN_GPIO(Z, 1) GPIO_ACTIVE_LOW>;
                                };
#endif

Flashing process fails:

[    8.688283] tegra_actmon d230000.actmon: in actmon_register()...
[    8.693639] tegra_actmon d230000.actmon: bwmgr_disable = 1
[    8.699517] tegra_actmon d230000.actmon: initialization Completed for the device mc_all
[    8.706960] tegra-xudc 3550000.xudc: failed to get usbphy-0: -517
[    8.712735] hvc_sysfs: hypervisor is not present
[    8.753431] ALSA device list:
[    8.753511]   No soundcards found.
[    8.754280] Freeing unused kernel memory: 3968K
[    8.754463] Run /init as init process
[    8.767417] Root device found: initrd
[    8.767887] Mount initrd as rootfs and enter recovery mode
enable_remote_access
enable remote access
insmod /lib/modules/5.10.104-tegra/kernel/drivers/mtd/mtd.ko 
insmod /lib/modules/5.10.104-tegra/kernel/drivers/mtd/devices/qspi_mtd.ko 
[    8.792064] qspi_mtd spi6.0: MX25U51279G (65536 Kbytes)
[    8.792206] qspi_mtd spi6.0: mtd .name = spi6.0, .size = 0x4000000 (64MiB) .erasesize = 0x00010000
 (64KiB) .numeraseregions = 0
[    8.799615] 1 fixed-partitions partitions found on MTD device spi6.0
[    8.799770] Creating 1 MTD partitions on "spi6.0":
[    8.799902] 0x000000000000-0x000004000000 : "Whole_flash0"
[    8.800479] tegra-xudc 3550000.xudc: failed to get usbphy-0: -517
insmod /lib/modules/5.10.104-tegra/kernel/drivers/spi/spi-tegra210-qspi.ko 
insmod /lib/modules/5.10.104-tegra/kernel/drivers/hwmon/pwm-fan.ko 
[    8.815351] tegra-xudc 3550000.xudc: failed to get usbphy-0: -517
[    9.344738] mmc1: SDHCI controller on 3400000.sdhci [3400000.sdhci] using ADMA 64-bit
No known UDC device found
bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell

Finally, my question is: how to change mode for USB2-0 from otg to host?

Could you please confirm this assumption.
In Orin NX board with external NVMe memory USB2-0 MUST be configurated as otg.

Hi,

What really matters is my question here and you didn’t answer it.

Is your usb0 hardware a type A port or a micro B port?

And for your question.

In Orin NX board with external NVMe memory USB2-0 MUST be configurated as otg.

Your guess is almost correct. You have to set usb0 into device mode. Not even otg mode.

The reason behind this is due to you are not using flash.sh to flash nvme or usb anymore. You are using initrd flash tool. And this tool is actually boot into initrd first and use initrd to flash.

This means there is no hardware pin that can help your board go into “recovery mode” when initrd flash is trying to flash nvme. It will read your device tree. Generally, a type A port cannot be otg mode. That is why I asked if your port is type A or micro usb.

If your port is type A, then there is a very tricky way to flash your device… I will share it later.

Hi.

I answered before. This it custom connector like this, which contains one more functionality.
Screenshot from 2023-02-02 18-22-12

Thank you a lot for this method, I will be waiting for it.

Hi,

So your design for USB0 is a type A usb port, right…?

Please try to follow below one for your device tree. This may make your board able to flash the external drive.

ports {
 			usb2-0 {
 				mode = "peripheral";
 				status = "okay";
 				usb-role-switch;
 				/* The port only works on device mode and needs to be default on.
 				 * We do not have any singal from STM which indicate the cable
 				 * connected now.
 				 */
 				connector {
 					compatible = "usb-b-connector", "gpio-usb-b-connector";
 					label = "micro-USB";
 					type = "micro";
 					cable-connected-on-boot = <USB_ROLE_DEVICE>;
 				};
 			};
 	tegra_xudc: xudc@3550000 {
 		status = "disabled";
 		phys = <&{/xusb_padctl@3520000/pads/usb2/lanes/usb2-0}>,
			<&{/xusb_padctl@3520000/pads/usb3/lanes/usb3-0}>;
 		phy-names = "usb2-0", "usb3-0";
 		nvidia,xusb-padctl = <&xusb_padctl>;
 		nvidia,boost_cpu_freq = <1200>;
 	};

But your usb function may not work after boot into kernel. We can handle that after we confirm you could flash nvme.

Hi.

I can’t compile such device tree:

arch/arm64/boot/dts/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/_ddot_/hardware/nvidia/platform/t23x/p3768/kernel-dts/tegra234-p3767-0000-p3509-a02.dtb
Error: arch/arm64/boot/dts/../../../../../../hardware/nvidia/platform/t23x/p3768/kernel-dts/cvb/tegra234-p3509-a02.dtsi:103.34-35 syntax error
FATAL ERROR: Unable to parse input tree

Error line is:
cable-connected-on-boot = <USB_ROLE_DEVICE>;

please include this file.

include <dt-bindings/usb/role.h>

Hi.

Thank you for hint, now it is compiled successfully.

But I can’t flash it.
There is a log:

[    8.599462] input: gpio-keys as /devices/platform/gpio-keys/input/input0
[    8.606959] tegra-se-nvhost 15810000.se: Adding to iommu group 50
[    8.612744] tegra-se-nvhost 15810000.se: initialized
[    8.626949] tegra-se-nvhost 15810000.se: tegra_se_probe: complete
[    8.627225] tegra-se-nvhost 15820000.se: Adding to iommu group 51
[    8.629947] tegra-se-nvhost 15820000.se: initialized
[    8.637672] tegra-se-nvhost 15820000.se: tegra_se_probe: complete
[    8.640688] tegra-se-nvhost 15840000.se: Adding to iommu group 52
[    8.647193] tegra-se-nvhost 15840000.se: initialized
[    8.655688] tegra-se-nvhost 15840000.se: tegra_se_probe: complete
[    8.658567] tegra_actmon d230000.actmon: in actmon_register()...
[    8.664183] tegra_actmon d230000.actmon: bwmgr_disable = 1
[    8.669869] tegra_actmon d230000.actmon: initialization Completed for the device mc_all
[    8.677585] hvc_sysfs: hypervisor is not present
[    8.716477] ALSA device list:
[    8.716557]   No soundcards found.
[    8.717286] Freeing unused kernel memory: 3968K
[    8.717477] Run /init as init process
[    8.729973] Root device found: initrd
[    8.730444] Mount initrd as rootfs and enter recovery mode
enable_remote_access
enable remote access
insmod /lib/modules/5.10.104-tegra/kernel/drivers/mtd/mtd.ko 
insmod /lib/modules/5.10.104-tegra/kernel/drivers/mtd/devices/qspi_mtd.ko 
[    8.754176] qspi_mtd spi6.0: MX25U51279G (65536 Kbytes)
[    8.754316] qspi_mtd spi6.0: mtd .name = spi6.0, .size = 0x4000000 (64MiB) .erasesize = 0x00010000
 (64KiB) .numeraseregions = 0
[    8.761395] 1 fixed-partitions partitions found on MTD device spi6.0
[    8.761563] Creating 1 MTD partitions on "spi6.0":
[    8.761695] 0x000000000000-0x000004000000 : "Whole_flash0"
insmod /lib/modules/5.10.104-tegra/kernel/drivers/spi/spi-tegra210-qspi.ko 
insmod /lib/modules/5.10.104-tegra/kernel/drivers/hwmon/pwm-fan.ko 
[    9.352221] mmc1: SDHCI controller on 3400000.sdhci [3400000.sdhci] using ADMA 64-bit
[    9.748016] [RCE] WARNING: core/hsp/hsp-vm.c:283 [camrtc_hsp_full_ss_isr] "VM0 issued IVC in inact
ive state."
[    9.748299] [RCE] WARNING: core/hsp/hsp-vm.c:283 [camrtc_hsp_full_ss_isr] "VM0 issued IVC in inact
ive state."
[    9.748575] [RCE] WARNING: core/hsp/hsp-vm.c:283 [camrtc_hsp_full_ss_isr] "VM0 issued IVC in inact
ive state."
[    9.748849] [RCE] WARNING: core/hsp/hsp-vm.c:283 [camrtc_hsp_full_ss_isr] "VM0 issued IVC in inact
ive state."
No known UDC device found
bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell
bash-5.0#

Hi @dimaz

Whenever you share any log, attach the full log here.

Partial log does not help.

Hi @WayneWWW

I’ve attached both logs: uart and flash.

flash_log.txt (250.2 KB)
uart_log.txt (87.1 KB)

Thank you for help in advance.

Sorry, did you set the xudc into disabled state?

Yes, it is disabled as you recommended in your device tree example.

Sorry. That was wrong. Please enable it.

What I want to say is you should list the usb2-0 node to the xudc nodes.

After enabling xudc, nvme is flashed successfully.
What is our next step?

Hi,

The next one is complicated one.

Basically, we are doing similar thing as this.

step1, you need to create a image which contains the type A usb device tree. With “–no-flash”, this step won’t really flash. But just create an image. This image will enable usb port as type A port.

$ sudo ./tools/kernel_flash/l4t_initrd_flash.sh --external-device nvme0n1p1 -c tools/kernel_flash/flash_l4t_external.xml -p “-c bootloader/t186ref/cfg/flash_t234_qspi.xml --no-systemimg” --network usb0 –no-flash board_config1 external

step2, you need to use a board config where you force the usb port into device mode. And Initrd flash will use this dtb to only do the flash job. “–use-backup-image” will use the image you create from step(1).

$ sudo ./tools/kernel_flash/l4t_initrd_flash.sh --external-device nvme0n1p1 -c tools/kernel_flash/flash_l4t_external.xml -p “-c bootloader/t186ref/cfg/flash_t234_qspi.xml --no-systemimg” --network usb0 –use-backup-image board_config_2 external

In brief, “initrd” will use the “device mode” dtb to do flash work and the flash work will flash the “type A dtb” into the board.

Currently, you have validated "“initrd” + “device mode” dtb can flash the board.

Hi!

Thank you, I will try this solution today.

One more questions:

  1. Can I change (replace) device tree file (tegra234-p3767-0000-p3509-a02.dtb) from Linux (target Ubuntu)?
  2. Can I use USB2-0 OTG for reading flash card. Maybe I can configure USB OTG as HOST inside Linux and use it?

HI,

  1. If you are talking about using the device mode dtb to flash into board first and then use type A dtb, then it is feasible.

  2. Sorry, I am not quite sure about “reading flash card” meaning here? Could you clarify it?
    Also, what I suggested in previous comment was to let your usb otg go back to host…
    So I am not sure what is your purpose of question (2)…