LinuxCommandLibrary

pio-init

Initialize PlatformIO project environment

TLDR

View documentation for the original command

$ tldr pio project
copy

SYNOPSIS

pio init [options] [project_dir]

PARAMETERS

-b, --board ID
    Specify the target board ID (e.g., `esp32dev`, `uno`).

-f, --framework ID
    Specify the development framework (e.g., `arduino`, `espidf`).

-p, --project-dir PATH
    Define the project's root directory. Defaults to the current directory.

--ide ID
    Generate configuration files for a specific IDE (e.g., `vscode`, `clion`).

-e, --env ID
    Initialize project with a specific environment ID defined in `platformio.ini`.

--ecc
    Exclude generation of `.vscode/c_cpp_properties.json` for VSCode.

--skip-versioning-generation
    Prevent generation of version control files like `.gitignore`.

--rebuild-project-ide
    Force regeneration of IDE project files, useful for updates.

DESCRIPTION

The `pio init` command is a core component of the PlatformIO ecosystem, used to initialize a new embedded development project. It establishes the foundational project structure in a specified or current directory, making it ready for coding, building, and uploading. The command creates essential folders like `src` for source code, `lib` for private libraries, and `test` for unit tests. Crucially, it generates the `platformio.ini` configuration file, which defines the project's board, framework, dependencies, and build settings. This allows developers to quickly set up a consistent and organized environment for various microcontrollers and development boards, streamlining the embedded software development workflow from inception.

CAVEATS

The `pio init` command is part of the PlatformIO Core CLI and requires PlatformIO to be installed on your system; it is not a standalone Linux utility. Running it in a non-empty directory will initialize the project within that directory, potentially overwriting an existing `platformio.ini` file if parameters conflict or if rebuilding is forced.

PROJECT STRUCTURE

Upon successful execution, `pio init` establishes a standard directory layout for your project:
  `platformio.ini` - Main project configuration file.
  `src/` - Directory for your primary source code files.
  `lib/` - Location for project-specific or private libraries.
  `test/` - Folder designated for unit testing code.
  `.vscode/` (if `--ide vscode` used) - VS Code specific configuration.
  `.gitignore` (unless `--skip-versioning-generation` used) - Git ignore rules.

CONFIGURATION FILE (`PLATFORMIO.INI`)

The `platformio.ini` file is the central configuration hub for any PlatformIO project. It defines critical settings such as target boards, development frameworks, build flags, upload protocols, and library dependencies. `pio init` automatically generates a basic `platformio.ini` file, pre-configured based on the board and framework options provided during initialization, providing a solid starting point for further project customization.

HISTORY

PlatformIO emerged in 2014-2015 as an open-source solution to standardize embedded development across diverse hardware. The `pio init` command has been a foundational element since its inception, providing the essential capability to rapidly set up new projects with a consistent structure. Its design principles reflect modern software development practices, bringing structured project management and dependency handling to the embedded world, continually evolving to support new boards, frameworks, and IDE integrations.

SEE ALSO

pio(1), pio run(1), pio build(1), pio lib(1), pio board(1)

Copied to clipboard