Using Segger tools instead of Arduino IDE

Status
Not open for further replies.

MattMatic

Member
After a lot of head-scratching and puzzling over the Arduino GCC configuration, I have finally got a nice template project working in Segger's Embedded Studio along with the J-Link USB hardware debug probe on the Teensy 3.6.

You will need to modify the Teensy to add SWD (see this thread and my guide and notes here).

You must install Arduino 1.8.4, Teensyduino 1.39 and create a symbolic link in Windows (I did this for the sake of makefile, but the project could probably be reconfigured to point to the horrible path that Arduino is installed in).
Full notes are in the _README_FIRST_.txt file in the zip.

This is very much a work-in-progress and YMMV. If you find issues, please let me know. However, please don't assume a quick answer - I am incredibly busy with several serious projects not involving Teensy. But I'll do my best to help out ;)

View attachment TeensyDuinoTemplate.2017-11-01.zip

Matt
 
Matt, thanks much for this help for us newbs. I’m following along and have a couple things on Windows 7. In the Create a symbolic link step, in Win 7 go to Start — Accessories then right click on Command Prompt and select Run as Administrator. Then enter:

mklink /D C:\Arduino “C:\ProgramFiles(x86)\Arduino”

Spaces in the path “Program Files (x86)” caused it to give me a syntax error.

Just to clarify, "This template project." is the contents of the zip file? And you make a directory, e.g., \Documents\TeensyDuinoTemplate and unzip the zip file into it?

Now, before the “Using the Project Library” step, do I open Embedded Studio and do a File/Open Studio Folder…/Project Folder, then navigate to the new template directory and double click “TeensyDuino.emProject”?

When I do it gives a message box saying Missing Packages and do I want to install NXP Kinetis_K60 CPU Support Package. I said yes. It takes a few minutes to install packages.

At this point, the Project Explorer has the Project: TeensyDuinoTemplate, with _Sketch and Blink.cpp in it. Hitting F7 comes back with an "Arduino.h: No such file or directory" error.

I'll work more on this later and will order a J-Link mini next week to play with. And will post more dumb questions as I get them. :)

Tim
 
Hi Tim,
It's your mklink command that's the problem. You can create a link to a non-existent directory. So, in your case, looking in C:\Arduino will probably be empty - hence the "can't find Arduino.h" issue!

First, find your "real" Arduino directory. If you have 32-bit Win7 it may be in "C:\Program Files\Arduino". Find it with Explorer.
Then, use TAB expansion in the CMD prompt.
e.g. TYPE: mklink /D C:\Arduino C:\PRO[TAB]Ard[TAB]
Hitting the TAB key will locate the directory, and fill in the appropriate quotes etc. Pressing TAB repeatedly will cycle through the available matches.

Once you have done the symbolic link, check that C:\Arduino does indeed contain the same as the "real" directory.
Then you should be good to go :)

Matt
 
Matt, this is really good info.

What mods would need to be made to get all this to work on a Teensy 3.2 based design? I tried a few things based on your files last night but cannot yet get the download to work (somekind of copy to RAM problem, maybe my RAM addresses are not correct).
 
Last edited:
Matt, this is really good info.

What mods would need to be made to get all this to work on a Teensy 3.2 based design? I tried a few things based on your files last night but cannot yet get the download to work (somekind of copy to RAM problem, maybe my RAM addresses are not correct).

Alas, I don't have a T3.2 to test. But here is an educated guess at the changes:

1. Change the linker script. In the project it's under Arduino / Linker Scripts. You'll need to remove the "mk66fx1m0.ld" and instead drag in the "mk20dx256.ld" from the C:\Arduino\hardware\teensy\avr\cores\teensy3 directory. HINT: Before removing the mk66 one, right click in SES and choose "Select in File Explorer" - you'll be in the right directory. As you drag the mk20 linker file onto the "Linker Scripts" folder in SES it will ask you if you want it used for the current build configuration. Of course, answer Yes.

Alternatively you could just drag in the mk20 linker file and decide which linker is active by right clicking in SES and choosing "Use this linker script"

2. Change the CPU definition in the project. Right click on the "Project TeensyDuinoTemplate", switch to the "Common" target, and search for "target device". For the T3.6 it will be "MK66FX1M0xxx18". Change this to "MK20DX256xxx7" (I believe!)

Now all should be good for compilation and uploading etc.



You may also want to grab the register definition files for the CPU. In the common project options it's under "Register Definition File". I hadn't mentioned this, but in Segger Embedded Studio (SES) this is an incredible life saver for hardware issues. Essentially you can peek into any hardware register and see the decoded status without faffing about with a hex/binary calculator. Just see the status of any peripheral immediately. Saved me weeks of work in debugging ultra low power controls for an Atmel SAM CPU :)

You can grab a Keil pack from http://www.keil.com/pack/ - rename the file to .zip; unzip and pick out the SVD file for the CPU. Then point SES to that SVD file and you'll get register definitions directly.

...however, looks like the MK20DX isn't available :( Perhaps there's a compatible CPU?

Let me know how things work out ;)
Matt
 
Hi, Matt - thanks for the template! I've managed to get Segger Embedded Studio 3.40 working in Mac OS, and have got the Blink example uploaded and working.

I'm using a JLink EDU to upload code to a Teensy 3.6, using Teensyduino 1.8.4, after removing the KL02 chip following Erich Styger's guide. (I'd already removed the chip before finding your guide here; will do this with the other 3.6s I'm experimenting with).

The only change I had to make was to replace the Windows drive and pathnames in TeensyDuino.emProject. I've attached the modified file here: View attachment TeensyDuino.emProject.Mac-HighSierra.zip.

Thanks again!
 
Status
Not open for further replies.
Back
Top