Use Sublime Text as an Arduino IDE replacement.

KurtE

Senior Member+
As I have converted over to using Sublime Text version 3 as my main editor when I am working on libraries or Teensy Core... I was wondering if anyone has integrated Arduino IDE capabilities into it.

It turns out there is a python install package for sublime text that was created to do this. I believe the most current sources for it is up at: https://github.com/Robot-Will/Stino/tree/new-stino

So I thought I would give it a try. After a few install issues, which was resolved by deleting some python cache file, it came up. I was able to compile Blink for the Arduino Mega, but when I try compiling for Teensy, the compiler fails...

From looking at some of the current issues, I see a few others have tried this. The first fix (hack) was to update the Teensy platform.txt.

There code does not appear to handle: compiler.path={runtime.hardware.path}/../tools/ It was sort of interesting I did a search of the entire Arduino install and this key only showed up this and the backup of this file that TYQT created.

So I edited, and changed the line to: compiler.path=C:\arduino-1.6.12\hardware\tools\

Now the compiler runs and compiles all of the sources. But now fails in the archive steps.

Code:
[Stino - Start building "Blink"...]
[ 25%] Creating C:\Users\Kurt\AppData\Local\Temp\Stino_build\Blink\core.a...
"C:\arduino-1.6.12\hardware\tools\arm/bin/arm-none-eabi-ar" rcs "C:\Users\Kurt\AppData\Local\Temp\Stino_build\Blink/core/core.a" "C:\Users\Kurt\AppData\Local\Temp\Stino_build\Blink\core_teensy3\analog.c.o"
C:/arduino-1.6.12/hardware/tools/arm/bin/arm-none-eabi-ar: C:/Users/Kurt/AppData/Local/Temp/Stino_build/Blink/core/core.a: No such file or directory


[Stino - Exit with error code 1.]
It turns out when they are doing a compile it looks like they are doing the compile of the core files, the files are being built in:
:/Users/Kurt/AppData/Local/Temp/Stino_build/Blink/core_teensy3

But the archive is looking for them in :/Users/Kurt/AppData/Local/Temp/Stino_build/Blink/core so it fails.

My guess, is I may need to play with the line: recipe.ar.pattern="{compiler.path}{build.toolchain}{build.command.ar}" rcs "{build.path}/core/{archive_file}" "{object_file}"

Will look at what the Arduino platform file does here as the build for the AVR processors is built into the directory: C:\Users\Kurt\AppData\Local\Temp\Stino_build\Blink\core_arduino
And it runs fine...

So it looks like I need to do a little more digging.

Was wondering if anyone already has it working?

Thanks
Kurt
 
This may turn into a bigger project, so not sure how far I will go.

So for pas 1, I hacked platform.txt:
##compiler.path={runtime.hardware.path}/../tools/
compiler.path=C:\arduino-1.6.12\hardware\tools\

But now editing Python code. Might be nice if I really understood python... But, I have made some more progress.
I Added code to their arduino_compiler.py code to define extra.time.local, plus runtime.platform.path
Code:
        # TEENSY BUILD UPDATEBuild Time - 
        self.params['extra.time.local'] = str(int(time.time()))
        platform_path = self.params.get('runtime.platform.path', '')
        hardware_path = os.path.dirname(platform_path)
        self.params['runtime.hardware.path'] = hardware_path
        # END TEENSY
Plus updated where they processed compiler_path
Code:
        compiler_path = self.params.get('compiler.path')
        self.message_queue.put(
            '[Stino - compiler path "{0}"]\\n', compiler_path)
        compiler_path = compiler_path.replace('{runtime.ide.path}', ide_path)
        # TEENSY BUILD UPDATEBuild Time - 
        compiler_path = compiler_path.replace('{runtime.hardware.path}', hardware_path)
        # END TEENSY
Need to remove messages I added to figure out why paths was not working.

The only change I have left in the boards.txt is to do the Archive. The code in the Teensy boards.txt is hard coded for the core directory. That is it is:
Code:
recipe.ar.pattern="{compiler.path}{build.toolchain}{build.command.ar}" rcs "{build.path}/core/{archive_file}" "{object_file}"

I changed this over with modifications over to what the standard arduino boards.txt has:
Code:
archive_file_path={build.path}/{archive_file}
recipe.ar.pattern="{compiler.path}{build.toolchain}{build.command.ar}"  rcs "{archive_file_path}" "{object_file}"
Actually the Arduino one has the RCS flags I believe defined in another variable which they use instead...

Paul: Wonder if it makes sense to update the official teensy board.txt file?

With this change I am able to build simple programs like blink.

However it appears like they are not handling finding libraries where Teensy installs them. Not sure how hard this would be to add, or if it is worth it. Will see.

Kurt
 
Found one or more issues on their github project on this. I tried a one line fix which was mentioned in their issue #330 and was able to build a reasonably complex project.
 
I know I may be only talking to myself here ;)

But since I have seen a few issues on github for using Stino with Teensy processors, I will fill in more information here, in case someone else wishes to try this.

Today was able to use diptrace to compile and download to T3.2 and T3.6

Again with only changing platform.txt like:
## Create archives
archive_file_path={build.path}/{archive_file}
recipe.ar.pattern="{compiler.path}{build.toolchain}{build.command.ar}" rcs "{archive_file_path}" "{object_file}"
##recipe.ar.pattern="{compiler.path}{build.toolchain}{build.command.ar}" rcs "{build.path}/core/{archive_file}" "{object_file}"

Note the ## line is what is in the released file. (minus ##). Also the change works fine with normal Arduino build

So far I have it working ok using the teensy loader, however TYQT setup current fails. The problem is that it can not find the HEX file.

The problem is that the TyQt code add the recipe:
recipe.objcopy.tyqt.pattern="{compiler.path}{build.toolchain}{build.command.objcopy}" {compiler.elf2hex.flags} "{build.path}/{build.project_name}.elf"

Which makes a new file name like: ...\arduino_build_548836/Blink.ino.TEENSY31.hex"

This step is not done in Stino and as such when it launches tyqt with this file name it does not find it...

Again will see how hard to integrate...
 
I take it SubLime is your editor of choice and you've made it over this hurdle?

Mastering Sublime Text Takes Time
Mastering Sublime Text requires time and practice. Luckily, it’s built around a handful of concepts that make for a consistent system once all the pieces come together.

I'm watching hoping to see it work for you to usably have an All in one build environment.

The other thing I'd try would be MS Visual Studio and VisualMicro.

Both would be a learning curve . . .
 
... just finished reading p#4 . . .
I suppose you looked at the changes TYQT makes when 'Integrate to Arduino' is selected? When I mentioned it was cool how TYQT incorporated the TEENSY## in the file he noted he did not do that. But it works as done from the IDE to pass the right file to TYQT.
Koromix - given time - might work out your issue.
What's stino?
 
Yes, currently Sublime text is my main editor. For quite awhile I was using Programmers Notepad, but it was mainly only available on PC. Sublime Text also works on Mac, Linux...

I like some of the tools like Visual Studio and Visual Micro, as they do a lot of great stuff, but for most things now, I like using Sublime text as it is pretty light weight. I don't know all of it yet, like
setting up projects and the like, which probably work great, but I simply do things like, use the open folder command and later open recent command which gives a list of recent open files and folders.

So for example when I am working on fixing Teensyduino installed stuff, I might open: c:\arduino-1.6.12\hardware\teensy

Then I do a lot of Search files, to find where everything is referenced. Also it works in the background and often I can right click on something like a method and choose to goto the Definition...

Stino (https://github.com/Robot-Will/Stino) is a Python Add that someone wrote to add Arduino Build support into Sublime text. When I did a google search about Arduino support for Sublime text it showed up in several different places. It appears like the branch new-stino is the current and somewhat community supported branch. It took a little work to install. Though not bad, simply open the correct folder and copy Stino into it and then restart sublime text. The main issue is it did not work and found you need to delete a file, I believe it was: package-metadata.json

But back to TyQt: I added a hack to their python code to check for, the definition of: recipe.objcopy.tyqt.pattern if found, it processes it the same way that it processed the pattern: recipe.objcopy.hex.pattern

My guess, is the normal Arduino code looks for all: recipe.objcopy defines and enumerates them. The Stino code is pretty hard coded, it was doing:
Code:
        eep_cmd = self.params.get('recipe.objcopy.eep.pattern', '')
        hex_cmd = self.params.get('recipe.objcopy.hex.pattern', '')
        # TEENSY BUILD TYQT
        tyqt_cmd = self.params.get('recipe.objcopy.tyqt.pattern', '')
        # END TEENSY
So now it appears like, it can generate it's special file name (not sure why?) and TYQT is launched and does update the chip. I still get a beep from somewhere? But at least it appears to be functional.

One nice thing by doing this, with newer Arduino builds, I was getting some warnings in some of my libraries, which I never got around to fixing. But with this, it actually loaded the file up out of the (my documents)\arduino\libraries and marked all of those lines. So I went ahead and fixed them.

Today I went ahead and issued Pull Request to main Stino... Not sure if/when it might be picked up. Sounds like main person who did Stino is maybe not doing much, but is supported by community.
 
Paul: I would do a pull request to try to get the simple change to how the archive command is built to make it compatible

Again it is changing:
Code:
recipe.ar.pattern="{compiler.path}{build.toolchain}{build.command.ar}" rcs "{build.path}/core/{archive_file}" "{object_file}"
to
Code:
archive_file_path={build.path}/{archive_file}
recipe.ar.pattern="{compiler.path}{build.toolchain}{build.command.ar}"  rcs "{archive_file_path}" "{object_file}"
Probably could be done in one line, but followed what was in the Arduino/avr/platform.txt file

Also talking about the Arduino platform.txt, was wondering about some of the stuff in the Arduino builds. Not sure how much it is used on standard Arduino AVR boards.

Their actual recipe.ar.pattern looks like:
Code:
## Create archives
# archive_file_path is needed for backwards compatibility with IDE 1.6.5 or older, IDE 1.6.6 or newer overrides this value
archive_file_path={build.path}/{archive_file}
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"

They up earlier in the file define things like: compiler.ar.flags=rcs

Again would be easy to do same, but in addition they define: compiler.ar.extra_flags=
Under a comment: # These can be overridden in platform.local.txt

They also define other extras like: compiler.c.extra_flags=

So far I don't see very little documentation on the platform.local.txt, but from some Arduino forum postings, it looks like the intent was to allow you to override some of the defaults. But unclear on where these files can be located. For example could these be put into a sketch folder to allow me to define some extra options to the compiler? If this does work with other boards, does it make sense to add these "extra" defines to usage to the Teensy platform.txt file?

Just wondering.
 
You still need to update the platform.txt file, which I still need to do to the new released version.

But can work reasonably... At least it allows me to edit both the sketch as well as the libraries I am working on at the same time... A still mostly use the IDE, but helps to do fast debug...
 
Cool - I haven't sat down with the intent on trying it yet - not sure If I could expect it to work in the end.

If you do the platform.txt update and find it to work with steps posted above I'll give it a look.

I'm still using Source Insight I left my last job in 1998 with (though still supported and updated in 2016 and sold at $239/user). My use has been so casual I forget much of what I knew - so I may as well start fresh.
It does an AWESOME job of GREP across any source tree you point it at and jumping right to definition(s) of any object you point it at. And quick access to any file in that tree. Will look into Sublime - hopefully this means it is similarly capable?
Use Goto Anything to open files with only a few keystrokes, and instantly jump to symbols, lines or words.

< Looks like this came with Sublime Text V.3 in 2013 so maybe by now it will be as good as my 20 year old tool :) >
* Also new in 3124 is Show Definition, which will show where a symbol is defined when hovering over it with the mouse.
* Some of the core features in Sublime Text 3 are Goto Definition and Goto Symbol in Project. Both of these work by indexing the files in the current project to determine where each symbol is defined.
* Symbol Indexing, for Goto Definition and Goto Symbol in Project. Complementing these are the Jump Forward and Jump Back features.

Just downloaded: Sublime Text 3, Build 3126, 64 bit

Buying it for $70 is a good indicator! That is a reasonable price - and Per-user! - I hate free stuff that isn't "OWNED" Buy me and by those responsible for it.
Sublime Text may be downloaded and evaluated for free, however a license must be purchased for continued use.
Licenses are per-user, rather than per-machine, so you can enjoy Sublime Text on as many computers and operating systems as you wish with your license
 
Yep - When I left work, I used to use Visual Slick (https://customer.slickedit.com/) Actually used to use their non windows version back a long time ago.
But again at about $300 per user for single platform...

I have bounced around using different editors and the like, but this last year moved over to sublime as it appears to do most everything I need to do, plus works on every platform and is light weight enough that it does not take forever to startup.
 
Yeah SlickEdit was the other option I heard of in use - I only looked at SourceInsight and found it to be a good tool. Odd now it says 239/user - not sure if that is multiple machines - but the two copies I was given as I left were each single machine.

Indeed one of the features of the Sublime V 3.0 was faster startup which is nice. I've been using NotePad++ as a minimal editor I just put on ANY machine - sounds like I can stop not using that well and maybe learn SubLime Text and be satisfied.
 
Kurt - Have you tried FrankB's defs.h scheme for 'command line' like build enhancements?

NOW I have better context for Stino:: hackaday.com sublime-text-as-an-arduino-ide - reading the above will make more sense now. Had to 'Tools / Install package control' - that is covered differently in following link.

Directions HERE to install Arduino-like IDE

Now I have the Arduino menu! More in some hours . . .

As far as Editor pointing to Teensy installed code::
I just pointed it to the Teensy folder there and it found all refs to USB_init - faster than SourceInsight ( better cache indexing )!
Hover the mouse over yield() and it pops up the list of files that contain it - faster than SourceInsight - and keyboard mouse button has a 'goto definition' when you don't want to leave keyboard!
Also supports text resize Ctrl+wheel or Ctrl+, Ctrl- : Source insight is lacking this fit text to screen!

New keys to learn - but intuitive and some features won't require a hotkey!

Now I just need to read your posts to see how well it integrates and if it can kick off a compile and work with TYQT . . .

I changed color scheme to Sunburst - nice colors without the olde schoole white background.
Has F11 Full Screen!
And like IE - Ctrl+Shift+T to reopen closed file.
"Properly" works the menus with mouse and keyboard!
As noted - seems intuitive enough - o
 
Sounds like you are making progress.

I started looking around for an editor early this year, when I was jumping back and forth using my MAC notebook as secondary setup (it is setup with MAC os, plus windows and Ubuntu). I had been mainly using programmers Notepad, but that only worked on PC. Sometimes on MAC was using Text Wrangler which has some interesting capabilities, like an easy way to setup to edit remote files (on Odroid or the like), but... So I asked on Trossen Robotics forum and got several positive comments for sublime...

As I think I have said, I am not a complete power user. I too use the open folder (as well as the open recent - with the folder list), and often have a couple of sublime windows open. One on my Arduino install (typically at hardware\teensy), and another one open either on my <user>/Arduino folder or <user>/Arduio/Libraries folder. Could probably setup projects for this, but ...

There are lots of other contributed additions one can install. I have installed a few, like I believe I have one on that allows for some more window layouts. Also I don't remember if the bookmarking was a default or if I had to add. I experimented with a file merge add on, but found I preferred using WinMerge or Meld(Linux) And I simply use the two column mode to do manual merges (ALT+SHIFT+2)

As you mentioned, it does a pretty good job of tagging items. I also use the find in files a lot to find everywhere something is used.

I think I am currently using the cobalt color scheme.

Now back to playing around... Merging in Origin/Clip rectangle into ili9341_t3n
 
Using Sublime Text to edit the cores files is working well, not integrated to compile yet. Great global search! And very good UNDO.

One thing I find is I can't open a second instance - I like Alt+Tab between CORES and SKETCH code?
 
I use Sublime as well, but I'm not fond of the fact that it seems to match my typing against anything (not having an indication of what is a variable, a function, or an #def).
Also, is lacking the context pop-up (forget the proper name) where it shows the comments for a function.
 
Hi Defragster,

Not sure exactly when you say open second instance...

But you can have multiple open windows, a few different ways.
Example: I simply go to File->OpenRecent and select one of the previous open folders (bottom of list), which opens in new top level window. Same for Open Folder

Currently I have two windows opened for: C:\arduino-1.6.12\hardware\teensy\avr\ and C:\Users\Kurt\Documents\Arduino\libraries\

Or I use File->New Window - Which again opens a new Top level window.

Or if I have a file open that I want to display in different top level window, I use the mouse to drag the tab out of the top main window and if not in another sublime-text window it opens new window, if in Sublime it puts that tab that window.

Or if I wish to edit the same file with two views of it I use: File->New view into file
 
Hi Defragster,
...
Currently I have two windows opened for: C:\arduino-1.6.12\hardware\teensy\avr\ and C:\Users\Kurt\Documents\Arduino\libraries\

Or I use File->New Window - Which again opens a new Top level window.
...

Top level - where Alt+Tab works ... too many stacked sub-windows gets ugly quick.

Thanks - some of those I hadn't tried . But just hitting the EXE twice didn't do it and touching something under project did a new TL window once - but not the view I wanted.

Between Source Insight and Notepad++I've learned a few ways that don't match the 'Project' style of ST. Those two and the IDE and you told me open a new instance when RUN a second time - SubLime doesn't

I use Sublime as well, but I'm not fond of the fact that it seems to match my typing against anything (not having an indication of what is a variable, a function, or an #def).
Also, is lacking the context pop-up (forget the proper name) where it shows the comments for a function.

So you mean auto complete of syntax coloring - for matching?

If you open a folder/project and it 'greps' it all you get the 'tool-tip'? But when I did a Quick Switch Project yesterday to try to try a new instance - then those tool-tips went away on Hover. I did a project for installed teensy and it works with that open.
 
I should note, that at times, I will also use multiple columns (and or rows) to be able to see multiple files in the same window at the same time:
View->Layout->Single or ... (ALT+SHIFT+1) back to single, (ALT+SHIFT+2) Two columns.... I also installed some add on to allow custom 3 pane...

I use this mode for example when I am merging changes in from lets say one library to another...
 
So are only the changes in #4 needed to get it to find the compiler and compile or do I need to do changes in #1-#3 too? Sublime runs ok but can't find the compiler here. I ran the installer for stino.
 
Also am I understanding this correctly,it's the exact same compiler behind the normal Arduino ide and wit Atmel studio it's a different compiler? Code size is very slightly different when I use Atmel studio.
 
To work, you need the changes that I have in my version of github for STINO, plus you need to edit the platform file, like I mentioned.

To find the compiler and the like, you need to go into the Arduino/Preferences/Select Arduino... menu item, and browse to where you installed Arduino. You may also need to go through some of the other menu items here to select your sketch folder and your libraries folder.

Yes it uses the compiler(s) installed with Arduino. As for Atmel Studio, you are probably using some other add on as atmel does not make the Teensy processors. I only used this when doing stuff for some AVR processors, like when I was playing with some Atmega32u4 processors. I have used Visual Micro stuff, which I think can add on here, but I have it installed directly with Visual Studio... I don't remember if some of these may install their own copy/version of compiler, if so probably GCC? Could be different version. Or could simply be different compiler options or...
 
You're correct I'm using Visual Micro with Atmel Studio. It integrated so well I almost forgot about it. I'll try to get Sublim to find the compiler this afternoon with the code on your get hub and changes in post #4. I like what I have seen of Sublime 3. Thanks again.
 
Back
Top