You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On occasion USB initialization will fail, and I am trying to figure out why this is happening. I am currently using a custom board with a SAMD51P19A. I've adjusted the linker files in the bootloader to take into account the difference in memory/program space for the SAMD51P19A compared to the SAMD51P20A.
It seems that USB initialization is failing under the following circumstances:
Immediately after I flash the bootloader onto the chip. I am using the "Device Programming" screen in Microchip Studio in combination with an Atmel ICE to get the bootloader onto the chip. The USB won't be recognized unless I completely power cycle the chip by unplugging the USB cable and plugging it back in.
If I have an Arduino sketch loaded onto the board, and then I try to upload a new sketch (this should enter bootloader mode using the 1200 bps method, and it does indeed enter the bootloader, but the USB initialization of the bootloader is failing under this circumstance, and thus it fails to upload a new Arduino sketch).
Circumstances in which USB initialization is succeeding in the bootloader:
If I unplug the USB cable and plug it back in (assuming no Arduino sketch is loaded onto the board, because then it would jump to the sketch of course)
The function usb_init seems to be running fine as far as I can tell. When I get to the loop which polls USB_Ok, this is where I am running into issues.
while (1) {
if (USB_Ok()) {
/* code */
So I've been looking at what's happening in the USB_Ok function. This function essentially has 3 code paths:
Path A if this if-statement on line 553 is true: if (USB->DEVICE.INTFLAG.reg & USB_DEVICE_INTFLAG_EORST)
Path B if this if-statement on line 579 is true: else if (USB->DEVICE.DeviceEndpoint[0].EPINTFLAG.reg & USB_DEVICE_EPINTFLAG_RXSTP)
Path C: do nothing if neither of the above if-statements are true
Upon debugging, it seems like when the bootloader is successful this function first goes through code path "A", and then later it will go through code path "B". When the bootloader is unsuccessful, it never enters either of these code paths. So basically it seems like th EORST bit of the INTFLAG register is never getting set sometimes.
Any ideas on why this could be?
My computer that I have the board connected to is a Windows 10 machine.
The text was updated successfully, but these errors were encountered:
On occasion USB initialization will fail, and I am trying to figure out why this is happening. I am currently using a custom board with a SAMD51P19A. I've adjusted the linker files in the bootloader to take into account the difference in memory/program space for the SAMD51P19A compared to the SAMD51P20A.
It seems that USB initialization is failing under the following circumstances:
Circumstances in which USB initialization is succeeding in the bootloader:
The function
usb_init
seems to be running fine as far as I can tell. When I get to the loop which pollsUSB_Ok
, this is where I am running into issues.So I've been looking at what's happening in the
USB_Ok
function. This function essentially has 3 code paths:if (USB->DEVICE.INTFLAG.reg & USB_DEVICE_INTFLAG_EORST)
else if (USB->DEVICE.DeviceEndpoint[0].EPINTFLAG.reg & USB_DEVICE_EPINTFLAG_RXSTP)
Upon debugging, it seems like when the bootloader is successful this function first goes through code path "A", and then later it will go through code path "B". When the bootloader is unsuccessful, it never enters either of these code paths. So basically it seems like th EORST bit of the INTFLAG register is never getting set sometimes.
Any ideas on why this could be?
My computer that I have the board connected to is a Windows 10 machine.
The text was updated successfully, but these errors were encountered: