Hi All, Just joined the mailing list (as I will no doubt be calling on the community's expertise in the near future). I am looking to get my hands dirty with some kernel development - mainly because I want to improve my understanding of the kernel and I honestly believe that getting involved will be a worthwhile investment of my time and will also be highly educational. Over the next coming months, I shall be undertaking a more structured approach to studying and gaining familiarity with the kernel source. I will also be looking to get involved in some simple patch development (e.g., simple janitorial type jobs), such that I can gain some experience of the patch development and submission process. I am aware that kernelnewbies.org typically lists some of these types of job and that the kernel project has plenty of documentation and tips from veteran contributors concerning these topics. Areas of particular interest to me include: - Industrial I/O - Device Driver Development - 'Real-Time' Systems - Time Synchronisation - Networking & Communication Protocols If anyone knows of any newbie projects in these specific areas, then it would be great to hear from you. Lastly, the Kernel Newbies website seems to be unavailable at the moment (Google last cached the site on 31 Jan 2020 01:49:1 UTC). Any idea when it will be available again? Many Thanks, Jack W. _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
On 1/31/20, Jack Winch <sunt.un.morcov@gmail.com> wrote: > Hi All, > > < snipped down to part that I can respond to.. > > > Lastly, the Kernel Newbies website seems to be unavailable at the > moment (Google last cached the site on 31 Jan 2020 01:49:1 UTC). Any > idea when it will be available again? Started to respond a few minutes ago then got sidetracked. STARTED to say, "Good news, looks like it's working!" Except that now it's NOT working, on my end anyway. Just now received the "502 Bad Gateway" error/advisement message when I tried to "ALT+left arrow" to go back to a previous page (which was the homepage). Prior to that, I viewed a couple webpages with no problems. The word "sporadic" comes to mind. :) Good luck with your own adventure! Cindy :) -- * runs with.. Linux From Scratch source files downloading in the background LITERALLY right now. That's quite the trick on dialup. #ThankYou, Kernel Newbies, for introducing me to that very cool project! :) * _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
[-- Attachment #1.1: Type: text/plain, Size: 1810 bytes --] On Fri, Jan 31, 2020 at 11:14 PM Jack Winch <sunt.un.morcov@gmail.com> wrote: > Hi All, > > Just joined the mailing list (as I will no doubt be calling on the > community's expertise in the near future). I am looking to get my > hands dirty with some kernel development - mainly because I want to > improve my understanding of the kernel and I honestly believe that > getting involved will be a worthwhile investment of my time and will > also be highly educational. > > Over the next coming months, I shall be undertaking a more structured > approach to studying and gaining familiarity with the kernel source. > I will also be looking to get involved in some simple patch > development (e.g., simple janitorial type jobs), such that I can gain > some experience of the patch development and submission process. I am > aware that kernelnewbies.org typically lists some of these types of > job and that the kernel project has plenty of documentation and tips > from veteran contributors concerning these topics. > > Areas of particular interest to me include: > - Industrial I/O > - Device Driver Development > - 'Real-Time' Systems > - Time Synchronisation > - Networking & Communication Protocols > > If anyone knows of any newbie projects in these specific areas, then > it would be great to hear from you. > > Lastly, the Kernel Newbies website seems to be unavailable at the > moment (Google last cached the site on 31 Jan 2020 01:49:1 UTC). Any > idea when it will be available again? > > Rik maintains the website, I think. ccing him for an answer. Many Thanks, > Jack W. > > _______________________________________________ > Kernelnewbies mailing list > Kernelnewbies@kernelnewbies.org > https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies > -- Thank you Warm Regards Anuz [-- Attachment #1.2: Type: text/html, Size: 2772 bytes --] [-- Attachment #2: Type: text/plain, Size: 170 bytes --] _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
[-- Attachment #1.1: Type: text/plain, Size: 534 bytes --] On Sun, 2020-02-02 at 23:26 +0000, Anuz Pratap Singh Tomar wrote: > > > > > > > Lastly, the Kernel Newbies website seems to be unavailable at the > > moment (Google last cached the site on 31 Jan 2020 01:49:1 UTC). > > Any > > idea when it will be available again? > > > > Rik maintains the website, I think. > ccing him for an answer. The web site seems to be up now, without me having made any changes at all. Were you getting timeouts (routing issues?) or web server errors? -- All Rights Reversed. [-- Attachment #1.2: This is a digitally signed message part --] [-- Type: application/pgp-signature, Size: 488 bytes --] [-- Attachment #2: Type: text/plain, Size: 170 bytes --] _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
[-- Attachment #1: Type: text/plain, Size: 252 bytes --] Hi, I'm trying to write a Hid driver for MCP2210. But the USB Hid specification is quite complicated. I would like to know how to send and receive data to the device. Any links to a good tutorial ? This is my current driver is attached. Thanks Lucas [-- Attachment #2: mcp2210.c --] [-- Type: text/x-csrc, Size: 1058 bytes --] #define DEBUG #include <linux/module.h> #include <linux/hid.h> #include <linux/usb.h> static int mcp2210_probe(struct hid_device *hdev, const struct hid_device_id *id) { struct usb_interface *intf = to_usb_interface(hdev->dev.parent); int ret = 0; hid_dbg(hdev, "%s\n", __FUNCTION__); ret = hid_parse(hdev); if (ret) { hid_err(hdev, "parse failed\n"); return ret; } else { hid_dbg(hdev, "parse success\n"); } ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); if (ret) { hid_err(hdev, "hw start failed\n"); return ret; } else { hid_dbg(hdev, "start success\n"); } return 0; } static const struct hid_device_id mcp2210_table[] = { { HID_USB_DEVICE(0x04d8, 0x00de) }, {} }; MODULE_DEVICE_TABLE(hid, mcp2210_table); static struct hid_driver mcp2210_driver = { .name = "MCP2210 USB SPI Driver", .probe = mcp2210_probe, .id_table = mcp2210_table, }; module_hid_driver(mcp2210_driver); MODULE_AUTHOR("Lucas Tanure <tanure@linux.com>"); MODULE_DESCRIPTION("Core driver for MCP2210 USB SPI adapter"); MODULE_LICENSE("GPL v2"); [-- Attachment #3: Type: text/plain, Size: 170 bytes --] _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
[-- Attachment #1.1: Type: text/plain, Size: 1536 bytes --] > > The web site seems to be up now, without me having > made any changes at all. Were you getting timeouts > (routing issues?) or web server errors? > Using the Chrome browser, I was getting various errors relating to DNS. But, the problem appears to be intermittent and is happening on my work device in the office and on my personal computer at home. This evening it appears to be working from home, but not the office. If I get the issue again, I shall undertake some further investigation. At home, I make use of the public Google DNS servers and the DNS server at work is setup to forward to these servers also. When I was having issues on my personal computer (i.e., when I originally posted to the mailing list), clearing the DNS cache of both my computer and the modem-router had no effect, leaving me unable to access the website. However, today, it appears I can access the site from home. ~ Jack On Mon, Feb 3, 2020 at 12:36 AM Rik van Riel <riel@surriel.com> wrote: > On Sun, 2020-02-02 at 23:26 +0000, Anuz Pratap Singh Tomar wrote: > > > > > > > > > > > > Lastly, the Kernel Newbies website seems to be unavailable at the > > > moment (Google last cached the site on 31 Jan 2020 01:49:1 UTC). > > > Any > > > idea when it will be available again? > > > > > > > Rik maintains the website, I think. > > ccing him for an answer. > > The web site seems to be up now, without me having > made any changes at all. Were you getting timeouts > (routing issues?) or web server errors? > > -- > All Rights Reversed. > [-- Attachment #1.2: Type: text/html, Size: 2431 bytes --] [-- Attachment #2: Type: text/plain, Size: 170 bytes --] _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
[-- Attachment #1.1: Type: text/plain, Size: 1720 bytes --] On Mon, 2020-02-03 at 19:49 +0000, Jack Winch wrote: > > The web site seems to be up now, without me having > > made any changes at all. Were you getting timeouts > > (routing issues?) or web server errors? > > > > Using the Chrome browser, I was getting various errors relating to > DNS. But, the problem appears to be intermittent and is happening > on my work device in the office and on my personal computer at home. > This evening it appears to be working from home, but not the office. > If I get the issue again, I shall undertake some further > investigation. At home, I make use of the public Google DNS servers > and the DNS server at work is setup to forward to these servers > also. When I was having issues on my personal computer (i.e., when I > originally posted to the mailing list), clearing the DNS cache of > both my computer and the modem-router had no effect, leaving me > unable to access the website. However, today, it appears I can > access the site from home. It could well be a time of day thing. When I looked earlier, some spammers were trying to create multiple wiki accounts a second, slowing the site to a crawl due to the way MoinMoin stores user data. The accounts themselves are useless without the ability to make any edits, but I assume they must be making a little bit of money selling (useless) account credentials... Over 50,000 accounts created just in the past week, on just one of the wikis. With MoinMoin 1.9 essentially dead, and the next development version quite moribund, I think it is time for me to move to another wiki, where the worst case for lookups is O(log(N)), not O(N). Maybe Dokuwiki. -- All Rights Reversed. [-- Attachment #1.2: This is a digitally signed message part --] [-- Type: application/pgp-signature, Size: 488 bytes --] [-- Attachment #2: Type: text/plain, Size: 170 bytes --] _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
On Mon, Feb 03, 2020 at 04:32:46PM +0000, Lucas Tanure wrote: > Hi, > > I'm trying to write a Hid driver for MCP2210. What type of device is this? > But the USB Hid specification is quite complicated. The kernel should do it "all for you" already, why do you need to create a custom HID driver for this device? What type of HID reports does the device export and why doesn't the existing kernel drivers work for you? > I would like to know how to send and receive data to the device. Any > links to a good tutorial ? HID has the idea of "reports" and data comes in and out in that specific format, all depending on how the device describes itself. There's isn't usually a normal "send/receive" type of thing, but it all depends on the type of device. > This is my current driver is attached. > > Thanks > Lucas > #define DEBUG > #include <linux/module.h> > #include <linux/hid.h> > #include <linux/usb.h> > > static int mcp2210_probe(struct hid_device *hdev, > const struct hid_device_id *id) > { > struct usb_interface *intf = to_usb_interface(hdev->dev.parent); > int ret = 0; > > hid_dbg(hdev, "%s\n", __FUNCTION__); > > ret = hid_parse(hdev); > if (ret) { > hid_err(hdev, "parse failed\n"); > return ret; > } else { > hid_dbg(hdev, "parse success\n"); > } > > ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); > if (ret) { > hid_err(hdev, "hw start failed\n"); > return ret; > } else { > hid_dbg(hdev, "start success\n"); > } Does this all work? What fails? thanks, greg k-h _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
On Mon, Feb 3, 2020 at 8:11 PM Greg KH <greg@kroah.com> wrote: > > On Mon, Feb 03, 2020 at 04:32:46PM +0000, Lucas Tanure wrote: > > Hi, > > > > I'm trying to write a Hid driver for MCP2210. > > What type of device is this? It is a USB <-> SPI converter. > > > But the USB Hid specification is quite complicated. > > The kernel should do it "all for you" already, why do you need to create > a custom HID driver for this device? I need a driver that register an SPI controller with in the kernel. So this SPI controller would receive regmap reads/writes and translate to USB HID packages and send to the SPI device attached in the other side of the cable. > > What type of HID reports does the device export and why doesn't the > existing kernel drivers work for you? I don't know enough yet to answer about HID Reports, but at end of this e-mail I attached the lsub -v of the device. I want to use this device in kernel space, registering a SPI controller. And with this SPI controller another SPI slave device will be registered. So, for the SPI slave device it will be like there is no USB in between itself and the kernel. > > > I would like to know how to send and receive data to the device. Any > > links to a good tutorial ? > > HID has the idea of "reports" and data comes in and out in that specific > format, all depending on how the device describes itself. There's isn't > usually a normal "send/receive" type of thing, but it all depends on the > type of device. Ok. Reading the datasheet of this device I need to send some 64 byte arrays to configure the SPI bus. And after that I start to send reports to communicate with the SPI slave device. > > > This is my current driver is attached. > > > > Thanks > > Lucas > > > #define DEBUG > > #include <linux/module.h> > > #include <linux/hid.h> > > #include <linux/usb.h> > > > > static int mcp2210_probe(struct hid_device *hdev, > > const struct hid_device_id *id) > > { > > struct usb_interface *intf = to_usb_interface(hdev->dev.parent); > > int ret = 0; > > > > hid_dbg(hdev, "%s\n", __FUNCTION__); > > > > ret = hid_parse(hdev); > > if (ret) { > > hid_err(hdev, "parse failed\n"); > > return ret; > > } else { > > hid_dbg(hdev, "parse success\n"); > > } > > > > ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); > > if (ret) { > > hid_err(hdev, "hw start failed\n"); > > return ret; > > } else { > > hid_dbg(hdev, "start success\n"); > > } > > Does this all work? For this version, it`s takes precedence from HID generic driver, wich is great. > > What fails? If I try to execute small test of data communcation: u8 *buf = kzalloc (64, GFP_KERNEL); buf[0] = 0x50; //read EEPROM command buf[1] = 0x03 ; // Address to read ret = hid_hw_raw_request(hdev, 0, buf, 64, HID_INPUT_REPORT, HID_REQ_GET_REPORT) ret is -EPIPE. > > thanks, > > greg k-h Many Thanks Lucas Bus 001 Device 008: ID 04d8:00de Microchip Technology, Inc. MCP2210 USB to SPI Master Couldn't open device, some information will be missing Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 0 bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 8 idVendor 0x04d8 Microchip Technology, Inc. idProduct 0x00de bcdDevice 0.02 iManufacturer 1 iProduct 2 iSerial 3 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 0x0029 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0x80 (Bus Powered) MaxPower 100mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 2 bInterfaceClass 3 Human Interface Device bInterfaceSubClass 0 bInterfaceProtocol 0 iInterface 0 HID Device Descriptor: bLength 9 bDescriptorType 33 bcdHID 1.11 bCountryCode 0 Not supported bNumDescriptors 1 bDescriptorType 34 Report wDescriptorLength 29 Report Descriptors: ** UNAVAILABLE ** Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x01 EP 1 OUT bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 1 _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
On Mon, Feb 3, 2020 at 10:00 PM Lucas Tanure <tanure@linux.com> wrote: > > On Mon, Feb 3, 2020 at 8:11 PM Greg KH <greg@kroah.com> wrote: > > > > On Mon, Feb 03, 2020 at 04:32:46PM +0000, Lucas Tanure wrote: > > > Hi, > > > > > > I'm trying to write a Hid driver for MCP2210. > > > > What type of device is this? > It is a USB <-> SPI converter. > > > > > > But the USB Hid specification is quite complicated. > > > > The kernel should do it "all for you" already, why do you need to create > > a custom HID driver for this device? > I need a driver that register an SPI controller with in the kernel. > So this SPI controller would receive regmap reads/writes and translate > to USB HID packages and send to the SPI device attached in the other > side of the cable. > > > > > What type of HID reports does the device export and why doesn't the > > existing kernel drivers work for you? > I don't know enough yet to answer about HID Reports, but at end of > this e-mail I attached the lsub -v of the device. > I want to use this device in kernel space, registering a SPI > controller. And with this SPI controller another SPI slave device will > be registered. > So, for the SPI slave device it will be like there is no USB in > between itself and the kernel. > > > > > > I would like to know how to send and receive data to the device. Any > > > links to a good tutorial ? > > > > HID has the idea of "reports" and data comes in and out in that specific > > format, all depending on how the device describes itself. There's isn't > > usually a normal "send/receive" type of thing, but it all depends on the > > type of device. > Ok. Reading the datasheet of this device I need to send some 64 byte > arrays to configure the SPI bus. > And after that I start to send reports to communicate with the SPI slave device. > > > > > > This is my current driver is attached. > > > > > > Thanks > > > Lucas > > > > > #define DEBUG > > > #include <linux/module.h> > > > #include <linux/hid.h> > > > #include <linux/usb.h> > > > > > > static int mcp2210_probe(struct hid_device *hdev, > > > const struct hid_device_id *id) > > > { > > > struct usb_interface *intf = to_usb_interface(hdev->dev.parent); > > > int ret = 0; > > > > > > hid_dbg(hdev, "%s\n", __FUNCTION__); > > > > > > ret = hid_parse(hdev); > > > if (ret) { > > > hid_err(hdev, "parse failed\n"); > > > return ret; > > > } else { > > > hid_dbg(hdev, "parse success\n"); > > > } > > > > > > ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); > > > if (ret) { > > > hid_err(hdev, "hw start failed\n"); > > > return ret; > > > } else { > > > hid_dbg(hdev, "start success\n"); > > > } > > > > Does this all work? > For this version, it`s takes precedence from HID generic driver, wich is great. > > > > > What fails? > If I try to execute small test of data communcation: > > u8 *buf = kzalloc (64, GFP_KERNEL); > buf[0] = 0x50; //read EEPROM command > buf[1] = 0x03 ; // Address to read > > ret = hid_hw_raw_request(hdev, 0, buf, 64, HID_INPUT_REPORT, HID_REQ_GET_REPORT) > ret is -EPIPE. > > > > > thanks, > > > > greg k-h > > Many Thanks > Lucas > > Bus 001 Device 008: ID 04d8:00de Microchip Technology, Inc. MCP2210 > USB to SPI Master > Couldn't open device, some information will be missing > Device Descriptor: > bLength 18 > bDescriptorType 1 > bcdUSB 2.00 > bDeviceClass 0 > bDeviceSubClass 0 > bDeviceProtocol 0 > bMaxPacketSize0 8 > idVendor 0x04d8 Microchip Technology, Inc. > idProduct 0x00de > bcdDevice 0.02 > iManufacturer 1 > iProduct 2 > iSerial 3 > bNumConfigurations 1 > Configuration Descriptor: > bLength 9 > bDescriptorType 2 > wTotalLength 0x0029 > bNumInterfaces 1 > bConfigurationValue 1 > iConfiguration 0 > bmAttributes 0x80 > (Bus Powered) > MaxPower 100mA > Interface Descriptor: > bLength 9 > bDescriptorType 4 > bInterfaceNumber 0 > bAlternateSetting 0 > bNumEndpoints 2 > bInterfaceClass 3 Human Interface Device > bInterfaceSubClass 0 > bInterfaceProtocol 0 > iInterface 0 > HID Device Descriptor: > bLength 9 > bDescriptorType 33 > bcdHID 1.11 > bCountryCode 0 Not supported > bNumDescriptors 1 > bDescriptorType 34 Report > wDescriptorLength 29 > Report Descriptors: > ** UNAVAILABLE ** > Endpoint Descriptor: > bLength 7 > bDescriptorType 5 > bEndpointAddress 0x81 EP 1 IN > bmAttributes 3 > Transfer Type Interrupt > Synch Type None > Usage Type Data > wMaxPacketSize 0x0040 1x 64 bytes > bInterval 1 > Endpoint Descriptor: > bLength 7 > bDescriptorType 5 > bEndpointAddress 0x01 EP 1 OUT > bmAttributes 3 > Transfer Type Interrupt > Synch Type None > Usage Type Data > wMaxPacketSize 0x0040 1x 64 bytes > bInterval 1 Hi, If I use hid_hw_output_report I can write my 64 bytes buffer to the device. And I would expect a 64 bytes answer from the device, but I don't know how to get it. How do I know where my output data is going to ? Control Pipe or Interrupt Pipe ? How to I get the answer data from the device ? Thanks Lucas static int mcp2210_probe(struct hid_device *hdev, const struct hid_device_id *id) { //struct usb_interface *intf = to_usb_interface(hdev->dev.parent); int ret = 0; //struct hid_report *report = kzalloc(sizeof(struct hid_report), GFP_KERNEL); u8 *buf = kzalloc(64, GFP_KERNEL); u8 *buf2 = kzalloc(64, GFP_KERNEL); hid_dbg(hdev, "%s\n", __FUNCTION__); ret = hid_parse(hdev); if (ret) { hid_err(hdev, "parse failed\n"); return ret; } else { hid_dbg(hdev, "parse success\n"); } ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); if (ret) { hid_err(hdev, "hw start failed\n"); return ret; } else { hid_dbg(hdev, "start success\n"); } ret = hid_hw_open(hdev); hid_dbg(hdev, "hid_hw_open %d\n", ret); buf[0] = 0x50; buf[1] = 0x07; ret = hid_hw_output_report(hdev, buf, 64); hid_dbg(hdev, "hid_hw_output_report %d back [%x][%x][%x][%x]\n", ret, buf[0], buf[1], buf[2], buf[3]); //dmesg prints ret 0 ret = hid_hw_raw_request(hdev, 0x81, buf2, 64, HID_INPUT_REPORT, HID_REQ_SET_REPORT); hid_dbg(hdev, "hid_input_report %d back [%x][%x][%x][%x]\n", ret, buf2[0], buf2[1], buf2[2], buf2[3]); //dmesg prints ret -32 kfree(buf); kfree(buf2); return 0; } Dmesg: [ 72.991830] MCP2210 USB SPI Driver 0003:04D8:00DE.0002: mcp2210_probe [ 73.001793] MCP2210 USB SPI Driver 0003:04D8:00DE.0002: parse success [ 73.020234] MCP2210 USB SPI Driver 0003:04D8:00DE.0002: hiddev96,hidraw0: USB HID v1.11 Device [Microchip Technology Inc. MCP2210 USB-to-SPI Master] on usb-3f980000.usb-1.3/input0 [ 73.039798] MCP2210 USB SPI Driver 0003:04D8:00DE.0002: start success [ 73.111858] MCP2210 USB SPI Driver 0003:04D8:00DE.0002: hid_hw_open 0 [ 73.126599] MCP2210 USB SPI Driver 0003:04D8:00DE.0002: hid_hw_output_report 64 back [50][7][0][0] [ 73.140170] MCP2210 USB SPI Driver 0003:04D8:00DE.0002: hid_input_report -32 back [81][0][0][0] _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
On Tue, Feb 4, 2020 at 1:27 PM Lucas Tanure <tanure@linux.com> wrote: > > On Mon, Feb 3, 2020 at 10:00 PM Lucas Tanure <tanure@linux.com> wrote: > > > > On Mon, Feb 3, 2020 at 8:11 PM Greg KH <greg@kroah.com> wrote: > > > > > > On Mon, Feb 03, 2020 at 04:32:46PM +0000, Lucas Tanure wrote: > > > > Hi, > > > > > > > > I'm trying to write a Hid driver for MCP2210. > > > > > > What type of device is this? > > It is a USB <-> SPI converter. > > > > > > > > > But the USB Hid specification is quite complicated. > > > > > > The kernel should do it "all for you" already, why do you need to create > > > a custom HID driver for this device? > > I need a driver that register an SPI controller with in the kernel. > > So this SPI controller would receive regmap reads/writes and translate > > to USB HID packages and send to the SPI device attached in the other > > side of the cable. > > > > > > > > What type of HID reports does the device export and why doesn't the > > > existing kernel drivers work for you? > > I don't know enough yet to answer about HID Reports, but at end of > > this e-mail I attached the lsub -v of the device. > > I want to use this device in kernel space, registering a SPI > > controller. And with this SPI controller another SPI slave device will > > be registered. > > So, for the SPI slave device it will be like there is no USB in > > between itself and the kernel. > > > > > > > > > I would like to know how to send and receive data to the device. Any > > > > links to a good tutorial ? > > > > > > HID has the idea of "reports" and data comes in and out in that specific > > > format, all depending on how the device describes itself. There's isn't > > > usually a normal "send/receive" type of thing, but it all depends on the > > > type of device. > > Ok. Reading the datasheet of this device I need to send some 64 byte > > arrays to configure the SPI bus. > > And after that I start to send reports to communicate with the SPI slave device. > > > > > > > > > This is my current driver is attached. > > > > > > > > Thanks > > > > Lucas > > > > > > > #define DEBUG > > > > #include <linux/module.h> > > > > #include <linux/hid.h> > > > > #include <linux/usb.h> > > > > > > > > static int mcp2210_probe(struct hid_device *hdev, > > > > const struct hid_device_id *id) > > > > { > > > > struct usb_interface *intf = to_usb_interface(hdev->dev.parent); > > > > int ret = 0; > > > > > > > > hid_dbg(hdev, "%s\n", __FUNCTION__); > > > > > > > > ret = hid_parse(hdev); > > > > if (ret) { > > > > hid_err(hdev, "parse failed\n"); > > > > return ret; > > > > } else { > > > > hid_dbg(hdev, "parse success\n"); > > > > } > > > > > > > > ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); > > > > if (ret) { > > > > hid_err(hdev, "hw start failed\n"); > > > > return ret; > > > > } else { > > > > hid_dbg(hdev, "start success\n"); > > > > } > > > > > > Does this all work? > > For this version, it`s takes precedence from HID generic driver, wich is great. > > > > > > > > What fails? > > If I try to execute small test of data communcation: > > > > u8 *buf = kzalloc (64, GFP_KERNEL); > > buf[0] = 0x50; //read EEPROM command > > buf[1] = 0x03 ; // Address to read > > > > ret = hid_hw_raw_request(hdev, 0, buf, 64, HID_INPUT_REPORT, HID_REQ_GET_REPORT) > > ret is -EPIPE. > > > > > > > > thanks, > > > > > > greg k-h > > > > Many Thanks > > Lucas > > > > Bus 001 Device 008: ID 04d8:00de Microchip Technology, Inc. MCP2210 > > USB to SPI Master > > Couldn't open device, some information will be missing > > Device Descriptor: > > bLength 18 > > bDescriptorType 1 > > bcdUSB 2.00 > > bDeviceClass 0 > > bDeviceSubClass 0 > > bDeviceProtocol 0 > > bMaxPacketSize0 8 > > idVendor 0x04d8 Microchip Technology, Inc. > > idProduct 0x00de > > bcdDevice 0.02 > > iManufacturer 1 > > iProduct 2 > > iSerial 3 > > bNumConfigurations 1 > > Configuration Descriptor: > > bLength 9 > > bDescriptorType 2 > > wTotalLength 0x0029 > > bNumInterfaces 1 > > bConfigurationValue 1 > > iConfiguration 0 > > bmAttributes 0x80 > > (Bus Powered) > > MaxPower 100mA > > Interface Descriptor: > > bLength 9 > > bDescriptorType 4 > > bInterfaceNumber 0 > > bAlternateSetting 0 > > bNumEndpoints 2 > > bInterfaceClass 3 Human Interface Device > > bInterfaceSubClass 0 > > bInterfaceProtocol 0 > > iInterface 0 > > HID Device Descriptor: > > bLength 9 > > bDescriptorType 33 > > bcdHID 1.11 > > bCountryCode 0 Not supported > > bNumDescriptors 1 > > bDescriptorType 34 Report > > wDescriptorLength 29 > > Report Descriptors: > > ** UNAVAILABLE ** > > Endpoint Descriptor: > > bLength 7 > > bDescriptorType 5 > > bEndpointAddress 0x81 EP 1 IN > > bmAttributes 3 > > Transfer Type Interrupt > > Synch Type None > > Usage Type Data > > wMaxPacketSize 0x0040 1x 64 bytes > > bInterval 1 > > Endpoint Descriptor: > > bLength 7 > > bDescriptorType 5 > > bEndpointAddress 0x01 EP 1 OUT > > bmAttributes 3 > > Transfer Type Interrupt > > Synch Type None > > Usage Type Data > > wMaxPacketSize 0x0040 1x 64 bytes > > bInterval 1 > > Hi, > > If I use hid_hw_output_report I can write my 64 bytes buffer to the device. > And I would expect a 64 bytes answer from the device, but I don't know > how to get it. > > How do I know where my output data is going to ? Control Pipe or > Interrupt Pipe ? > How to I get the answer data from the device ? > > Thanks > Lucas > > static int mcp2210_probe(struct hid_device *hdev, > const struct hid_device_id *id) > { > //struct usb_interface *intf = to_usb_interface(hdev->dev.parent); > int ret = 0; > //struct hid_report *report = kzalloc(sizeof(struct > hid_report), GFP_KERNEL); > u8 *buf = kzalloc(64, GFP_KERNEL); > u8 *buf2 = kzalloc(64, GFP_KERNEL); > > hid_dbg(hdev, "%s\n", __FUNCTION__); > > ret = hid_parse(hdev); > if (ret) { > hid_err(hdev, "parse failed\n"); > return ret; > } else { > hid_dbg(hdev, "parse success\n"); > } > > ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); > if (ret) { > hid_err(hdev, "hw start failed\n"); > return ret; > } else { > hid_dbg(hdev, "start success\n"); > } > ret = hid_hw_open(hdev); > hid_dbg(hdev, "hid_hw_open %d\n", ret); > > buf[0] = 0x50; > buf[1] = 0x07; > ret = hid_hw_output_report(hdev, buf, 64); > hid_dbg(hdev, "hid_hw_output_report %d back > [%x][%x][%x][%x]\n", ret, buf[0], buf[1], buf[2], buf[3]); > //dmesg prints ret 0 > > ret = hid_hw_raw_request(hdev, 0x81, buf2, 64, > HID_INPUT_REPORT, HID_REQ_SET_REPORT); > hid_dbg(hdev, "hid_input_report %d back [%x][%x][%x][%x]\n", > ret, buf2[0], buf2[1], buf2[2], buf2[3]); > //dmesg prints ret -32 > > kfree(buf); > kfree(buf2); > > return 0; > } > > Dmesg: > [ 72.991830] MCP2210 USB SPI Driver 0003:04D8:00DE.0002: mcp2210_probe > [ 73.001793] MCP2210 USB SPI Driver 0003:04D8:00DE.0002: parse success > [ 73.020234] MCP2210 USB SPI Driver 0003:04D8:00DE.0002: > hiddev96,hidraw0: USB HID v1.11 Device [Microchip Technology Inc. > MCP2210 USB-to-SPI Master] on usb-3f980000.usb-1.3/input0 > [ 73.039798] MCP2210 USB SPI Driver 0003:04D8:00DE.0002: start success > [ 73.111858] MCP2210 USB SPI Driver 0003:04D8:00DE.0002: hid_hw_open 0 > [ 73.126599] MCP2210 USB SPI Driver 0003:04D8:00DE.0002: > hid_hw_output_report 64 back [50][7][0][0] > [ 73.140170] MCP2210 USB SPI Driver 0003:04D8:00DE.0002: > hid_input_report -32 back [81][0][0][0] Hi, Doing some hacks I can see that using a user space library for this device uses: [ 38.188226] [<806b9728>] (usbhid_output_report) from [<806b7db4>] (hidraw_send_report+0x100/0x180) And the layer between hidraw_send_report and usbhid_output_report is hid_hw_output_report. So the function I should use is hid_hw_output_report. [ 38.137293] usbhid_output_report START ############################################################################### [ 38.137306] usbhid_output_report 30 0 0 0 1 0 0 [ 38.148204] CPU: 3 PID: 475 Comm: hidusbtest Tainted: G C 4.19.69-v7+ #8 [ 38.148210] Hardware name: BCM2835 [ 38.164463] [<80111dac>] (unwind_backtrace) from [<8010d36c>] (show_stack+0x20/0x24) [ 38.172494] [<8010d36c>] (show_stack) from [<808166bc>] (dump_stack+0xcc/0x110) [ 38.179928] [<808166bc>] (dump_stack) from [<806b9728>] (usbhid_output_report+0x94/0x144) [ 38.188226] [<806b9728>] (usbhid_output_report) from [<806b7db4>] (hidraw_send_report+0x100/0x180) [ 38.197311] [<806b7db4>] (hidraw_send_report) from [<806b7e78>] (hidraw_write+0x44/0x58) [ 38.205517] [<806b7e78>] (hidraw_write) from [<802ac2ec>] (__vfs_write+0x48/0x170) [ 38.213193] [<802ac2ec>] (__vfs_write) from [<802ac5fc>] (vfs_write+0xb4/0x1c4) [ 38.220604] [<802ac5fc>] (vfs_write) from [<802ac8d4>] (ksys_write+0x6c/0xec) [ 38.227841] [<802ac8d4>] (ksys_write) from [<802ac96c>] (sys_write+0x18/0x1c) [ 38.235076] [<802ac96c>] (sys_write) from [<80101000>] (ret_fast_syscall+0x0/0x28) [ 38.242750] Exception stack(0xb391ffa8 to 0xb391fff0) [ 38.247869] ffa0: 00000000 00014bec 00000003 7e9ec8b4 00000040 00000000 [ 38.256161] ffc0: 00000000 00014bec 00010f38 00000004 00000000 00000000 76fc9000 7e9ec844 [ 38.264451] ffe0: 0000006c 7e9ec810 00012f00 76cd4944 [ 38.272431] usbhid_output_report END ############################################################################### And after using hid_hw_output_report my driver get a call at mcp2210_raw_event: [ 38.333979] [<7f32a04c>] (mcp2210_raw_event [mcp2210]) from [<806ae188>] (hid_input_report+0xf4/0x18c) So, to receive the success status of the command sent with hid_hw_output_report the driver receives an event. Now I need to understand how to register my driver to receive this event, once the hidraw driver will not be in use. [ 38.284788] hid_irq_in 0 [ 38.284798] mcp2210_raw_event START ############################################################################### [ 38.287370] CPU: 0 PID: 322 Comm: rs:main Q:Reg Tainted: G C 4.19.69-v7+ #8 [ 38.306324] Hardware name: BCM2835 [ 38.309787] [<80111dac>] (unwind_backtrace) from [<8010d36c>] (show_stack+0x20/0x24) [ 38.317642] [<8010d36c>] (show_stack) from [<808166bc>] (dump_stack+0xcc/0x110) [ 38.325062] [<808166bc>] (dump_stack) from [<7f32a04c>] (mcp2210_raw_event+0x4c/0x120 [mcp2210]) [ 38.333979] [<7f32a04c>] (mcp2210_raw_event [mcp2210]) from [<806ae188>] (hid_input_report+0xf4/0x18c) [ 38.343420] [<806ae188>] (hid_input_report) from [<806ba39c>] (hid_irq_in+0x20c/0x248) [ 38.351452] [<806ba39c>] (hid_irq_in) from [<8061bc48>] (__usb_hcd_giveback_urb+0xa0/0x15c) [ 38.359923] [<8061bc48>] (__usb_hcd_giveback_urb) from [<8061befc>] (usb_hcd_giveback_urb+0xd4/0xf4) [ 38.369188] [<8061befc>] (usb_hcd_giveback_urb) from [<80647434>] (completion_tasklet_func+0x8c/0xcc) [ 38.378542] [<80647434>] (completion_tasklet_func) from [<80656374>] (tasklet_callback+0x20/0x24) [ 38.387544] [<80656374>] (tasklet_callback) from [<80126a14>] (tasklet_action_common.constprop.5+0x64/0xec) [ 38.397426] [<80126a14>] (tasklet_action_common.constprop.5) from [<80126af4>] (tasklet_hi_action+0x28/0x30) [ 38.407394] [<80126af4>] (tasklet_hi_action) from [<801023f4>] (__do_softirq+0x184/0x424) [ 38.415687] [<801023f4>] (__do_softirq) from [<801266ac>] (irq_exit+0xf8/0x134) [ 38.423102] [<801266ac>] (irq_exit) from [<8017f710>] (__handle_domain_irq+0x70/0xc4) [ 38.431044] [<8017f710>] (__handle_domain_irq) from [<801021a0>] (bcm2836_arm_irqchip_handle_irq+0x60/0xa8) [ 38.440924] [<801021a0>] (bcm2836_arm_irqchip_handle_irq) from [<801019bc>] (__irq_svc+0x5c/0x7c) [ 38.449919] Exception stack(0xb63e5bf0 to 0xb63e5c38) [ 38.455038] 5be0: b59d022c 00000005 80c66000 b9bb87c0 [ 38.463331] 5c00: b59d00b0 00000400 80c66000 b59d022c b97dc400 b63e5da0 b63e5cd4 b63e5c4c [ 38.471622] 5c20: b63e5c50 b63e5c40 8036a1e4 808322fc 40000013 ffffffff [ 38.478330] [<801019bc>] (__irq_svc) from [<808322fc>] (_raw_spin_lock+0xc/0x54) [ 38.485834] [<808322fc>] (_raw_spin_lock) from [<8036a1e4>] (ext4_mark_iloc_dirty+0x108/0x8c8) [ 38.494569] [<8036a1e4>] (ext4_mark_iloc_dirty) from [<8036aca4>] (ext4_mark_inode_dirty+0x84/0x1f8) [ 38.503832] [<8036aca4>] (ext4_mark_inode_dirty) from [<8037058c>] (ext4_dirty_inode+0x54/0x70) [ 38.512656] [<8037058c>] (ext4_dirty_inode) from [<802de768>] (__mark_inode_dirty+0x50/0x414) [ 38.521305] [<802de768>] (__mark_inode_dirty) from [<802c97a8>] (generic_update_time+0xf4/0x11c) [ 38.530215] [<802c97a8>] (generic_update_time) from [<802c9c88>] (file_update_time+0x128/0x158) [ 38.539039] [<802c9c88>] (file_update_time) from [<8023b158>] (__generic_file_write_iter+0xa0/0x1e0) [ 38.548305] [<8023b158>] (__generic_file_write_iter) from [<80357a20>] (ext4_file_write_iter+0xfc/0x4b8) [ 38.557921] [<80357a20>] (ext4_file_write_iter) from [<802ac3b0>] (__vfs_write+0x10c/0x170) [ 38.566390] [<802ac3b0>] (__vfs_write) from [<802ac5fc>] (vfs_write+0xb4/0x1c4) [ 38.573800] [<802ac5fc>] (vfs_write) from [<802ac8d4>] (ksys_write+0x6c/0xec) [ 38.581034] [<802ac8d4>] (ksys_write) from [<802ac96c>] (sys_write+0x18/0x1c) [ 38.588269] [<802ac96c>] (sys_write) from [<80101000>] (ret_fast_syscall+0x0/0x28) [ 38.595941] Exception stack(0xb63e5fa8 to 0xb63e5ff0) [ 38.601059] 5fa0: 0000004a 75700bc0 00000007 75700bc0 0000004a 00000000 [ 38.609351] 5fc0: 0000004a 75700bc0 00000007 00000004 75700bc0 fffff815 00092410 000924e8 [ 38.617641] 5fe0: 00000002 760fe6e8 00000000 76eeb1bc [ 38.622762] MCP2210 USB SPI Driver 0003:04D8:00DE.0001: mcp2210_raw_event 64 [ 38.629930] MCP2210 USB SPI Driver 0003:04D8:00DE.0001: 30 0 0 0 1 0 2 2 2 2 2 0 0 ff 1 ff 1 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 [ 38.646944] mcp2210_raw_event END ############################################################################### _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
> The accounts themselves are useless without the ability to > make any edits, but I assume they must be making a little > bit of money selling (useless) account credentials... Reprobates... > With MoinMoin 1.9 essentially dead, and > the next development version quite moribund, I think it is > time for me to move to another wiki, where the worst case for > lookups is O(log(N)), not O(N). Maybe Dokuwiki. Along with worst case lookup, given the current bombardment of malicious requests to the site (which is having a real impact on site availability at the moment), a solution with support for deterrents of this kind of malice would also be welcome. Additionally, migration of the site's content to a new solution could pose an ideal time to review the validity and currency of some of the information available on the site. By and large, most of the information available on the site seems to be current and / or valid, although there are some parts which could use an update (one area which springs to mind without being able to access the site is the list of potential beginner projects for those looking to introduce new features to the kernel). ~ Jack _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies