0

Metro M4 Express and Atmel Studio 7
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Metro M4 Express and Atmel Studio 7

by KB1HFT on Wed Mar 06, 2019 5:31 pm

I am impressed with the capabilities of the Metro M4 Express (MM4E), and would like to use it in several projects. Before I do that tho, I want to be able to debug my Arduino code, built in the Arduino IDE, on Atmel's Studio 7 (AS7). Unfortunately, AS7 does not have the MM4E predefined. So it looks like I'll have to configure a "custom" "user" board, unless someone knows of where I can find an AS7 definition of the MM4E.

I remember reading in some Adafruit document a statement that using AS7 was recommended for the MM4E . I also see that the board is targeted for use with Circuit Python, and there IS documentation: Debugging CircuitPython On SAMD w/ Atmel Studio 7 ( https://cdn-learn.adafruit.com/download ... 1551895726).

By following that document I was able to gain some insight into the complexities of this endevour. However, the document is somewhat out of date in its depiction of the steps needed in AS7, and I'm looking for directions on how to use AS7 with an imported _Arduino_ sketch.

Are there plans for a similar document that focuses on Arduino sketches instead of Circuit Python?

Are there any other online resources that I might mine to resolve this dilemma? -- All advice is appreciated! --
Thanks & 73!

KB1HFT
 
Posts: 17
Joined: Mon Jun 11, 2018 4:20 pm

Re: Metro M4 Express and Atmel Studio 7

by westfw on Thu Mar 07, 2019 3:51 am

Does AS7 require a board-level definition? I thought you could say "I have a SAMD51mumble" chip, and get pretty far with that...
User avatar
westfw
 
Posts: 1508
Joined: Fri Apr 27, 2007 1:01 pm
Location: SF Bay area

Re: Metro M4 Express and Atmel Studio 7

by KB1HFT on Thu Mar 07, 2019 8:39 am

westfw: Thanks you.

I have not yet delved into the process of defining the Metro M4 Express' layout around the SAMD51J19A, and was hoping that someone had gone down that particular road before me and might share.

I'll dig deeper into creating an ASF Board project today.

Onward!

KB1HFT
 
Posts: 17
Joined: Mon Jun 11, 2018 4:20 pm

Re: Metro M4 Express and Atmel Studio 7

by KB1HFT on Thu Mar 07, 2019 9:28 am

westfw:
I don’t yet know enough about AS7’s requirements & capabilities.

I’m assuming, perhaps incorrectly, that to debug an Arduino sketch via AS7, AS7 must know about the target board’s cpu/board pin mapping and other hardware features of the board that the Arduino code is to manipulate. Therefor, it seems to me, a definition of the board is needed.

Please correct me if I have mis-assumed.

KB1HFT
 
Posts: 17
Joined: Mon Jun 11, 2018 4:20 pm

Re: Metro M4 Express and Atmel Studio 7

by westfw on Sat Mar 09, 2019 5:46 am

I'm not sure. Normally, to use AS7 for Arduino development, you'd probably first create the Arduino Sketch, and then uses AS7 to "create project from Arduino Sketch" but as you said, there doesn't seem to be AS "configuration" for the M4 boards (nor for SOME of the SAMD21 boards. I'm not sure why it needs that info (when it's essentially present in the arduino files), and I don't see where it's getting its info from :-( (You get the same error trying to import an ITSYBITSY M0 sketch.)

You COULD create a SAMD51 project "from scratch" (or maybe by starting with an M0 sketch) and manually adding the Metro M4-specific files. Sounds unpleasant, though.

On the third hand, it's not clear that importing SAMD21 sketches works, either. :-(
User avatar
westfw
 
Posts: 1508
Joined: Fri Apr 27, 2007 1:01 pm
Location: SF Bay area

Re: Metro M4 Express and Atmel Studio 7

by Adafruit_UMjT7KxnxP8YN8 on Sat Mar 09, 2019 3:13 pm

I tried to import an Arduino sketch for the Adafruit Metro M4 and after resolving a number of other issues learned that the import of sketches for the SAMD51 processor is not supported. I was, however, able to use AS7 to debug Arduino sketches I'd already loaded onto the board using the Arduino IDE.

Perhaps a more fruitful line of inquiry would be how to manually convert an Arduino sketch for the Metro M4 to an AS7 application? I'd be happy to help as time permits.

Adafruit_UMjT7KxnxP8YN8
 
Posts: 29
Joined: Tue Jul 17, 2018 1:28 pm

Re: Metro M4 Express and Atmel Studio 7

by KB1HFT on Thu Mar 14, 2019 11:14 am

Adafruit_UMjT7KxnxP8YN8:

How did you go about debugging your Metro M4 Express sketch via AS7? I. e., what steps did you perform?

I _can_ program the board via Arduino IDE, but want to be able to debug. I presume that AS7 is an appropriate debugging tool, since it is suggested for debugging Python projects.

If not AS7, then what tool does Adafruit suggest for debugging IDE C++ sketches on the Metro M4 Express?

All suggestions welcome!

KB1HFT
 
Posts: 17
Joined: Mon Jun 11, 2018 4:20 pm

Re: Metro M4 Express and Atmel Studio 7

by Adafruit_UMjT7KxnxP8YN8 on Sun Mar 17, 2019 11:34 am

I loaded the program I built with the Arduino IDE, then opened AS7 and did the following:

1. File->Open->Open file for debugging.
2. Navigate to the .elf file generated by the Arduino IDE (usually /temp/arduino_xxxxxx)
3. Enter name and location for AS7 to create a project
4. Debug->Attach to target (I use this; you may want to do it differently). It will fail because you haven't configured your debugger yet.

At this point AS7 will prompt you to set up your debugger. You must select the target device (ATSAMD51J19A) then set up your debugger. AS7 displays a list of the debuggers it detects and you just click on one. A dialog will open to configure its clock rate, connection method, etc. I use the Segger J-Trace. The J-Link Edu works just fine too.

I configured the debugger NOT to erase any target memory (skip) since I'd already loaded my program. If you want to overwrite your boot loader and render your Metro M4 unusable with Arduino, you may want to choose a different option. You can configure AS7 to only load program memory, but you'll have to figure that out on your own if you want to try it.

Next I select Debug->Attach to target again and viola, I''m debugging.

Note that if you're doing this as a hobbyist rather than as a for-profit business, you can also use Segger Ozone, a very nice debugger that's much faster than AS7.

Adafruit_UMjT7KxnxP8YN8
 
Posts: 29
Joined: Tue Jul 17, 2018 1:28 pm

Please be positive and constructive with your questions and comments.