Compiling Teensy Sketches with VisualCode (Win10)

Didn't find a place yet where to read the information out of the current installation...

platforms.txt says something like this
Code:
-DARDUINO={runtime.ide.version}
guess runtime.ide.version is set by Arduino

anyhow
Paul's makefile says
Code:
OPTIONS += -D__$(MCU)__ -DARDUINO=10805 -DTEENSYDUINO=144

and
mk20dx128.c
has
Code:
#if ARDUINO >= 10600
		rtc_set((uint32_t)&__rtc_localtime);
#else
		rtc_set(TIME_T);
#endif
 
@Luni
I would like see two features implemented
- possibility to use a Teemsy_loader_cli (would open path to custom teensy loader)
- possibility to launch a monitor (e.g. putty) (maybe this is already there but could not find it)
any chance?
 
Sure, launching any program shouldn't be a problem. Do you know the command line arguments of the Teensy_loader_cli?
Before I started using TyTools I used putty as serial monitor. Works perfectly if you connect it to a dedicated serial port but usinig it with USB Serial is a pain because it grabs the port so that you need to manually quit it before uploading.

Any reason not to use TyTools? The integrated serial monitor is just pefect?
 
VisualTeensy Release Candidate V0.8.2

Just published a new release candidate of VisualTeensy on Github https://github.com/luni64/VisualTeensy/releases/tag/0.8.2.

Changes/improvments:

Libraries
It now has a library manager which currently supports the following repositories:

  • Libraries from the Arduino sketchbook
  • Teensyduino libraries
  • The huge web repository from the Arduino IDE library manger. Those libraries are automatically downloaded.

Uploading
In addition to the Teensy.exe GUI and TyCommander it now also supports the PJRC CLI uploader (thanks WXMZ)

GUI
  • Added a standard File menu (New, Open, Save, Save as)
  • Simplified the Quick setup mode

ToDo:
  • Search filters on the library tab
  • Auto dependency for the libraries
  • Allow users to add additional library repositories
  • Multi configuration builds. I.e. automatically build for several target boards or for different settings. (Might be useful for testing libraries...)

Here a screenshot of the new library manager:

libman.PNG
 
That looks very good. I hope to try it out again soon.

And yes, TyTools is just about perfect … Thanks @Koromix!
> It handles selective uploading to multiple connected Teensys, with auto USB swap to program
> Serial Monitoring of multiple Teensys
> Nice GUI and device info
> Persistent output onscreen ( when desired ) - adjustable buffer size and auto saved to a file
> Reset button
> Bootloader to Pause
> No JAVA overhead as a stand alone EXE
 
I just updated to the RC2 version and copied over my open Dhrystone sketch from the T_3.6 OC to 256 MHz thread and it worked!

That uses an alternate CORE from Frank_B with timing adjustments to support OC of the 180 MCU beyond 240 MHz to 256 MHz. It is a single file program with no libraries - but the create uses an updated boards.txt to define the new speed.

It built the makefile correctly and created a usable HEX with no problem. The first time in creation I did not specify desired 256 MHz speed and optimization, I restarted VisualTeensy made the changes and they were properly applied! I have an update pending for 'Visual Studio Code' and that applied correctly and the build worked.

Two things I note:
> Building with IDE to Tycommander allows selecting one or more - in my case 5 T_3.6's to send the same HEX to. For some reason what works in the IDE does not under VisualTeensy as only a single device can be selected from the list for upload?
> When built in the IDE the code compiled "Fastest, pure-code with LTO" had a count selected that resulted in exactly 100,000 microseconds used in Dhrystone loop execution on all 5 T_3.6's - on multiple compile/upload cycles. Occasionally 1 or 2 T_3.6's would use 100,001 us.
--- when built with VisualTeensy the T_3.6's somehow come out to these 'slightly higher' values suggesting something is not building the same:: Micros Run Time: 100008, 100009, 100009, 100008, 100014. On two GUI resets of each they all stabilized to 100009

Question: Could VisualTeensy be added as a Build Task in tasks.json? This would allow project adjustments within without leaving VScode to find a way to run VisualTeensy.exe

Good work! That piece of code is much more colorful and readable than in the Arduino IDE.

Here is the project folder in case it helps - of course it won't build without the 256 MHz CORE: View attachment Dhrystone.zip

<Update > Of course it can be built at 240 MHz - just longer runtime - and still a small 4/106671 part difference::
> IDE on all 5 T_3.6's gives: Micros Run Time: 106671
> Visual Teensy gives: Micros Run Time: 106675 or 106676 on Reset, but the first exec on upload had a 106681 and 106686 as well.
 
Last edited:
Great that it worked without problems.

I tried your attached benchmark with the same settings as you suggest on two T3.6. Both gave 100018. The result seems to be somehow dependend on the hardware? Anyway, I'm really interested if VisualTeensy builts differently than the IDE. It is definitely possible that I have some compiler flags wrong. Could you post the IDE compiler log of a build which gave the different results?

Also a log of the call to TyCommander would be great. Maybe I missed a commandline parameter to enable multiple uploads?

Question: Could VisualTeensy be added as a Build Task in tasks.json? This would allow project adjustments within without leaving VScode to find a way to run VisualTeensy.exe
Good idea, will add that in the next version.

BTW: During testing with Franks core I found a small bug when changing the core library folder from the standard location to a folder with Franks core. I'll fix that also in the next version.
 
Complete fresh build verbose attached.

I see this answers TyComm --multi:
T:\TyComm\TyCommanderC.exe upload --autostart --wait --multi T:\TEMP\arduino_build_133842/DHRYSTONE.ino.TEENSY36.hex

I just did a multi upload from IDE and all Five are 100000 us.
Micros Run Time: 100000
MilliSeconds Run Time: 100
CycleCount Run Time: 25600041
F_CPU: 256000000
Microseconds for one run through Dhrystone: 0.000895167002
Dhrystones per Second: 1117110.000000000000

The cycles counts may be +/- ~ 50, and small diff's on 1 or 2 units sometimes adds 1us - not surprising.
 
Hm, checked everything found no differences in compiler and linker flags. Here my output.

Code:
Micros Run Time: 100018
MilliSeconds Run Time: 100
CycleCount Run Time: 25604700
F_CPU: 256000000
Microseconds for one run through Dhrystone: 0.000895167002
Dhrystones per Second:            1117110.000000000000

I didn't dig into the Dhrystone code so I can't judge if the difference is related to something in the build or hardware related. Can you post your *.hex just to be sure?
 
> Building with IDE to Tycommander allows selecting one or more - in my case 5 T_3.6's to send the same HEX to. For some reason what works in the IDE does not under VisualTeensy as only a single device can be selected from the list for upload?

Tried it, works without problems for me.
 
I edited makefile to include "--multi" and it was all that was needed for TyComm.
UPL_TYCMD := $(UPL_TYCMD_B)\tyCommanderC upload $(TARGET_HEX) --autostart --multi

Hm, checked everything found no differences in compiler and linker flags. Here my output.

Code:
Micros Run Time: 100018
MilliSeconds Run Time: 100
CycleCount Run Time: 25604700
F_CPU: 256000000
Microseconds for one run through Dhrystone: 0.000895167002
Dhrystones per Second:            1117110.000000000000

I didn't dig into the Dhrystone code so I can't judge if the difference is related to something in the build or hardware related. Can you post your *.hex just to be sure?

Look in the ZIP posted before - I left the HEX in there :: Dhrystone.zip\Dhrystone\bin

That is similar to what I see with VisualStudio - 18 wasted microseconds! In my last (VisualTeensy) build I get (4) of 100,009 and one of 100,008 with a Reset on each - for some reason their first run is more varied - different from IDE after upload.

Here is that HEX:

COOL - I see the MASM Listing file stored there in BIN too.

<EDIT>: To be sure I had same sources I just reset the INO in the IDE with the Main.cpp Source text and recompiled and it came out again at the expected :: Micros Run Time: 100000
Versus this from VisualTeensy :: Micros Run Time: 100009

I only have one 256 MHz source tree so they are both building from the same Arduino folder with Frank_B's Teensy Core.
 
Last edited:
Did a clean compile with the IDE (1.8.5, Settings: 256MHz, fastest + pure + LTO) which gives :

Code:
Dhrystone Benchmark, Version 2.1 (Language: C)
Program compiled without 'register' attribute
Please give the number of runs through the benchmark: 
Execution starts, 111711 runs through Dhrystone
Execution ends

Final values of the variables used in the benchmark:
Int_Glob:            5
        should be:   5
Bool_Glob:           1
        should be:   1
Ch_1_Glob:           A
        should be:   A
Ch_2_Glob:           B
        should be:   B
Arr_1_Glob[8]:       7
        should be:   7
Arr_2_Glob[8][7]:    111721
        should be:   Number_Of_Runs + 10
Ptr_Glob->
  Ptr_Comp:          536821216
        should be:   (implementation-dependent)
  Discr:             0
        should be:   0
  Enum_Comp:         2
        should be:   2
  Int_Comp:          17
        should be:   17
  Str_Comp:          DHRYSTONE PROGRAM, SOME STRING
        should be:   DHRYSTONE PROGRAM, SOME STRING
Next_Ptr_Glob->
  Ptr_Comp:          536821216
        should be:   (implementation-dependent), same as above
  Discr:             0
        should be:   0
  Enum_Comp:         1
        should be:   1
  Int_Comp:          18
        should be:   18
  Str_Comp:          DHRYSTONE PROGRAM, SOME STRING
        should be:   DHRYSTONE PROGRAM, SOME STRING
Int_1_Loc:           5
        should be:   5
Int_2_Loc:           13
        should be:   13
Int_3_Loc:           7
        should be:   7
Enum_Loc:            1
        should be:   1
Str_1_Loc:           DHRYSTONE PROGRAM, 1'ST STRING
        should be:   DHRYSTONE PROGRAM, 1'ST STRING
Str_2_Loc:           DHRYSTONE PROGRAM, 2'ND STRING
        should be:   DHRYSTONE PROGRAM, 2'ND STRING

Micros Run Time: 108788
MilliSeconds Run Time: 108
CycleCount Run Time: 27849869
F_CPU: 256000000
Microseconds for one run through Dhrystone: 0.000966780353
Dhrystones per Second:                      1034361.125000000000

Maybe I'm doing something completely wrong here. Output of both firmwares looks identical besides the difference in the performance.
 
Did you upload either of the HEX files and see what that shows?

Just realized it was probably one from the IDE that was requested …


Just built and uploaded that with these results:
Micros Run Time: 100000
MilliSeconds Run Time: 100
CycleCount Run Time: 25600009
F_CPU: 256000000
Microseconds for one run through Dhrystone: 0.000895167002
Dhrystones per Second: 1117110.000000000000

Three showed 100000, one this time clocked in at 100001 and one of the others 99999
 
With your IDE hex I get:
Micros Run Time: 100008
MilliSeconds Run Time: 100
CycleCount Run Time: 25602137
F_CPU: 256000000
Microseconds for one run through Dhrystone: 0.000895167002
Dhrystones per Second: 1117110.000000000000

Interestingly the "Microseconds for one run" and the Dhrystones per Second" are exactly the same as I get with VisualTeensy. Anyway, since the differences are very small (100018/100008 => 0.01%) I'll leave that for the time being. Maybe the difference comes from the preprocessing the IDE builder does before compiling.
 
Sounds like all is well, indeed it is a tiny difference - I just wanted to make sure there wasn't 'one more thing' needing attention that might break something more significant later. My counts of cycles is just over 2,000 lower too - where of course CycleCounts and MCU speed are tied with F_CPU - my five are showing CycleCounts between : 25599937 and 25600177 versus above 25602137.

My Pre-Beta K66 board and the 4 production units I have out are consistent. Odd that always using TyComm to upload that the IDE results in always the same usRunTime after Upload and Reset - and the VisualCode version gets one varying number after upload - and then more consistent when all are RESET. Did you hit RESET in TyComm and get the same numbers from the manual upload?
 
@luni

I had a problem when I first ran VisualTeensy (V0.8.2). I got an "Object not set" exception on startup.

I downloaded the source and stepped through it in debug. The problem turned out to be my non standard Arduino install directory (G:\Arduino). I had to manually edit VisualTeensy.exe.config and change the value in the setting arduinoBase (which was blank). After that all was well.

Many thanks for VisualTeensy!
 
Compiler cant find include files

I get several include errors like this: utility/dspinst.h: No such file or directory
How do I set up the include paths?
I tried to edit c_cpp_properties.json but I am not sure thats the correct location to edit...
Pls advice. Nice tool by the way! I hate the Arduino std IDE!!
 
I get several include errors like this: utility/dspinst.h: No such file or directory
How do I set up the include paths?
I tried to edit c_cpp_properties.json but I am not sure thats the correct location to edit...
Pls advice. Nice tool by the way! I hate the Arduino std IDE!!

the include files are specified in the visual-teensy program.
You may need to use expert setup
 
Hi, there is no include settings in the expert setup panel of my VisualTeensy V0.8.2
There is the possibility to add something to makefile however ... I have no idea what syntax to use for that
 
I get several include errors like this: utility/dspinst.h: No such file or directory
How do I set up the include paths?
I tried to edit c_cpp_properties.json but I am not sure thats the correct location to edit...
Pls advice. Nice tool by the way! I hate the Arduino std IDE!!

dspinst.h seems to belong to the audio library? Did you add the audio library (and its dependencies) using the library tab?
 
Just gave it a try, for the audio lib you would need the following libraries:

audiolibs.PNG

Hope that helps
 
That helped ....

but now I get these errors.

[LD] bin\visual_teensy_testproj.elf
bin/lib/Audio//output_i2s.o: In function `AudioOutputI2S::isr()':
C:\Users\user2\Documents\Arduino\visual_teensy_testproj/lib/Audio//output_i2s.cpp:101: undefined reference to `memcpy_tointerleaveLR'
C:\Users\user2\Documents\Arduino\visual_teensy_testproj/lib/Audio//output_i2s.cpp:105: undefined reference to `memcpy_tointerleaveL'C:\Users\user2\Documents\Arduino\visual_teensy_testproj/lib/Audio//output_i2s.cpp:108: undefined reference to `memcpy_tointerleaveR'collect2.exe: error: ld returned 1 exit status
make: *** [makefile:216: bin\visual_teensy_testproj.elf] Error 1
The terminal process terminated with exit code: 1
 
Hm, compiles without a problem here. Can you try a minimal example showing the problem and post or pm the sketch?
 
I think I already found it. There is an issue with assembly files in my makefile. I'll fix it and update the repo at github. Needs an hour or so.
 
Cool! Thanks!

Is it this file that causes an issue with your makefile ?
https://github.com/PaulStoffregen/Audio/blob/master/memcpy_audio.S
 
Last edited:
Back
Top