From eeecd408829faa3e799b273de7586306d79bd76e Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Thu, 7 Mar 2024 12:04:40 +0100 Subject: [PATCH] Update lagarto-hun config --- lagarto-hun.nix | 121 ++++++++++++++++++++++++++---------------------- 1 file changed, 66 insertions(+), 55 deletions(-) diff --git a/lagarto-hun.nix b/lagarto-hun.nix index 4760e05..f7fbc76 100644 --- a/lagarto-hun.nix +++ b/lagarto-hun.nix @@ -1,39 +1,72 @@ { config, lib, pkgs, modulesPath, ... }: -let - overlay = final: prev: { +{ + imports = [ + "${modulesPath}/installer/sd-card/sd-image.nix" + ]; + + #boot.kernelPackages = pkgs.linuxPackages_latest; + boot = { + kernelPatches = [ + { + name = assert false; "sbi-early-console"; + patch = null; + extraConfig = + # Early console via SBI + '' + RISCV_SBI y + RISCV_SBI_V01 y + SERIAL_EARLYCON y + SERIAL_EARLYCON_RISCV_SBI y + HVC_DRIVER y + HVC_RISCV_SBI y + '' + # Allows regions of persistent memory to be described in the device-tree. + + '' + OF_PMEM y + '' + # Allow you to use a contiguous range of reserved memory as one or more + # persistent block devices (/dev/pmem0) + + '' + LIBNVDIMM y + BLK_DEV_PMEM y + '' + ; + } + ]; + + initrd = { + # Avoid zstd as we don't have the tools in "cucu" machine + compressor = "gzip"; + kernelModules = [ ]; + }; + + loader = { + grub.enable = false; + generic-extlinux-compatible.enable = true; + }; + }; + + sdImage = { + # The image will be loaded as-is in memory, so no compression + compressImage = false; + imageName = "rootfs.img"; + # Not needed for now + expandOnBoot = false; + populateFirmwareCommands = ""; + populateRootCommands = '' + mkdir -p ./files/boot + ${config.boot.loader.generic-extlinux-compatible.populateCmd} \ + -c ${config.system.build.toplevel} \ + -d ./files/boot + ''; + }; + + nixpkgs.overlays = [ (final: prev: { 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 @@ -50,31 +83,9 @@ let 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}/u-boot-nodtb.bin" + "PLATFORM=fpga/openpiton" + "FW_PAYLOAD_PATH=${final.uboot}/u-boot-nodtb.bin" ]; }); - }; -in { - nixpkgs.overlays = [ overlay ]; - - #boot.kernelPackages = pkgs.linuxPackages_latest; - boot.kernelPatches = [ - { - name = assert false; "sbi-early-console"; - patch = null; - extraConfig = '' - # Early console via SBI - RISCV_SBI y - RISCV_SBI_V01 y - SERIAL_EARLYCON y - SERIAL_EARLYCON_RISCV_SBI y - HVC_DRIVER y - HVC_RISCV_SBI y - ''; - } - ]; + }) ]; }