C2 - HID Keyboard/ Device / Gadget for USB output on linux

Post Reply
br-devb-1
Posts: 11
Joined: Wed Oct 16, 2019 7:13 am
languages_spoken: english, french
ODROIDs: c2
Location: APAC
Has thanked: 0
Been thanked: 0
Contact:

C2 - HID Keyboard/ Device / Gadget for USB output on linux

Unread post by br-devb-1 » Wed Oct 16, 2019 7:59 am

Hi,
I planned to use droid c2 in a project which require to output string via USB. Hence i was thinking HID device keyboard would work with the native USB-A ports.

it seems even if i am seeing g_hid.ko then it's not working on the last ubuntu release 18.04 kernel 3.16-72.46. i can modeprob libcomposite but cannot load g_hid. I read in some thread the linux kernel should be up to 3.19.
it fails when i try to create the mkdir -p functions/hid.usb0

my questions are :
  • Is there any image i can use with new kernel allowing g_hid on c2 ?
  • Is there any other unix OS i can use (i supposed Aarch but not sure) to support the feature g_hid on c2
  • Is there any other boards/component/hat i can use with the c2 ?
  • Have you other boards model you could recommend that support this feature ? I do not require much CPU for my app. any ARM should do it easily. it's a console curses apps.
thanks a lot

User avatar
odroid
Site Admin
Posts: 32489
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 178 times
Been thanked: 345 times
Contact:

Re: C2 - HID Keyboard/ Device / Gadget for USB output on linux

Unread post by odroid » Wed Oct 16, 2019 9:22 am

We tested only g_ether, g_mass_storage and g_serial on Kernel 3.14 and 3.16.

I think you need to use an experimental Kernel 4.x ~ 5.x if you don't need the GPU/VPU acceleration.
https://magazine.odroid.com/article/hid ... odroid-c2/

br-devb-1
Posts: 11
Joined: Wed Oct 16, 2019 7:13 am
languages_spoken: english, french
ODROIDs: c2
Location: APAC
Has thanked: 0
Been thanked: 0
Contact:

Re: C2 - HID Keyboard/ Device / Gadget for USB output on linux

Unread post by br-devb-1 » Wed Oct 16, 2019 8:36 pm

Hi mate, thanks. I do not need GPU. i do understand that you are suggesting Arch at my know risk but are you sure it will fix the issue ? . What about questions 3&4 "other boards" or other "models" from odroid that can fix the stuff !. I personally do not want to run into experimental problems )... thanks br

User avatar
odroid
Site Admin
Posts: 32489
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 178 times
Been thanked: 345 times
Contact:

Re: C2 - HID Keyboard/ Device / Gadget for USB output on linux

Unread post by odroid » Thu Oct 17, 2019 10:58 am

ODROID-N2 Kernel 4.9 might support the HID gadget driver but we didn't try.
ODROID-XU4 has no OTG port.

If you don't mind, try an Armbian OS image on your C2 which supports Kernel 4.19.
https://www.armbian.com/odroid-c2/

br-devb-1
Posts: 11
Joined: Wed Oct 16, 2019 7:13 am
languages_spoken: english, french
ODROIDs: c2
Location: APAC
Has thanked: 0
Been thanked: 0
Contact:

Re: C2 - HID Keyboard/ Device / Gadget for USB output on linux

Unread post by br-devb-1 » Fri Oct 18, 2019 9:54 pm

hi mate, Thanks I did load armbian but sudo modeprob libcomposit is not sucess full. module libcomposite not found in /lib/modules/4.16.69-meson64. Pain is on the way. will upload a thread on armbian ! i need to fix this inconsistancy :D

br-devb-1
Posts: 11
Joined: Wed Oct 16, 2019 7:13 am
languages_spoken: english, french
ODROIDs: c2
Location: APAC
Has thanked: 0
Been thanked: 0
Contact:

Re: C2 - HID Keyboard/ Device / Gadget for USB output on linux

Unread post by br-devb-1 » Sat Oct 19, 2019 6:41 pm

Hi, I managed to recompile the kernel with Armbian and did verify the settings which seems to include HID. I am loading libcomposite and usb_f_hid and run that attached script without error. ls /sys/class/udc show an EMPTY directory !
I did connect with USB-A (one of the port) and the Micro USB too each time rebooting, running the script and connecting on a Mint host. No messages in dmesg (both server) . In other words i am stuck :o :o
I also try to generate some output (writing in hid.usb0) but the USB HID in keyboard port do not act to output characters.
From the www i found that usually people on rasberry experience the /sys/class/udc empty when they do not load dwc2.. not sure it make sense here ?
thanks for any tips.
Attachments
usb.sh
script
(1.21 KiB) Downloaded 18 times

br-devb-1
Posts: 11
Joined: Wed Oct 16, 2019 7:13 am
languages_spoken: english, french
ODROIDs: c2
Location: APAC
Has thanked: 0
Been thanked: 0
Contact:

Re: C2 - HID Keyboard/ Device / Gadget for USB output on linux

Unread post by br-devb-1 » Sun Oct 20, 2019 2:32 pm

Giving some more content on the ls /sys/class/udc show an EMPTY directory to get more help ?
Thank mates
root@odroidc2:/home/kco# zcat /proc/config.gz | grep -i dwc
# CONFIG_SATA_DWC is not set
CONFIG_DWMAC_DWC_QOS_ETH=m
CONFIG_DWC_XLGMAC=m
CONFIG_USB_DWC3=m
# CONFIG_USB_DWC3_HOST is not set
# CONFIG_USB_DWC3_GADGET is not set
CONFIG_USB_DWC3_DUAL_ROLE=y
CONFIG_USB_DWC3_OF_SIMPLE=m
CONFIG_USB_DWC2=y
# CONFIG_USB_DWC2_HOST is not set
# CONFIG_USB_DWC2_PERIPHERAL is not set
CONFIG_USB_DWC2_DUAL_ROLE=y
# CONFIG_USB_DWC2_DEBUG is not set
# CONFIG_USB_DWC2_TRACK_MISSED_SOFS is not set
root@odroidc2:/home/kco# uname -r
4.14.150-meson64

-----------------------------------------------------

dmesg | grep dwc2
[ 1.759729] dwc2 c9000000.usb: c9000000.usb supply vusb_d not found, using dummy regulator
[ 1.759771] dwc2 c9000000.usb: c9000000.usb supply vusb_a not found, using dummy regulator
[ 1.765281] dwc2: probe of c9000000.usb failed with error -22

[ 1.765628] dwc2 c9100000.usb: c9100000.usb supply vusb_d not found, using dummy regulator
[ 1.765673] dwc2 c9100000.usb: c9100000.usb supply vusb_a not found, using dummy regulator
[ 1.884845] dwc2 c9100000.usb: DWC OTG Controller
[ 1.884864] dwc2 c9100000.usb: new USB bus registered, assigned bus number 1
[ 1.884889] dwc2 c9100000.usb: irq 34, io mem 0xc9100000
-----------------------------------------------------------
# insmod g_hid.ko
insmod: ERROR: could not insert module g_hid.ko: No such device
root@odroidc2:/lib/modules/4.14.150-meson64/kernel/drivers/usb/gadget/legacy#

ashren0
Posts: 14
Joined: Sat Jul 22, 2017 6:54 pm
languages_spoken: english french
ODROIDs: c1+ / c2
Has thanked: 0
Been thanked: 0
Contact:

Re: C2 - HID Keyboard/ Device / Gadget for USB output on linux

Unread post by ashren0 » Tue Oct 22, 2019 5:37 am

Hi, i just sent you a PM.

as i said, i may be able to check out your setup in the weekends only.

But in addition to a kernel compilation (if you are under 3.19), did you try to hack up the DTS ?

br-devb-1
Posts: 11
Joined: Wed Oct 16, 2019 7:13 am
languages_spoken: english, french
ODROIDs: c2
Location: APAC
Has thanked: 0
Been thanked: 0
Contact:

Re: C2 - HID Keyboard/ Device / Gadget for USB output on linux

Unread post by br-devb-1 » Tue Oct 22, 2019 5:01 pm

Hi Ashren0,

Thanks mate,
Yes i did modify as you mentioned in thread the dr_mode by converting the current DTB to DTS, Set the dr_mode to dr_mode = "peripheral";
recompile the DTB and reboot.
Then i still have no output and the directory ls /sys/class/udc/ is STILL EMPTY but a grep on dmesg for dwc2 is better now.
I try to plug the USB before or after without change in the behaviour

[ 1.760113] dwc2 c9100000.usb: c9100000.usb supply vusb_d not found, using dummy regulator
[ 1.760176] dwc2 c9100000.usb: c9100000.usb supply vusb_a not found, using dummy regulator
[ 1.880757] dwc2 c9100000.usb: DWC OTG Controller

[ 1.880776] dwc2 c9100000.usb: new USB bus registered, assigned bus number 1
[ 1.880802] dwc2 c9100000.usb: irq 34, io mem 0xc9100000
[ 1.880996] usb usb1: Manufacturer: Linux 4.14.150-meson64 dwc2_hsotg
[ 2.276512] usb 1-1: new high-speed USB device number 2 using dwc2
[ 2.772482] usb 1-1.1: new full-speed USB device number 3 using dwc2

Thanks to follow up the topics.

ashren0
Posts: 14
Joined: Sat Jul 22, 2017 6:54 pm
languages_spoken: english french
ODROIDs: c1+ / c2
Has thanked: 0
Been thanked: 0
Contact:

Re: C2 - HID Keyboard/ Device / Gadget for USB output on linux

Unread post by ashren0 » Wed Oct 23, 2019 4:15 am

Did you try removing the power OTG jumper (you have then to power the C2 with the power port) ? because that vusb and regulator thing seems rather strange

br-devb-1
Posts: 11
Joined: Wed Oct 16, 2019 7:13 am
languages_spoken: english, french
ODROIDs: c2
Location: APAC
Has thanked: 0
Been thanked: 0
Contact:

Re: C2 - HID Keyboard/ Device / Gadget for USB output on linux

Unread post by br-devb-1 » Wed Oct 23, 2019 4:58 pm

Hi, thanks for your time again
  • the jumper J1 was set as I never removed it and always power the c2 with the DC jack.
  • I did remove the J1 and try to power the c2 via the micro USB with different trusted and efficient power supply for ARM - 5V 2A. the c2 Never boot while it should ? .
  • The c2 always and only boot with the DC Jack. Having the power supply with the micro USB port powered at the same time do not change the message [ dwc2 c9100000.usb: c9100000.usb supply vusb_a not found, using dummy regulator
Did i am doing wrong ? my c2 is one months old.

Regards

ashren0
Posts: 14
Joined: Sat Jul 22, 2017 6:54 pm
languages_spoken: english french
ODROIDs: c1+ / c2
Has thanked: 0
Been thanked: 0
Contact:

Re: C2 - HID Keyboard/ Device / Gadget for USB output on linux

Unread post by ashren0 » Thu Oct 24, 2019 2:35 am

From the wiki on the USB OTG jumper, it stipulates that when you remove it you disable powering the C2 via the usb port. Did you try powering it via the power connector while having the jumper off ? (i may not have understood your post correctly)

br-devb-1
Posts: 11
Joined: Wed Oct 16, 2019 7:13 am
languages_spoken: english, french
ODROIDs: c2
Location: APAC
Has thanked: 0
Been thanked: 0
Contact:

Re: C2 - HID Keyboard/ Device / Gadget for USB output on linux

Unread post by br-devb-1 » Thu Oct 24, 2019 7:35 am

hi thanks, rephrasing.

1) from the beginning the J1 was set and i was powering the c2 with the DC jack. c9000000.usb failed with error -22 disappeared with the "dr_mode=peripherical"
2) I power the c2 without jumper J1 using power from USB : not booting not powering no led. I did thought the expected results was it boot ! Checking the notice again your right ! errata
3) i power the c2 without jumper J1 using power from DC jack : booting, Same message dwc2 c9100000.usb: c9100000.usb supply vusb_a not found, using dummy regulator when i am connecting the micro usb or not or either when i am connecting the USB-A to another device.

After rechecking the notice, my understanding is that Power should be DC jack and Jumper J1 removed for OTG data transfert. Hence i have this message and ls /sys/class/udc empty.

regards

ashren0
Posts: 14
Joined: Sat Jul 22, 2017 6:54 pm
languages_spoken: english french
ODROIDs: c1+ / c2
Has thanked: 0
Been thanked: 0
Contact:

Re: C2 - HID Keyboard/ Device / Gadget for USB output on linux

Unread post by ashren0 » Sat Oct 26, 2019 4:35 pm

Got my device now, dumping my info

zcat /proc/config.gz | grep -i dwc

Code: Select all

# CONFIG_SCSI_UFS_DWC_TC_PCI is not set
# CONFIG_SCSI_UFS_DWC_TC_PLATFORM is not set
# CONFIG_SATA_DWC is not set
# CONFIG_DWMAC_DWC_QOS_ETH is not set
# CONFIG_DWC_XLGMAC is not set
CONFIG_USB_DWC3=y
CONFIG_USB_DWC3_ULPI=y
# CONFIG_USB_DWC3_HOST is not set
# CONFIG_USB_DWC3_GADGET is not set
CONFIG_USB_DWC3_DUAL_ROLE=y
CONFIG_USB_DWC3_PCI=y
CONFIG_USB_DWC3_OF_SIMPLE=y
CONFIG_USB_DWC2=y
# CONFIG_USB_DWC2_HOST is not set
# CONFIG_USB_DWC2_PERIPHERAL is not set
CONFIG_USB_DWC2_DUAL_ROLE=y
CONFIG_USB_DWC2_PCI=y
# CONFIG_USB_DWC2_DEBUG is not set
# CONFIG_USB_DWC2_TRACK_MISSED_SOFS is not set
dmesg | grep dwc2

Code: Select all

[    1.946388] dwc2 c9000000.usb: c9000000.usb supply vusb_d not found, using dummy regulator
[    1.949054] dwc2 c9000000.usb: c9000000.usb supply vusb_a not found, using dummy regulator
[    1.986641] dwc2 c9000000.usb: dwc2_check_param_tx_fifo_sizes: Invalid parameter g-tx-fifo-size, setting to default average
[    1.986645] dwc2 c9000000.usb: dwc2_check_param_tx_fifo_sizes: Invalid parameter g_tx_fifo_size[1]=0
[    1.986648] dwc2 c9000000.usb: dwc2_check_param_tx_fifo_sizes: Invalid parameter g_tx_fifo_size[2]=0
[    1.986651] dwc2 c9000000.usb: dwc2_check_param_tx_fifo_sizes: Invalid parameter g_tx_fifo_size[3]=0
[    1.986654] dwc2 c9000000.usb: dwc2_check_param_tx_fifo_sizes: Invalid parameter g_tx_fifo_size[4]=0
[    1.986657] dwc2 c9000000.usb: dwc2_check_param_tx_fifo_sizes: Invalid parameter g_tx_fifo_size[5]=0
[    1.986671] dwc2 c9000000.usb: EPs: 7, dedicated fifos, 1984 entries in SPRAM
[    2.053040] dwc2 c9100000.usb: c9100000.usb supply vusb_d not found, using dummy regulator
[    2.059624] dwc2 c9100000.usb: c9100000.usb supply vusb_a not found, using dummy regulator
[    2.205766] dwc2 c9100000.usb: DWC OTG Controller
[    2.205911] dwc2 c9100000.usb: new USB bus registered, assigned bus number 1
[    2.211830] dwc2 c9100000.usb: irq 33, io mem 0xc9100000
[    2.235620] usb usb1: Manufacturer: Linux 4.15.7-1-ARCH dwc2_hsotg
[    2.695667] usb 1-1: new high-speed USB device number 2 using dwc2
uname -r

Code: Select all

4.15.7-1-ARCH
by the way, i see that you are using the ubuntu 18.04 image but what kind of modifications did you try exactly, so that i can replicate on my end ?

br-devb-1
Posts: 11
Joined: Wed Oct 16, 2019 7:13 am
languages_spoken: english, french
ODROIDs: c2
Location: APAC
Has thanked: 0
Been thanked: 0
Contact:

Re: C2 - HID Keyboard/ Device / Gadget for USB output on linux

Unread post by br-devb-1 » Sun Oct 27, 2019 3:15 pm

Hi, thanks a lot mate. I did recompile
  • modify the DTB by doing via DTB-> DTS -> TDB. and changed dr_mode
sudo dtc -I dtb -O dts -o dts meson-gxbb-odroidc2.dts meson-gxbb-odroidc2.dtb
sudo dtc -I dts -O dtb -o meson-gxbb-odroidc2.dtb meson-gxbb-odroidc2.dts
and reboot.
Then the error -22 disapeared.

In other words i likely try follow the steps provided trying to understand step/step. Please find attached the DTS modified. From your configuration i did not see any differences in the config.gz at least

Thanks for your help.

droidc2:~$ uname -r
4.14.150-meson64
droidc2:~$ uname -i
aarch64
Attachments
meson-gxbb-odroidc2-dts.txt
DTS file use
(29.56 KiB) Downloaded 10 times

br-devb-1
Posts: 11
Joined: Wed Oct 16, 2019 7:13 am
languages_spoken: english, french
ODROIDs: c2
Location: APAC
Has thanked: 0
Been thanked: 0
Contact:

Re: C2 - HID Keyboard/ Device / Gadget for USB output on linux

Unread post by br-devb-1 » Tue Oct 29, 2019 5:18 pm

Hi ashren0, I did try with 18.04 Bionic and Xenial as i mentioned and also Debian 10 Buster. All compile smoothly with the ARMbian sh ./compile.sh script but all come to the same ls /sys/class/udc empty having changing the DTB for 0x9000000 dr_mode=peripherical !.
regards

ashren0
Posts: 14
Joined: Sat Jul 22, 2017 6:54 pm
languages_spoken: english french
ODROIDs: c1+ / c2
Has thanked: 0
Been thanked: 0
Contact:

Re: C2 - HID Keyboard/ Device / Gadget for USB output on linux

Unread post by ashren0 » Wed Nov 06, 2019 4:59 am

I'm trying to compile a kernel to test it this weekend but a quick question :

When you had the kernel makemenu, did you enable "HID functions" and "FunctionFS" ?

Device Drivers > USB support > USB Gadget Support > HID function
Device Drivers > USB support > USB Gadget Support > Function filesystem

I'll test it this weekend

br-devb-1
Posts: 11
Joined: Wed Oct 16, 2019 7:13 am
languages_spoken: english, french
ODROIDs: c2
Location: APAC
Has thanked: 0
Been thanked: 0
Contact:

Re: C2 - HID Keyboard/ Device / Gadget for USB output on linux

Unread post by br-devb-1 » Thu Nov 07, 2019 7:02 pm

Hey mate, Merci beaucoup
Yes these 2 options are activated per default on the Bionic release. I just did rechecked (see capture) now.
How ever i notice there is an option Filesystem (FS) (third lines) and Function Filesystem (just the last 2 lines on the screen shot) and the last one ( :!: ) is not ticked and is (modularised features ?? not sure what it means :?: )
I thank you very much for the effort.
Best Regards
Attachments
Screenshot from 2019-11-07 20-52-02.png
Screenshot from 2019-11-07 20-52-02.png (91.95 KiB) Viewed 220 times

ashren0
Posts: 14
Joined: Sat Jul 22, 2017 6:54 pm
languages_spoken: english french
ODROIDs: c1+ / c2
Has thanked: 0
Been thanked: 0
Contact:

Re: C2 - HID Keyboard/ Device / Gadget for USB output on linux

Unread post by ashren0 » Wed Nov 13, 2019 4:19 am

I'm having some difficulties actually installing the kernel built with the link you provided.

1) Installing the latest ubuntu 18.04.3 img to my emmc
2) In a ubuntu 18.04.3 VM running the compile script (and selecting the appropriate modules)
-> it outputs a few .deb files
3) copy the deb files to the device and run dpkg -i on them.
4) copy the meson*.dtb and Image (vmlinuz.. since it's FAT32 on the destination) from /boot to /media/boot
and the device is stuck until i put the files back from the 3.x kernel to the boot partition.

What were the steps you undertook exactly ?

Post Reply

Return to “Hardware and peripherals”

Who is online

Users browsing this forum: br-devb-1 and 2 guests