Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README.md out of date or missing something obvious! #20

Open
tlaurion opened this issue May 9, 2024 · 8 comments
Open

README.md out of date or missing something obvious! #20

tlaurion opened this issue May 9, 2024 · 8 comments

Comments

@tlaurion
Copy link

tlaurion commented May 9, 2024

Hey @jmbaur ! Frist, amazing work here and this project is inspiring in a lot of regards (linuxboot/heads maintainer here)

I did not have enough nix knowledge before to be able to test this project. Now I somewhat do, but still not enough to understand where I fail to produce qemu x86 target

Here's a summary of my understanding:

  • The flake.nix file defines the top-level structure of the Nix flake and imports the boards.nix file, which defines the board configurations, including qemu-x86_64.
  • The boards.nix file defines a function lib.mapAttrs' that maps over the available board configurations, including qemu-x86_64. This function takes an optional config argument and evaluates a set of modules, including options.nix and boards/${board}/config.nix, to build the board configuration.
  • The options.nix file provides a comprehensive set of default options and configurations for building the tinyboot project and its board configurations. These options cover various aspects, such as the kernel package, kernel configuration file, command line arguments, device tree blobs (DTBs), firmware directories, coreboot integration, verified boot settings, log levels, and more.
  • The pkgs/tinyboot.nix file defines the tinyboot package, which is a core component of the tinyboot project. It is responsible for fetching the source code, setting up the build environment, compiling the code using the zig compiler, and installing the built artifacts.
  • The pkgs/linux/default.nix file defines a function for building a custom Linux kernel package with specific configurations, including applying patches, setting kernel configuration options, and baking in command-line arguments.
  • The boards/qemu-x86_64/config.nix file contains the specific configuration options and settings for the qemu-x86_64 board configuration.
  • Based on the provided files and the structure of the project, the correct way to build the qemu-x86_64 board configuration should be:
    nix build .#coreboot-qemu-x86_64

But it doesn't :)
From my understanding, I would have expected to be able to do
nix build .#coreboot-qemu-x86_64

But nope.

What Am I missing?

@tlaurion
Copy link
Author

tlaurion commented May 9, 2024

From https://github.com/jmbaur/tinyboot/blob/f35cf5a87207ff7b093b0c68fd24b7cf818d5290/README.md#usage

It should be as simple as:
nix run github:jmbaur/tinyboot#coreboot-<your_board>.config.build.installScript

user@heads-tests-deb12-nix:~/tinyboot$ nix run github:jmbaur/tinyboot#coreboot-qemu-x86_64.config.build.installScript
error: flake 'github:jmbaur/tinyboot' does not provide attribute 'apps.x86_64-linux.coreboot-qemu-x86_64.config.build.installScript', 'packages.x86_64-linux.coreboot-qemu-x86_64.config.build.installScript', 'legacyPackages.x86_64-linux.coreboot-qemu-x86_64.config.build.installScript' or 'coreboot-qemu-x86_64.config.build.installScript'

@jmbaur
Copy link
Owner

jmbaur commented May 9, 2024

Hi @tlaurion, thanks for the appreciation! Most of this work has been experimental, and a work-in-progress, but at points has been something that I've used on a daily basis on some chromebooks I have. There's been a rewrite of the original rust codebase to zig for a few reasons (final binary size being one of them), and the port is not yet complete, so I wouldn't expect everthing to work quite yet.

Regarding your description of the nix setup, most of it is correct. I apologize about the lacking/incorrect documentation, I'll work on fixing that up. nix build .#coreboot-qemu-x86_64 doesn't work because that attribute is an output from lib.evalModules. You should be able to run nix build .#coreboot-qemu-x86_64.config.build.firmware and that should be something you can pass to qemu-system-x86_64 -bios ... to boot up a full coreboot image. I don't regularly test the qemu coreboot builds though, as for development (with zig build run), I'm just doing direct boot into the linux kernel (i.e. qemu-system-x86_64 -kernel ...).

@jmbaur
Copy link
Owner

jmbaur commented May 9, 2024

It looks like the current build of coreboot-qemu-x86_64.config.build.firmware is broken right now due to some invalid fetches from review.coreboot.org for the amd_blobs repo.

@jmbaur
Copy link
Owner

jmbaur commented May 9, 2024

Should be fixed with c32354b

Actually seems like something is not working quite well with fetching from review.coreboot.org...

coreboot> error: RPC failed; curl 92 HTTP/2 stream 3 was not closed cleanly: PROTOCOL_ERROR (err 1)
coreboot> error: 30 bytes of body are still expected
coreboot> fatal: expected flush after ref listing
coreboot> remote: Counting objects: 802524, done

Edit: sorry for the churn, switched to using the mirrors on github, try from main

@jmbaur
Copy link
Owner

jmbaur commented May 13, 2024

Hey @tlaurion, I ended up changing the attribute path for building the coreboot builds since it makes more sense to be able to run a build command like you had expected. You should now be able to do something like nix build .#tinyboot-qemu-x86_64 and get a full coreboot ROM file.

@tlaurion
Copy link
Author

Builds! Thanks! Happy to finally test this :)

@tlaurion
Copy link
Author

tlaurion commented May 20, 2024

Well. It built, but then how to run it?

EDIT

user@heads-tests-deb12-nix:~/tinyboot$ find /nix/store/*tinyboot*
/nix/store/1j9sd3mkng1k3xl8pdi5qdv1dvzg0ps1-tinyboot-0.1.0.drv
/nix/store/bdx4q1cnwp08a5p40v5nrwknbg267447-tinyboot-qemu-x86_64
/nix/store/cd9v8x64nv1qb1v7a2v3j4gg91hjigp2-tinyboot-0.1.0
/nix/store/cd9v8x64nv1qb1v7a2v3j4gg91hjigp2-tinyboot-0.1.0/bin
/nix/store/cd9v8x64nv1qb1v7a2v3j4gg91hjigp2-tinyboot-0.1.0/bin/tboot-nixos-install
/nix/store/cd9v8x64nv1qb1v7a2v3j4gg91hjigp2-tinyboot-0.1.0/bin/tboot-bless-boot-generator
/nix/store/cd9v8x64nv1qb1v7a2v3j4gg91hjigp2-tinyboot-0.1.0/bin/xmodem
/nix/store/cd9v8x64nv1qb1v7a2v3j4gg91hjigp2-tinyboot-0.1.0/bin/tboot-bless-boot
/nix/store/cd9v8x64nv1qb1v7a2v3j4gg91hjigp2-tinyboot-0.1.0/tboot-loader.cpio.xz
/nix/store/kdc81bx17lvjw37n9xlmjiy3a63nj6n2-tinyboot-qemu-x86_64.drv

No kernel?

EDIT:
okok
qemu-system-x86_64 -machine q35 -bios /nix/store/bdx4q1cnwp08a5p40v5nrwknbg267447-tinyboot-qemu-x86_64

@tlaurion tlaurion reopened this May 20, 2024
@tlaurion
Copy link
Author

tlaurion commented May 20, 2024

Would be nice if you provided a lillte more information then the now updated README.md not explaining how to reproduce testing environement a little mode detailed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants