๐Ÿ“ฃ๐Ÿ“ช ๐Ÿšš Adafruit will not be shipping USPS orders Monday January 20, 2020 ๐Ÿ—“. Expedited USPS orders placed after 11am ET ๐Ÿ•š Friday January 17 will go out Tuesday January 21 ๐Ÿ“ฃ๐Ÿ“ช๐Ÿšš

Custom board based on trinket m0 doesn't run code
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Custom board based on trinket m0 doesn't run code

by johnswenson1 on Wed Jul 03, 2019 7:34 pm

I'm trying to do a commercial product which has a SAMD21E16B for programming other chips via SPI. I developed the code in Arduino on trinket M0. I have a test board built with the SAMD and SWD interface to program it.

I decided to use an rpi 3B+ as SWD programmer (the tutorial is great but the pins in the current openocd are different than the pins in the tutorial, I finally got that figured out). I finally figured out what openocd commands I needed to talk to the chip, that is all running now.

I have two processors on the board, one that will be using a modified Adafruit bootloader, it has a USB microB jack connected. The other will not be using a bootloader, Arduino code just running raw.

For the one without the bootloader I linked the sketch with the without_bootloader link file so it SHOULD run without a bootloader. Openocd says it programed and verified the flash but after power off and on nothing happens. I tried a simple little sketch that just outputs a 500Hz square wave, on the trinket m0 it works great, but on mine, nothing. I checked the fuses they look good. Both the WDT and the BOD33 are turned off so they shouldn't be causing a problem. I checked the supply ramp time and it is about 6 mili-seconds which shouldn't cause a problem.

For the other processor I loaded the latest version of the trinket M0 bootloader.bin file, then loaded the above sketch, this time set to link at 0x2000, made sure the openocd program command had an offset of 0x2000. Again openocd says everything loaded fine. But upon power up, nothing. I hooked up the USB port, did the double click on the reset button, nothing. The real trinket M0 comes up with several things ont eh PC when doing the double click. This does nothing. If I don't double click or just a single click the reset button, the bootloader should run the sketch, but nothing happens.

The board is hooked up the same as the trinket M0 except for the LEDs.

I THINK the board is hooked up correctly (this is about the simplest thing I've done in years, this is a simple processor to hook up), it could be a bad chip, but openocd CAN talk to it. The VDD and core voltage are correct.

Most likely is that I'm doing something wrong with openocd so it's not programming it correctly. Openocd does say it programs and verifies, so it would have to be something like a wrong fuse setting, or loading the code in the wrong place etc. The program command is supposed to deal with the proper erase operation, so it's hard to see how I could be doing that wrong.

I am following how the trinket M0 did the SWD did the SWD interface and just hook up SWDCLK, SWDIO and GND to the programmer, no reset line. I had to set
reset_config none
in order to get it to work right without a hardware reset line. I don't know if that is a problem or not. I was trying to match the trinket M0 schematic as much as possible.

The chip can't be completely dead because openocd does talk to it. It just doesn't seem to be starting to run any programs. I was thinking that it might be WDT or BOD33 reseting things but they are both turned off in the fuses.

Any hint where to look would be greatly appreciated.

John S.

Posts: 8
Joined: Wed Aug 01, 2018 1:06 am

Re: Custom board based on trinket m0 doesn't run code

by XRAD on Thu Jul 04, 2019 5:47 pm

Maybe issue is in the link address? is there a different address in the IDE using flash access without_bootloader? 0x0?

there are a few other arduino flash access without bootloader codes out there.....

Posts: 567
Joined: Sat Nov 19, 2016 3:28 pm

Please be positive and constructive with your questions and comments.