Custom samd21 board disconnects when uploading sketch

Hello, I have recently designed a custom board with the ATSAMD21G18A. After soldering it, I followed these directions. Now, every time I upload the bootloader with a J-Link and Microchip Studio, the board enters bootloader mode and it appears as a USB drive. It also appears in the Arduino IDE as COM 4. However, when I upload any sketch to the board through that port, the board disconnects (according to the IDE the upload is successful). Now, the board doesn't show up in the explorer or as a port in the IDE. It only shows up again if I use the J-Link and Microchip Studio to flash the bootloader again. I cannot figure out how to make the board appear as a port without doing so. [I can upload the bootloader and the Arduino15 folder if necessary.]


The crystal is a TSX-3225 16.0000MF18X-AC6

Welcome! You have an advantage we do not, you can see the board, code and have an annotated schematic. If you upload the above you will even the field and probably get a good answer. On the schematic show all connections, power sources, ground, power wiring and note any leads over 10"/25cm.

I uploaded the schematic. I don't know how to upload the Arduino15 folder, because it can't be compressed (it has characters that can't be in a compressed folder).

No, do NOT upload the folder. The forum guidelines explain how to use code tags. Click on code at the top that opens ready s the forum to receive a sketch. in your sketch enter a control T (formats the sketch) check, then click anywhere in the sketch and enter a control A (copy all) control C (TAC). then in the forum click the ... and then Control V (paste).

int led = 19;

void setup() {
  Serial.begin(115200);
  pinMode(led, OUTPUT);
}

void loop() {
  Serial.println("Hello!");

  digitalWrite(led, HIGH);
  delay(500);
  digitalWrite(led, LOW);
  delay(500);
}

Normally this behaviour is either due to incorrect crystal setup, or incorrect memory boundaries. You could try using an adafruit bootloader for a SAMD21G18A with the CRYSTALLESS flag set in the boards file and boot loader .bin, that will at least tell you whether or not your hardware is generally ok. If that works then have another look at your crystal config. From memory most of the “standard” SAMD21G18A boards use a 32kHz crystal on PA00 - 01, so a 16MHz crystal may be a bit of a challenge to setup with the bossa bootloader.

Are you correctly setting the text segment start past the bootloader in your platform.txt or whatever?

(Hmm. For arduino samd boards, this happens via "-T{build.variant.path}/{build.ldscript}", where that contains:

MEMORY
{
  FLASH (rx) : ORIGIN = 0x00000000+0x2000, LENGTH = 0x00040000-0x2000 /* First 8KB used by bootloader */
  RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000
}

I followed those instructions and it works perfectly. Thank you very much!

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.