I connected a USB Host Shield (M5STACK-M020) to the M5Stack BASIC 2.7 (M5Core), but encountered a USB initialization error.
-
I connected a USB Host Shield (M5STACK-M020) to the M5Stack BASIC 2.7 (M5Core), but it's not working due to a USB initialization error, returning -1 from Usb.Init().
Has anyone encountered and resolved this issue?-
list itemI also experienced the same error with M5Stack GRAY.
-
list itemI've tried UHS versions v1.6.2 and v1.3.2 without success.
-
list itemDespite changing the INT connection from ESP32's pin 17 to 35 to match M5STACK-M020's design, the issue persisted.
-
list itemSwitching from M5Stack.h to M5Unified.h didn't help.
-
list itemA source code from 2 years ago, which previously worked, now fails, suggesting updates to M5Core might affect compatibility. Interestingly, using the same shield with M5Core2 works, indicating the shield isn't faulty. Rebuilding with the current setup results in initialization errors.
-
-
Upon analyzing the contents of Usb.Init(), it was discovered that in the reset() function of usbhost.h, the bmOSCOKIRQ bit of the USBIRQ register does not get set. The USBCTL register is set with bmCHIPRES to reset, and then reset is cleared with 0x00. Normally, this should lead to the PLL starting, stabilizing, and then setting the bmOSCOKIRQ bit of the USBIRQ register, but it seems not to happen. Even after increasing the wait time for oscillator stabilization, the bmOSCOKIRQ never gets set. What could be the reason for bmOSCOKIRQ not getting set?
/* reset MAX3421E. Returns number of cycles it took for PLL to stabilize after reset
or zero if PLL haven't stabilized in 65535 cycles */
template< typename SPI_SS, typename INTR >
uint16_t MAX3421e< SPI_SS, INTR >::reset() {
uint16_t i = 0;
regWr(rUSBCTL, bmCHIPRES);
regWr(rUSBCTL, 0x00);
while(++i) {
if((regRd(rUSBIRQ) & bmOSCOKIRQ)) {
break;
}
}
return ( i);
} -
Subsequent investigations revealed that the initialization error was due to a physical connection issue. Initially, I didn't pay much attention to the fact that the M5Stack did not come with screws to secure its bottom, but after using my own screws to fasten the USB Host Shield (M5STACK-M020) in place, Usb.init() began to succeed. I apologize for any inconvenience this may have caused and appreciate everyone's patience.