Platformio: Difference between revisions
imported>IgorM m Added to the category "Development" |
imported>Delan update udev and vscode advice |
||
Line 23: | Line 23: | ||
{ | { | ||
services.udev.packages = [ | services.udev.packages = [ | ||
pkgs.platformio | pkgs.platformio-core | ||
pkgs.openocd | pkgs.openocd | ||
]; | ]; | ||
Line 38: | Line 38: | ||
"platformio-ide.useBuiltinPIOCore": false, | "platformio-ide.useBuiltinPIOCore": false, | ||
} | } | ||
</syntaxHighlight> | |||
[https://discourse.nixos.org/t/how-to-use-platformio-with-vscode/15805/3 As of PlatformIO IDE 2.0.0], you will need a shell that allows the extension to run “python -m platformio” ([https://github.com/NixOS/nixpkgs/pull/237313 #237313]): | |||
<syntaxHighlight lang=nix> | |||
{ pkgs ? import (builtins.fetchTarball { | |||
# NixOS/nixpkgs#237313 = ppenguin:refactor-platformio-fix-ide | |||
url = "https://github.com/NixOS/nixpkgs/archive/3592b10a67b518700002f1577e301d73905704fe.tar.gz"; | |||
}) {}, | |||
}: | |||
let | |||
envname = "platformio-fhs"; | |||
mypython = pkgs.python3.withPackages (ps: with ps; [ platformio ]); | |||
in | |||
(pkgs.buildFHSUserEnv { | |||
name = envname; | |||
targetPkgs = pkgs: (with pkgs; [ | |||
platformio-core | |||
mypython | |||
openocd | |||
]); | |||
# NixOS/nixpkgs#263201, NixOS/nixpkgs#262775, NixOS/nixpkgs#262080 | |||
runScript = "env LD_LIBRARY_PATH= bash"; | |||
}).env | |||
</syntaxHighlight> | </syntaxHighlight> | ||
Revision as of 03:11, 9 December 2023
PlatformIO is a SDK/toolchain manager for various microcontrollers and and embedded platforms i.e. esp32.
Basic development environment
{ pkgs ? import <nixpkgs> {} }:
let
in
pkgs.mkShell {
buildInputs = [
pkgs.platformio
# optional: needed as a programmer i.e. for esp32
# pkgs.avrdude
];
}
NixOS
Add the required udev rules.
{
services.udev.packages = [
pkgs.platformio-core
pkgs.openocd
];
}
Use in vscode
To use the nix-shell provided PlatformIO rather the builtin one first open vscode
within the nix-shell
and also modify it's settings.json
to also contain the following line:
{
"platformio-ide.useBuiltinPIOCore": false,
}
As of PlatformIO IDE 2.0.0, you will need a shell that allows the extension to run “python -m platformio” (#237313):
{ pkgs ? import (builtins.fetchTarball {
# NixOS/nixpkgs#237313 = ppenguin:refactor-platformio-fix-ide
url = "https://github.com/NixOS/nixpkgs/archive/3592b10a67b518700002f1577e301d73905704fe.tar.gz";
}) {},
}:
let
envname = "platformio-fhs";
mypython = pkgs.python3.withPackages (ps: with ps; [ platformio ]);
in
(pkgs.buildFHSUserEnv {
name = envname;
targetPkgs = pkgs: (with pkgs; [
platformio-core
mypython
openocd
]);
# NixOS/nixpkgs#263201, NixOS/nixpkgs#262775, NixOS/nixpkgs#262080
runScript = "env LD_LIBRARY_PATH= bash";
}).env