* device that supports both usb host & usb device modes?
@ 2024-10-10 7:31 Marek Behún
2024-10-14 16:09 ` Quentin Schulz
2024-10-14 16:20 ` neil.armstrong
0 siblings, 2 replies; 3+ messages in thread
From: Marek Behún @ 2024-10-10 7:31 UTC (permalink / raw)
To: u-boot
Hi all,
I am searching for HW that supports both USB host & USB device/gadget
mode, on the same USB port, capable of switching between these modes
at runtime.
Preferably supported in upstream kernel.
Has anyone done this for example with Raspberry Pi?
Thanks.
Marek
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: device that supports both usb host & usb device modes?
2024-10-10 7:31 device that supports both usb host & usb device modes? Marek Behún
@ 2024-10-14 16:09 ` Quentin Schulz
2024-10-14 16:20 ` neil.armstrong
1 sibling, 0 replies; 3+ messages in thread
From: Quentin Schulz @ 2024-10-14 16:09 UTC (permalink / raw)
To: Marek Behún, u-boot
Hi Marek,
On 10/10/24 9:31 AM, Marek Behún wrote:
> Hi all,
>
> I am searching for HW that supports both USB host & USB device/gadget
> mode, on the same USB port, capable of switching between these modes
> at runtime.
>
> Preferably supported in upstream kernel.
>
I'm doing a very simple test on our (formerly known as Theobroma
Systems) RK3399 Puma with Haikou devkit and it seems to work fine
(insert USB stick into microUSB, detect the stick was connected, remove
USB stick, loop microUSB to USB, configure as ACM, send
test123test123test one way and then the other) as I have not commented
out the test for our internal releases :)
I believe that our RK3588 Tiger with Haikou devkit also supports it
(same test) but I am not the one who upstreamed nor tested that part
(and it doesn't work on our devices in peripheral mode on Rockchip BSP
kernel 5.10/6.1).
I don't think we do anything crazy here on the HW level, so I would say
anything based on RK3399 and RK3588(S) which advertises an USB OTG port
should be able to work. For RK3588(S) maybe check if it's on USB-C, as I
am not entirely sure whether we (upstream kernel) support FUSB302 (used
in the reference design from Rockchip I believe, so most manufacturers
do use them to limit risks) USB-C connector for OTG just yet (about to
though if I remember correctly). Maybe have a look on the side of RK356x
(RK3566/RK3568) as well, I've seen a few with ROCKUSB enabled in U-Boot,
which means OTG (at least in peripheral mode) is supported in U-Boot.
For reference, this is the test I run:
"""
#!/bin/sh
# Change UDC environment variable according to USB controller connected
to USB OTG port
set -eu
UDC=${UDC:-"fc000000.usb"}
cleanup_usb_otg() {
echo "" > "$CONFIGFS_HOME/usb_gadget/q7-usb-p2/UDC"
rm "$CONFIGFS_HOME/usb_gadget/q7-usb-p2/configs/conf.1/acm.1"
rmdir "$CONFIGFS_HOME/usb_gadget/q7-usb-p2/configs/conf.1/strings/0x409/"
rmdir "$CONFIGFS_HOME/usb_gadget/q7-usb-p2/configs/conf.1/"
rmdir "$CONFIGFS_HOME/usb_gadget/q7-usb-p2/functions/acm.1/"
rmdir "$CONFIGFS_HOME/usb_gadget/q7-usb-p2/strings/0x409/"
rmdir "$CONFIGFS_HOME/usb_gadget/q7-usb-p2/"
}
run_cmd() {
set -x
"$@"
set +x
}
test_serial() {
TX=$1
RX=$2
RXPROOF=$(mktemp)
ORIG=$(mktemp)
(cat "$RX" > "$RXPROOF")&
PID=$!
printf "test123test123test\n" > "$ORIG"
# NOTE: \r instead of \n
# The message is sent only if \r or \n is passed, however the receiving
# end adds an additional newline. Therefore, to check data integrity the
# last character is different in the reference file and the message
# being sent.
printf "test123test123test\r" > "$TX"
# Give some time for the message to make it to the other side of the
# communication before killing the process.
sleep 1
kill $PID
wait $PID || true
diff "$ORIG" "$RXPROOF"
rm -rf "$ORIG" "$RXPROOF"
}
CONFIGFS_HOME=$(findmnt --noheadings --types configfs -o target)
if [ -z "$CONFIGFS_HOME" ]; then
CONFIGFS_HOME=$(mktemp --directory)
run_cmd mount none -t configfs "$CONFIGFS_HOME"
fi
if [ -e "$CONFIGFS_HOME/usb_gadget/q7-usb-p2" ]; then
set +e
run_cmd cleanup_usb_otg
set -e
fi
run_cmd mkdir "$CONFIGFS_HOME/usb_gadget/q7-usb-p2"
run_cmd echo 0xabcd > "$CONFIGFS_HOME/usb_gadget/q7-usb-p2/idVendor"
run_cmd echo 0xef01 > "$CONFIGFS_HOME/usb_gadget/q7-usb-p2/idProduct"
run_cmd mkdir "$CONFIGFS_HOME/usb_gadget/q7-usb-p2/strings/0x409"
run_cmd echo SN1234567890 >
"$CONFIGFS_HOME/usb_gadget/q7-usb-p2/strings/0x409/serialnumber"
run_cmd echo Theobroma >
"$CONFIGFS_HOME/usb_gadget/q7-usb-p2/strings/0x409/manufacturer"
run_cmd echo Tiger-Haikou >
"$CONFIGFS_HOME/usb_gadget/q7-usb-p2/strings/0x409/product"
run_cmd mkdir "$CONFIGFS_HOME/usb_gadget/q7-usb-p2/configs/conf.1/"
run_cmd mkdir
"$CONFIGFS_HOME/usb_gadget/q7-usb-p2/configs/conf.1/strings/0x409"
run_cmd echo "USB ACM test" >
"$CONFIGFS_HOME/usb_gadget/q7-usb-p2/configs/conf.1/strings/0x409/configuration"
run_cmd mkdir "$CONFIGFS_HOME/usb_gadget/q7-usb-p2/functions/acm.1"
run_cmd ln -s "$CONFIGFS_HOME/usb_gadget/q7-usb-p2/functions/acm.1"
"$CONFIGFS_HOME/usb_gadget/q7-usb-p2/configs/conf.1"
run_cmd echo "$UDC" > "$CONFIGFS_HOME/usb_gadget/q7-usb-p2/UDC"
# Give some time for the ACM device to be probed by the kernel
sleep 2
ACM="/dev/ttyACM0"
GS="/dev/ttyGS$(cat
"$CONFIGFS_HOME/usb_gadget/q7-usb-p2/functions/acm.1/port_num")"
run_cmd test_serial "$ACM" "$GS"
run_cmd test_serial "$GS" "$ACM"
echo "All good!"
"""
Once run, connect a USB stick to the port, it should be detected.
Cheers,
Quentin
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: device that supports both usb host & usb device modes?
2024-10-10 7:31 device that supports both usb host & usb device modes? Marek Behún
2024-10-14 16:09 ` Quentin Schulz
@ 2024-10-14 16:20 ` neil.armstrong
1 sibling, 0 replies; 3+ messages in thread
From: neil.armstrong @ 2024-10-14 16:20 UTC (permalink / raw)
To: Marek Behún, u-boot
Hi,
On 10/10/2024 09:31, Marek Behún wrote:
> Hi all,
>
> I am searching for HW that supports both USB host & USB device/gadget
> mode, on the same USB port, capable of switching between these modes
> at runtime.
>
> Preferably supported in upstream kernel.
The following commercial dev boards support dual and runtime switch on mainline U-Boot and Mainline Linux:
- Khadas VIM3/L (with external supply)
- Odroid-N2(+) https://www.hardkernel.com/shop/odroid-n2-with-4gbyte-ram-2/
- Odroid-N2L https://www.hardkernel.com/shop/odroid-n2l-with-2gbyte-ram/
- Odroid-HC4 https://www.hardkernel.com/shop/odroid-hc4/
- Libre Computer AML-A311D-CC https://libre.computer/products/aml-a311d-cc/ (with external supply)
- Libre Computer AML-S905D3-CC https://libre.computer/products/aml-s905d3-cc/ (with external supply)
- BananaPi M5 https://wiki.banana-pi.org/Banana_Pi_BPI-M5 (with external supply)
- BananaPi M2S hhttps://wiki.banana-pi.org/Banana_Pi_BPI-M2S (with external supply)
Neil
>
> Has anyone done this for example with Raspberry Pi?
>
> Thanks.
>
> Marek
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-10-14 16:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-10 7:31 device that supports both usb host & usb device modes? Marek Behún
2024-10-14 16:09 ` Quentin Schulz
2024-10-14 16:20 ` neil.armstrong
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.