Forum Rule: Always post complete source code & details to reproduce any issue!
Page 2 of 6 FirstFirst 1 2 3 4 ... LastLast
Results 26 to 50 of 147

Thread: Compiling Teensy Sketches with VisualCode (Win10)

  1. #26
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    7,052
    Got the two EXE's: luni64/VisualTeensy/releases
    Installed Ver 1.27 of visual studio code
    Installed c/C++ extensions: ms-vscode.cpptools

    Doing Expert setup - as my install is ZIP variety on Windows:
    > I have my boards.txt: T:\arduino-1.8.7_144_TYC\hardware\teensy\avr
    > Not sure what the :: 'Path to TeensyCore Library' is asking for? :: T:\arduino-1.8.7_144_TYC\hardware\teensy\avr\cores\teensy3
    > And Compiler folder? :: T:\arduino-1.8.7_144_TYC\hardware\tools\arm

    All it should need is the root of my IDE/TeensyDuino UnZip folder?

    I got a build - but no upload with TyCommander? Does it use the GUI? How does it link to it? I get this error text:
    > Executing task: T:/Programs/VisualTeensy/make.exe upload -j -Otarget <

    process_begin: CreateProcess(NULL, \teensy_post_compile -test -file=BlinkMin -path=bin -tools= -board=TEENSY36 -reboot, ...) failed.
    make (e=2): The system cannot find the file specified.
    make: *** [makefile:104: upload] Error 2
    The terminal process terminated with exit code: 1

  2. #27
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    306
    Interesting, can you try the Quick setup first? All you should need to enter is "T:\arduino-1.8.7_144_TYC" in the Arduino folder field. The rest should be derived automatically. If you want to use TyCommander you need to enter the path to the TyTools folder in the setup Tab.
    Can you give that a try and post the first lines of the makefile or a screenshot of VisualTeensy?


    > I have my boards.txt: T:\arduino-1.8.7_144_TYC\hardware\teensy\avr
    > Not sure what the :: 'Path to TeensyCore Library' is asking for? :: T:\arduino-1.8.7_144_TYC\hardware\teensy\avr\cores\teensy3
    > And Compiler folder? :: T:\arduino-1.8.7_144_TYC\hardware\tools\arm
    That looks all good. You probably didn't set the path to the teensy uploader in the setup tab correctly. That should be "T:\arduino-1.8.7_144_TYC\hardware\tools". Need to make a better desrciption...
    Last edited by luni; 09-23-2018 at 11:06 PM.

  3. #28
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    306
    The autoconf feature at the first startup does only look in C: for installed Arduino and TyCommander. Silly me. I'll extend that to all found volumes.

  4. #29
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    7,052
    All Okay doing quick with "T:\arduino-1.8.7_144_TYC" worked to find the IDE install.

    I missed understanding that apparently and then found the unvisited Setup Tab - it now knows where TyTools are located and works perfectly!

    This looks good - except the 1,500+ INO files in my sketchbook directory are IDE INO Hacks not cpp.

    And understanding how the sketchbook\libraries folder will get referenced for those needed files? Explicit path to #include "T:\tCode\libraries\debug_t3\debug_t3.h" ends in may "undefined reference to …" I'll need to resolve.

    And then a new editor to learn - and this environment and the Multi_Teensy built noted above.

  5. #30
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    306
    Glad that it works. Once you get used to intellisense, code completion and all the other stuff (have the cursor on e.g. digitalWriteFast(...) and press F12...) you'll not want to go back :-).

    Translating .ino to .cpp:
    - make sure that the functions are defined before you use them. Arduino is doing that for you in the background. Usually it is enough to have loop() and setup() at the end of the sketch.
    - Libraries can be tricky, for now the best is to copy the used lib to a subfolder of the src folder. I'll have a library manager soon. I can post an example showing how that works. Any "difficult" library you'd want to see?

  6. #31
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    7,052
    Indeed back to 'c' rules with functions manually prototyped versus the INO way, took care of that.

    I just got and paid for an awesome new editor SublimeText I'm getting used to - switching to a new one with alternate autocomplete and such will be a learning curve. I'll still use that { as I do now with IDE } as it supports global search across the WHOLE of Teensy installed libs!

    I just put my debug_t3 library into "T:\Programs\VisualTeensy\Source\DebugMin\src" and then it builds with: #include "debug_t3\debug_t3.h"


    I made a special Dir for T:\Programs\VisualTeensy on my SSD - where I do all my Teensy stuff. That DIR holds the make and VisualTeensy.exe's.

    I put the Source folder there. If the libraries Folder were linked from there {in or above?} it would mirror the IDE's sketchbook directory layout. As it is even an explicit path is rooted to : 'src/debug_t3\debug_t3.h' and fails.

    Having an independent copy of each library used in each source folder makes library updates tedious, how it is done for pulling Teensy Core libs is nice where they pull from a fixed update location.

    I'll have to do more with it to figure out the makefile creation and process with VisualTeensy.exe.

    But it works well and quickly from what I've tested so far. Two small sketches are consuming 8.6 MB in the Source folder compiled for just one T_3.6

  7. #32
    Senior Member
    Join Date
    Jul 2014
    Posts
    1,938
    @luni,
    just realized that there is an Arduino for VSCode extension.
    Any reason (apart for not touching VSCode) for not using that path?

  8. #33
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    7,052
    Quote Originally Posted by luni View Post
    Sure, that can be done. Just tried it, works great. It needs a little manual tweaking of course:

    • Generate a project for say a T3.6. Then rename the generated makefile to makefile_36.mk (or any other name you prefer)
    • Go back to VisualTeensy, change the board to a Teensy 3.2 and update the project. Rename the newly generated makefile to makefile_32.mk.


    • To avoid the need for deleting all binaries and rebuilding for the new board whenever you switch boards, we let both makefiles generate their own seperated binaries. To achieve this you need to open the makefiles and adjust the BIN variable from BIN := bin to BIN := bin32 and to BIN = bin36 respectively. Now all binaries go into those folders instead of the standard ./bin folder.


    • Last but not least we need two build commands. One for T3.2 and one for T3.6. So, lets open tasks.json and rename the build command to "Build T3.2" and add a "--file=.\\makefile_32.mk" to the args. After that, copy the complete command, rename it to "Build T3.6" and change the file argument to "--file=.\\makefile_36.mk".


    That's it!. You now have a project with 2 build commands one for the T3.2 build the other for the T3.1 build. Both commands build from the same source of course. The corresponding hex files live bin32 and bin36 respectively. This can be improved of course, but for a quick test it should be good enough. BTW: as always, it sounds much more complicated than it really is.
    Trying these steps - I renamed to mk_36, then edit mk to have unique bin, then edited the json entry - went to make a version for T_LC and it wiped my json edits

    Would it be possible to have the VisualTeensy.exe make these edits upfront for all or selected Teensy versions? Then VisualTeensy could be re-run without overwrite.

    Let me know if you see a way to do a shared source for Libraries - I'll test it out.

  9. #34
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    7,052
    Quote Originally Posted by WMXZ View Post
    @luni,
    just realized that there is an Arduino for VSCode extension.
    Any reason (apart for not touching VSCode) for not using that path?
    See posts #2 and #4 … doesn't offer help for Teensy

  10. #35
    Senior Member
    Join Date
    Jul 2014
    Posts
    1,938
    Quote Originally Posted by defragster View Post
    Check out addition to post #1 - Added above link and copied the open of the Readme with links.
    must have forgotten the early posts :-(

  11. #36
    Senior Member
    Join Date
    Jul 2014
    Posts
    1,938
    Now, I also have to learn c#

    Before doing that and customize the code to my 0.1% users relevant requirements, I will ask first

    I note that rtc_localtime symbol is not estimated, how difficult is it to do that in the makefile and to generate a task that forces a relink for every upload ?

    on an eclipse base system I added the following (windows relevant ) instruction

    Code:
    -Xlinker --defsym -Xlinker __rtc_localtime=$$(date +%s)
    I guess, It should be the same, right?

  12. #37
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    306
    Quote Originally Posted by WMXZ View Post
    @luni,
    just realized that there is an Arduino for VSCode extension.
    Any reason (apart for not touching VSCode) for not using that path?
    @WMXZ as defragster already wrote, it currently doesn't support teensy, but I'm sure it will soon.

    Just my personal opinion / use case:
    I like clean build systems which do as little as possible behind the scenes to avoid being dependent on them in the long run. I had a few very bad experiences with old projects needing a fix or some enhancements years after the launch. Of course the original IDE didn't work in my new operating system, or they changed some libraries which are not compatible to my old code anymore etc... Even if you get it compiled in the new system, you probably need to go to all the testing again since you might have broke something...

    I therefore always try building with standard tools. In fact VisualTeensy can easily set up a project that only depends on "gnu make" and the "gcc compiler". You don't need VisualTeensy after generation of the project, you don't even need vsCode. If you want, you can simply say "make" on the command line and it will build the project. This is somehow very reassuring for me :-)

    The good thing with vsCode is that I get all the conveniences of a modern IDE without the price of being dependent on it. So, this is a somehow ideal solution for me.

  13. #38
    Senior Member
    Join Date
    Jul 2014
    Posts
    1,938
    Quote Originally Posted by luni View Post
    I like clean build systems which do as little as possible behind the scenes to avoid being dependent on them in the long run.
    me too, but I only was curious, and forgot earlier posts.

  14. #39
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    306
    Quote Originally Posted by defragster View Post
    Trying these steps - I renamed to mk_36, then edit mk to have unique bin, then edited the json entry - went to make a version for T_LC and it wiped my json edits
    Would it be possible to have the VisualTeensy.exe make these edits upfront for all or selected Teensy versions? Then VisualTeensy could be re-run without overwrite.
    Hm, that would be a solution for a very special use case and would be somehow confusing for normal users? I'll think of something to solve this but I want to do that library manager first.

    Let me know if you see a way to do a shared source for Libraries - I'll test it out.
    Yes, first version of the makefile is working already (no GUI yet) if you would like to test it (which I would appreciate very much), I can send you a beta later today.

  15. #40
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    306
    @defragster:

    here a quick improvement of the procedure to do mulitple target builds described in #20. Add a new makefile with the following contents, name it "makefile" and copy it to the root folder

    Code:
    all:
    	@$(MAKE) -j -Otarget --no-print-directory -f ./makefile_32.mk
    	@$(MAKE) -j -Otarget --no-print-directory -f ./makefile_36.mk
    
    clean:
    	@if exist bin32 rd /s/q bin32
    	@if exist bin36 rd /s/q bin36

    With this makefile you don't need to touch tasks.json at all. Just do a normal build and it will generate the firmware for all your target boards automatically. (Doesn't solve the overwrite problem of course)

  16. #41
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    306
    Here: https://github.com/luni64/VisualTeensy/issues/1 you can download a first prototype of the library management functionality. Currently you have to manually enter a list of the used libraries in the autogenerated makefile. This will be done in the next step by the GUI of course. Any tests and bug reports very welcome.

    Click image for larger version. 

Name:	libman.png 
Views:	8 
Size:	69.3 KB 
ID:	14810

  17. #42
    Senior Member
    Join Date
    Jul 2014
    Posts
    1,938
    OK,
    I have some difficulties installing the system (better compiling)
    Windows 10
    sketch
    Code:
    #include "Arduino.h"
    
    //#include "core_pins.h" // this call also kinetis.h
    #include "Audio.h"
    
        AudioInputAnalog  acq(0);
        AudioRecordQueue  queue;
    
        AudioConnection     patchCord(acq, queue); 
    
    void setup()
    {
      AudioMemory (10);
    
      pinMode(LED_BUILTIN,OUTPUT);
    }
    
    void loop()
    {
    
      digitalWriteFast(LED_BUILTIN,!digitalReadFast(LED_BUILTIN));
      delay(100);
    }
    c_pp_properties.json
    Code:
    {
      "configurations": [
        {
          "name": "VisualTeensy",
          "includePath": [
            "${workspaceFolder}/src/**",
            "C:/Users/Walter/Documents/arduino-1.8.7/hardware/teensy/avr/cores/teensy3/**",
            "C:/Users/Walter/Documents/arduino-1.8.7/hardware/teensy/avr/library/audio/**"
          ],
          "defines": [
            "__MK66FX1M0__",
            "TEENSYDUINO=144",
            "F_CPU=180000000",
            "USB_SERIAL",
            "LAYOUT_US_ENGLISH"
          ],
          "compilerPath": "C:/Users/Walter/Documents/arduino-1.8.7/hardware/tools/arm/arm-none-eabi/bin/bin/arm-none-eabi-gcc.exe",
          "intelliSenseMode": "gcc-x64"
        }
      ],
      "version": 4
    }
    error
    Code:
    > Executing task: C:/Users/Walter/Desktop/Luni/make.exe all <
    
    [CC] CORE usb_serial.c
    /usr/bin/sh: -c: line 1: syntax error: unexpected end of file
    make: *** [makefile:120: bin\core/usb_serial.o] Error 258
    The terminal process terminated with exit code: 1

    the incriminating line is

    Code:
    @if not exist $(dir $@)  @mkdir "$(dir $@)"

    interesting, if I add as makefile target
    Code:
    test:
    	ls
    	dir
    I get
    Code:
    PS C:\Users\Walter\Documents\Arduino\Test_Code> make test
    ls
    bin  makefile  src
    dir
    process_begin: CreateProcess(NULL, dir, ...) failed.
    make (e=2): The system cannot find the file specified.
    make: *** [makefile:104: test] Error 2
    PS C:\Users\Walter\Documents\Arduino\Test_Code>
    that is only the Linux command ls is known to make but not the windows dir (both give on PS the same result)

  18. #43
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    306
    Looks like make tries to use /usr/bin/sh as shell not the usual windows shell. Maybe you have some environment variables set which are evaluated by make so that it starts a linux shell? I'll have a closer look into that.

  19. #44
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    306
    Can you check the value of the ComSpec and SHELL (if set) environment variables? (Just type SET in a command window)

    EDIT:
    can you add the lines

    Code:
    SHELL := cmd.exe
    export SHELL
    at the top of the makefile and see if it works then?

    Click image for larger version. 

Name:	shell.PNG 
Views:	4 
Size:	14.0 KB 
ID:	14821
    Last edited by luni; 09-25-2018 at 01:22 PM.

  20. #45
    Senior Member
    Join Date
    Jul 2014
    Posts
    1,938
    Quote Originally Posted by luni View Post
    Can you check the value of the ComSpec and SHELL (if set) environment variables? (Just type SET in a command window)

    EDIT:
    can you add the lines

    Code:
    SHELL := cmd.exe
    export SHELL
    at the top of the makefile and see if it works then?
    Now it works.

    Maybe previous problem is because I have ubuntu for windows (AKA windows subsystem for Linux (WSL)) installed?

  21. #46
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    306
    Yes, that makes sense. I added the shell defnition to the autogenerated makefile already. Thanks for finding this one...


    Above you wrote:
    I note that rtc_localtime symbol is not estimated, how difficult is it to do that in the makefile and to generate a task that forces a relink for every upload ?
    on an eclipse base system I added the following (windows relevant ) instruction
    Code:
    -Xlinker --defsym -Xlinker __rtc_localtime=$$(date +%s)
    I guess, It should be the same, right?
    I'll have a look at this. I assume it is for the built in RTC? Do you have any documentation or forum link on the feature?

  22. #47
    Senior Member
    Join Date
    Jul 2014
    Posts
    1,938
    Before searching info on rtc_localtime here another issue
    compiling the audio library there is an include file missing issue
    Code:
    C:\Users\Walter\Documents\arduino-1.8.7\hardware\teensy\avr\libraries/Audio/analyze_fft1024.cpp:29:26: fatal error: sqrt_integer.h: No such file or directory
    compilation terminated.
    make: *** [makefile:163: bin/lib/Audio/analyze_fft1024.o] Error 1
    The terminal process terminated with exit code: 1
    Now, sqrt_integer.h file is in Audio/utility among other include files

    strange enough, the cpp file has at lines 29/30
    Code:
    #include "sqrt_integer.h"
    #include "utility/dspinst.h"
    As this never was coming up as an error in all my previous compilations, maybe Arduino can handle this,
    and it should be an issue for Paul, but I bring it up anyhow

  23. #48
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    306
    Interesting , can you post the first lines of the makefile?

  24. #49
    Senior Member
    Join Date
    Jul 2014
    Posts
    1,938
    some info on rtc_localtime is in thread https://forum.pjrc.com/threads/47988...tes-wrong-time

  25. #50
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    7,052
    VisualMicro Add-on recently had posts about adding in the localtime created at each compile- not sure if the details can be found from that perhaps
    Last edited by defragster; 09-25-2018 at 06:24 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •