Lesson1: Difference between revisions
(Added zlib build dependency) |
MartinRoth (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
coreboot lesson 1 - Starting from scratch | coreboot lesson 1 - Starting from scratch | ||
From a fresh [http://releases.ubuntu.com/ | From a fresh [http://releases.ubuntu.com/16.04/ubuntu-16.04-desktop-amd64.iso ubuntu 16.04 linux] install, here are all the steps required for a very basic build: | ||
==Download, configure, and build coreboot== | ==Download, configure, and build coreboot == | ||
=== | ===Step [[Lesson1#1|1]] - Install tools and libraries needed for coreboot === | ||
$ sudo apt-get install git-core libncurses5-dev m4 bison flex zlib1g-dev | $ sudo apt-get install -y g++ git-core libncurses5-dev m4 bison flex zlib1g-dev | ||
=== | ===Step [[Lesson1#2|2]] - Download coreboot source tree === | ||
$ git clone http://review.coreboot.org/coreboot | $ git clone http://review.coreboot.org/coreboot | ||
$ cd coreboot | $ cd coreboot | ||
=== | ===Step [[Lesson1#3|3]] - Build the coreboot toolchain === | ||
Please note that this can take a significant amount of time | Please note that this can take a significant amount of time | ||
$ make crossgcc-i386 CPUS=$(nproc) | $ make crossgcc-i386 CPUS=$(nproc) | ||
=== | ===Step [[Lesson1#4|4]] - Build the payload - coreinfo === | ||
$ | $ make -C payloads/coreinfo olddefconfig | ||
$ make -C payloads/coreinfo | |||
$ make | |||
=== | ===Step [[Lesson1#5|5]] - Configure the mainboard === | ||
$ make menuconfig | $ make menuconfig | ||
select 'Mainboard' menu | select 'Mainboard' menu | ||
Beside 'Mainboard vendor' should be '(Emulation)' | |||
Beside 'Mainboard model' should be 'QEMU x86 i440fx/piix4' | |||
select exit | select exit | ||
Line 41: | Line 39: | ||
$ make savedefconfig | $ make savedefconfig | ||
$ cat defconfig | $ cat defconfig | ||
There should only be | There should only be two lines: | ||
CONFIG_PAYLOAD_ELF=y | CONFIG_PAYLOAD_ELF=y | ||
CONFIG_PAYLOAD_FILE="payloads/coreinfo/build/coreinfo.elf" | CONFIG_PAYLOAD_FILE="payloads/coreinfo/build/coreinfo.elf" | ||
=== | ===Step [[Lesson1#6|6]] - build coreboot === | ||
$ make | $ make | ||
At the end of the build, you should see: | |||
Build emulation/qemu-i440fx (QEMU x86 i440fx/piix4) | |||
This means your build was successful. The output from the build | |||
is in the build directory. build/coreboot.rom is the full rom file. | |||
== Test the image using QEMU == | == Test the image using QEMU == | ||
Install QEMU | === Step [[Lesson1#7|7]] - Install QEMU === | ||
$ sudo apt-get install qemu | $ sudo apt-get install -y qemu | ||
Start QEMU: | === Step [[Lesson1#8|8]] - Run QEMU === | ||
Start QEMU, and point it to the ROM you just built: | |||
$ qemu-system-x86_64 -bios build/coreboot.rom -serial stdio | $ qemu-system-x86_64 -bios build/coreboot.rom -serial stdio | ||
Line 68: | Line 72: | ||
- git-core is needed to download coreboot from the coreboot git repository. | - git-core is needed to download coreboot from the coreboot git repository. | ||
- libncurses5-dev is needed to build the menu for 'make menuconfig' | - libncurses5-dev is needed to build the menu for 'make menuconfig' | ||
- m4, bison, and flex are needed to build the coreboot toolchain. | - g++, m4, bison, and flex are needed to build the coreboot toolchain. | ||
If you had started from a different distribution, you might need to install the basic gcc toolchain, wget, make, or many other items. | If you had started from a different distribution, you might need to install the basic gcc toolchain, wget, make, or many other items. | ||
Line 80: | Line 84: | ||
This builds one of the coreboot cross-compiler toolchains for X86 platforms. Because of the variability of compilers and the other required tools between the various operating systems that coreboot can be built on, coreboot supplies and uses its own cross-compiler toolchain to build the binaries that end up as part of the coreboot ROM. The toolchain provided by the operating system (the 'host toolchain') is used to build various tools that will run on the local system during the build process. | This builds one of the coreboot cross-compiler toolchains for X86 platforms. Because of the variability of compilers and the other required tools between the various operating systems that coreboot can be built on, coreboot supplies and uses its own cross-compiler toolchain to build the binaries that end up as part of the coreboot ROM. The toolchain provided by the operating system (the 'host toolchain') is used to build various tools that will run on the local system during the build process. | ||
You may also notice that a number of other pieces are downloaded at the beginning of the build process. These are the git submodules used in various coreboot builds. | |||
=== 4 === | === 4 === | ||
Line 95: | Line 101: | ||
This attempts to build the coreboot rom. The rom file itself ends up in the build directory as 'coreboot.rom'. If you noticed at the end of the build process, the build displayed the contents of the rom file. | This attempts to build the coreboot rom. The rom file itself ends up in the build directory as 'coreboot.rom'. If you noticed at the end of the build process, the build displayed the contents of the rom file. | ||
=== 7 === | |||
Install QEMU | |||
QEMU is a processor emulator which we can use to show coreboot | |||
=== 8 === | |||
Run QEMU. | |||
Here's the command line broken down: | |||
qemu-system-x86_64 | |||
This starts the QEMU emulator with the i440FX host PCI bridge and PIIX3 PCI to ISA bridge. | |||
-bios build/coreboot.rom | |||
Use the bios rom image that we just built. If this is left off, the standard SeaBIOS image that comes with QEMU is used. | |||
-serial stdio | |||
Send the serial output to the console. This allows you to view the coreboot debug output. |
Revision as of 22:17, 5 December 2016
coreboot lesson 1 - Starting from scratch
From a fresh ubuntu 16.04 linux install, here are all the steps required for a very basic build:
Download, configure, and build coreboot
Step 1 - Install tools and libraries needed for coreboot
$ sudo apt-get install -y g++ git-core libncurses5-dev m4 bison flex zlib1g-dev
Step 2 - Download coreboot source tree
$ git clone http://review.coreboot.org/coreboot $ cd coreboot
Step 3 - Build the coreboot toolchain
Please note that this can take a significant amount of time
$ make crossgcc-i386 CPUS=$(nproc)
Step 4 - Build the payload - coreinfo
$ make -C payloads/coreinfo olddefconfig $ make -C payloads/coreinfo
Step 5 - Configure the mainboard
$ make menuconfig select 'Mainboard' menu Beside 'Mainboard vendor' should be '(Emulation)' Beside 'Mainboard model' should be 'QEMU x86 i440fx/piix4' select exit select 'Payload' menu select 'Add a Payload' choose 'An Elf executable payload' select 'Payload path and filename' enter 'payloads/coreinfo/build/coreinfo.elf' select exit select exit select yes
check your configuration:
$ make savedefconfig $ cat defconfig
There should only be two lines:
CONFIG_PAYLOAD_ELF=y CONFIG_PAYLOAD_FILE="payloads/coreinfo/build/coreinfo.elf"
Step 6 - build coreboot
$ make
At the end of the build, you should see:
Build emulation/qemu-i440fx (QEMU x86 i440fx/piix4)
This means your build was successful. The output from the build is in the build directory. build/coreboot.rom is the full rom file.
Test the image using QEMU
Step 7 - Install QEMU
$ sudo apt-get install -y qemu
Step 8 - Run QEMU
Start QEMU, and point it to the ROM you just built:
$ qemu-system-x86_64 -bios build/coreboot.rom -serial stdio
You should see the serial output of coreboot in the original console window, and a new window will appear running the coreinfo payload.
Summary:
1
Install tools and libraries needed for coreboot.
You installed the minimum additional requirements for ubuntu to download and build coreboot. Ubuntu already has most of the other tools that would be required installed by default.
- git-core is needed to download coreboot from the coreboot git repository. - libncurses5-dev is needed to build the menu for 'make menuconfig' - g++, m4, bison, and flex are needed to build the coreboot toolchain.
If you had started from a different distribution, you might need to install the basic gcc toolchain, wget, make, or many other items.
2
Download coreboot source tree.
This will download a 'read-only' copy of the coreboot tree. This just means that if you made changes to the coreboot tree, you couldn't immediately contribute them back to the community. To pull a copy of coreboot that would allow you to contribute back, you would first need to sign up for an account on gerrit.
3
Build the coreboot toolchain.
This builds one of the coreboot cross-compiler toolchains for X86 platforms. Because of the variability of compilers and the other required tools between the various operating systems that coreboot can be built on, coreboot supplies and uses its own cross-compiler toolchain to build the binaries that end up as part of the coreboot ROM. The toolchain provided by the operating system (the 'host toolchain') is used to build various tools that will run on the local system during the build process.
You may also notice that a number of other pieces are downloaded at the beginning of the build process. These are the git submodules used in various coreboot builds.
4
Build the payload.
To actually do anything useful with coreboot, you need to build a payload to include in the rom. The idea behind coreboot is that it does the minimum amount possible before passing control of the machine to a payload. There are various payloads such as grub or SeaBIOS that are typically used to boot the operating system. Instead, we used coreinfo, a small demonstration payload that allows the user to look at various things such as memory and the contents of coreboot's cbfs - the pieces that make up the coreboot rom.
5
Configure the mainboard.
This step configures coreboot's build options using the menuconfig interface to Kconfig. Kconfig is the same configuration program used by the linux kernel. It allows you to enable, disable, and change various values to control the coreboot build process, including which mainboard(motherboard) to use, which toolchain to use, and how the runtime debug console should be presented and saved.
6
Build coreboot.
This attempts to build the coreboot rom. The rom file itself ends up in the build directory as 'coreboot.rom'. If you noticed at the end of the build process, the build displayed the contents of the rom file.
7
Install QEMU
QEMU is a processor emulator which we can use to show coreboot
8
Run QEMU.
Here's the command line broken down:
qemu-system-x86_64
This starts the QEMU emulator with the i440FX host PCI bridge and PIIX3 PCI to ISA bridge.
-bios build/coreboot.rom
Use the bios rom image that we just built. If this is left off, the standard SeaBIOS image that comes with QEMU is used.
-serial stdio
Send the serial output to the console. This allows you to view the coreboot debug output.