diff --git a/flake.nix b/flake.nix index a119f39..16fcd9e 100644 --- a/flake.nix +++ b/flake.nix @@ -28,6 +28,15 @@ ./no-compressed.nix ]; }; + + # FPGA Lagarto Hun CPU + lagarto-hun = nixpkgs.lib.nixosSystem { + system = "${system}"; + modules = [ + ./configuration.nix + ./lagarto-hun.nix + ]; + }; }; # A development shell with QEMU ready to boot the RISC-V system in an x86 diff --git a/lagarto-hun.nix b/lagarto-hun.nix new file mode 100644 index 0000000..3259beb --- /dev/null +++ b/lagarto-hun.nix @@ -0,0 +1,63 @@ +{ config, lib, pkgs, modulesPath, ... }: + +let + overlay = prev: final: { + uboot = prev.ubootQemuRiscv64Smode.override { + filesToInstall = [ "u-boot.bin" "u-boot-nodtb.bin" ]; + extraConfig = '' + CONFIG_RISCV=y + CONFIG_RISCV_SMODE=y + CONFIG_SYS_MALLOC_LEN=0x800000 + CONFIG_NR_DRAM_BANKS=1 + CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y + CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x80200000 + CONFIG_ENV_SIZE=0x20000 + CONFIG_SYS_LOAD_ADDR=0x80200000 + CONFIG_ARCH_RV64I=y + CONFIG_FIT=y + CONFIG_DISTRO_DEFAULTS=y + CONFIG_DISPLAY_CPUINFO=y + CONFIG_DISPLAY_BOARDINFO=y + CONFIG_SYS_CBSIZE=256 + CONFIG_SYS_PBSIZE=276 + CONFIG_SYS_BOOTM_LEN=0x4000000 + CONFIG_CMD_BOOTEFI_SELFTEST=y + CONFIG_CMD_NVEDIT_EFI=y + # CONFIG_CMD_MII is not set + CONFIG_SYS_RELOC_GD_ENV_ADDR=y + CONFIG_DM_MTD=y + CONFIG_FLASH_SHOW_PROGRESS=0 + CONFIG_SYS_MAX_FLASH_BANKS=2 + #CONFIG_TEXT_BASE=0x80000000 + # ------------------------- + CONFIG_RISCV_ISA_C=n + # CONFIG_OF_EMBED=n + # CONFIG_OF_SEPARATE=y + # CONFIG_OF_OMIT_DTB=y + CONFIG_REQUIRE_SERIAL_CONSOLE=n + CONFIG_SERIAL_SEARCH_ALL=y + CONFIG_OF_CONTROL=y + CONFIG_OF_BOARD=y + CONFIG_OF_HAS_PRIOR_STAGE=y + CONFIG_BLKMAP=y + CONFIG_CMD_BLKMAP=y + CONFIG_SBI_V01=y + CONFIG_DEBUG_UART=y + CONFIG_DEBUG_UART_ANNOUNCE=y + CONFIG_DEBUG_SBI_CONSOLE=y + ''; + }; + + opensbi = prev.opensbi.overrideAttrs (old: { + makeFlags = old.makeFlags ++ [ + # Build OpenSBI without compressed instructions + "PLATFORM_RISCV_ISA=rv64g" + "PLATFORM=fpga/openpiton" + # Check with: riscv64-unknown-elf-objdump -d -M no-aliases rotate + "FW_PAYLOAD_PATH=${final.uboot-fpga}/u-boot-nodtb.bin" + ]; + }); + }; +in { + nixpkgs.overlays = [ overlay ]; +} diff --git a/overlay.nix b/overlay.nix index f442738..33896b1 100644 --- a/overlay.nix +++ b/overlay.nix @@ -3,14 +3,6 @@ final: prev: # Changes to packages from nixpkgs { - opensbi = prev.opensbi.overrideAttrs (old: { - makeFlags = old.makeFlags ++ [ - # Build OpenSBI without compressed instructions - "PLATFORM_RISCV_ISA=rv64g" - # Check with: riscv64-unknown-elf-objdump -d -M no-aliases rotate - ]; - }); - # Fix GCC 13 format-overflow warning/error: # ../src/shared/install.c:444:64: error: ā€˜%sā€™ directive argument is null [-Werror=format-overflow=] # 444 | err = log_error_errno(changes[i].type, "Failed to %s unit, unit %s does not exist.", @@ -40,62 +32,6 @@ final: prev: ]; }); - uboot-fpga = prev.ubootQemuRiscv64Smode.override { - filesToInstall = [ "u-boot.bin" "u-boot-nodtb.bin" ]; - extraConfig = '' - CONFIG_RISCV=y - CONFIG_RISCV_SMODE=y - CONFIG_SYS_MALLOC_LEN=0x800000 - CONFIG_NR_DRAM_BANKS=1 - CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y - CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x80200000 - CONFIG_ENV_SIZE=0x20000 - CONFIG_SYS_LOAD_ADDR=0x80200000 - CONFIG_ARCH_RV64I=y - CONFIG_FIT=y - CONFIG_DISTRO_DEFAULTS=y - CONFIG_DISPLAY_CPUINFO=y - CONFIG_DISPLAY_BOARDINFO=y - CONFIG_SYS_CBSIZE=256 - CONFIG_SYS_PBSIZE=276 - CONFIG_SYS_BOOTM_LEN=0x4000000 - CONFIG_CMD_BOOTEFI_SELFTEST=y - CONFIG_CMD_NVEDIT_EFI=y - # CONFIG_CMD_MII is not set - CONFIG_SYS_RELOC_GD_ENV_ADDR=y - CONFIG_DM_MTD=y - CONFIG_FLASH_SHOW_PROGRESS=0 - CONFIG_SYS_MAX_FLASH_BANKS=2 - #CONFIG_TEXT_BASE=0x80000000 - # ------------------------- - CONFIG_RISCV_ISA_C=n - # CONFIG_OF_EMBED=n - # CONFIG_OF_SEPARATE=y - # CONFIG_OF_OMIT_DTB=y - CONFIG_REQUIRE_SERIAL_CONSOLE=n - CONFIG_SERIAL_SEARCH_ALL=y - CONFIG_OF_CONTROL=y - CONFIG_OF_BOARD=y - CONFIG_OF_HAS_PRIOR_STAGE=y - CONFIG_BLKMAP=y - CONFIG_CMD_BLKMAP=y - CONFIG_SBI_V01=y - CONFIG_DEBUG_UART=y - CONFIG_DEBUG_UART_ANNOUNCE=y - CONFIG_DEBUG_SBI_CONSOLE=y - ''; - }; - - opensbi-fpga = prev.opensbi.overrideAttrs (old: { - makeFlags = old.makeFlags ++ [ - # Build OpenSBI without compressed instructions - "PLATFORM_RISCV_ISA=rv64g" - "PLATFORM=fpga/openpiton" - # Check with: riscv64-unknown-elf-objdump -d -M no-aliases rotate - "FW_PAYLOAD_PATH=${final.uboot-fpga}/u-boot-nodtb.bin" - ]; - }); - linuxPackagesCustom = prev.linuxPackagesFor (prev.linux.override { structuredExtraConfig = with prev.lib.kernel; { KEXEC = yes;