Coreboot: Difference between revisions

imported>Lenzj
No edit summary
Ehmry (talk | contribs)
Coreboot comes with a nix-shell expression.
 
(4 intermediate revisions by 4 users not shown)
Line 1: Line 1:
== Building in nix-shell ==
== Building as Nix Derivation ==
Note: the following was tested and working on NixOS 21.11 (Porcupine) while compiling the QEMU target for Coreboot v4.15 as well as Coreboot master (7b168c92f6).


To build your own coreboot bios:
There is a commented example of building Coreboot as Nix derivation at [https://github.com/blitz/nix-coreboot blitz/nix-coreboot] on Github.


Create a <code>shell.nix</code>, and run <code>nix-shell</code>
== Building in nix-shell ==
 
Coreboot as of 24.02 comes with a Nix shell expression for x86 at <code>util/nixshell//devshell-i386.nix</code>.
<syntaxhighlight lang="nix">
# shell.nix
 
# NOTE we need mkShellNoCC
# mkShell would add the regular gcc, which has no ada (gnat)
# https://github.com/NixOS/nixpkgs/issues/142943
 
with import <nixpkgs> { };
mkShellNoCC {
  buildInputs = [
    gnat11 # gcc with ada
    #gnatboot # gnat1
    ncurses # make menuconfig
    m4 flex bison # Generate flashmap descriptor parser
    #clang
    zlib
    #acpica-tools # iasl
    pkgconfig
    qemu # test the image
  ];
  shellHook = ''
    # TODO remove?
    NIX_LDFLAGS="$NIX_LDFLAGS -lncurses"
  '';
}
</syntaxhighlight>
 
Now we can build coreboot:


<syntaxHighlight lang=bash>
<syntaxHighlight lang=bash>
Line 46: Line 17:
git submodule update --init --checkout --depth 1
git submodule update --init --checkout --depth 1
du -sh . # ~700 MByte
du -sh . # ~700 MByte
nix-shell --pure util/nixshell/devshell-i386.nix


# configure
# configure
# set mainboard model, chip size, ...
# set mainboard model, chip size, ...
make menuconfig MENUCONFIG_COLOR=blackbg # blackbg = dark mode
make menuconfig MENUCONFIG_COLOR=blackbg # blackbg = dark mode
# build toolchain for a x86 target
# Note: the i386 toolchain is used for all x86 platforms including x86_64.
# See https://doc.coreboot.org/tutorial/part1.html
# to list all targets: make help
make crossgcc-i386 CPUS=$(nproc)


# build firmware
# build firmware
Line 85: Line 52:
* https://wiki.gentoo.org/wiki/Coreboot
* https://wiki.gentoo.org/wiki/Coreboot
* flashing the new bios image
* flashing the new bios image
** https://doc.coreboot.org/flash_tutorial/
** https://doc.coreboot.org/tutorial/flashing_firmware/index.html
** https://libreboot.org/docs/install/spi.html
** https://libreboot.org/docs/install/spi.html
[[Category:Booting]]