Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: T3.2 How to compile Arduino .ino file and obtain HEX file from command line

  1. #1
    Junior Member
    Join Date
    May 2021

    T3.2 How to compile Arduino .ino file and obtain HEX file from command line

    I'm trying to find a way to compile an Arduino .ino file and obtain the output HEX/ELF file, from command line (on windows). Uploading to the board will be done via JTAG and a programmer, so I don't need the TeensyLoader.

    So far I've come across the following:

    • There is the Teensy loader, command line. However I understand it that is only for loading already compiled code onto the Teensy Board, not for compiling .ino files. So that is of no use.
    • Then there is the GCC compiler for Teensy. That would mean using a make file. I'm not very familiar with using Make, would I then still be able to compile an arduino file? Or does it only work with .c or .cpp files? Besides, it seems to cover teensy 2 only. Would it also work for T3.2? I came across this discussion, but it doesn't show anything about .ino files. It's also from more than 5 years ago so things could've changed since then.
    • I've tried copying the first line from verbose output from Arduino IDE upload, and pasting that in the CMD/Powershell.
      The command is this:
      "C:\Program Files (x86)\Arduino\arduino-builder" -dump-prefs -logger=machine -hardware "C:\Program Files (x86)\Arduino\hardware" -hardware "C:\Users\xxxe\AppData\Local\Arduino15\packages" -tools "C:\Program Files (x86)\Arduino\tools-builder" -tools "C:\Program Files (x86)\Arduino\hardware\tools\avr" -tools "C:\Users\xxxx\AppData\Local\Arduino15\packages" -built-in-libraries "C:\Program Files (x86)\Arduino\libraries" -libraries "C:\Users\xxx\Documents\Arduino\libraries" -fqbn=teensy:avr:teensy31:usb=serial,speed=96,opt=o2std,keys=en-us -ide-version=10813 -build-path "C:\Users\xxxx~1\AppData\Local\Temp\arduino_build_755527" -warnings=none -build-cache "C:\Users\xxxx~1\AppData\Local\Temp\arduino_cache_486966" -verbose "R:\ardir\blink.ino"
      The error I get is:
      At line:1 char:50
      + "C:\Program Files (x86)\Arduino\arduino-builder" -dump-prefs -logger= ...
      +                                                  ~~~~~
      Unexpected token '-dump' in expression or statement.
      At line:1 char:55
      + "C:\Program Files (x86)\Arduino\arduino-builder" -dump-prefs -logger= ...
      +                                                       ~~~~~~
      Unexpected token '-prefs' in expression or statement.
          + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
          + FullyQualifiedErrorId : UnexpectedToken
      Tried looking this up, didn't get very far.

    Any suggestions on what direction to proceed on would be appreciated a lot! Many thanks

  2. #2
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    There are a few different options that I know of.

    There are makefiles that can build teensy sketches. I have not tried them in awhile or know how well they are working on windows...
    But they are found in your <arduino install>/hardware/teensy/avr/cores/teensy4 ... Or teensy3 ...

    @FrankB and @defrasger setup a set of batch files TSet... Which are a set of batch files that work on windows. Dragster setup a way to integrate into sublimetext editor and I use this setup a lot. One nice thing about this setup is it uses the Arduino build system to build... So I get the same results as I do from doing build within the IDE

  3. #3
    Junior Member knickish's Avatar
    Join Date
    May 2021
    Bit of a shameless self plug, but I made, which supports windows with docker as the only dependency and drops the hex file out at the end. It's based on the makefiles that KurtE mentioned.

Posting Permissions

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