Lesson1: Difference between revisions

From coreboot
Jump to navigation Jump to search
No edit summary
No edit summary
Line 5: Line 5:
==Download, configure, and build coreboot==
==Download, configure, and build coreboot==


Install tools and libraries needed for coreboot
Install tools and libraries needed for coreboot [https://www.coreboot.org/index.php?title=Lesson1&action=submit#1]
  $ sudo apt-get install git-core libncurses5-dev m4 bison flex
  $ sudo apt-get install git-core libncurses5-dev m4 bison flex


Download coreboot source tree:
Download coreboot source tree: [https://www.coreboot.org/index.php?title=Lesson1&action=submit#2]
  $ git clone http://review.coreboot.org/coreboot
  $ git clone http://review.coreboot.org/coreboot
  $ cd coreboot
  $ cd coreboot


build toolchain (This can take a significant amount of time)
Build the coreboot toolchain (This can take a significant amount of time) [https://www.coreboot.org/index.php?title=Lesson1&action=submit#3]
  $ make crossgcc-i386 CPUS=$(nproc)
  $ make crossgcc-i386 CPUS=$(nproc)


Build the payload - coreinfo
Build the payload - coreinfo [https://www.coreboot.org/index.php?title=Lesson1&action=submit#4]
  $ pushd payloads/coreinfo
  $ pushd payloads/coreinfo
  $ make olddefconfig
  $ make olddefconfig
Line 21: Line 21:
  $ popd
  $ popd


configure mainboard to build coreboot
Configure the mainboard [https://www.coreboot.org/index.php?title=Lesson1&action=submit#5]
  $ make menuconfig
  $ make menuconfig
     select 'Mainboard' menu
     select 'Mainboard' menu
Line 45: Line 45:
  CONFIG_PAYLOAD_FILE="payloads/coreinfo/build/coreinfo.elf"
  CONFIG_PAYLOAD_FILE="payloads/coreinfo/build/coreinfo.elf"


build coreboot:
build coreboot: [https://www.coreboot.org/index.php?title=Lesson1&action=submit#6]
  $ make
  $ make


Line 57: Line 57:


You should see the serial output of coreboot in the original console window, and a new window will appear running the coreinfo payload.
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'
-  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.
You downloaded 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.
=== 3 ===
Build the coreboot toolchain.
You built 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.
=== 4 ===
Build the payload.
You built a payload for coreboot.  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.
You configured coreboot's build options using the menuconfig interface to Kconfig.  This is the same configuration program used by the linux kernel.  This allows you to enable, disable, and change various values to control the coreboot build process.
=== 6 ===
Build coreboot.
You ran make and built a 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.

Revision as of 04:01, 18 January 2016

coreboot lesson 1 - Starting from scratch

From a fresh ubuntu 15.10 linux install, here are all the steps required:

Download, configure, and build coreboot

Install tools and libraries needed for coreboot [1]

$ sudo apt-get install git-core libncurses5-dev m4 bison flex

Download coreboot source tree: [2]

$ git clone http://review.coreboot.org/coreboot
$ cd coreboot

Build the coreboot toolchain (This can take a significant amount of time) [3]

$ make crossgcc-i386 CPUS=$(nproc)

Build the payload - coreinfo [4]

$ pushd payloads/coreinfo
$ make olddefconfig
$ make
$ popd

Configure the mainboard [5]

$ make menuconfig
   select 'Mainboard' menu
   select 'Mainboard model'
   choose '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 three lines:

CONFIG_BOARD_EMULATION_QEMU_X86_I440FX=y
CONFIG_PAYLOAD_ELF=y
CONFIG_PAYLOAD_FILE="payloads/coreinfo/build/coreinfo.elf"

build coreboot: [6]

$ make

Test the image using QEMU

Install QEMU

$ sudo apt-get install qemu

Start QEMU:

$ 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'
-  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.

You downloaded 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.

3

Build the coreboot toolchain.

You built 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.

4

Build the payload.

You built a payload for coreboot. 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.

You configured coreboot's build options using the menuconfig interface to Kconfig. This is the same configuration program used by the linux kernel. This allows you to enable, disable, and change various values to control the coreboot build process.

6

Build coreboot.

You ran make and built a 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.