2024-05-09 20:29:14 +01:00
|
|
|
{
|
|
|
|
inputs = {
|
|
|
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
|
|
|
devshell.url = "github:numtide/devshell";
|
|
|
|
devshell.inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
devenv.url = "github:cachix/devenv";
|
|
|
|
devenv.inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
|
|
|
|
rootdir = {
|
|
|
|
url = "file+file:///dev/null";
|
|
|
|
flake = false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
outputs = inputs@{ nixpkgs, flake-parts, devenv, rootdir, ... }:
|
|
|
|
flake-parts.lib.mkFlake { inherit inputs; } {
|
|
|
|
imports = [
|
|
|
|
devenv.flakeModule
|
|
|
|
];
|
|
|
|
systems = [ "x86_64-linux" ];
|
|
|
|
|
|
|
|
perSystem = { inputs', system, pkgs, config, ... }:
|
|
|
|
let
|
|
|
|
rootdirOpt =
|
|
|
|
let
|
|
|
|
rootFileContent = builtins.readFile rootdir.outPath;
|
|
|
|
in
|
|
|
|
pkgs.lib.mkIf (rootFileContent != "") rootFileContent;
|
2024-05-11 00:57:43 +01:00
|
|
|
|
|
|
|
ocdInterface = mcu/tigard-swd.cfg;
|
2024-05-09 20:29:14 +01:00
|
|
|
in
|
|
|
|
{
|
|
|
|
devenv.shells.mcu = {
|
|
|
|
devenv.root = rootdirOpt;
|
|
|
|
|
|
|
|
packages = with pkgs; [
|
|
|
|
gnumake
|
|
|
|
cmake
|
2024-05-11 00:57:43 +01:00
|
|
|
pkgsCross.arm-embedded.buildPackages.gdb # ARM one is broken
|
2024-05-09 20:29:14 +01:00
|
|
|
gcc-arm-embedded
|
|
|
|
python3
|
|
|
|
picotool
|
|
|
|
openocd-rp2040
|
|
|
|
];
|
|
|
|
|
|
|
|
env = {
|
|
|
|
PICO_SDK_PATH = "${pkgs.pico-sdk}/lib/pico-sdk";
|
|
|
|
};
|
2024-05-11 00:57:43 +01:00
|
|
|
|
|
|
|
scripts = {
|
|
|
|
build.exec = ''
|
|
|
|
cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -D PICO_STDIO_SEMIHOSTING=1
|
|
|
|
cmake --build build --parallel
|
|
|
|
'';
|
|
|
|
build-rel.exec = ''
|
|
|
|
cmake -S . -B build-release -D CMAKE_BUILD_TYPE=Release
|
|
|
|
cmake --build build-release --parallel
|
|
|
|
'';
|
|
|
|
clean.exec = ''
|
|
|
|
rm -rf build/ build-release/
|
|
|
|
'';
|
|
|
|
|
|
|
|
ocd.exec = ''
|
|
|
|
openocd -f ${ocdInterface} -f target/rp2040.cfg
|
|
|
|
'';
|
|
|
|
gdb.exec = ''
|
|
|
|
arm-none-eabi-gdb -x .gdbinit build/qclk.elf
|
|
|
|
'';
|
|
|
|
};
|
2024-05-09 20:29:14 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|