Go Down

Topic: how to compile arduino sketch from termnial and then upload the firmware  (Read 291 times) previous topic - next topic

seaurchin

 I want to know how can I compile and upload the arduino sketch from my terminal instead of using Arduino IDE.

I want to use a different IDE for writing code then compile from terminal and upload.

sterretje

Do a search for Arduino makefile. I have no experience with the Arduino specifics but it should get you on the right track.
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

pert

The Arduino IDE has a command line interface (CLI):
https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc

There is a new official command line only tool called arduino-cli:
https://github.com/arduino/arduino-cli
That is still in beta so you might run into some occasional problems, but beta testers are welcome.

The Arduino IDE also allows you to set it to use an external editor (File > Preferences > Use external editor). The Arduino IDE's text editor will be disabled and it will pick up any changes made to the file externally. This way, you can use the Arduino IDE only for compilation and upload and your favorite editor/IDE for writing the code.

seaurchin

The Arduino IDE has a command line interface (CLI):
https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc

There is a new official command line only tool called arduino-cli:
https://github.com/arduino/arduino-cli
That is still in beta so you might run into some occasional problems, but beta testers are welcome.

The Arduino IDE also allows you to set it to use an external editor (File > Preferences > Use external editor). The Arduino IDE's text editor will be disabled and it will pick up any changes made to the file externally. This way, you can use the Arduino IDE only for compilation and upload and your favorite editor/IDE for writing the code.
so the new arduino cli allows compiling the hex code to binary and upload as well ?

sterretje

so the new arduino cli allows compiling the hex code to binary and upload as well ?
You don't compile hex code, you compile source code; the result is a hex-file (in the Arduino environment). You can convert it to binary if you feel like that (not sure if its part of the cli, I haven't played with that) but I don't know if it's useful.
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

pert

You can use arduino-cli to upload, just like how the Arduino IDE does it. You can find details here:
https://github.com/arduino/arduino-cli#step-6-upload-your-sketch

In the near future, the Arduino IDE is going to use arduino-cli for installing hardware packages, installing libraries, compiling, uploading. At that point, the IDE will only be a graphical interface for the arduino-cli. So arduino-cli will do anything the Arduino IDE can do, and more. This is something Arduino has been working towards for years. It used to be that everything was crammed into the IDE's Java code but they've gradually been moving it out into separate tools. That's extremely helpful for people like you who want to use a different IDE or not use an IDE at all.

Go Up