Skip to content

Instantly share code, notes, and snippets.

@karmanyaahm
Last active March 18, 2024 17:43
Show Gist options
  • Save karmanyaahm/cd1326b0a8bc4ad1d2e51247bfc80951 to your computer and use it in GitHub Desktop.
Save karmanyaahm/cd1326b0a8bc4ad1d2e51247bfc80951 to your computer and use it in GitHub Desktop.
Put this in a directory and then call `nix develop --impure` This is assuming flakes are enabled in the nix config (I'm using it on NixOS but it should??? work on any nix package manager installation?)
{
description = "Scratch dir for various testing";
outputs = {nixpkgs, ...}: let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
nixarm = import <nixpkgs> {
crossSystem = {
config = "aarch64-unknown-linux-gnu";
};
};
# this will use aarch64 binaries from binary cache, so no need to build those
pkgsArm = import <nixpkgs> {
config = {};
overlays = [];
system = "aarch64-linux";
};
# these will be your cross packages
pkgsCross = import <nixpkgs> {
overlays = [(self: super: {
# things
})];
crossSystem = {
config = "aarch64-unknown-linux-gnu";
};
};
in {
devShells.${system}.default = pkgs.mkShell {
packages = [
pkgs.qemu
pkgsArm.gdb
pkgsArm.gef
#pkgs.gcc-arm-embedded
pkgsArm.gcc
];
};
};
}
all: clean build
build:
gcc student_a64_template.s a64_testbench.o -o ac_lab -g -lm
run: build
qemu-aarch64 ./ac_lab ${ARGS}
run-and-wait-for-debug:
while true; do make build && qemu-aarch64 -g 25540 ./ac_lab ${ARGS}; sleep 1; done
#pass arguments to makefile like BREAK_AT=aiken_to_long
debug:
gef -q ac_lab -ex 'target remote localhost:25540' -ex 'gef config context.layout "-legend regs -stack code args source memory threads -trace extra"' -ex 'break ${BREAK_AT}'
clean:
rm -f ac_lab qemu*.core
verify:
python3 verify.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment