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

Post Reply
br-devb-1
Posts: 17
Joined: Wed Oct 16, 2019 7:13 am
languages_spoken: english, french
ODROIDs: c2
Location: APAC
Has thanked: 0
Been thanked: 1 time
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: 32704
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 213 times
Been thanked: 367 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: 17
Joined: Wed Oct 16, 2019 7:13 am
languages_spoken: english, french
ODROIDs: c2
Location: APAC
Has thanked: 0
Been thanked: 1 time
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: 32704
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 213 times
Been thanked: 367 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: 17
Joined: Wed Oct 16, 2019 7:13 am
languages_spoken: english, french
ODROIDs: c2
Location: APAC
Has thanked: 0
Been thanked: 1 time
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: 17
Joined: Wed Oct 16, 2019 7:13 am
languages_spoken: english, french
ODROIDs: c2
Location: APAC
Has thanked: 0
Been thanked: 1 time
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 26 times

br-devb-1
Posts: 17
Joined: Wed Oct 16, 2019 7:13 am
languages_spoken: english, french
ODROIDs: c2
Location: APAC
Has thanked: 0
Been thanked: 1 time
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: 19
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: 17
Joined: Wed Oct 16, 2019 7:13 am
languages_spoken: english, french
ODROIDs: c2
Location: APAC
Has thanked: 0
Been thanked: 1 time
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: 19
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: 17
Joined: Wed Oct 16, 2019 7:13 am
languages_spoken: english, french
ODROIDs: c2
Location: APAC
Has thanked: 0
Been thanked: 1 time
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: 19
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: 17
Joined: Wed Oct 16, 2019 7:13 am
languages_spoken: english, french
ODROIDs: c2
Location: APAC
Has thanked: 0
Been thanked: 1 time
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: 19
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: 17
Joined: Wed Oct 16, 2019 7:13 am
languages_spoken: english, french
ODROIDs: c2
Location: APAC
Has thanked: 0
Been thanked: 1 time
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 16 times

br-devb-1
Posts: 17
Joined: Wed Oct 16, 2019 7:13 am
languages_spoken: english, french
ODROIDs: c2
Location: APAC
Has thanked: 0
Been thanked: 1 time
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: 19
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: 17
Joined: Wed Oct 16, 2019 7:13 am
languages_spoken: english, french
ODROIDs: c2
Location: APAC
Has thanked: 0
Been thanked: 1 time
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 1198 times

ashren0
Posts: 19
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 ?

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

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

Unread post by br-devb-1 » Wed Nov 13, 2019 5:22 pm

Hi Ashren0,

I did compile in a VM virtual box NAME="Ubuntu" VERSION="18.04.3 LTS (Bionic Beaver)". Execute ./compile.sh with option Bionic, Show module and IMG then extract the .img (been created in /build/output/images/Armbian_5.98_Odroidc2_Ubuntu_bionic_default_4.14.150_desktop.img ) and install it with balenaEtcher-1.5.58 on a SD CARD 32G. Easy. Nothing particular

Regards

ashren0
Posts: 19
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 Nov 14, 2019 3:22 am

Managed to compile and run the image but i'm having the same issue you had.

But something ticked me when i typed

Code: Select all

dmesg | grep usb
this line in particular

Code: Select all

[    2.775186] dwc2 c9000000.usb: Configuration mismatch. dr_mode forced to host
I stumbled upon this kernel patch for DWC3 (even if we use DWC2 here)

https://lore.kernel.org/patchwork/patch/714651/

And the table lists that when kernel config is set to host, any dr_mode is ignored and the result is host.

I'll try recompiling and removing that "y" in the makemenu and i'll get back to you.

ashren0
Posts: 19
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 Nov 14, 2019 4:18 am

Made it work by actually selecting "*" instead of "M" on USB related stuff and then setting DWC2 mode to dual role in kernel conf

[*] Device Drivers > USB support > USB Gadget Support > USB Gadget functions configurable through configfs
[*] Device Drivers > USB support > USB Gadget Support > USB Gadget functions configurable through configfs > Function filesystem
[*] Device Drivers > USB support > USB Gadget Support > USB Gadget functions configurable through configfs > HID function

then

Device Drivers > USB support > USB Gadget Support > DWC2 Mode Selection > Dual Role mode

now you only have to edit the dtb to change host to peripheral and you are good to go.

Hope it helps.

EDIT: modifying the dtb file may be pretty barbaric so if anybody knows how that "dual role" thing works that could remove a step but in the meantime ...

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

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

Unread post by br-devb-1 » Fri Nov 15, 2019 2:08 pm

Hi Ahsren0 thanks sure it's helps. thanks a lot.
root@odroidc2:/sys/kernel/config/usb_gadget/kcd_key# ls /sys/class/udc
c9000000.usb
root@odroidc2:/sys/kernel/config/usb_gadget/kcd_key# ls /sys/class/udc > UDC
ls: write error: Device or resource busy

the kernel execute an error on the ls /sys/class/udc > UDC. Attaching the file. have you the same or did you use the python script ? may be my USB.sh script is bad!

regards
Attachments
dmesg.txt
(4.85 KiB) Downloaded 11 times

ashren0
Posts: 19
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 » Fri Nov 15, 2019 2:55 pm

I used my python script (here's a pastebin if you need a clean indented version https://pastebin.com/V6W5e8Da) if you want to try if it works.

From memory :
- load kernel modules (libcomposite, usb_f_hid)
- define your device in the FunctionFS filetree (/sys/kernel/config/usb_gadget/your_device_name
- then bind to UDC by writing it's reference in the UDC file.

The script should be pretty straightforward to understand, the most difficult part is actually getting the device definition right.

The keyboard definition in my script should fit a general purpose keyboard, but if need be the links on the article are what i used to actually make it.

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

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

Unread post by br-devb-1 » Fri Nov 15, 2019 5:32 pm

Hi Ashren0,

I got the same error at the first run (sudo python3 odroit_c2_hid_test_script.py keyboard) but after the second run of the python script it is running and the dmesg error dissipated.
[ 1310.586685] dwc2 c9000000.usb: new device is high-speed
[ 1310.666694] dwc2 c9000000.usb: new device is high-speed
[ 1310.731809] dwc2 c9000000.usb: new address 13
[ 1310.752712] configfs-gadget gadget: high-speed config #1: c
[ 1342.073569] dwc2 c9000000.usb: new device is high-speed
[ 1342.153608] dwc2 c9000000.usb: new device is high-speed
[ 1342.218672] dwc2 c9000000.usb: new address 14
[ 1342.239808] configfs-gadget gadget: high-speed config #1: c
[ 1388.325979] dwc2 c9000000.usb: bound driver configfs-gadget
[ 1388.659805] dwc2 c9000000.usb: new device is high-speed
[ 1388.739846] dwc2 c9000000.usb: new device is high-speed
[ 1388.804868] dwc2 c9000000.usb: new address 15
[ 1388.825955] configfs-gadget gadget: high-speed config #1: c
[ 1435.505883] dwc2 c9000000.usb: new device is high-speed
[ 1435.585974] dwc2 c9000000.usb: new device is high-speed
[ 1435.655022] dwc2 c9000000.usb: new address 16
Hence I can confirm you are sorting out this one again!
I did connect a Mint on the USB micro with USB-A output to test an output. It seems a bit erratic (but i did receive one character and saw the device with dmesg on the tests machine) .
[29814.999923] usb 2-3.4: USB disconnect, device number 15
[29826.486189] usb 2-3.4: new high-speed USB device number 16 using xhci_hcd
[29826.590654] usb 2-3.4: New USB device found, idVendor=16c0, idProduct=0488
[29826.590658] usb 2-3.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[29826.590661] usb 2-3.4: Product: ODROID C2 KBD HID
[29826.590663] usb 2-3.4: Manufacturer: author
[29826.590665] usb 2-3.4: SerialNumber: fedcba9876543210
[29826.591795] input: author ODROID C2 KBD HID as /devices/pci0000:00/0000:00:14.0/usb2/2-3/2-3.4/2-3.4:1.0/0003:16C0:0488.000B/input/input51
[29826.650812] hid-generic 0003:16C0:0488.000B: input,hidraw3: USB HID v1.01 Keyboard [author ODROID C2 KBD HID] on usb-0000:00:14.0-3.4/input0
[29884.375992] usb 2-3.4: USB disconnect, device number 16
I need to proceed to more tests and let you know...
thanks a lot!
Cheers

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

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

Unread post by br-devb-1 » Sun Nov 17, 2019 7:30 pm

heya, it's working! i did observe that a flush must be performed after transmission or to specified a 0 size buffer. without you can observe strange issue like repeating chars... Thanks playing around again. 8-)
These users thanked the author br-devb-1 for the post:
odroid (Mon Nov 18, 2019 11:13 am)

ashren0
Posts: 19
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 Nov 19, 2019 2:04 am

Glad that it solved your problem.

That flushing thing might be a programming/scripting quirk ? i know that in python for example you have to explicitly set buffering to 0 when opening file descriptors.

That being said, using armbian and their compile script is a little easier than the archlinux setup i had going, so it's great.

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

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

Unread post by br-devb-1 » Tue Nov 19, 2019 8:39 pm

hi Ashren0 thanks a lot. Try some char output to confirm! i am supposing the option is to :
with open('/dev/hidg0', 'rb+',0)
fd.write(report.encode())
fd.flush()
the
Still doing some test but i am thinking it's reliable!
I agree on Armbian, it 's pretty efficient including some compilation tests on other fruits boards( orange, banana).
Keep in touch +1
i am thinking to close the thread soon! thanks.

ashren0
Posts: 19
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 20, 2019 2:09 am

I'd explicitly use the named parameter "buffering" but that should do it.

And in theory with the buffering set to 0 you don't need to flush.

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

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

Unread post by br-devb-1 » Thu Nov 21, 2019 8:09 pm

100% but some sample on the WEB are not very accurate on the flush! As we are not engineer on HID but consumers :idea: i do think it's a tips to outline. i really thank you to followed the topic! merci l'ami

Post Reply

Return to “Hardware and peripherals”

Who is online

Users browsing this forum: No registered users and 0 guests