Where could we find arduino code source in ide v2.x ?

Hi everyone,

I don't find Arduino IDE v2.x core code source files, where can I find them ?

PS : With Arduino v1.8.19 under Windows, I can find the following folder "C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" which contains main.cpp and Arduino.h

Take a look in the folders under C:\Users<username>\AppData\Local\Arduino15\packages

I have well a "C:\Users\username\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino" folder.

I'm using portable version of v2.x series instead of the v1.8.19, I don't know where code source files are located with portable versions.
This is a bit strange, the "1.8.6" sub-folder, I didn't installed this version on my computer by memory.

I thought that there wasn't a portable version of the 2.x IDE. Where did you get it from ?

From the official link https://www.arduino.cc/en/software Windows ZIP file (3rd Windows option from the top)

What exactly are you looking for, it sounds like you want the source to the IDE, tool chain, and built in libraries. All that is in Github somewhere, there is a search bar.

I'm looking for the arduino core source files location for Arduino IDE v2.x series (especially portable versions). As example, where can I find main.cpp and Arduino.h files ?

What is it you are trying to do?

The source to the various cores are on github. Why do you want them? Unless you are cloning all or some of the Arduino ecosystem, you don;t need them to build an Arduino app.
It would really help if you could explain why you think you need them.
Maybe the following will help you understand. I did a screen grab of all the main.cpp and arduino.h files on my laptop in the Arduino ecosystem.


That's the version of the board, not the IDE. On this Linux box, the Arduino15 directory is instead ~/.arduino15, but all the files are in the same relative position

~/.arduino15/packages$ ls -1d */hardware/*/*
arduino/hardware/avr/1.8.6
arduino/hardware/renesas_uno/1.3.2
esp32/hardware/esp32/3.0.7
esp8266/hardware/esp8266/3.1.2
m5stack/hardware/esp32/2.1.1

Five different boards here.

~/.arduino15/packages$ find  */hardware/*/* -name Arduino.h
arduino/hardware/avr/1.8.6/cores/arduino/Arduino.h
arduino/hardware/renesas_uno/1.3.2/cores/arduino/Arduino.h
esp32/hardware/esp32/3.0.7/cores/esp32/Arduino.h
esp8266/hardware/esp8266/3.1.2/cores/esp8266/Arduino.h
m5stack/hardware/esp32/2.1.1/cores/esp32/Arduino.h

Five Arduino.h

~/.arduino15/packages$ find  */hardware/*/* -name main.cpp
arduino/hardware/avr/1.8.6/cores/arduino/main.cpp
arduino/hardware/renesas_uno/1.3.2/cores/arduino/main.cpp
esp32/hardware/esp32/3.0.7/libraries/LittleFS/examples/LITTLEFS_PlatformIO/src/main.cpp
esp32/hardware/esp32/3.0.7/cores/esp32/main.cpp
m5stack/hardware/esp32/2.1.1/cores/esp32/main.cpp
m5stack/hardware/esp32/2.1.1/libraries/LittleFS/examples/LITTLEFS_PlatformIO/src/main.cpp

Only four of the main.cpp though (the other two are the same example for LittleFS). Apparently the esp8266 one is called something else.

Hi @deejayone

They are at the folder you already found:

Arduino IDE 2.x automatically installs it on the first run after a fresh installation.

1 Like

@ptillisch ptillisch

Thanks for the answer.
So, the portable version is not truely portable if some files are copied on the Windows OS partition.
Is there a way to store them in the "Portable folder" (where all files are unzipped in a new sub-folder) and specify the new "access path" for a right loading by Arduino IDE ?

My goal is having a real portable folder of each portable version and avoid any common files between each version. It could be also useful to compare any updates between 2 different versions.

As @UKHeliBob said previously, there is no portable version of Arduino IDE 2.x.

You can configure the location where Arduino IDE stores these files by editing a configuration file.

I'll provide instructions you can follow to do that:

  1. Select File > Quit from the Arduino IDE menus if it is running.
    All IDE windows will close.
  2. Open the file at the following path in any text editor:
    C:\Users\<username>\.arduinoIDE\arduino-cli.yaml
    
    (where <username> is your Windows username)
  3. In the content of the arduino-cli.yaml file, you might see some lines like this:
    directories:
        data: c:\Users\<username>\AppData\Local\Arduino15
    
    If those lines are not already present, add them to the file.
  4. Adjust the value of the directories.data key to the path you want the IDE to use.
  5. Save the file.
  6. Move the files from the previous path to the newly configured path.
  7. Start Arduino IDE.

The path configured via the directories.data field is where Arduino IDE stores the following files:

A couple other paths are also configurable by the file:

  • directories.downloads: The path where Arduino IDE stores the archive files that are downloaded when you install a library via Library Manager or a platform via Boards Manager.
    • By default, these files are stored at the following path:
      c:\Users\<username>\AppData\Local\Arduino15
      
  • directories.user: The path of the Arduino IDE "sketchbook" folder, where libraries installed via Library Manager are stored, as well as being a convenient place to store your sketches. You can also configure this path via Arduino IDE's "Preferences" dialog (accessed via File > Preferences).
  • directories.builtin.libraries: The path where Arduino IDE stores some fundamental libraries, which are automatically installed on the first run after a fresh installation.
    • By default, these files are stored at the following path:
      c:\Users\<username>\AppData\Local\Arduino15\libraries
      

Note that there is no way to configure the location of the arduino-cli.yaml configuration file. So even if you configure a custom path via directories.data key in the file, all Arduino IDE 2.x installations will use that same path.

The workaround would be to change the file to point to each of the separate paths as needed. This file is written in the common YAML language, so it is fairly easy to set up scripts to modify the file automatically.

The arduino-cli.yaml configuration file can be generated and the data in the file adjusted using the arduino-cli config commands:

https://arduino.github.io/arduino-cli/latest/commands/arduino-cli_config/

For a general purpose command line tool for working with YAML, I can recommend the excellent yq:

You will find that a high quality YAML library is available for each programming language (example).

2 Likes

@ptillisch
I can see there are also other files as settings.json in the C:\Users\username\.arduinoIDE folder.
Is there a way to specify this .arduinoIDE folder in a new location on the "Portable Arduino IDE folder" ?

Unfortunately, no. This path is hardcoded in the Arduino IDE source code. The only way to configure a different location would be to change the path of the user folder (c:\Users\<username>) in the Windows settings.

It should be nice to have a new tab location in the File -> Preferences... window to store the main application paths as .arduinoIDE and Arduino15 folders and then sub-folders currently defined in the arduino-cli.yaml file.