at 25.11-pre 2.0 kB view raw
1# To build, use: 2# nix-build nixos -I nixos-config=nixos/modules/installer/sd-card/sd-image-armv7l-multiplatform.nix -A config.system.build.sdImage 3{ 4 config, 5 lib, 6 pkgs, 7 ... 8}: 9 10{ 11 imports = [ 12 ../../profiles/base.nix 13 ./sd-image.nix 14 ]; 15 16 boot.loader.grub.enable = false; 17 boot.loader.generic-extlinux-compatible.enable = true; 18 19 boot.consoleLogLevel = lib.mkDefault 7; 20 boot.kernelPackages = pkgs.linuxPackages_latest; 21 # The serial ports listed here are: 22 # - ttyS0: for Tegra (Jetson TK1) 23 # - ttymxc0: for i.MX6 (Wandboard) 24 # - ttyAMA0: for Allwinner (pcDuino3 Nano) and QEMU's -machine virt 25 # - ttyO0: for OMAP (BeagleBone Black) 26 # - ttySAC2: for Exynos (ODROID-XU3) 27 boot.kernelParams = [ 28 "console=ttyS0,115200n8" 29 "console=ttymxc0,115200n8" 30 "console=ttyAMA0,115200n8" 31 "console=ttyO0,115200n8" 32 "console=ttySAC2,115200n8" 33 "console=tty0" 34 ]; 35 36 sdImage = { 37 populateFirmwareCommands = 38 let 39 configTxt = pkgs.writeText "config.txt" '' 40 # Prevent the firmware from smashing the framebuffer setup done by the mainline kernel 41 # when attempting to show low-voltage or overtemperature warnings. 42 avoid_warnings=1 43 44 [pi2] 45 kernel=u-boot-rpi2.bin 46 47 [pi3] 48 kernel=u-boot-rpi3.bin 49 50 # U-Boot used to need this to work, regardless of whether UART is actually used or not. 51 # TODO: check when/if this can be removed. 52 enable_uart=1 53 ''; 54 in 55 '' 56 (cd ${pkgs.raspberrypifw}/share/raspberrypi/boot && cp bootcode.bin fixup*.dat start*.elf $NIX_BUILD_TOP/firmware/) 57 cp ${pkgs.ubootRaspberryPi2}/u-boot.bin firmware/u-boot-rpi2.bin 58 cp ${pkgs.ubootRaspberryPi3_32bit}/u-boot.bin firmware/u-boot-rpi3.bin 59 cp ${configTxt} firmware/config.txt 60 ''; 61 populateRootCommands = '' 62 mkdir -p ./files/boot 63 ${config.boot.loader.generic-extlinux-compatible.populateCmd} -c ${config.system.build.toplevel} -d ./files/boot 64 ''; 65 }; 66}