How to verify USB 2.0 device mode workable on jetson TK1?

Follow below topic to set USB 2.0 to device mode:
https://devtalk.nvidia.com/default/topic/988640/jetson-tk1/usb-2-0-device-mode-support-on-jetson-tk1

And did below test: Test on version R21.5.

root@tegra-ubuntu:/home/ubuntu# otgdev
/sys/devices/platform/tegra-otg/enable_device:1
/sys/devices/platform/tegra-otg/enable_host:0
root@tegra-ubuntu:/home/ubuntu# modprobe g_ether
modprobe: ERROR: …/libkmod/libkmod.c:556 kmod_search_moddep() could not open moddep file ‘/lib/modules/3.10.40/modules.dep.bin’

root@tegra-ubuntu:/home/ubuntu# echo connect > /sys/devices/platform/tegra-udc.0/udc/tegra-udc.0/soft_connect
In debug console got message below:
ubuntu@tegra-ubuntu:~$
[ 598.954866] Unable to handle kernel NULL pointer dereference at virtual address 00000024
[ 598.962949] pgd = e909c000
[ 598.965648] [00000024] *pgd=a8a7d831, *pte=00000000, *ppte=00000000
[ 598.971931] Internal error: Oops: 817 [#1] PREEMPT SMP ARM
[ 598.977403] Modules linked in: gspca_ov534(O) gspca_main(O)
[ 598.982992] CPU: 0 PID: 2722 Comm: bash Tainted: G O 3.10.40 #1
[ 598.989765] task: e9de8040 ti: e849c000 task.ti: e849c000
[ 598.995159] PC is at tegra_udc_start+0x2c/0xa4
[ 598.999593] LR is at tegra_udc_start+0x28/0xa4
[ 599.004026] pc : [] lr : [] psr: 60070093
[ 599.004026] sp : e849df10 ip : 00000000 fp : 00000000
[ 599.015479] r10: ed015810 r9 : ed01d548 r8 : c0855fec
[ 599.020691] r7 : 00000001 r6 : ed01c69c r5 : 00000000 r4 : ed01c400
[ 599.027203] r3 : 00000000 r2 : ed01c69c r1 : 00000002 r0 : 20070013
[ 599.033716] Flags: nZCv IRQs off FIQs on Mode SVC_32 ISA ARM Segment user
[ 599.040922] Control: 10c5387d Table: a909c06a DAC: 00000015
[ 599.046653]
[ 599.046653] PC: 0xc04f937c:
[ 599.050910] 937c e5863010 e1a08000 e59601b0 ebfff84b e5b54008 e1550004 e244400c 0a000005
[ 599.059141] 939c e1a00004 ebfff845 e594400c e1550004 e244400c 1afffff9 e1a00007 e1a01008
[ 599.067370] 93bc eb0bf4c3 e3a00000 e5860078 e58601a8 e8bd81f0 e92d4070 e52de004 e8bd4000
[ 599.075600] 93dc e3013ffc e34c30d7 e1a05001 e5934004 e2846fa7 e1a00006 eb0bf406 e3a03000
[ 599.083827] 93fc e5853024 e58451a8 e1a01000 e1a00006 eb0bf4af e5d432ba e3530000 1a00000a
[ 599.092055] 941c e5943264 e5932408 f57ff04f e3120b01 0a000005 e59431c4 e3530000 0a000009
[ 599.100285] 943c e5933010 e3530003 0a000006 e3030be8 e5941020 e5952020 e34c00a4 eb0bd1e7
[ 599.108513] 945c e3a00000 e8bd8070 e1a00004 e3a01001 ebfffef9 eafffff4 e92d4070 e52de004
[ 599.116740]
[ 599.116740] LR: 0xc04f9378:
[ 599.120999] 9378 e3a03000 e5863010 e1a08000 e59601b0 ebfff84b e5b54008 e1550004 e244400c
[ 599.129226] 9398 0a000005 e1a00004 ebfff845 e594400c e1550004 e244400c 1afffff9 e1a00007
[ 599.137455] 93b8 e1a01008 eb0bf4c3 e3a00000 e5860078 e58601a8 e8bd81f0 e92d4070 e52de004
[ 599.145684] 93d8 e8bd4000 e3013ffc e34c30d7 e1a05001 e5934004 e2846fa7 e1a00006 eb0bf406
[ 599.153915] 93f8 e3a03000 e5853024 e58451a8 e1a01000 e1a00006 eb0bf4af e5d432ba e3530000
[ 599.162143] 9418 1a00000a e5943264 e5932408 f57ff04f e3120b01 0a000005 e59431c4 e3530000
[ 599.170371] 9438 0a000009 e5933010 e3530003 0a000006 e3030be8 e5941020 e5952020 e34c00a4
[ 599.178599] 9458 eb0bd1e7 e3a00000 e8bd8070 e1a00004 e3a01001 ebfffef9 eafffff4 e92d4070
[ 599.186830]
[ 599.186830] SP: 0xe849de90:
[ 599.191089] de90 c0cdedc0 00000000 00009600 00009600 00000000 00000002 ee01dd50 e8eb3090
[ 599.199317] deb0 c04f93fc 60070093 ffffffff e849defc c0855fec c000e858 20070013 00000002
[ 599.207546] ded0 ed01c69c 00000000 ed01c400 00000000 ed01c69c 00000001 c0855fec ed01d548
[ 599.215775] def0 ed015810 00000000 00000000 e849df10 c04f93f8 c04f93fc 60070093 ffffffff
[ 599.224002] df10 ed015808 e85d3000 00000008 c04f52e4 00000008 00000008 e8647f80 e8647f98
[ 599.232231] df30 e849df80 c01a75dc e8587900 000bac08 e849df80 00000008 e8587900 00000000
[ 599.240460] df50 00000000 c0146578 00000000 e92cbac0 00000001 00000000 00000000 000bac08
[ 599.248688] df70 00000008 e8587900 00000000 c0146c28 00000000 00000000 000cd408 00000008
[ 599.256917]
[ 599.256917] R2: 0xed01c61c:
[ 599.261175] c61c 00000000 00000000 ffffffe0 ed01c628 ed01c628 c04f6f58 ffffffe0 ed01c638
[ 599.269404] c63c ed01c638 c04f70b4 ffffffe0 ed01c648 ed01c648 c04f9304 00000001 00000000
[ 599.277633] c65c 00000000 00000000 fe200000 00000800 7d001000 00000020 00000034 00000000
[ 599.285862] c67c 00000000 00000001 00000000 00000000 00000000 00000000 0016e360 00000000
[ 599.294090] c69c 00030002 00000001 00000000 ed01c6a8 ed01c6a8 00000000 00000000 01000102
[ 599.302319] c6bc 00000100 ed0183c0 00000000 00000000 00000000 00000000 00000000 00000000
[ 599.310548] c6dc 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 599.318778] c6fc 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 599.327005]
[ 599.327005] R4: 0xed01c380:
[ 599.331262] c380 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 599.339491] c3a0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 599.347718] c3c0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 599.355946] c3e0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 599.364174] c400 c086dda4 ed013000 ed0130b4 ed013a38 00000000 00000003 00000000 00000000
[ 599.372401] c420 c086dd98 00000000 c0bdc058 ed0184c0 ed01ea40 ed015814 ed7e0254 c0bdc060
[ 599.380630] c440 edaf2640 c0c9a758 ed01d908 00000002 00000003 00000000 00000000 00000001
[ 599.388858] c460 00000000 ed01c464 ed01c464 00000000 00000000 00000000 00000000 00000000
[ 599.397088]
[ 599.397088] R6: 0xed01c61c:
[ 599.401345] c61c 00000000 00000000 ffffffe0 ed01c628 ed01c628 c04f6f58 ffffffe0 ed01c638
[ 599.409574] c63c ed01c638 c04f70b4 ffffffe0 ed01c648 ed01c648 c04f9304 00000001 00000000
[ 599.417803] c65c 00000000 00000000 fe200000 00000800 7d001000 00000020 00000034 00000000
[ 599.426029] c67c 00000000 00000001 00000000 00000000 00000000 00000000 0016e360 00000000
[ 599.434257] c69c 00030002 00000001 00000000 ed01c6a8 ed01c6a8 00000000 00000000 01000102
[ 599.442484] c6bc 00000100 ed0183c0 00000000 00000000 00000000 00000000 00000000 00000000
[ 599.450711] c6dc 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 599.458937] c6fc 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 599.467166]
[ 599.467166] R8: 0xc0855f6c:
[ 599.471423] 5f6c 5f617267 75636573 615f6572 636f6c6c 00000000 69766564 635f6563 74616572
[ 599.479651] 5f8c 65725f65 7361656c 00000065 69766564 725f6563 6d616e65 00000065 69766564
[ 599.487880] 5fac 755f6563 6765726e 65747369 00000072 69766564 6d5f6563 0065766f 69766564
[ 599.496107] 5fcc 615f6563 00006464 5f766564 65766575 0000746e c0403e54 c0404b40 c0405f94
[ 599.504335] 5fec c0404af0 c0403df8 00000000 76697264 725f7265 61656c65 00006573 5f737562
[ 599.512563] 600c 5f646461 76697264 00007265 c04064a4 00000000 00000000 5f737562 65726e75
[ 599.520790] 602c 74736967 00007265 5f737562 69676572 72657473 00000000 5f737562 6f6d6572
[ 599.529018] 604c 645f6576 65766972 00000072 5f737562 6f6d6572 645f6576 63697665 00000065
[ 599.537248]
[ 599.537248] R9: 0xed01d4c8:
[ 599.541505] d4c8 00000001 00000000 ed01d6c8 c0a43560 ed01d559 00000000 00000000 00000000
[ 599.549734] d4e8 00000000 7f0e4745 c0ca6720 00000000 00000000 81240002 000023f7 00000000
[ 599.557965] d508 00000001 00000000 ed01d6c8 c09fa73c ed01d659 ed01d618 ed01d358 00000000
[ 599.566195] d528 00000000 137e7407 c0ca6730 00000000 00000000 81240002 000023f6 00000000
[ 599.574424] d548 00000003 00000001 ed01d6c8 c0a43570 ed01d659 ed01d4d8 ed01d498 00000000
[ 599.582651] d568 00000000 736050a6 c0ca6740 e8640a40 00000000 80800002 000023f5 e9075140
[ 599.590881] d588 00000001 00000000 ed01d6c8 c0a43580 ed01d358 00000000 00000000 00000000
[ 599.599109] d5a8 00000000 002931b1 c0ca6750 00000000 00000000 80800002 000023f4 00000000
[ 599.607337]
[ 599.607337] R10: 0xed015790:
[ 599.611681] 5790 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 599.619909] 57b0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 599.628136] 57d0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 599.636366] 57f0 00000000 00000000 00000000 00000000 00000000 ed01c400 c0bdc058 ed018440
[ 599.644593] 5810 ed01e980 ed01560c ed01c434 ed01e940 edaf2640 c0c9a758 ed01d6c8 00000003
[ 599.652822] 5830 00000007 00000000 00000000 00000001 00000000 ed015844 ed015844 00000000
[ 599.661049] 5850 00000000 00000000 00000000 00000000 00000000 00000020 00000000 ed015664
[ 599.669275] 5870 ed01c48c 7fffffff 00010001 ed01587c ed01587c 00000000 00000000 00000000
[ 599.677506] Process bash (pid: 2722, stack limit = 0xe849c238)
[ 599.683324] Stack: (0xe849df10 to 0xe849e000)
[ 599.687670] df00: ed015808 e85d3000 00000008 c04f52e4
[ 599.695830] df20: 00000008 00000008 e8647f80 e8647f98 e849df80 c01a75dc e8587900 000bac08
[ 599.703991] df40: e849df80 00000008 e8587900 00000000 00000000 c0146578 00000000 e92cbac0
[ 599.712152] df60: 00000001 00000000 00000000 000bac08 00000008 e8587900 00000000 c0146c28
[ 599.720312] df80: 00000000 00000000 000cd408 00000008 000bac08 b6f27b50 00000004 c000eea4
[ 599.728472] dfa0: e849c000 c000ed00 00000008 000bac08 00000001 000bac08 00000008 00000000
[ 599.736631] dfc0: 00000008 000bac08 b6f27b50 00000004 00000008 00000000 000b5194 00000000
[ 599.744791] dfe0: 00000000 bedf9314 b6e9cc29 b6ed5c46 40070030 00000001 00000000 00000000
[ 599.752961] [] (tegra_udc_start+0x2c/0xa4) from [] (usb_udc_softconn_store+0x44/0xd4)
[ 599.762516] [] (usb_udc_softconn_store+0x44/0xd4) from [] (sysfs_write_file+0x168/0x198)
[ 599.772329] [] (sysfs_write_file+0x168/0x198) from [] (vfs_write+0xbc/0x19c)
[ 599.781100] [] (vfs_write+0xbc/0x19c) from [] (SyS_write+0x60/0x178)
[ 599.789179] [] (SyS_write+0x60/0x178) from [] (ret_fast_syscall+0x0/0x30)
[ 599.797687] Code: e2846fa7 e1a00006 eb0bf406 e3a03000 (e5853024)
[ 599.803768] —[ end trace 80715ba40268b691 ]—
[ 599.817576] note: bash[2722] exited with preempt_count 1

have any recommendation to help!

Hi FoxK,

Please try below command again:
echo 0 > /sys/devices/platform/tegra-otg/enable_host
echo 1 > /sys/devices/platform/tegra-otg/enable_device
modprobe g_mass_storage file=/dev/mmcblk0p1
echo connect > /sys/devices/platform/tegra-udc.0/udc/tegra-udc.0/soft_connect

Then connect microUSB cable to your linux system, it will pop up mmcblk0p1 storage.

Also, I notice the kernel version was exactly “3.10.40”, and a module could not be found. Is this a custom kernel? What does “uname -r” show?

Dear carolyuu,

root@tegra-ubuntu:/home/ubuntu# otgdev
/sys/devices/platform/tegra-otg/enable_device:1
/sys/devices/platform/tegra-otg/enable_host:0
root@tegra-ubuntu:/home/ubuntu# modprobe g_mass_storage file=/dev/mmcblk0p1
modprobe: ERROR: …/libkmod/libkmod.c:556 kmod_search_moddep() could not open moddep file ‘/lib/modules/3.10.40/modules.dep.bin’
root@tegra-ubuntu:/home/ubuntu# echo connect > /sys/devices/platform/tegra-udc.0/udc/tegra-udc.0/soft_connect
In debug console got message like above.

Dear linuxdev,

ubuntu@tegra-ubuntu:~$ uname -r
3.10.40

The zImage build is use original R21.5 kernel source.
[url]https://developer.nvidia.com/linux-tegra-r215[/url]

Best regards,

Something seems wrong with the version, but I’ll have to check when I’m near a TK1. I was thinking “uname -r” on all of the releases showed some suffix. What subdirectories exist in “/lib/modules/”? There must be one which matches “uname -r”. FYI, using the original source is not the same as using the original…configuration makes an enormous difference, and I’m thinking this is not configured correctly.

EDIT: The default kernel configuration on my R21.5 is “3.10.40-ga7da876”. So it looks like you have a custom kernel (configuration is the issue, not source code). I suspect your kernel has modules installed incorrectly and causes the kernel to not find what it is expecting. The fix may be as simple as setting up CONFIG_LOCALVERSION using your current config.

Dear linuxdev,
Use original source and use original configuration and make rule below:
mkdir $TEGRA_KERNEL_OUT
make O=$TEGRA_KERNEL_OUT tegra12_defconfig
make O=$TEGRA_KERNEL_OUT zImage

but not make modules.

/lib/modules/3.10.40-ga7da876

so, I need to make new modules for original source or change kernel version “Local Version” to “-ga7da876”?

Best regards,

This is why it failed…the defconfig does not set the CONFIG_LOCALVERSION, this must be done manually. The 3.10.40 comes from the source, the “-ga7da867” comes from CONFIG_LOCALVERSION.

Option 1 is what you mentioned, to rebuild modules as well without CONFIG_LOCALVERSION. This is probably not the best approach (it will work, but it’s kind of an ugly way of doing it). There are third party modules involved (not built with the kernel source), and you’d need to manually preserve those.

Option 2 is to completely reuse the existing modules since you did not change module features (there are a number of features which can be changed for modules and still not break existing modules). You’d end up copying just the one file, zImage, and not have to mess with setting up an entirely new module directory. You’d build the zImage again exactly as you did, but you’d first edit CONFIG_LOCALVERSION. One .config file change and one zImage copy and you’re done.

After you make tegra12_defconfig you can use something like “make menuconfig”, “make nconfig”, or simply edit the saved .config’s CONFIG_LOCALVERSION. CONFIG_LOCALVERSION has no dependencies so you can simply edit .config with “-ga7da876” and then build. If using either make menuconfig or nconfig, then:

General setup --->
   Local version -append to kernel release
      -ga7da867

Dear carolyuu, linuxdev,

After kernel version “Local Version” set to “-ga7da876” match the Jetson TK1 board current version.
Follow above command, then connect microUSB cable to linux system, it pop up a Devices name 15 GB Volume.

Best regards,

Hi FoxK,

Good news! 15GB Volume is correctly (mmcblk0p1)!