From c931b5633053d8a945a2aaaa73f0f1e8e6dd90c7 Mon Sep 17 00:00:00 2001 From: Andrew Newman Date: Thu, 11 Apr 2019 18:35:19 +0300 Subject: [PATCH 1/3] Add toradex apalis imx6 board configs --- machines/toradex_apalis_imx6/default.nix | 62 ++++++++++++++++++++++++ machines/toradex_apalis_imx6/system.nix | 22 +++++++++ 2 files changed, 84 insertions(+) create mode 100644 machines/toradex_apalis_imx6/default.nix create mode 100644 machines/toradex_apalis_imx6/system.nix diff --git a/machines/toradex_apalis_imx6/default.nix b/machines/toradex_apalis_imx6/default.nix new file mode 100644 index 0000000..21733a7 --- /dev/null +++ b/machines/toradex_apalis_imx6/default.nix @@ -0,0 +1,62 @@ +{ config, pkgs, ... }: +let + toradex_apalis_imx6 = import ./system.nix; +in +{ + # specify the system we're compiling to + nixpkgs.crossSystem = toradex_apalis_imx6; + + # enable free firmware + hardware.enableRedistributableFirmware = true; + + # specify a good kernel version + boot.kernelPackages = pkgs.linuxPackages_5_0; + + # do our own boot-loader + boot.loader.grub.enable = false; + boot.loader.systemd-boot.enable = false; + boot.loader.generic-extlinux-compatible.enable = false; + + # build & install boot loader + sdImage.populateBootCommands = let + kernel = toradex_apalis_imx6.platform.kernelTarget; + init = "${config.system.build.toplevel}/init"; + root = "/dev/mmcblk2p2"; + uboot = pkgs.buildUBoot { + defconfig = "apalis_imx6_defconfig"; + extraMeta.platforms = [toradex_apalis_imx6.system]; + filesToInstall = ["SPL" "u-boot.img"]; + }; + uEnv = pkgs.writeText "uEnv.txt" '' + bootdir= + bootcmd=run uenvcmd; + bootfile=${kernel} + fdtfile=${toradex_apalis_imx6.dtb} + loadaddr=0x11000000 + fdtaddr=0x12000000 + loadfdt=load mmc 0:1 ''${fdtaddr} ''${fdtfile} + loaduimage=load mmc 0:1 ''${loadaddr} ''${bootfile} + uenvcmd=mmc rescan; run loaduimage; run loadfdt; run fdtboot + fdtboot=run mmc_args; bootz ''${loadaddr} - ''${fdtaddr} + mmc_args=setenv bootargs console=''${console} ''${optargs} root=${root} rootfstype=ext4 init=${init} + ''; + + # Populate result/nix-support/tezi folder for ToradexEasyInstaller. + populateToradexTezi = '' + mkdir -p $out/nix-support/tezi/ + cp ${uboot}/SPL $out/nix-support/tezi/ + cp ${uboot}/u-boot.img $out/nix-support/tezi/ + cp ${config.boot.kernelPackages.kernel}/${kernel} $out/nix-support/tezi/ + cp ${config.boot.kernelPackages.kernel}/dtbs/${toradex_apalis_imx6.dtb} $out/nix-support/tezi/ + cp ${uEnv} $out/nix-support/tezi/uEnv.txt + ''; + + in '' + ${populateToradexTezi} + cp ${uboot}/SPL boot/ + cp ${uboot}/u-boot.img boot/ + cp ${config.boot.kernelPackages.kernel}/${kernel} boot/ + cp ${config.boot.kernelPackages.kernel}/dtbs/${toradex_apalis_imx6.dtb} boot/ + cp ${uEnv} boot/uEnv.txt + ''; +} diff --git a/machines/toradex_apalis_imx6/system.nix b/machines/toradex_apalis_imx6/system.nix new file mode 100644 index 0000000..49aa68a --- /dev/null +++ b/machines/toradex_apalis_imx6/system.nix @@ -0,0 +1,22 @@ +with builtins; +{ + config = "armv7l-unknown-linux-gnueabihf"; + system = "armv7l-linux"; + platform = { + name = "toradex_apalis_imx6"; + kernelBaseConfig = "imx_v6_v7_defconfig"; + kernelAutoModules = false; + kernelTarget = "zImage"; + kernelMajor = "2.6"; # Using "2.6" enables 2.6 kernel syscalls in glibc. + kernelArch = "arm"; + kernelDTB = true; + kernelPreferBuiltin = true; + kernelExtraConfig = '' + ''; + gcc = { + cpu = "cortex-a9"; + fpu = "neon"; + }; + }; + dtb = "imx6q-apalis-eval.dtb"; +} From e9cfe64997bdffe96c84fdc43bf51eb9ee745946 Mon Sep 17 00:00:00 2001 From: Andrew Newman Date: Mon, 22 Apr 2019 10:41:41 +0300 Subject: [PATCH 2/3] Disable firmware for toradex apalis imx6 --- machines/toradex_apalis_imx6/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/machines/toradex_apalis_imx6/default.nix b/machines/toradex_apalis_imx6/default.nix index 21733a7..86cbb5c 100644 --- a/machines/toradex_apalis_imx6/default.nix +++ b/machines/toradex_apalis_imx6/default.nix @@ -7,7 +7,7 @@ in nixpkgs.crossSystem = toradex_apalis_imx6; # enable free firmware - hardware.enableRedistributableFirmware = true; + hardware.enableRedistributableFirmware = false; # specify a good kernel version boot.kernelPackages = pkgs.linuxPackages_5_0; From 2887446511450a19126aa76c2d5cacc4e67d14fe Mon Sep 17 00:00:00 2001 From: Andrew Newman Date: Mon, 22 Apr 2019 11:37:30 +0300 Subject: [PATCH 3/3] Add build for toradex apalis imx6 minimal image into TravisCI --- .travis.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.travis.yml b/.travis.yml index d094d60..9d5bcae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -49,6 +49,21 @@ script: | cachix push cross-armed $(nix-store -qd result) fi + # build a toradex apalis imx6 sample image + nix-build . \ + --cores 2 \ + --max-jobs 2 \ + --no-build-output \ + -I nixpkgs=nixpkgs \ + -I machine=machines/toradex_apalis_imx6 \ + -I image=images/minimal + + # push toradex apalis imx6 with permission + if [[ ${CACHIX_AUTH_TOKEN:-} ]]; then + cachix push cross-armed $(readlink -f result) + cachix push cross-armed $(nix-store -qd result) + fi + # kill the background process kill %1 )