Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove custom RISC-V toolchain from Nix shell, remove Segger J-Link, update Tockloader to v1.11.0 #365

Merged
merged 2 commits into from
Jan 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 23 additions & 43 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,23 @@
# * `tockloader`
# * arm-none-eabi toolchain
# * elf2tab
# * (optionally) riscv32-embedded toolchain
# * riscv32-embedded toolchain
#
# To use:
#
# $ nix-shell
#
# The RISC-V toolchain can be disabled optionally. This will further
# prevent RISC-V specific environment variables from being set in the
# Nix shell environment:
#
# $ nix-shell shell.nix --arg disableRiscvToolchain true

{ pkgs ? import <nixpkgs> {}, disableRiscvToolchain ? false, withUnfreePkgs ? false }:
{ pkgs ? import <nixpkgs> {}, withUnfreePkgs ? false }:

with builtins;
let
inherit (pkgs) stdenv stdenvNoCC lib;

# Tockloader v1.11.0pre-git
tockloader = import (pkgs.fetchFromGitHub {
owner = "tock";
repo = "tockloader";
rev = "df8823545cbdd3ef49ce3d255404b7adaef5fcfc";
sha256 = "sha256-gl+uz+JrzZ6RRIu2r7xALtstKzhfiUENbKeNhuSNXAQ=";
rev = "v1.11.0";
sha256 = "sha256-bPEfpfOZOjOiazqRgn1cnqe4ohLPvocuENKoZx/Qw80=";
}) { inherit pkgs withUnfreePkgs; };

elf2tab = pkgs.rustPlatform.buildRustPackage rec {
Expand All @@ -49,41 +42,28 @@ in
name = "tock-dev";

buildInputs = with pkgs; [
nrf-command-line-tools
elf2tab
gcc-arm-embedded
python3Full
tockloader
] ++ (lib.optionals withUnfreePkgs [
segger-jlink
tockloader.nrf-command-line-tools
]) ++ (lib.optional (!disableRiscvToolchain) (
pkgsCross.riscv32-embedded.buildPackages.gcc.override (oldCc: {
cc = (pkgsCross.riscv32-embedded.buildPackages.gcc.cc.override (oldCcArgs: {
libcCross = oldCcArgs.libcCross.overrideAttrs (oldNewlibAttrs: {
configureFlags = oldNewlibAttrs.configureFlags ++ [
"--enable-libssp"
];
});
})).overrideAttrs (oldCcAttrs: {
configureFlags = oldCcAttrs.configureFlags ++ [
"--without-headers"
"--disable-shared"
"--disable-libssp"
"--disable-multilib"
"--with-newlib"
];
gcc_cv_libc_provides_ssp = "yes";
});
})
));

shellHook = ''
${if (!disableRiscvToolchain) then ''
export RISCV=1
'' else ""}
pkgsCross.riscv32-embedded.buildPackages.gcc
];

# TODO: This should be patched into the rpath of the respective libraries!
export LD_LIBRARY_PATH=${pkgs.libusb}/lib:${pkgs.segger-jlink}/lib:$LD_LIBRARY_PATH
'';
# Unfortunately, `segger-jlink` has been removed from Nixpkgs due to its
# hard dependency in Qt4, which has multiple security issues and is
# deprecated since a few years now. Efforts exist to bring the package back,
# but for now we don't assume it's available. Once [1] is merged, we can add
# the following back:
#
# buildInputs ++ (lib.optionals withUnfreePkgs [
# segger-jlink
# tockloader.nrf-command-line-tools
# ])
#
# shellHook = ''
# # TODO: This should be patched into the rpath of the respective libraries!
# export LD_LIBRARY_PATH=${pkgs.libusb}/lib:${pkgs.segger-jlink}/lib:$LD_LIBRARY_PATH
# '';
#
# [1]: https://github.com/NixOS/nixpkgs/pull/255185
}
Loading