Skip to content

Commit

Permalink
Merge pull request #1 from Emin017/dev
Browse files Browse the repository at this point in the history
Update for CI
  • Loading branch information
Emin017 authored May 9, 2024
2 parents bd6e7dd + a72d810 commit 2b1f835
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 4 deletions.
37 changes: 37 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
description = "MEMU";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, flake-utils }@inputs:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs { inherit system;};
deps = with pkgs; [
git
gnumake autoconf automake
cmake ninja
pkgsCross.riscv64-embedded.buildPackages.gcc
];
in
{
legacyPackages = pkgs;
devShell = pkgs.mkShell.override { stdenv = pkgs.clangStdenv; } {
buildInputs = deps;
RV64_TOOLCHAIN_ROOT = "${pkgs.pkgsCross.riscv64-embedded.buildPackages.gcc}";
shellHook = ''
export EMU_CC=$RV64_TOOLCHAIN_ROOT/bin/riscv64-none-elf-gcc
export EMU_OBJCOPY=$RV64_TOOLCHAIN_ROOT/bin/riscv64-none-elf-objcopy
make test-img
unset EMU_CC
unset EMU_OBJCOPY
'';
};
}
)
// { inherit inputs;};
}
8 changes: 4 additions & 4 deletions src/imgfile/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
CSRCS = $(wildcard *.c)
CC ?= riscv64-linux-gnu-gcc
OBJCOPY ?= riscv64-linux-gnu-objcopy
EMU_CC ?= riscv64-linux-gnu-gcc
EMU_OBJCOPY ?= riscv64-linux-gnu-objcopy

compile:
@echo "Compiling..."
@riscv64-linux-gnu-gcc -march=rv64g -ffreestanding -nostdlib -static -Wl,-Ttext=0 -O2 -o prog $(CSRCS)
@riscv64-linux-gnu-objcopy -O binary --only-section=.text prog prog.bin
$(EMU_CC) -march=rv64g -ffreestanding -nostdlib -static -Wl,-Ttext=0 -O2 -o prog $(CSRCS)
$(EMU_OBJCOPY) -O binary --only-section=.text prog prog.bin
@echo "Compilation complete."

0 comments on commit 2b1f835

Please sign in to comment.