USB Host Shield works on Uno R3 not on Uno R4 Wifi

I have a Phoncoo USB Host Shield. It works with my Uno R3, but does not work with my Uno R4 WiFi. I have this working now. See udpate at the bottom of the post if you are interested in how I got it to work.

I have run board_qc on both systems. The output is below.

I would like to get the Host Shield to work on the Uno R4 WiFi. Absent that, I would like a recommendations on USB Host Shields that are known to work with the R4 WiFi. I know there was some talk last year about native support on the R4 for USB Host, but that doesn't seem to have happened yet.

Thanks.

Uno R4 Wifi output:

board_qc started

Circuits At Home 2011
USB Host Shield Quality Control Routine
Reading REVISION register... Die revision invalid. Value returned: 09
Unrecoverable error - test halted!!
0x55 pattern is transmitted via SPI
Press RESET to restart test

Uno R3 output

board_qc started

Circuits At Home 2011
USB Host Shield Quality Control Routine
Reading REVISION register... Die revision 03
SPI long test. Transfers 1MB of data. Each dot is 64K................ SPI long test passed
GPIO test. Connect GPIN0 to GPOUT7, GPIN1 to GPOUT6, and so on
Test failed. Value written: 00 Value read: FF
Press any key to continue...
GPIO test passed.
PLL test. 100 chip resets will be performed
Resetting oscillator
Reset number 0 Time to stabilize - 333 cycles
Reset number 1 Time to stabilize - 333 cycles
*** deleted 2 through 98 ***
Reset number 99 Time to stabilize - 333 cycles

Checking USB device communication.

Reset complete. Waiting for the first SOF...
Getting device descriptor
Descriptor Length: 12
Descriptor type: 01
USB version: 0200
Device class: 00
Device Subclass: 00
Device Protocol: 00
Max.packet size: 08
Vendor ID: 046D
Product ID: C52F
Revision ID: 3000
Mfg.string index: 01
Prod.string index: 02
Serial number index: 00
Number of conf.: 01

All tests passed. Press RESET to restart test

1 Like

Check out posts 11 and 12. This thread started out about the shield and then moved to host support. I never was able to get it working and fried one of my R4WiFi in the process so I stopped messing with it.

I didn't try this code for the shield because I moved to trying to get native working. It might be worth looking at though.

Have you checked that you are using the proper libraries?

Unfortunately using the updated code did not fix the issue. Still getting an invalid die revision of 09.

have tried both the USB Host Shield Library 2.0 from the library manage (version 1.7.0) as well as the version referred to by Delta_G https://github.com/mjs513/USB_Host_Shield_2.0/tree/master.

The USB Host Shield Library 2.0 works fine with the Uno R3 and the USB Host Shield.

Yes, but the R4 has a completely different architecture and isn't compatible with the library for it. Looks like the updated library isn't compatible with your shield.

Maybe you could figure out what they changed in the updated library and use that to fix the one that works for the shield on the R3?

1 Like

Delta_G,

Yes, that is most likely the problem. I was hoping the library had been fixed by now, but these things take time.

Looks like I will have my work cut out for me if I go and try to fix it.

Thanks for your input.

Hardware: USB host shield board (UHS) + Arduino Uno R4 Minima

Installed the following using IDE library manager.

  • USB Host Shield Library 2.0 by Kristian Sloth Lauszus version 1.7.0

Result: board_qc works on Uno R4 Minima + UHS board

As far as I can tell the latest UHS library has all the changes for the Uno R4 Minima. I do not have an Uno R4 WiFi at the moment.

Are the two boards plugged in to each other? Or are there other boards in the stack? Are boards connected via long wires? UHS library uses 26 Mbits/sec for the SPI clock on Uno R4 so this can be a problem. As I recall AVR boards like Uno and Mega default to 8 Mbits/sec for SPI clock. I do not know if this has changed.

If you want to try a slower SPI clock speed, see usbhost.h in the UHS library. For example, search and replace all occurrences of 26000000 with 8000000. Recompile and upload.

Thanks customecontroller for the info on the SPI speed. I will have to look at the SPI clock speed.

Please don't do that. Just make a reply to add new information. You're messing with the arrow of time here.

At least mark out what has been added since I read it last.

I have this working now.

There is a bug in the board_qc.ino file.

The following statement in particular (line 36) is the problem:

Usb.Init(); // Initializes SPI, we don't care about the return value here

On the R4 with this board you DO care about the return value. I knew better than to not check the return value but didn't follow my own advice in this case.

On my UNO R3 it always connects fine with the first call to init(). On the R4 is NEVER connects on the first call to Init() but connects on the 2nd call to Init().

I made one change to the board_qc program. I check the return code from Usb.init()and retry it several times if the return code is -1.

After that the board passed the tests on the Uno Wifi R4.

I then tried the host shield again in a very simple program and it worked (again doing the Init multiple times).

I then tried to add my display/SD card to the program. I only enabled the display.

The USB Host Shield stopped working.

It seems there is a problem when both the host shield and the display are using the same SPI support. I will have to look into this more. I know there have been some compaints about the SPI speed on the R4. Someone posted a update to the SPI.h and SPI.cpp files, but I have not looked to see if those have been incorporated in the most current versions.

I made sure there were no conflicts on the pins being used by both. Still no luck.

The driver for the display allows for software SPI and I changed the display to use a software SPI driver and I was able to get both to work.

I added the SD reader using the software SPI (since it is on the display card, it is going to use the same pins as the display) and now the program can use the host shield, display and SD card. The Host Shield uses the built-in SPI. The library is USB Host Shield Library 2.0 version 1.7.0. The display and SD card use the software SPI driver, The display uses the GFX Library for Arduino version 1.5.0. The SD card is using the SdFat - Adafruit Fork verison 2.2.3.

2 Likes

I wonder if this is the problem with my host mode attempt.

On the WiFi you can get a second SPI port from the SCI. I think you have to give up one of the serial lines to do it maybe. MISO2 on pin 0, MOSI2 on pin 1 and SCK2 on pin 6.

I don't know all the details about using the SCI for SPI, but the FSP code is all there so it shouldn't be very hard to set up.

You also have with the SCI MOSI1 and SCK1 in the QWIIC connector, that could be set up for a write only SPI port and would be working at 3.3V which might save a level converter one day.

1 Like