Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

MCP2221 read error
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: MCP2221 read error

by jklem on Wed Feb 05, 2020 1:03 am

Bingo.
I need BLINKA_MCP2221_RESET_DELAY=0.2, and no BLINKA_MCP2221_HID_DELAY.
I tested it driving I2C and a GPIO output, and both seem to work fine.
Thanks for your amazing support!

jklem
 
Posts: 12
Joined: Sun Dec 08, 2019 10:20 pm

Re: MCP2221 read error

by joncubs on Wed Feb 05, 2020 1:20 am

Silly question, but how do you install this new version?

I extracted the zip file and tried 'pip install .' and got this error:

ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

joncubs
 
Posts: 9
Joined: Wed Jan 01, 2020 2:24 am

Re: MCP2221 read error

by adafruit_support_carter on Wed Feb 05, 2020 12:00 pm

Cool. Sounds like this latest fix was closer to the actual issue. Will wait for others to report success before claiming victory. And if it seems like a higher default value is good, we can change that. So thanks for letting us known what actual BLINKA_MCP2221_RESET_DELAY you needed. And also confirming that it works with BLINKA_MCP2221_HID_DELAY=0, which was probably a red herring in terms of being a fix.

@joncubs Upgrade using pip, similar to the original install. You can check current versions with:
Code: Select all | TOGGLE FULL SIZE
pip freeze

and then to upgrade Blinka:
Code: Select all | TOGGLE FULL SIZE
pip install --upgrade --force-reinstall adafruit-blinka

Just make sure "pip" is actually running Python 3 pip on your machine. Change if needed, ex: pip3 vs. pip.

adafruit_support_carter
 
Posts: 17282
Joined: Tue Nov 29, 2016 2:45 pm

Re: MCP2221 read error

by pnw on Wed Feb 05, 2020 11:09 pm

adafruit_support_carter wrote:Cool. Sounds like this latest fix was closer to the actual issue. Will wait for others to report success before claiming victory. And if it seems like a higher default value is good, we can change that. So thanks for letting us known what actual BLINKA_MCP2221_RESET_DELAY you needed. And also confirming that it works with BLINKA_MCP2221_HID_DELAY=0, which was probably a red herring in terms of being a fix.

@joncubs Upgrade using pip, similar to the original install. You can check current versions with:
Code: Select all | TOGGLE FULL SIZE
pip freeze

and then to upgrade Blinka:
Code: Select all | TOGGLE FULL SIZE
pip install --upgrade --force-reinstall adafruit-blinka

Just make sure "pip" is actually running Python 3 pip on your machine. Change if needed, ex: pip3 vs. pip.


I will report that the delay also worked for me.
These are the environment variables I set.
BLINKA_MCP2221=1
BLINKA_MCP2221_HID_DELAY=0.004
BLINKA_MCP2221_RESET_DELAY=0.0

I discovered that on my machine, an HID_DELAY of at least 0.004 was required.
The Windows machine has an AMD Ryzen 7 3700X processor.
The Python code is running the ADC example from the learning guide.

pnw
 
Posts: 4
Joined: Wed Apr 16, 2014 7:57 pm

Re: MCP2221 read error

by pnw on Wed Feb 05, 2020 11:44 pm

One more thing.
I found that I could get the ADC example code to work with either delay set to at least 0.005.
All three of these worked for me.

BLINKA_MCP2221_HID_DELAY=0.005
BLINKA_MCP2221_RESET_DELAY=0.000

BLINKA_MCP2221_HID_DELAY=0.000
BLINKA_MCP2221_RESET_DELAY=0.005

BLINKA_MCP2221_HID_DELAY=0.005
BLINKA_MCP2221_RESET_DELAY=0.005

pnw
 
Posts: 4
Joined: Wed Apr 16, 2014 7:57 pm

Re: MCP2221 read error

by Hulker on Thu Feb 06, 2020 8:39 am

Hey, great fix as far as I can tell.

I have BLINKA_MCP2221_HID_DELAY not set and BLINKA_MCP2221_RELAY_DELAY=0.2

This works for both my ANKER USB hub and my non-hub USB ports (both 2.0 and 3.0).

I assume (after looking at your code in Blinka) that it is much better to use BLINKA_MCP2221_RELAY_DELAY as this is called when the MCP2221 is reset (which is infrequently like when a script is started) whilst the BLINKA_MCP2221_HID_DELAY affects each and every read/write from/to the USB (and therefore has a very large effect on the performance of the MCP2221). Is that right?

Hulker
 
Posts: 13
Joined: Thu Jul 20, 2017 9:30 am

Re: MCP2221 read error

by adafruit_support_carter on Thu Feb 06, 2020 12:28 pm

I should probably crank the default value of BLINKA_MCP2221_RESET_DELAY up. That way it will probably work on more machines without ever being explicitly set. The current default of 0.1 sounds too low. But it's at least good to hear that it seems to be working in general, once set as needed.

@Hulker Correct. Ideally you would want BLINKA_MCP2221_HID_DELAY=0. That is the default. So if you just ignore it, that is what will get used. And then hopefully all that is needed is setting BLINKA_MCP2221_RESET_DELAY, or not if you can get away with the default.

@pnw Similarly for you. Go with these settings:
BLINKA_MCP2221_HID_DELAY=0.000
BLINKA_MCP2221_RESET_DELAY=0.005

Or just do nothing. If a reset delay of 0.005 worked for you, then the default 0.1 should also work.

I think/hope that BLINKA_MCP2221_HID_DELAY is not really a fix, even though it *seems* to work on some machines. So what would be interesting is if anyone finds that they need to have BLINKA_MCP2221_HID_DELAY be a non-zero value even with BLINKA_MCP2221_RESET_DELAY set as needed.

adafruit_support_carter
 
Posts: 17282
Joined: Tue Nov 29, 2016 2:45 pm

Re: MCP2221 read error

by joncubs on Thu Feb 06, 2020 11:47 pm

Thanks for helping. Any non-zero value seems to work for me, even this:
Code: Select all | TOGGLE FULL SIZE
set BLINKA_MCP2221_RESET_DELAY=0.000001

joncubs
 
Posts: 9
Joined: Wed Jan 01, 2020 2:24 am

Re: MCP2221 read error

by adafruit_support_carter on Fri Feb 07, 2020 12:13 pm

OK, this is sounding like it is hopefully resolved. At least for now. Thanks for all the patience and providing requested info to help us figure this one out. A new FAQ about this has been added here:
https://learn.adafruit.com/circuitpytho ... aq-3055702

adafruit_support_carter
 
Posts: 17282
Joined: Tue Nov 29, 2016 2:45 pm

Re: MCP2221 read error

by durapensa on Wed Oct 14, 2020 10:26 am

Earlier this month I encountered the error
Code: Select all | TOGGLE FULL SIZE
  File "/usr/local/lib/python3.8/dist-packages/adafruit_blinka/microcontroller/mcp2221/mcp2221.py", line 131, in _reset
    raise OSError("open failed")
OSError: open failed

But is working now after updating adafruit-blinka & Adafruit-PlatformDetect
Code: Select all | TOGGLE FULL SIZE
sudo pip3 install --upgrade --force-reinstall adafruit-blinka Adafruit-PlatformDetect

Also, since Linux kernel 5.7, an MCP2221 driver has been mainlined which I found also causes the error above. The driver can be removed with
Code: Select all | TOGGLE FULL SIZE
sudo rmmod hid_mcp2221

And excluded from loading at boot (on most Linux distros) by adding the line below to /etc/modprobe.d/blacklist.conf
Code: Select all | TOGGLE FULL SIZE
blacklist hid_mcp2221

durapensa
 
Posts: 1
Joined: Sun Sep 20, 2020 9:47 am

Re: MCP2221 read error

by adafruit2 on Wed Oct 14, 2020 10:39 am

thank you!

adafruit2
Site Admin
 
Posts: 19408
Joined: Fri Mar 11, 2005 7:36 pm

Please be positive and constructive with your questions and comments.