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

Thread: Compiling Teensy Sketches with VisualCode (Win10)

  1. #51
    Senior Member
    Join Date
    Jul 2014
    Posts
    1,938
    Quote Originally Posted by luni View Post
    Interesting , can you post the first lines of the makefile?
    Code:
    SHELL := cmd.exe
    export SHELL
    
    TARGET_NAME := myProject
    
    LIBS_SHARED_BASE := C:\Users\Walter\Documents\arduino-1.8.7\hardware\teensy\avr\libraries
    LIBS_SHARED	     := Audio Wire SPI
    
    LIBS_LOCAL_BASE  := C:\Users\Walter\Documents\Arduino\libraries
    LIBS_LOCAL       := 
    
    BOARD_ID    := TEENSY36
    CORE_BASE   := C:\Users\Walter\Documents\arduino-1.8.7\hardware\teensy\avr\cores\teensy3
    GCC_BASE    := C:\Users\Walter\Documents\arduino-1.8.7\hardware\tools\arm
    UPL_PJRC_B  := C:\Users\Walter\Documents\arduino-1.8.7\hardware\tools
    sketch same as in #42

  2. #52
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    306
    Nothing to be sorry about. Finding bugs is most helpful for me.

    Nothing is cached, at least not by me? Changing to

    Code:
    #include "utility/sqrt_integer.h"
    fixes the problem, but there are a lot of others.
    Need to find out how to generate the -I statements for the compiler recursively. Seems like Arduino does this. (don't really like it since this supports sloppy programming, but it is as it is...)
    I'll have a look what Arduino tells gcc to compile this lib.

  3. #53
    Senior Member
    Join Date
    Jul 2014
    Posts
    1,938
    Quote Originally Posted by luni View Post
    Nothing to be sorry about. Finding bugs is most helpful for me.

    Nothing is cached, at least not by me? Changing to

    Code:
    #include "utility/sqrt_integer.h"
    fixes the problem, but there are a lot of others.
    Need to find out how to generate the -I statements for the compiler recursively. Seems like Arduino does this. (don't really like it since this supports sloppy programming, but it is as it is...)
    I'll have a look what Arduino tells gcc to compile this lib.
    Found the issue (was mixing 256 with 1024)
    IMO, this should be an action for Paul to 'clean' up the Audio library.

    Now, another issue: the VSCode compiles also the examples, I guess this should not happen, as examples are not part of library und may result in link errors.

  4. #54
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    306
    OK, got it compiled!

    But this is a difficult one indeed. Looks like the library is heavily relying on the Ardunino build system. It definitely needs some manual tweaking.

    1) First, delete all the folders but /utilities. Otherwise the makefile tries to build all the PC GUI stuff and all the examples.
    2) You need to add utility/... in front of about 4-5 includes (sorry, didnt note them down when I changed them) -> This can most probably be fixed in the makefile...
    3) You need to add the additionally required libraries

    Code:
    LIBS_SHARED      := Audio SD SerialFlash Wire SPI
    Now it compiles without a single warning :-)

  5. #55
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    306
    Found the issue (was mixing 256 with 1024)
    What does that mean?

  6. #56
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    306
    Now, another issue: the VSCode compiles also the examples, I guess this should not happen, as examples are not part of library und may result in link errors.
    The new library style uses the /src subfolder for the library sources
    Code:
    lib
    |__ src
    |    |__lib.h
    |    |__lib.cpp
    |    |__....
    |__ examples
    |__ other stuff
    which is much easier to handle than the old style...
    EDIT:
    Instead of deleting the subfolders as mentioned above it might be better to copy the library sources to a /src folder...

  7. #57
    Senior Member
    Join Date
    Jul 2014
    Posts
    1,938
    Quote Originally Posted by luni View Post
    What does that mean?
    I edited the *_256.cpp file but the compiler complained about the *_1024.cpp file

    concerning the libraries, the question is, can VSCode makefile be compatible with TD (which may or may not following the 'new' style)?

    one option would be to allow in addition to simple libraries (without GUI, wiki, documentation, etc) also explicit library paths.

  8. #58
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    306
    The makefile recursively collects all *.c, *.cpp, *.S files in a given library folder and tries to compile them. Additionally it tells the compiler to look for *.h files in the library base folder.

    Usually this works nicely since the libs either have the sources collected in a /src folder or don't have a lot of additional folders. Example folders usually only contain *.ino which are not collected anyway.

    I had a quick look at the libraries in ...teensy\avr\libraries. Most of them are structured the old way but they have a repeating pattern of /examples and /doc folders. I could exclude those folders from the build process which should solve most of the problems. The problem with not fully qualified #includes can be solved by recursively add all subfolders to the include path. I try to work something out after I have a working library manager prototype. Meanwhile I have no better suggestion than manually tweaking the problematic libraries.

    BTW: You can copy them to the lib subdirectory of the project folder and do the changes there. Use the local lib section of the makefile...

    Code:
    LIBS_LOCAL_BASE  := lib
    LIBS_LOCAL           := audio etc..
    .

  9. #59
    Senior Member
    Join Date
    Jul 2014
    Posts
    1,938
    Quote Originally Posted by luni View Post
    The makefile recursively collects all *.c, *.cpp, *.S files in a given library folder and tries to compile them. Additionally it tells the compiler to look for *.h files in the library base folder.

    Usually this works nicely since the libs either have the sources collected in a /src folder or don't have a lot of additional folders. Example folders usually only contain *.ino which are not collected anyway.

    I had a quick look at the libraries in ...teensy\avr\libraries. Most of them are structured the old way but they have a repeating pattern of /examples and /doc folders. I could exclude those folders from the build process which should solve most of the problems. The problem with not fully qualified #includes can be solved by recursively add all subfolders to the include path. I try to work something out after I have a working library manager prototype. Meanwhile I have no better suggestion than manually tweaking the problematic libraries.

    BTW: You can copy them to the lib subdirectory of the project folder and do the changes there. Use the local lib section of the makefile...

    Code:
    LIBS_LOCAL_BASE  := lib
    LIBS_LOCAL           := audio etc..
    .
    OK, I could do that,
    At the moment I tried a different approach
    with

    Code:
    LIBS_SHARED_BASE := C:\Users\Walter\Documents\arduino-1.8.7\hardware\teensy\avr\libraries
    LIBS_SHARED	     := Audio Wire SPI SD SD\Utility SerialFlash
    and
    Code:
    #LIB_CPP_SHARED  := $(foreach d, $(LIB_DIRS_SHARED),$(call rwildcard,$d/,*.cpp))
    #LIB_C_SHARED    := $(foreach d, $(LIB_DIRS_SHARED),$(call rwildcard,$d/,*.c))
    LIB_CPP_SHARED  := $(foreach d, $(LIB_DIRS_SHARED),$(call wildcard,$d/*.cpp))
    LIB_C_SHARED    := $(foreach d, $(LIB_DIRS_SHARED),$(call wildcard,$d/*.c))
    I could compile everything as delivered by PJRC
    but I run in a link error
    Code:
    [LD]  bin\myProject.elf
    bin/lib/SD/SD.o: In function `SdFile::SdFile()':
    C:\Users\Walter\Documents\arduino-1.8.7\hardware\teensy\avr\libraries/SD/utility/SdFat.h:138: undefined reference to `vtable for SdFile'
    collect2.exe: error: ld returned 1 exit status
    make: *** [makefile:205: bin\myProject.elf] Error 1
    The terminal process terminated with exit code: 1
    not sure how to approach this

  10. #60
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    306
    Code:
    #LIB_CPP_SHARED  := $(foreach d, $(LIB_DIRS_SHARED),$(call rwildcard,$d/,*.cpp))
    #LIB_C_SHARED    := $(foreach d, $(LIB_DIRS_SHARED),$(call rwildcard,$d/,*.c))
    LIB_CPP_SHARED  := $(foreach d, $(LIB_DIRS_SHARED),$(call wildcard,$d/*.cpp))
    LIB_C_SHARED    := $(foreach d, $(LIB_DIRS_SHARED),$(call wildcard,$d/*.c))
    I could compile everything as delivered by PJRC
    But that only collects files in the library base folder? Any source file in a subdirectory is ignored which explains the linker error.

    If you now manually include the \utility folder it works, but isn't this even more ugly than automatically exluding the obvious "non code" folders.

    Code:
    LIBS_SHARED      :=  SD SD\utility SPI

  11. #61
    Senior Member
    Join Date
    Jul 2014
    Posts
    1,938
    Quote Originally Posted by luni View Post
    If you now manually include the \utility folder it works, but isn't this even more ugly the automatically exluding the obvious "non code" folders.
    Any trick on how to exclude automatically "non-code" folders like "examples"?

  12. #62
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    306
    I thought of something simple like filtering the list of source files (e.g. LIB_CPP_SHARED) to get rid of all sources with "example" "doc" etc in the path. That should be possible using text filtering. Since I'm not very good at "make" I need to read into the filtering functions first. I you want to give it a try I'd be happy to use your solution.

    In case you don't know: you can print out variables with the info command e.g. $(info lib-cpps: $(LIB_CPP_SHARED)) which is very useful for experimenting.

    https://www.gnu.org/software/make/ma...Functions.html

  13. #63
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    306
    Using $(wildcard ) to get a list of "bad" entries in LIB_CPP_SHARED and then removing those with $(filter-out pattern…,text) could work.

  14. #64
    Senior Member
    Join Date
    Jul 2014
    Posts
    1,938
    Thinking again about "non-code" part of libraries
    I return to the assumption that I prefer to tell what the compiler should use than what to exclude,But YMMV.
    to avoid the link problem, which I guess is due to circular dependencies I recall an earlier thread https://forum.pjrc.com/threads/28119...Linker-problem
    and therefore replaced
    Code:
    # Linking ---------------------------------------------------------------------
    $(TARGET_ELF): $(CORE_LIB) $(LIB_OBJ) $(USR_OBJ) 
    	@echo [LD]  $@
    	@$(CC) $(LD_FLAGS) -T$(CORE_SRC)/$(LD_SCRIPT) -o "$@"  $(USR_OBJ) $(LIB_OBJ) $(CORE_LIB) $(LIBS)
    	@echo User code built and linked to libraries &&echo.
    with
    Code:
    # Linking ---------------------------------------------------------------------
    $(TARGET_ELF): $(CORE_LIB) $(LIB_OBJ) $(USR_OBJ) 
    	@echo [LD]  $@
    	@$(CC) $(LD_FLAGS) -T$(CORE_SRC)/$(LD_SCRIPT) -o "$@" -Wl,-( $(USR_OBJ) $(LIB_OBJ) $(CORE_LIB) $(LIBS) -Wl,-)
    	@echo User code built and linked to libraries &&echo.

  15. #65
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    306
    Sometimes reading the manuals helps :-)

    Of course there is a spec for the structure of Arduino libraries (old and new version): https://github.com/arduino/arduino/w...-specification. It clearly states the following:

    • Old version: all code goes in the base folder and a folder called /utility. Code in other folders will not get compiled
    • New version: all code goes in /src and subdirectories of arbitrary depth


    So that was easy to implement. Here https://github.com/luni64/VisualTeensy/issues/2 a version which should build everything as it should.

    Audio Lib:
    Code:
    LIBS_SHARED_BASE := C:\Arduino\arduino-1.8.5\hardware\teensy\avr\libraries
    LIBS_SHARED      := audio sd spi wire serialflash

  16. #66
    Senior Member
    Join Date
    Jul 2014
    Posts
    1,938
    Quote Originally Posted by luni View Post
    Sometimes reading the manuals helps :-)
    lets hope that all libraries follow that rule.
    but we can ague about aesthetics
    (having to entries in LIBS_SHARED or two entries in LIB_DIRS_SHARED)

    changing LIBS_SHARED would allow me to take any code even if not Arduino compatible.
    However, no need for you to change, I know how to do it

  17. #67
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    306
    lets hope that all libraries follow that rule.
    I checked the teensyduino libraries, at least they seem to comply.

    changing LIBS_SHARED would allow me to take any code even if not Arduino compatible.
    However, no need for you to change, I know how to do it
    Understood, that would mean that VisualTeensy would have to look into the library and decide if it is old / or new style when it generates the entries to LIBS_SHARED. Would be possible of course...

    BTW: I plan to divide the makefile in a variable part (say settings.mk) with all the flags which are filled in by VisualTeensy and a static part. settings.mk will then be included by the static makefile. After writing that at project generation VisualTeensy would not touch it anymore so that it can be exchanged easily without beeing overwriten when you update settings. That might be useful for advanced applications.

  18. #68
    Senior Member
    Join Date
    Jul 2014
    Posts
    1,938
    @luni,
    downloaded, compiled and run Develop branch successfully.
    great tool.

    minor issue: c_cpp_properties.json is not updated with library path for intellisense.

    in order to facilitate changes during development,
    would it be possible to modify information only in one place (say c_cpp_properties.json) and to have makefile to pase intellisense info constructing required libraries.
    Alternatively (or even better?) let user reopen VisualTeensy but read from either .json file or makefile to pre-check loaded libraries.
    on exit existing json file and makefile are already replaced.

  19. #69
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    306
    Glad that it works for you. The library integration GUI was the very first try from yesterday. There still is a lot to do to make this more useful.

    c_cpp_properties.json is not updated with library path for intellisense.
    Yes, I know, will add that later today.

    Alternatively (or even better?) let user reopen VisualTeensy but read from either .json file or makefile to pre-check loaded libraries.
    on exit existing json file and makefile are already replaced.
    Same as already implemented for the other settings I will store them in visualTeensy.json where they will be read from if you open an existing project.

    Open:
    • Optionally copying the libraries to the project folder
    • Still need to find a way to resolve the dependencies of libraries. It would be much better to only need to add the "audio" lib instead of "audio + wire + SD + serialflash" A lot of libraries have a library.json which would have a mechanism to define dependencies but that doesn't seem to be maintained well. Any ideas
      welcome. (If nothing helps I need to walk through the include tree but I would like to avoid that...)
    • Currently I only present the libraries from Teensyduino. But there might be much more on the system. E.g. the ones installed in Ardunino/libraries. Downloading from GitHub would also be interesting. Does anybody know if the library repository which is used by the Arduino Library manager has a public API or anything similar?

  20. #70
    Senior Member
    Join Date
    Jul 2014
    Posts
    1,938
    @luni,
    not that it is important, but as in cores there is already a main.cpp, which calls setup and loop,
    would it be clearer to avoid the filename main.cpp in the sketch?
    maybe it is OK to have multiple files with same name as long entries are different, but same names may create confusion.

    (I edited the code to generate a file App.cpp instead).

  21. #71
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    306
    That isn't a problem at all. (In fact, I'm using this since a couple of years without any issue). The same problem would occur for libraries having files with the same name. -> The makefile takes care of giving the linker qualified names (e.g. bin/src/main.o and bin/core/main.o) so it will not clash. But you can of course use any name you like. As long as the linker finds a void loop() and void setup() somewhere it shout be happy.
    BTW: For me it would be confusing not to have a main.cpp. I can make this configurable later...

  22. #72
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    306
    @WMXZ BTW: did you try to implement that RTC setting for the linker? If you find a solution I'd be happy to include it in the makefile

  23. #73
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    7,046
    Nice to see this developing …

    In the boards.txt is 'extra.time.local' from the "linker"?
    631: teensy30.build.flags.ld=-Wl,--gc-sections,--relax,--defsym=__rtc_localtime={extra.time.local} "-T{build.core.path}/mk20dx128.ld" -lstdc++
    See posts #5 and #7 here :: Teensy3Time-ino-updates-wrong-time

  24. #74
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    306
    c_cpp_properties.json is not updated with library path for intellisense.
    Alternatively (or even better?) let user reopen VisualTeensy but read from either .json file or makefile to pre-check loaded libraries.
    Both fixed in 0.71. If you now open an existing project the libraries already used in this project are preselected and you can add / remove libraries . Path to the libraries is added to the c_cpp_properties.json to enable intellisense for the libraries.

    Begins to be fun working with it :-)

    Open:
    • Found out where to download the list of libraries the arduino library manager uses and will integrate this.
    • Copying libs to the project folder
    • Since Paul now has the Core library nicely taged, I think of adding a dropdown for different Teensyduino versions to the expert section and download it directly from GitHub Being able to quickly change the Teensyduino version might be useful for testing
    • Improving the GUI, kind of ugly at the moment.

  25. #75
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    306
    Quote Originally Posted by defragster View Post
    Nice to see this developing

    In the boards.txt is 'extra.time.local' from the "linker"?


    See posts #5 and #7 here :: Teensy3Time-ino-updates-wrong-time
    Thanks defragster. The 'problem' is that "extra.time.local" will be set by the Arduino IDE at link time I assume. I'll have a look at the output from the IDE to find out which format is required and if I can mimic that.

Posting Permissions

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