Mini2440 USB gadget_hid

bluscape
I'm trying to enumerate my Mini as a HID USB device.
In the kernel I've enabled all possible HID related drivers:

Device Drivers->HID Devices->/dev/hidraw
Device Drivers->HID Devices->full HID support
Device Drivers->HID Devices->/dev/hiddev
Device Drivers->USB Support->/dev/hidraw->USB Gadget Support->USB Gadget
Driver->HID Gadget

But there is NO HID files in my /dev folder.
I'm looking to read() and write() /dev/hidgX but it does not exist.

What should I do?

I'm using the hid_gadget_test example to start with but my HID interface is
not available.

Juergen Beisert
You need CONFIG_USB_GADGET, CONFIG_USB_S3C2410, CONFIG_USB_G_HID. I run my
Mini2440 as a serial and printer gadget and it works without any problem.

bluscape
Sorry for being naive, but where/how/when do I do that?

I did try google but cant find the answer.

bluscape
Ok, I now understand which files to edit but still have a few questions:

1.) Do I edit Kconfig in build-target?
2.) What do I need to edit. Do you have an example please?

bluscape
A link for future reference:

https://www.ridgerun.com/developer/wiki/index.php/How_to_configure_DM365...

I don't if this will solve my problem but it has good info.

bluscape
I only saw this now. All the time assumed the kernel compilation was fine.

make[1]: Entering directory
`/home/jdoe/local/OSELAS.BSP-Pengutronix-Mini2440-2011.05.0/platform-mini2440/bu
ild-target/linux-2.6.38'
  CHK     include/linux/version.h
  CHK     include/generated/utsrelease.h
make[2]: `include/generated/mach-types.h' is up to date.
  CALL    scripts/checksyscalls.sh
  CHK     include/generated/compile.h
  CC      drivers/usb/musb/musb_core.o
In file included from drivers/usb/musb/musb_core.c:102:0:
drivers/usb/musb/musb_core.h:103:2: error: #error bogus Kconfig output ...
select CONFIG_USB_GADGET_MUSB_HDRC
make[3]: *** [drivers/usb/musb/musb_core.o] Error 1
make[2]: *** [drivers/usb/musb] Error 2
make[1]: *** [drivers] Error 2
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory
`/home/jdoe/local/OSELAS.BSP-Pengutronix-Mini2440-2011.05.0/platform-mini2440/bu
ild-target/linux-2.6.38'
make: ***
[/home/jdoe/local/OSELAS.BSP-Pengutronix-Mini2440-2011.05.0/platform-mini2440/st
ate/kernel.compile]
Error 2

Juergen Beisert
Just run "make menuconfig" in the kernel source tree and hit the enter '/'
key and then enter the symbol names without the leading CONFIG_. Kconfig
will then show you, where in the menu these symbols can be changed. Change
to this menu and enable them. Do it for all symbols I listed in my answer. 
Then re-build your kernel

bluscape
I go to:

/home/jdoe/local/OSELAS.BSP-Pengutronix-Mini2440-2011.05.0/platform-mini2440/bui
ld-target/linux-2.6.38

type "make menuconfig" and then hit enter but I only get the kernel config
menu?

bluscape
Hi Juergen, I need your help on this please.
I cant enter menuconfig.

Juergen Beisert
Sorry, my fault. "make menuconfig" only work with the plain kernel. But you
are using PTXdist. In this case just run "ptxdist kernelconfig" in the
project directory and PTXdist will present you the kernel's configuration.

bluscape
Then I'm back to the original problem.

In the kernel I've enabled all possible HID related drivers:

Device Drivers->HID Devices->/dev/hidraw
Device Drivers->HID Devices->full HID support
Device Drivers->HID Devices->/dev/hiddev
Device Drivers->USB Support->/dev/hidraw->USB Gadget Support->USB Gadget
Driver->HID Gadget

But there is NO HID files in my /dev folder.
I'm looking to read() and write() /dev/hidgX but it does not exist.

What should I do?

Juergen Beisert
You mostly enabled host side HID drivers. But you need the device (e.g.
gadget) side. Once again: Did you enable CONFIG_USB_GADGET,
CONFIG_USB_S3C2410, CONFIG_USB_G_HID in your kernel?

BTW: OSELAS.BSP-Pengutronix-Mini2440-2011.05.0 and linux-2.6.38 is very old
;) 2012.02.0 with kernel 3.2.7 is available since february. And in the git
repository you can find kernel 3.3.3.

bluscape
It seems like I should enable the Inventra High Speed Dual Role Controller

USB Support->Inventra High Speed Dual Role Controller->Driver Mode->Both
host and peripheral

but whenever I enable this driver I get the following error:

#error bogus Kconfig output ... select CONFIG_USB_GADGET_MUSB_HDRC

bluscape
Hi Juergen,

In the mini2440 defconfig file I have the following:

CONFIG_USB_GADGET=y
CONFIG_USB_GADGET_S3C2410=y

I do not have an option for CONFIG_USB_S3C2410 and CONFIG_USB_G_HID.

I'm going to try and use/install the latest BSP but can you refresh my
memory please:

1.) Can I install two different distributions on the same PC?
2.) How do I switch between them?

Thank you

bluscape
Ok, my g_serial is working fine so the g_hid must work too!

After TONS of reading and searching I found that I must first register the
device from code using "platform_device_register", only then I will be able
to probe g_hid.

But problems still remain. To use "platform_device_register" I need to
include:

#include <linux/platform_device.h>
#include <linux/usb/g_hid.h>

But my compiler gives me an error:

fatal error: linux/usb/platform_device.h: No such file or directory
fatal error: linux/usb/g_hid.h: No such file or directory

These files exist but it seems like they are not available in the user
space.

What should I do to get access to these files?

Juergen Beisert
No, these header files are reserved for the kernel. Why do you need
'platform_device.h' in user-land????? Register your devices in the platform
(e.g. 'arch/arm/mach-s3c2440/mach-mini2440.c').

Juergen Beisert
> 1.) Can I install two different distributions on the same PC?

Yes. All PTXdist revisions can live side by side
And as PTXdist is project centric, also the projects can live side by side

> 2.) How do I switch between them?

Create in each project a symbolic link to the correct ptxdist executable.
I'm always naming it 'p'. So, I can switch between the project directories
and when I'm using 'p' instead of "ptxdist" command I'm always using the
matching PTXdist version.

bluscape
Awesome! That makes sense to register the device in mach-mini2440.c!

What do you mean by "link to the correct ptxdist executable"?
Which executable?

Do you have a link example please. 

I feel so stupid when I work with linux because it is SO different to what
I'm used to!!! (To comfort me I always go and read the first page on your
mini2440 quick start guide "Don't Panic")

bluscape
Its working!!! 

Thanks a million Juergen

Juergen Beisert
> What do you mean by "link to the correct ptxdist executable"?

my_1st_ptxdist_project$ ln -s /usr/local/bin/ptxdist-2012.04.0 p
my_1st_ptxdist_project$ ./p menuconfig

my_2nd_ptxdist_project$ ln -s /usr/local/bin/ptxdist-2011.11.0 p
my_2nd_ptxdist_project$ ./p menuconfig

With this trick you always get the correct PTXdist revision for your
project. As I'm working with many projects and PTXdist revisions at the
same time you can imagine it can safe life.