Platformio: Difference between revisions

imported>Mic92
add platformio page
 
formatting
 
(9 intermediate revisions by 7 users not shown)
Line 1: Line 1:
[Platformio https://platformio.org/] is a SDK/toolchain manager for various microcontrollers  and and embedded platforms i.e. esp32.
[https://platformio.org/ PlatformIO] is a SDK/toolchain manager for various microcontrollers  and and embedded platforms i.e. esp32.


== Basic development environment ==
== Basic development environment ==
Line 13: Line 13:
       # pkgs.avrdude
       # pkgs.avrdude
     ];
     ];
}
</syntaxHighlight>
== NixOS ==
Add the required udev rules.
<syntaxHighlight lang=nix>
{
  services.udev.packages = [
    pkgs.platformio-core
    pkgs.openocd
  ];
}
}
</syntaxHighlight>
</syntaxHighlight>
Line 18: Line 31:
== Use in vscode ==
== Use in vscode ==


To use the nix-shell provided platformio rather the builtin one first open <code>vscode</code> within the nix-shell
To use the nix-shell provided PlatformIO rather the builtin one first open <code>vscode</code> within the nix-shell
and also modify it's <code>settings.json</code> to also contain the following line:
and also modify it's <code>settings.json</code> to also contain the following line:


Line 26: Line 39:
}
}
</syntaxHighlight>
</syntaxHighlight>
[https://discourse.nixos.org/t/how-to-use-platformio-with-vscode/15805/3 As of PlatformIO IDE 2.0.0], <s>you will need a shell that allows the extension to run “python -m platformio” ([https://github.com/NixOS/nixpkgs/pull/237313 #237313])</s>:
Recently (2024?) simply building an FHS shell with the referred <code>nixpkgs</code> commit doesn't work anymore. The modification is probably incompatible with newer <code>nixpkgs</code>.
There's a quick&dirty fix available as a <code>flake</code> <code>devShell</code>. For usage with <code>direnv</code> (recommended), make an <code>.envrc</code> in your project dir like this:<syntaxhighlight lang="bash">
#!/usr/bin/env bash
PRJROOT="$(git rev-parse --show-toplevel)"
FLAKE=github:ppenguin/nixenvs
# avoid a "load loop" of direnv when the new fhs env is entered
# https://github.com/direnv/direnv/issues/992
if [ -z "$IN_NIX_SHELL" ]; then
    use flake $FLAKE\#pio-arduino-fhs
fi
export PRJROOT
</syntaxhighlight>This will start a the <code>devShell</code> defined here: https://github.com/ppenguin/nixenvs/blob/main/dev/devshell-pio-arduino-fhs.nix, which includes a working update of the <code>platformio</code> <code>python</code> module for <code>nixpkgs</code>.
== See also ==
* [https://github.com/NixOS/nixpkgs/issues/224895 Platformio permission denied[13]]
[[Category:Development]]