Not Finding devices and warnings on Arduino M0
dvlkv opened this issue · 1 comments
In file included from /Users/mrmld/Library/Arduino15/packages/arduino/hardware/samd/1.6.18/cores/arduino/Arduino.h:129:0,
from /Users/mrmld/Documents/Arduino/libraries/WebUSB/WebUSB.h:23,
from /Users/mrmld/Documents/Arduino/libraries/WebUSB/WebUSB.cpp:26:
/Users/mrmld/Documents/Arduino/libraries/WebUSB/WebUSB.cpp: In member function 'virtual int WebUSB::getInterface(uint8_t*)':
/Users/mrmld/Library/Arduino15/packages/arduino/hardware/samd/1.6.18/cores/arduino/USB/USBCore.h:36:56: warning: narrowing conversion of '(int)((WebUSB*)this)->WebUSB::.PluggableUSBModule::pluggedEndpoint' from 'int' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
#define USB_ENDPOINT_OUT(addr) ((addr) | 0x00)
^
/Users/mrmld/Library/Arduino15/packages/arduino/hardware/samd/1.6.18/cores/arduino/USB/USBCore.h:276:10: note: in definition of macro 'D_ENDPOINT'
{ 7, 5, _addr,_attr,_packetSize, _interval }
^
/Users/mrmld/Documents/Arduino/libraries/WebUSB/WebUSB.cpp:150:14: note: in expansion of macro 'USB_ENDPOINT_OUT'
D_ENDPOINT(USB_ENDPOINT_OUT(pluggedEndpoint),USB_ENDPOINT_TYPE_BULK,0x40,0),
^
/Users/mrmld/Library/Arduino15/packages/arduino/hardware/samd/1.6.18/cores/arduino/USB/USBCore.h:37:56: warning: narrowing conversion of '((((int)((WebUSB*)this)->WebUSB::.PluggableUSBModule::pluggedEndpoint) + 1) | 128)' from 'int' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
#define USB_ENDPOINT_IN(addr) ((addr) | 0x80)
^
/Users/mrmld/Library/Arduino15/packages/arduino/hardware/samd/1.6.18/cores/arduino/USB/USBCore.h:276:10: note: in definition of macro 'D_ENDPOINT'
{ 7, 5, _addr,_attr,_packetSize, _interval }
^
/Users/mrmld/Documents/Arduino/libraries/WebUSB/WebUSB.cpp:151:14: note: in expansion of macro 'USB_ENDPOINT_IN'
D_ENDPOINT(USB_ENDPOINT_IN (pluggedEndpoint+1),USB_ENDPOINT_TYPE_BULK,0x40,0)
^
@DiE-MaRMeLaDe due to differences in 32bit SAMD21 in M0 and 8bit 32U4 using int
, you may be able to cast (uint8_t) in line 150 and 151 of WebUSB.cpp
D_ENDPOINT((uint8_t)USB_ENDPOINT_OUT(pluggedEndpoint),USB_ENDPOINT_TYPE_BULK,0x40,0),
D_ENDPOINT((uint8_t)USB_ENDPOINT_IN (pluggedEndpoint+1),USB_ENDPOINT_TYPE_BULK,0x40,0)
This will remove the -Wnarrowing error. However there should more error that was missed
C:\Users\JP\Documents\Arduino\libraries\WebUSB\WebUSB.cpp:164:42: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
if (USB_SendControl(0, &landingPage, 1) < 0)
It will be really hard to get rid of this without major reworking on the M0 USBCore.cpp
uint32_t USBDeviceClass::sendControl(const void* _data, uint32_t len)
{
const uint8_t *data = reinterpret_cast<const uint8_t *>(_data);
uint32_t length = len;
uint32_t sent = 0;
uint32_t pos = 0;
if (_dry_run == true)
return length;
if (_pack_message == true) {
memcpy(&_pack_buffer[_pack_size], data, len);
_pack_size += len;
return length;
}
while (len > 0)
{
sent = armSend(EP0, data + pos, len);
pos += sent;
len -= sent;
}
return length;
}
Above, you can see that in SAMD21's USBCore.cpp
the command sendControl
only returns unsigned
number but in Leonardo sendControl
has negative 1 number return that mean something
int USB_SendControl(u8 flags, const void* d, int len)
{
int sent = len;
const u8* data = (const u8*)d;
bool pgm = flags & TRANSFER_PGM;
while (len--)
{
u8 c = pgm ? pgm_read_byte(data++) : *data++;
if (!SendControl(c))
return -1;
}
return sent;
}
So, either you report a bug at Arduino M0's github or it will be easier and less stress to use another board that is listed here, since M0 is a retired product.
Hope this helps. If you think this answer your questions, please close this issue.