How to set USB as slave device on Nano?

How to set USB2.0 or USB3.0 as slave device on Nano, for other PC can scan it ?

If you use Jetson Nano developer kit, it supports USB2.0 device mode in the micro-B port. Please connect to the host PC through type-A to micro-B cable and Jetson Nano will enter device mode automatically.

Use micro-B cable, I can see ethernet and serial and read-only storage on host PC. Now I want to use this port as custom usb device, with custom slave driver for communication, how it should be done in kernel 4.9? thanks

If you don’t mind using ethernet, then the content is already there. The default is to have that port produce what looks like an ethernet router and DHCP server. If the host PC accepts it, then the host PC would create a network with IP address, and could ping or talk to the Jetson at address

So far as customizing goes, you can only use the “gadget” convenience API for “standard devices” which use some standard class driver, e.g., keyboard/mouse/ethernet. If you want something else, then you will need to learn to write custom kernel drivers.