cyclicredundancy
Posts: 1
Joined: Fri Apr 26, 2013 7:24 am

Support for MAX3421E USB host controller

Mon Jan 01, 2018 12:31 am

I am trying to figure out if the raspberry pi has linux drivers for the maxim MAX3421E SPI USB host controller.
https://www.maximintegrated.com/en/prod ... 3421E.html
This is the same chip used in the various USB host shield boards:
https://www.circuitsathome.com/arduino_ ... _projects/

Googling around randomly.... I see that there seems to be code in the linux kernel for this:
https://github.com/torvalds/linux/blob/ ... 3421-hcd.c

And the same code is also there in the raspberry pi kernel source tree:
https://github.com/raspberrypi/linux/bl ... 3421-hcd.c

Is there some way for me to figure out if that driver is supported in Raspbian which is running kernel version 4.9.72 ?

Will the driver be compiled as a module?
I tried a grep and could not locate it under /lib/modules , so does that mean it is not compiled by default?

$ find /lib/modules/ | grep hcd
/lib/modules/4.9.59-v7+/kernel/drivers/usb/usbip/vhci-hcd.ko
/lib/modules/4.9.72+/kernel/drivers/usb/usbip/vhci-hcd.ko
/lib/modules/4.9.72-v7+/kernel/drivers/usb/usbip/vhci-hcd.ko
/lib/modules/4.9.59+/kernel/drivers/usb/usbip/vhci-hcd.ko

If the driver is not preset if it fairly straightforward to add support for it, or build it on my own?
The last time I tried to build a linux kernel was sometime in 2001 :-p so I will pretty much be starting from scratch.

Thanks!

kernel config:
https://cateee.net/lkddb/web-lkddb/USB_MAX3421_HCD.html
email list post where support for this driver was requested to be pulled into the kernel:
https://www.spinics.net/lists/linux-usb/msg104882.html

broe23
Posts: 903
Joined: Thu Jan 28, 2016 9:35 pm
Location: Central IL
Contact: Website

Re: Support for MAX3421E USB host controller

Mon Jan 01, 2018 7:19 am

Does Raspbian not see that controller?
Ren: Now listen, Cadet. I've got a job for you. See this button? Ren: Don't touch it! It's the History Eraser button, you fool! Stimpy: So what'll happen? Ren: That's just it. We don't know. Maybe something bad, maybe something good.

User avatar
rpdom
Posts: 14472
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Support for MAX3421E USB host controller

Mon Jan 01, 2018 9:27 am

You can check the kernel config, which is now held in a module, so you need to load that first, then check the config file.

Code: Select all

[email protected]:~ $ sudo modprobe configs
[email protected]:~ $ zgrep MAX3421 /proc/config.gz 
# CONFIG_USB_MAX3421_HCD is not set
So that looks like it isn't available in the kernel that I'm currently running (4.9.35-v7+).

You'd need to make a custom kernel to add support.

cezar.santanna
Posts: 5
Joined: Thu Jun 23, 2016 7:25 pm

Re: Support for MAX3421E USB host controller

Sat Jun 30, 2018 9:34 pm

Does any one get any success using this chip as USB HOST?

emw
Posts: 44
Joined: Tue Apr 12, 2016 2:53 pm

Re: Support for MAX3421E USB host controller

Thu Sep 27, 2018 2:37 pm

Bump. Has anyone had any experience at all with this chip on the PI?

dconnx
Posts: 1
Joined: Tue Feb 19, 2019 9:56 am

Re: Support for MAX3421E USB host controller

Tue Feb 19, 2019 9:58 am

Hi, Did anyone get anywhere (with getting a MAX3421 recognised as a USB controller on the RP SPI bus) ? I'm interested in this too. thanks Derek

emw
Posts: 44
Joined: Tue Apr 12, 2016 2:53 pm

Re: Support for MAX3421E USB host controller

Tue Feb 19, 2019 1:34 pm

Yes I have it working on a pi zero w. Do you have any specific questions?

billoo2378
Posts: 2
Joined: Tue Feb 19, 2019 7:08 pm

Re: Support for MAX3421E USB host controller

Tue Feb 19, 2019 7:16 pm

The MAX3421E USB peripheral/host controller contains the digital logic and analog circuitry necessary to implement a full-speed USB peripheral or a full-/low-speed host compliant to USB specification rev 2.0. A built-in transceiver features ±15kV ESD protection and programmable USB connect and disconnect.

billoo2378
Posts: 2
Joined: Tue Feb 19, 2019 7:08 pm

Re: Support for MAX3421E USB host controller

Wed Feb 20, 2019 11:48 am

:P The MAX3421E USB peripheral/host controller contains the digital logic and analog circuitry necessary to implement a full-speed USB peripheral or a full-/low-speed host compliant to USB specification rev 2.0. A built-in transceiver features ±15kV ESD protection and programmable USB connect and disconnect. An internal serial interface engine (SIE) handles low-level USB protocol details such as error checking and bus retries. The MAX3421E operates using a register set accessed by an SPI interface that operates up to 26MHz. Any SPI master (microprocessor, ASIC, DSP, etc.) can add USB peripheral or host functionality using the simple 3- or 4-wire SPI interface. :P :P :P

scarlyon
Posts: 2
Joined: Sun Jun 23, 2019 10:24 am

Re: Support for MAX3421E USB host controller

Sun Jun 23, 2019 11:49 am

emw wrote:
Tue Feb 19, 2019 1:34 pm
Yes I have it working on a pi zero w. Do you have any specific questions?
Hi.

I am going to use a barcode scanner with MAX3421E as I can't use the original USB port.

Could you please guide me on how to use that?

Cheers.

emw
Posts: 44
Joined: Tue Apr 12, 2016 2:53 pm

Re: Support for MAX3421E USB host controller

Mon Jun 24, 2019 3:48 pm

here are my notes:

''' Note this was originally done with the 4.14 kernel and should be updated for newer versions'''

Code: Select all

 
sudo wget https://raw.githubusercontent.com/notro/rpi-source/master/rpi-source -O /usr/bin/rpi-source && sudo chmod +x /usr/bin/rpi-source && /usr/bin/rpi-source -q --tag-update
sudo apt-get install bc libncurses5-dev bison flex libssl-dev
rpi-source
This may take a while

back porting is not required for kernel 4.19

cd linux/drivers/usb/host/
mv max3421-hcd.c max3421-hcd.c.old

The next line gets the new version of max3421-hcd.c with device tree support

wget https://raw.githubusercontent.com/torva ... 3421-hcd.c


Code: Select all

cd ~/linux
make menuconfig
-> set <M> MAX3421 HCD (USB-over-SPI) support

Code: Select all

scripts/diffconfig
should respond with 'USB_MAX3421_HCD n -> m'

Code: Select all

grep MAX3421 .config
should respond with 'CONFIG_USB_MAX3421_HCD=m'

Code: Select all

make prepare
make SUBDIRS=drivers/usb/host/ modules

Code: Select all

sudo make SUBDIRS=drivers/usb/host/ modules_install
above line may create warning

Code: Select all

sudo depmod

Code: Select all

 cd ~/linux/arch/arm/boot/dts/overlays/
create the file max3421-spi0-overlay.dts

Code: Select all

/dts-v1/;
 /plugin/;
 
 / {
         compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";
 
         [email protected] {
         target = <&spidev0>;
                 __overlay__ {
                         status = "disabled";
                 };
         };
 
         /* the interrupt pin of the usb-controller */
         [email protected] {
                 target = <&gpio>;
                 __overlay__ {
                         usb2_pins: usb2_pins {
                                 brcm,pins = <25>;
                                 brcm,function = <0>; /* input */
                         };
                 };
         };
 
 
         [email protected] {
                 target = <&spi0>;
                 __overlay__ {
 
                         #address-cells = <1>;
                         #size-cells = <0>;
                         pinctrl-names = "default";
                         pinctrl-0 = <&spi0_pins &spi0_cs_pins>;
                         cs-gpios = <&gpio 8 1>;
                         status = "okay";
 
                         maxim3421: [email protected] {
                                 compatible = "maxim,max3421";
                                 reg = <0>; /* CE0 */
                                 maxim,vbus-en-pin = <3 1>;
                                 interrupt-parent = <&gpio>;
                                 interrupts = <25 8>; /* low irq */
                                 #gpio-controller;
                                 #gpio-cells = <2>;
                                 spi-max-frequency = <10000000>;
                         };
                 };
         };
 
 };
then

Code: Select all

 sudo dtc [email protected] -I dts -O dtb -o /boot/overlays/max3421-spi0.dtbo max3421-spi0-overlay.dts
this will include 3 warnings '/boot/overlays/max3421-spi0.dtbo: Warning (unit_address_vs_reg): Node /[email protected] has a unit name, but no reg property'


Code: Select all

 sudo nano /boot/config.txt
  • uncomment
    #dtparam=spi=on
  • add
    dtoverlay=max3421-spi0
    dtoverlay=dwc2



reboot

emw
Posts: 44
Joined: Tue Apr 12, 2016 2:53 pm

Re: Support for MAX3421E USB host controller

Mon Jun 24, 2019 3:53 pm

You will also need some hardware, and the above may vary slightly on how/what hardware you use. I used a sparkfun board with a minor power modification (5v is provided from pi rather than lm 1117).

Sparkfun Max3421 to pi wiring
RX
TX
2
3
4
5
6
7

8
9 INT to Pin 22 (GPIO25)
10 SS to Pin 24 (GPIO 8)
11 MOSI to Pin 19 (GPIO 10)
12 MISO to Pin 21 (GPIO9)
13 SCLK to Pin 23 (GPIO11)
G
AREF


AIN5
AIN4
AIN3
AIN2
AIN1
AIN 0

VIN
G
G to Pin 15 (GND)
+5 to Pin 2 (+5)
+3.3
RST


The modification to the board is a jumper wire from +5 (on connector above) to +term of tantalum capacitor beside USB connector

Return to “General discussion”