{"id":13773692,"url":"https://github.com/linuxboot/heads","last_synced_at":"2025-04-12T12:37:35.683Z","repository":{"id":37740769,"uuid":"64810881","full_name":"linuxboot/heads","owner":"linuxboot","description":"A minimal Linux that runs as a coreboot or LinuxBoot ROM payload to provide a secure, flexible boot environment for laptops, workstations and servers.","archived":false,"fork":false,"pushed_at":"2024-10-29T12:58:10.000Z","size":8500,"stargazers_count":1419,"open_issues_count":304,"forks_count":186,"subscribers_count":65,"default_branch":"master","last_synced_at":"2024-10-29T15:24:18.621Z","etag":null,"topics":["bootrom","coreboot","firmware","linux","rom","tpm","verifiedboot","xen"],"latest_commit_sha":null,"homepage":"https://osresearch.net/","language":"Makefile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/linuxboot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"tlaurion","open_collective":"insurgo"}},"created_at":"2016-08-03T03:08:27.000Z","updated_at":"2024-10-29T13:11:43.000Z","dependencies_parsed_at":"2023-12-20T09:47:06.853Z","dependency_job_id":"ec4095b3-3547-4725-aa71-8e7cde57077c","html_url":"https://github.com/linuxboot/heads","commit_stats":null,"previous_names":["linuxboot/heads","osresearch/heads"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linuxboot%2Fheads","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linuxboot%2Fheads/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linuxboot%2Fheads/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linuxboot%2Fheads/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/linuxboot","download_url":"https://codeload.github.com/linuxboot/heads/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247318739,"owners_count":20919484,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bootrom","coreboot","firmware","linux","rom","tpm","verifiedboot","xen"],"created_at":"2024-08-03T17:01:19.053Z","updated_at":"2025-04-05T10:02:13.191Z","avatar_url":"https://github.com/linuxboot.png","language":"Makefile","readme":"![Heads booting on an x230](https://user-images.githubusercontent.com/827570/156627927-7239a936-e7b1-4ffb-9329-1c422dc70266.jpeg)\n\nHeads: the other side of TAILS\n==\n\nHeads is a configuration for laptops and servers that tries to bring\nmore security to commodity hardware.  Among its goals are:\n\n* Use free software on the boot path\n* Move the root of trust into hardware (or at least the ROM bootblock)\n* Measure and attest to the state of the firmware\n* Measure and verify all filesystems\n\n![Flashing Heads into the boot ROM](https://farm1.staticflickr.com/553/30969183324_c31d8f2dee_z_d.jpg)\n\nNOTE: It is a work in progress and not yet ready for non-technical users.\nIf you're interested in contributing, please get in touch.\nInstallation requires disassembly of your laptop or server,\nexternal SPI flash programmers, possible risk of destruction and\nsignificant frustration.\n\nMore information is available in [the 33C3 presentation of building \"Slightly more secure systems\"](https://trmm.net/Heads_33c3).\n\nDocumentation\n===\nPlease refer to [Heads-wiki](https://osresearch.net) for your Heads' documentation needs.\n\nContributing\n===\nWe welcome contributions to the Heads project! Before contributing, please read our [Contributing Guidelines](CONTRIBUTING.md) for information on how to get started, submit issues, and propose changes.\n\n\nBuilding heads with prebuilt and versioned docker images\n==\n\nHeads now builds with Nix built docker images since https://github.com/linuxboot/heads/pull/1661.\n\nThe short path to build Heads is to do what CircleCI would do (./docker_repro.sh under heads git cloned directory):\n- Install _docker-ce_ for your OS of choice (refer to their documentation)\n- run `./docker_repro.sh make BOARD=XYZ`\n\nUsing Nix local dev environement / building docker images with Nix\n==\n\nUnder QubesOS?\n===\n* Setup nix persistent layer under QubesOS (Thanks @rapenne-s !)\n  * https://dataswamp.org/~solene/2023-05-15-qubes-os-install-nix.html\n* Install docker under QubesOS (imperfect old article of mine. Better somewhere?)\n  * https://gist.github.com/tlaurion/9113983bbdead492735c8438cd14d6cd\n\nBuild docker from nix develop layer locally\n===\n\n#### Set up Nix and flakes  \n\n* If you don't already have Nix, install it:\n    * `[ -d /nix ] || sh \u003c(curl -L https://nixos.org/nix/install) --no-daemon`\n    * `. /home/user/.nix-profile/etc/profile.d/nix.sh`\n* Enable flake support in nix\n    * `mkdir -p ~/.config/nix`\n    * `echo 'experimental-features = nix-command flakes' \u003e\u003e~/.config/nix/nix.conf`\n\n\n#### Build image\n\n* Have docker and Nix installed\n\n* Build nix developer local environment with flakes locked to specified versions  \n    * `./docker_local_dev.sh`\n\nOn some hardened OSes, you may encounter problems with ptrace.\n```\n       \u003e proot error: ptrace(TRACEME): Operation not permitted\n```\nThe most likely reason is that your [kernel.yama.ptrace_scope](https://www.kernel.org/doc/Documentation/security/Yama.txt) variable is too high and doesn't allow docker+nix to run properly.\nYou'll need to set kernel.yama.ptrace_scope to 1 while you build the heads binary.\n\n```\nsudo sysctl kernel.yama.ptrace_scope #show you the actual value, probably 2 or 3\nsudo sysctl -w kernel.yama.ptrace_scope=1 #setup the value to let nix+docker run properly\n```\n(don't forget to put back the value you had after finishing build head)\n\nDone!\n\nYour local docker image \"linuxboot/heads:dev-env\" is ready to use, reproducible for the specific Heads commit used to build it, and will produce ROMs reproducible for that Heads commit ID.\n\nJump into nix develop created docker image for interactive workflow\n====\nThere is 3 helpers:\n- `./docker_local_dev.sh`: for developers wanting to customize docker image built from flake.nix(nix devenv creation) and flake.lock (pinned versions used by flake.nix)\n- `./docker_latest.sh`: for Heads developers, wanting to use latest published docker images to develop Heads\n- `./docker_repro.sh`: versioned docker image used under CircleCI to produce reproducivle builds, both locally and under CircleCI. **Use this one if in doubt**\n\nie: `./docker_repro.sh` will jump into CircleCI used versioned docker image for that Heads commit id to build images reproducibly if git repo is clean (not dirty).\n\nFrom there you can use the docker image interactively.\n\n`make BOARD=board_name` where board_name is the name of the board directory under `./boards` directory.\n\n\nOne such useful example is to build and test qemu board roms and test them through qemu/kvm/swtpm provided in the docker image. \nPlease refer to [qemu documentation](targets/qemu.md) for more information.\n\nEg:\n```\n./docker_repro.sh make BOARD=qemu-coreboot-fbwhiptail-tpm2 # Build rom, export public key to emulated usb storage from qemu runtime\n./docker_repro.sh make BOARD=qemu-coreboot-fbwhiptail-tpm2 PUBKEY_ASC=~/pubkey.asc inject_gpg # Inject pubkey into rom image\n./docker_repro.sh make BOARD=qemu-coreboot-fbwhiptail-tpm2 USB_TOKEN=Nitrokey3NFC PUBKEY_ASC=~/pubkey.asc ROOT_DISK_IMG=~/qemu-disks/debian-9.cow2 INSTALL_IMG=~/Downloads/debian-9.13.0-amd64-xfce-CD-1.iso run # Install\n```\n\nAlternatively, you can use locally built docker image to build a board ROM image in a single call **but do not expect reproducible builds if not using versioned docker images as per CircleCI as per usage of `./docker_repro.sh`**\n\nEg:\n`./docker_local_dev.sh make BOARD=nitropad-nv41`\n\n\nPull docker hub image to prepare reproducible ROMs as CircleCI in one call\n====\n```\n./docker_repro.sh make BOARD=x230-hotp-maximized\n./docker_repro.sh make BOARD=nitropad-nv41\n```\n\nMaintenance notes on docker image\n===\nRedo the steps above in case the flake.nix or nix.lock changes. Commit changes. Then publish on docker hub:\n\n```\n#put relevant things in variables:\ndocker_version=\"vx.y.z\" \u0026\u0026 docker_hub_repo=\"tlaurion/heads-dev-env\"\n#update pinned packages to latest available ones if needed, modify flake.nix derivatives if needed:\nnix flakes update\n#modify CircleCI image to use newly pushed docker image\nsed \"s@\\(image: \\)\\(.*\\):\\(v[0-9]*\\.[0-9]*\\.[0-9]*\\)@\\1\\2:$docker_version@\" -i .circleci/config.yml\n# commit changes\ngit commit --signoff -m \"Bump nix develop based docker image to $docker_hub_repo:$docker_version\"\n#use commited flake.nix and flake.lock in nix develop\nnix --print-build-logs --verbose develop --ignore-environment --command true\n#build new docker image from nix develop environement\nnix --print-build-logs --verbose build .#dockerImage \u0026\u0026 docker load \u003c result\n#tag produced docker image with new version\ndocker tag linuxboot/heads:dev-env \"$docker_hub_repo:$docker_version\"\n#push newly created docker image to docker hub\ndocker push \"$docker_hub_repo:$docker_version\"\n#test with CircleCI in PR. Merge.\ngit push ...\n#make last tested docker image version the latest\ndocker tag \"$docker_hub_repo:$docker_version\" \"$docker_hub_repo:latest\"\ndocker push \"$docker_hub_repo:latest\"\n```\n\nThis can be put in reproducible oneliners to ease maintainership.\n\nTest image in dirty mode:\n```\ndocker_version=\"vx.y.z\" \u0026\u0026 docker_hub_repo=\"tlaurion/heads-dev-env\" \u0026\u0026 sed \"s@\\(image: \\)\\(.*\\):\\(v[0-9]*\\.[0-9]*\\.[0-9]*\\)@\\1\\2:$docker_version@\" -i .circleci/config.yml \u0026\u0026 nix --print-build-logs --verbose develop --ignore-environment --command true \u0026\u0026 nix --print-build-logs --verbose build .#dockerImage \u0026\u0026 docker load \u003c result \u0026\u0026 docker tag linuxboot/heads:dev-env \"$docker_hub_repo:$docker_version\" \u0026\u0026 docker push \"$docker_hub_repo:$docker_version\"\n```\n\nNotes:\n- Local builds can use \":latest\" tag, which will use latest tested successful CircleCI run\n- To reproduce CirlceCI results, make sure to use the same versioned tag declared under .circleci/config.yml's \"image:\" \n\n\n\nGeneral notes on reproducible builds\n===\nIn order to build reproducible firmware images, Heads builds a specific\nversion of gcc and uses it to compile the Linux kernel and various tools\nthat go into the initrd.  Unfortunately this means the first step is a\nlittle slow since it will clone the `musl-cross-make` tree and build gcc...\n\nOnce that is done, the top level `Makefile` will handle most of the\nremaining details -- it downloads the various packages, verifies the\nhashes, applies Heads specific patches, configures and builds them\nwith the cross compiler, and then copies the necessary parts into\nthe `initrd` directory.\n\nThere are still dependencies on the build system's coreutils in\n`/bin` and `/usr/bin/`, but any problems should be detectable if you\nend up with a different hash than the official builds.\n\nThe various components that are downloaded are in the `./modules`\ndirectory and include:\n\n* [musl-libc](https://www.musl-libc.org/)\n* [busybox](https://busybox.net/)\n* [kexec](https://wiki.archlinux.org/index.php/kexec)\n* [mbedtls](https://tls.mbed.org/)\n* [tpmtotp](https://trmm.net/Tpmtotp)\n* [coreboot](https://www.coreboot.org/)\n* [cryptsetup](https://gitlab.com/cryptsetup/cryptsetup)\n* [lvm2](https://sourceware.org/lvm2/)\n* [gnupg](https://www.gnupg.org/)\n* [Linux kernel](https://kernel.org)\n\nWe also recommend installing [Qubes OS](https://www.qubes-os.org/),\nalthough there Heads can `kexec` into any Linux or\n[multiboot](https://www.gnu.org/software/grub/manual/multiboot/multiboot.html)\nkernel.\n\nNotes:\n---\n\n* Building coreboot's cross compilers can take a while.  Luckily this is only done once.\n* Builds are finally reproducible! The [reproduciblebuilds tag](https://github.com/osresearch/heads/issues?q=is%3Aopen+is%3Aissue+milestone%3Areproduciblebuilds) tracks any regressions.\n* Currently only tested in QEMU, the Thinkpad x230, Librem series and the Chell Chromebook.\n** Xen does not work in QEMU.  Signing, HOTP, and TOTP do work; see below.\n* Building for the Lenovo X220 requires binary blobs to be placed in the blobs/x220/ folder.\nSee the readme.md file in that folder\n* Building for the Librem 13 v2/v3 or Librem 15 v3/v4 requires binary blobs to be placed in\nthe blobs/librem_skl folder. See the readme.md file in that folder\n\nQEMU:\n---\n\nOS booting can be tested in QEMU using a software TPM.  HOTP can be tested by forwarding a USB token from the host to the guest.\n\nFor more information and setup instructions, refer to the [qemu documentation](targets/qemu.md).\n\ncoreboot console messages\n---\nThe coreboot console messages are stored in the CBMEM region\nand can be read by the Linux payload with the `cbmem --console | less`\ncommand.  There is lots of interesting data about the state of the\nsystem.\n","funding_links":["https://github.com/sponsors/tlaurion","https://opencollective.com/insurgo"],"categories":["Technologies and Terminology","Makefile"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinuxboot%2Fheads","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flinuxboot%2Fheads","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinuxboot%2Fheads/lists"}