Giter VIP home page Giter VIP logo

nixos-imx's Introduction

NixOS for i.MX (8)

As part of my master thesis I need to run experiments booting NixOS on an "IoT"-ish device that has a reasonably industry-standard boot architecture. NXP kindly provided me with an i.MX 8M Plus EvaluationKit board, so here are Nix packages that build -- and a NixOS module that "installs" -- the boards firmware, bootloader, and kernel.

Status

  • All boot components (except the proprietary firmware-imx) are built from sources, and they seem to be working fine.
  • The board boots both with the mainline kernel and with NXP's fork. (At least) serial, USB and Ethernet work with either.
  • Only NXP's kernel enables HDMI output (for TTYs), but GPU drivers are still missing (or not configured).
  • Some things in the imx8-boot module, especially the script constructing default-boot-image, are somewhat specific to the iMX8MP and may very well require adjustments for other i.MX boards.
  • Cross-compiling (from x64) works and the resulting system boots.

Usage

This repository exports its NixOS module, example host configuration, and its nixpkgs overlays, including their packages, as a Nix flake, and thus expects to be used by other Nix flakes.

When aiming to configure a NixOS host running on an i.MX, and starting from scratch, it may be a good starting point to copy the flake.nix and host/imx8mp.nix.md to a new repo. Then uncomment the nixos-imx input and remove the overlays variable in flake.nix, rename and adjust the file in hosts/, and call nix build to see if things work. host/imx8mp.nix.md > Installation has basic instructions on how to create a boot medium from the configuration.

Building

Chances are that while the i.MX is aarch64, one wants to build its system installation (/OS image) on a x64 host.

With Nix/NixOS, (generally) either all or none of a host's configuration has to be cross-compiled. Anything else would be a huge mess to configure, and any dependencies that natively and cross-compiled packages have in common would (by default) not bw shared.

When building on a x64 host, native aarch64 builds can be executed via a qemu "user" binfmt registration. This incurs a slowdown of about 10x on anything that needs to be built (like the i.MX Kernel), but the official NixOS binary caches provide prebuilds for any packages that are defined in nixpkgs and used without modifications.

Creating a binfmt registration should be quite easy on most Linux distributions. With that, only an extra-platforms entry in the Nix config should be required to run aarch64 builds through emulation. On NixOS, this is entirely handled by setting boot.binfmt.emulatedSystems = [ "aarch64-linux" ] in the building hosts configuration.

Nix itself supports cross-compiling quite well, but few people seem to be using it with NixOS. Cross-compiling avoids the emulation slowdown, but the (official) binary cache can't be used, and (unless one sets up their own build cache) everything will have to be built locally from source, which overall may or may not be faster. Most of the packages for the i.MX cross-compile, but one (mkimage_imx8) still requires qemu. The flake.nix defines additional hosts prefixed with x64:, which are cross-built from x64 but should otherwise behave the same as their "normal" counterparts.

License

All files in this repository (nixos-imx / NixOS for i.MX) (except LICENSE) are authored by the authors of this repository, and are copyright 2022 Niklas Gollenstede.

This software may be used under the terms of the MIT license, as detailed in ./LICENSE.

This license applies to the files in this repository only. Any external packages are built from sources that have their own licenses, which should be the ones indicated in the package's metadata.

nixos-imx's People

Contributors

niklasgollenstede avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.