Custom SAMD21 Board - USB/Bootloader Issues

I have built a custom SAMD21 board based on the Adafruit Feather, but am having issues getting it working correctly.

After soldering the components I was able to successfully detect/flash the SAMD21. I begun by flashing the Adafruit M0 Feather bootloader via a JLink EDU Mini over SWD. However this is where my problems have begun.

When the board is plugged into my PC via the native USB it is detected but gives a “USB Device not recognized” error and is not detected by the Arduino IDE. I have tried multiple computers, which both have drivers that can successfully detect/program SAMD21 boards.

The boot loader appears to be entering the correct programming mode, (as a double reset button tap results in a flashing status light.)

I’ve tried alternate boot loaders, switching timing crystals, pulling reset high via a 10k resistor, and skipping the boot loader and just uploading a blink.bin file but nothing has worked correctly.

Here is a copy of my schematic: https://i.imgur.com/XyckwJX.jpg (does not include the newly added 10k reset pull-up resistor)

Any advice is greatly appreciated!

Hi gyundt,

The Adafruit M0 uses the UF2 bootloader that runs cyrstalless using the SAMD21's internal 32.768kHz oscillator. Usually, if there's an issue with the external crystal the board will enter bootloader mode, connect and upload successfully, but will fail to run any sketch as the crystal fails upon starting up the Arduino core code.

If the board is entering bootloader mode (after a double tap of the reset button) with a pulsing LED, but you're unable to connect, then this suggests perhaps an issue with the USB connection. In your schematic I notice that you're using a connector with the USB/DM and USB/DP signals, but no ground. Is there an adequate ground connection between your board and the host computer? Also, might I ask what type of cable are you're using for the USB connection?

Thank you so much for your reply!

MartinL:
If the board is entering bootloader mode (after a double tap of the reset button) with a pulsing LED, but you're unable to connect, then this suggests perhaps an issue with the USB connection.

If it is relevant currently the LED will begin pulsing as soon as the board is powered, even if the reset button is not double tapped.

MartinL:
In your schematic I notice that you're using a connector with the USB/DM and USB/DP signals, but no ground. Is there an adequate ground connection between your board and the host computer? Also, might I ask what type of cable are you're using for the USB connection?

For the USB connection I have cut apart an old USB cable (~1ft long) and connected it in accordance to this reference image. The ground connection was then attached directly to the power supply powering the board (3.3v bench supply) and I have left the 5v wire from the USB disconnected as my board has no 5v regulator.

For the USB connection I have cut apart an old USB cable (~1ft long) and connected it in accordance to this reference image. The ground connection was then attached directly to the power supply powering the board (3.3v bench supply) and I have left the 5v wire from the USB disconnected as my board has no 5v regulator.

Just to clarify, is the ground for the USB connection is routed to your board via the +3.3V bench power supply?

That’s correct, the USB and board are both running off the same supply and share a ground.

Have you tried connecting the ground from the host computer's USB directly to your board together with the USB/DM and USB/DP signals and also a separate ground with the +3.3V from your board back to the bench power supply?

Yes I have tried connecting the USB ground connected directly to my boards ground plane through an unpopulated ground pad. Unfortunately the result was the same.

Hi gyundt,

I had a look at your schematic again, I can see that pins 5 and 18 have been connected to GND. Have you also connected the microcontroller's ground on pins 35 and 42 to GND as well?

MartinL:
Have you also connected the microcontroller's ground on pins 35 and 42 to GND as well?

Pins 35 and 42 appear hidden in the schematic, however in the final layout they are both connected to GND.

Hi gyundt,

I think I know what's happening, the green LED resistor at 150R sources more current than the SAMD21 microcontroller can sink.

If your LED has a typical forward voltage drop of say +2.0V, then with a +3.3V supply this leaves a +1.3V drop across the resistor itself. This sets the current through the LED at around 8mA, however by default the SAMD21's IO port pin is only capable of sinkng 2.5mA, too much for the microcontroller to handle.

It's possible to set microcontroller's IO port pin driverstrength (DRVSTR) bit in it's pin configuration (PINCONFIG) register, to allow it to sink up to 10mA, but there's no guarantee that this has been set in the bootloader firmware.

The solution is to either use a higher value resistor for your LED, or modify the bootloader code to: assign the LED to an unused pin, or alternatively activate the driver strength bit for D13 (PA17). The bootloader modification option would also require you to turn on the driver strength bit before operating the LED in your sketch.

Thank you so much for the detailed reply, I had no idea about the driver strength setup!

Sadly after removing the LED and its resistor the board is still giving the same USB error and is still not being correctly detected. :frowning:

Hi gyundt,

The only other suggestions I can think of are inspecting the microcontroller for solder bridges, checking that it's receiving 3.3V and GND on its power pins and that the VDDCore is running at around 1.8V. It might also be worth checking the polarity of the USB signal lines.

It's also possible to run a sketch on the microcontroller's internal oscillator without using the external crystal, by adding the -DCRYSTALLESS switch to the Feather M0's "build.extra_flags" line in the Adafruit core "boards.txt" file. This would test if the start-up issue is with the external crystal itself.

It could also be a driver issue on your host computer.

Thank you for the pointers Martin, I really appreciate it!
I will do some probing and further inspection of the hardware.

Do you think it would be worth trying to compile the bootloader myself? Or would you expect this to be a hardware vs a software issue?

Hi gyundt,

Debugging your board should just be a gradual process of elimination.

If you've successfully uploaded the bootloader via the SWD port then your board should behave like an Adafruit Feather M0.

If you have a Feather M0 board then it would be worth plugging into the USB port of your host computer, to see if the USB connection and driver work correctly. This would eliminate any issue to do with the host's USB port or driver.

You should be getting around 1.8V on the VDDCore pin.

To test the board running crystalless, the "board.txt" file can be found (at least on my Windows machine) at:

C:\User\Computer\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.5.3\boards.txt

In the entry for the Feather M0 add -DCRYSTALLESS to the line:

adafruit_feather_m0_express.build.extra_flags=-DARDUINO_SAMD_ZERO -DARDUINO_SAMD_FEATHER_M0 -DARM_MATH_CM0PLUS -DADAFRUIT_FEATHER_M0_EXPRESS -D__SAMD21G18A__ {build.usb_flags}

As you've removed the LED resistor there shouldn't be any need to recompile the bootloader. However if the board still refuses to function, the bootloader also allows the option to upload code over the board's Tx and Rx serial port on digtial pins D0 and D1. I notice that you're not using these pins in your design, but it should be possible recompile the bootloader to operate the serial port from other pins. This would require a 3.3V FTDI (Serial to USB) board or a 5V FTDI with a 5V to 3.3V converter, such as an I2C level shifter. It should at least elminate any issues with the USB, but is more of a last resort.

If you have a second board it might be worth testing it as well. Sometimes testing two boards can help track down problems that afflicts just one of them.

Finally success! I soldered up a second board and it works perfectly... I am going to try using solder wick and hot air on the first board and try to get it working.

VDDCore on the first board is running at 2.4v

Martin thank you so much for all your input and advise. I really appreciate all your help, and I’m sure many people will find your input helpful for future trouble shooting.

Hi gyundt,

Glad to hear you got it working.