% % This document is released under the GPL % Initially written by Stefan Reinauer, % \documentclass[titlepage,12pt]{article} \usepackage{a4} \usepackage{graphicx} \usepackage{epsfig} \usepackage{epstopdf} \usepackage{url} \usepackage{color} % \usepackage{geometry} \usepackage[pdftex]{hyperref} % \usepackage{makeidx} % \makeindex % \geometry{left=2cm,right=2cm,top=2cm,bottom=2cm} \hypersetup{ urlbordercolor={1 1 1}, menubordercolor={1 1 1}, linkbordercolor={1 1 1}, colorlinks=false, % pdfpagemode=None, % PDF-Viewer starts without TOC % pdfstartview=FitH, pdftitle={coreboot Porting Guide}, pdfauthor={Zheng Bao}, pdfsubject={coreboot configuration and build process}, pdfkeywords={coreboot, AMD, configuration, Build} } \setlength{\parindent}{0pt} \setlength{\hoffset}{0pt} \title{coreboot from Scratch} \author{Stefan Reinauer $<$stepan@coresystems.de$>$\and Zheng Bao $<$zheng.bao@amd.com$>$} \date{Dec 4th, 2013} \begin{document} \maketitle \thispagestyle{empty} \tableofcontents \newpage \section{What is coreboot} coreboot aims to replace the normal BIOS found on x86, AMD64, PPC, Alpha, and other machines with a Linux kernel that can boot Linux from a cold start. The startup code of an average coreboot port is about 500 lines of assembly and 5000 lines of C. It executes 16 instructions to get into 32bit protected mode and then performs DRAM and other hardware initializations required before Linux can take over. The projects primary motivation initially was maintenance of large clusters. Not surprisingly interest and contributions have come from people with varying backgrounds. Nowadays a large and growing number of Systems can be booted with coreboot, including embedded systems, Desktop PCs and Servers. This document is used to build, modify, and port the coreboot code base on the AMD platform. \section{Changes} \begin{itemize} \item 2013/12/20 Add Git, Gerrit, toolchains building. \item 2009/04/19 replace LinuxBIOS with coreboot \item 2004/06/02 url and language fixes from Ken Fuchs $<$kfuchs@winternet.com$>$ \item 2004/02/10 ACPI and option ROM updates \item 2003/11/18 initial release \end{itemize} % % Build Requirements % \section{Build Requirements} To build coreboot for AMD64 from the sources you need a recent Linux. SUSE Linux 11.2, CentOS release 6.3, Fedora Core 16, Cygwin, FreeBSD, NetBSD are known to work fine. To build the toolchain, you need following host compilers: \begin{itemize} \item GNUtar \item GNUpatch \item GNUmake \item GCC \item binutils \item bison \item flex \item m4 \item wget \end{itemize} Besides the tools above, after the toolchains are built, you also need the following tools to build the source. \begin{itemize} \item git: Get the source code from repository \item libncurses-dev (or ncursesw, ncurses, curses, pdcursesw, pdcurses): for menuconfig \item python: Optional for gdb. \item perl: Optional for gdb. \end{itemize} % % Getting coreboot % \section{Getting coreboot} The latest coreboot sources are available via GIT. For users who doesn't need to change and commit the code: { \small \begin{verbatim} $ git clone https://review.coreboot.org/coreboot \end{verbatim} } For developers, you need to get a gerrit account which you can register at \url{https://review.coreboot.org}. Please refer section ~\ref{sec:gerrit} { \small \begin{verbatim} $ git clone ssh://@review.coreboot.org:29418/coreboot $ git clone https://[:@]review.coreboot.org/coreboot.git \end{verbatim} } Checks out a sub-repository in the 3rdparty directory. { \small \begin{verbatim} $ git submodule update --init --checkout \end{verbatim} } % % Building the toolchain % \section{Building the toolchain} coreboot recommends and guarantees the toolchain integrated with coreboot. Linux distributions usually modify their compilers in ways incompatible with coreboot. { \small \begin{verbatim} $ cd coreboot $ make crossgcc \end{verbatim} } or { \small \begin{verbatim} $ cd util/crossgcc $ buildgcc \end{verbatim} } The buildgcc will try to get packages from website. You need to make sure you can get access the internet. Or you can get the source.tar.gz and put it in util/crossgcc/tarballs. { \small \textcolor{blue} {Welcome to the} \textcolor{red} {coreboot} \textcolor{blue} {cross toolchain builder v1.23 (September 20th, 2013)} Target arch is now i386-elf Will skip GDB ... ok Downloading tar balls ... * gmp-5.1.2.tar.bz2 (cached) * mpfr-3.1.2.tar.bz2 (cached) * mpc-1.0.1.tar.gz (cached) * libelf-0.8.13.tar.gz (cached) * gcc-4.7.3.tar.bz2 (cached) * binutils-2.23.2.tar.bz2 (cached) * acpica-unix-20130626.tar.gz (cached) Downloaded tar balls ... \textcolor {green}{ok} Unpacking and patching ... * gmp-5.1.2.tar.bz2 * mpfr-3.1.2.tar.bz2 * mpc-1.0.1.tar.gz * libelf-0.8.13.tar.gz * gcc-4.7.3.tar.bz2 * binutils-2.23.2.tar.bz2 o binutils-2.23.2\_arv7a.patch o binutils-2.23.2\_no-bfd-doc.patch * acpica-unix-20130626.tar.gz Unpacked and patched ... \textcolor {green}{ok} Building GMP 5.1.2 ... \textcolor {green}{ok} Building MPFR 3.1.2 ... \textcolor {green}{ok} Building MPC 1.0.1 ... \textcolor {green}{ok} Building libelf 0.8.13 ... \textcolor {green}{ok} Building binutils 2.23.2 ... \textcolor {green}{ok} Building GCC 4.7.3 ... ok Skipping Expat (Python scripting not enabled) Skipping Python (Python scripting not enabled) Skipping GDB (GDB support not enabled) Building IASL 20130626 ... \textcolor {green}{ok} Cleaning up... \textcolor {green}{ok} \textcolor {green}{You can now run your i386-elf cross toolchain from /home/baozheng/x86/coreboot-gerrit/util/crossgcc/xgcc.} } If you are lucky, you can get toolchains located in util/crossgcc/xgcc. % % Build coreboot % \section{Building coreboot} \subsection{Build main module of coreboot} { \small \begin{verbatim} $ cd coreboot $ make menuconfig .config - coreboot v4.0-4895-gc5025a4-dirty Configuration +------------------------ coreboot Configuration -------------------------+ | Arrow keys navigate the menu. selects submenus --->. | | Highlighted letters are hotkeys. Pressing includes, excludes, | | modularizes features. Press to exit, for Help, | | for Search. Legend: [*] built-in [ ] excluded module < > | | +---------------------------------------------------------------------+ | | | General setup ---> | | | | Mainboard ---> | | | | Architecture (x86) ---> | | | | Chipset ---> | | | | Devices ---> | | | | VGA BIOS ---> | | | | Display ---> | | | | PXE ROM ---> | | | | Generic Drivers ---> | | | | Console ---> | | | | [ ] Relocatable Modules | | | | System tables ---> | | | | Payload ---> | | | | Debugging ---> | | | | --- | | | +----v(+)-------------------------------------------------------------+ | +-------------------------------------------------------------------------+ | < Exit > < Help > | +--------------------------------------------------------------------------+ \end{verbatim} } Select VGA BIOS. ``The VGA device PCI IDs'' should be the same as your device. Get the Option ROM from Vendor's website. \subsubsection{Payload} coreboot in itself is "only" minimal code for initializing a mainboard with peripherals. After the initialization, it jumps to a payload. Currently, SeaBIOS is the most widely used payload. The best way to integrate SeaBIOS is setting it in menuconfig. { \small \begin{verbatim} +------------------------------- Payload ---------------------------------+ | Arrow keys navigate the menu. selects submenus --->. | | Highlighted letters are hotkeys. Pressing includes, excludes, | | modularizes features. Press to exit, for Help, | | for Search. Legend: [*] built-in [ ] excluded module < > module | | +----------------------------------------------------------------------+ | | | Add a payload (SeaBIOS) ---> | | | | SeaBIOS version (1.7.2.1) ---> | | | | [*] Use LZMA compression for payloads (NEW) | | | | | | | | | | | | | | | | | | | | | | | | | | | +----------------------------------------------------------------------+ | +--------------------------------------------------------------------------+ |