From dea0a7f9ae03eba9b2b0f53da415b057c778ba82 Mon Sep 17 00:00:00 2001 From: Zheng Bao Date: Tue, 17 Nov 2015 23:50:14 +0800 Subject: documentation: Update the document about building coreboot The previous LinuxBIOS-AMD64.tex was still working with subversion. We need a document to give the preliminary steps to build coreboot for a new guys. Change-Id: I64240c8344456e724f0823680e0534cf1db4c4a8 Signed-off-by: Zheng Bao Signed-off-by: Zheng Bao Reviewed-on: http://review.coreboot.org/4510 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi --- Documentation/CorebootBuildingGuide.tex | 1980 +++++++------------------------ 1 file changed, 427 insertions(+), 1553 deletions(-) (limited to 'Documentation/CorebootBuildingGuide.tex') diff --git a/Documentation/CorebootBuildingGuide.tex b/Documentation/CorebootBuildingGuide.tex index 5b3eacf778..dac031ae3b 100644 --- a/Documentation/CorebootBuildingGuide.tex +++ b/Documentation/CorebootBuildingGuide.tex @@ -6,33 +6,35 @@ \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 on AMD64}, - pdfauthor={Stefan Reinauer}, - pdfsubject={coreboot configuration and build process}, - pdfkeywords={coreboot, Opteron, AMD64, configuration, Build} + 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} } - -% \newcommand{\sh}[1]{\begin{verbatim}\texttt{#1}\end{verbatim}} -% \newcommand{\prog}[1]{\textit{#1}} - \setlength{\parindent}{0pt} +\setlength{\hoffset}{0pt} -\title{coreboot on AMD64} -\author{Stefan Reinauer $<$stepan@coresystems.de$>$} -\date{April 19th, 2009} +\title{Coreboot from Scratch} +\author{Stefan Reinauer $<$stepan@coresystems.de$>$\and Zheng Bao $<$zheng.bao@amd.com$>$} +\date{Dec 4th, 2013} \begin{document} @@ -44,40 +46,7 @@ \newpage -% -% 1 Abstract -% - -\section{Abstract} - -This document targets porting coreboot to new mainboards and creating -custom firmware images using coreboot. It describes how to build -coreboot images for the AMD64 platform, including hypertransport -configuration and pertinent utilities. If you are missing information or -find errors in the following descriptions, contact -\href{mailto:stepan@coresystems.de}{\textit{Stefan Reinauer $<$stepan@coresystems.de$>$}} - - -% -% 2 Changes -% - -\section{Changes} - \begin{itemize} - \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} - - - -% -% 3 What is coreboot -% - -\section{What is coreboot?} - +\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 @@ -91,1663 +60,555 @@ 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} + % -% 4 Build Requirements +% Build Requirements % \section{Build Requirements} -To build coreboot for AMD64 from the sources you need a recent Linux -system for x86 or AMD64. SUSE Linux 8.2 or 9.0 are known to work fine. -The following toolchain is recommended: +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 GCC 3.3.1 - \item binutils 2.14.90.0.5 - \item Python 2.3 - \item CVS 1.11.6 + \item GNUtar + \item GNUpatch + \item GNUmake + \item GCC + \item binutils + \item bison + \item flex + \item m4 + \item wget \end{itemize} -\textbf{NOTE:} Later versions should also work. Prior versions might lead to problems. +Besides the tools above, after the toolchains are built, you also need the following +tools to build the source. -\newpage + \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} % -% 5 Getting the Sources +% Getting Coreboot % -\section{Getting the Sources} - -The latest coreboot sources are available via subversion. The subversion -repository is maintained at SourceForge.net (the project name is -\emph{FreeBIOS}). First you should create a directory for your -coreboot trees: - +\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} -$ mkdir coreboot -$ cd coreboot +$ git clone http://review.coreboot.org/p/coreboot \end{verbatim} } - -You can get the entire source tree via SVN: - +For developers, you need to get a gerrit account which you can register +at \url{http://review.coreboot.org}. Please refer section ~\ref{sec:gerrit} { \small \begin{verbatim} -$ svn co svn://coreboot.org/repos/trunk/coreboot-v2 +$ git clone ssh://@review.coreboot.org:29418/coreboot +$ git clone http://[:@]review.coreboot.org/coreboot.git \end{verbatim} } -Once the source tree is checked out, it can be updated with: - +Checks out a sub-repository in the 3rdparty directory. { \small \begin{verbatim} -% svn update +$ git submodule update --init --checkout \end{verbatim} } -For the case your corporate firewall blocks port 3690 (subversion) we set up a -snapshot site that keeps the last few hundred source code revisions. It -is available at \url{http://qa.coreboot.org/}. -Due to major structural enhancements to \hbox{coreboot}, AMD64 support -is only available in the \texttt{coreboot-v2} tree. This tree reflects (as -of November 2003) coreboot version 1.1.5 and will lead to coreboot 2.0 -when finished. Most x86 hardware is currently only supported by the -coreboot 1.0 tree. - -% -% 6 coreboot configuration overview -% - -\section{coreboot configuration overview} -To support a large variety of existing hardware coreboot allows for a -lot of configuration options that can be tweaked in several ways: - -\begin{itemize} -\item -Firmware image specific configuration options can be set in the image -configuration file which is usually found in -\texttt{coreboot-v2/targets/$<$vendor$>$/$<$mainboard$>$/}. Such -options are the default amount of output verbosity during bootup, image -size, use of fallback mechanisms, firmware image size and payloads -(Linux Kernel, Bootloader...) The default configuration file name is -\texttt{Config.lb}, but coreboot allows multiple configurations to -reside in that directory. - -\item Mainboard specific configuration options can be set in the -mainboard configuration file placed in -\texttt{coreboot-v2/src/mainboard/$<$vendor$>$/$<$mainboard$>$}. The -mainboard configuration file is always called \texttt{Config.lb}. It -contains information on the onboard components of the mainboard like -CPU type, northbridge, southbridge, hypertransport configuration and -SuperIO configuration. This configuration file also allows to include -addon code to hook into the coreboot initialization mechanism at -basically any point. - -\end{itemize} - -This document describes different approaches of changing and configuring the -coreboot source tree when building for AMD64. - -% -% 7 Building coreboot -% - -\section{Building coreboot} -One of the design goals for building coreboot was to keep object files -out of the source tree in a separate place. This is mandatory for -building parallel coreboot images for several distinct mainboards -and/or platforms. Therefore building coreboot consists of two steps: -\begin{itemize} -\item -creating a build tree which holds all files automatically created by the -configuration utility and the object files -\item -compiling the coreboot code and creating a flashable firmware image. -\end{itemize} - -The first of these two steps is accomplished by the \texttt{buildtarget} -script found in \texttt{coreboot-v2/targets/}. To build coreboot for -instance for the AMD Solo Athlon64 mainboard enter: - -\begin{verbatim} -% cd coreboot-v2/targets -% ./buildtarget amd/solo -\end{verbatim} - -This will create a directory containing a Makefile and other software -components needed for this build. The directory name is defined in the -firmware image specific configuration file. In the case of AMD's Solo -mainboard the default directory resides in -\texttt{coreboot-v2/targets/amd/solo/solo}. To build the coreboot image, do - -\begin{verbatim} -% cd amd/solo/solo -% make -\end{verbatim} - -The coreboot image filename is specified in the firmware image specific -configuration file. The default filename for AMD's Solo mainboard is -\texttt{solo.rom}. - % -% 8 Programming coreboot to flash memory +% Building the toolchain % -\section{Programming coreboot to flash memory} -The image resulting from a coreboot build can be directly programmed to -a flash device, either using a hardware flash programmer or by using the -Linux flash driver devbios or mtd. This document assumes that you use a -hardware flash programmer. If you are interested in doing in-system -software flash programming, find detailed information: - -\begin{itemize} -\item \url{http://www.openbios.org/development/devbios.html} (/dev/bios) -\item \url{http://www.linux-mtd.infradead.org/} (Memory Technology Device Subsystem MTD) -\end{itemize} - -\newpage - -% -% 9 coreboot configuration -% - -\section{coreboot configuration} -The following chapters will cope with configuring coreboot. All -configuration files share some basic rules -\begin{itemize} -\item -The default configuration file name in coreboot is \texttt{Config.lb}. -\item -All variables used in a configuration file have to be declared in this -file with \texttt{uses VARNAME} before usage. -\item -Comments can be added on a new line by using the comment identifier -\texttt{\#} at the beginning of the line. -\item -coreboot distinguishes between statements and options. Statements cause -the coreboot configuration mechanism to act, whereas options set -variables that are used by the build scripts or source code. -\item -Default configuration values can be set in the mainboard configuration -files (keyword default) -\item -Option overrides to the default configuration can only be specified in -the build target configuration file -\texttt{coreboot-v2/targets/$<$vendor$>$/$<$mainboard$>$/Config.lb} -(keyword option) -\end{itemize} - -\subsection{Common Configuration Statements} - -\begin{itemize} - -\item \begin{verbatim}uses\end{verbatim} - -All local configuration variables have to be declared before they can be -used. Example: -\begin{verbatim} - uses CONFIG_ROM_IMAGE_SIZE -\end{verbatim} - -\textbf{NOTE:} Only configuration variables known to the configuration -system can be used in configuration files. coreboot checks -\texttt{coreboot-v2/src/config/Options.lb} to see whether a configuration -variable is known. - -\item \begin{verbatim}default\end{verbatim} - -The \texttt{default} statement is used to set a configuration variable -with an overridable default value. It is commonly used in mainboard -configuration files. - -Example: - -\begin{verbatim} - default CONFIG_ROM_IMAGE_SIZE=0x10000 -\end{verbatim} - -It is also possible to assign the value of one configuration variable to -another one, i.e.: - -\begin{verbatim} - default CONFIG_FALLBACK_SIZE=CONFIG_ROM_SIZE -\end{verbatim} - -Also, simple expressions are allowed: - -\begin{verbatim} - default CONFIG_FALLBACK_SIZE=(CONFIG_ROM_SIZE - NORMAL_SIZE) -\end{verbatim} - -If an option contains a string, this string has to be protected with -quotation marks: - -\begin{verbatim} - default CC="gcc -m32" -\end{verbatim} - -\item \begin{verbatim}option\end{verbatim} - -The \texttt{option} statement basically behaves identically to the -\texttt{default} statement. But unlike default it can only be used in -build target configuration files -(\texttt{coreboot-v2/targets/$<$vendor$>$/$<$mainboard$>$}). The option -statement allows either to set new options or to override default values -set with the default statement in a mainboard configuration file. -Syntax and application are the same as with default. - -\end{itemize} - -\subsection{Firmware image specific configuration} -coreboot allows to create different firmware images for the same -hardware. Such images can differ in the amount of output they produce, -the payload, the number of subimages they consist of etc. - -The firmware image specific configuration file can be found in \\ -\texttt{coreboot-v2/targets/$<$vendor$>$/$}. - -\subsubsection{Firmware image specific keywords} -In addition to the above described keywords the following statements are -available in firmware image specific configuration files: - -\begin{itemize} -\item \begin{verbatim}romimage\end{verbatim} - -The \texttt{romimage} definition describes a single rom build within the -final coreboot image. Normally there are two romimage definitions per -coreboot build: \texttt{normal} and \texttt{fallback}. - -Each \texttt{romimage} section needs to specify a mainboard directory and a -payload. The mainboard directory contains the mainboard specific -configuration file and source code. It is specified relatively to -\texttt{coreboot-v2/src/mainboard}. The payload definition is an absolute -path to a static elf binary (i.e Linux kernel or etherboot) +\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} -romimage "normal" - option CONFIG_USE_FALLBACK_IMAGE=0 - option CONFIG_ROM_IMAGE_SIZE=0x10000 - option COREBOOT_EXTRA_VERSION=".0Normal" - mainboard amd/solo - payload /suse/stepan/tg3ide_ - disk.zelf -end +$ cd coreboot +$ make crossgcc \end{verbatim} +} -\item \begin{verbatim}buildrom\end{verbatim} - -The \texttt{buildrom} statement is used to determine which of the -coreboot image builds (created using \texttt{romimage}) are packed -together to the final coreboot image. It also specifies the order of -the images and the final image size: +or +{ \small \begin{verbatim} - buildrom ./solo.rom CONFIG_ROM_SIZE "normal" "fallback" +$ cd util/crossgcc +$ buildgcc \end{verbatim} +} -\end{itemize} - - -\subsubsection{Firmware image configuration options} -In addition to the definitions described above there are a number of -commonly used options. Configuration options set in the firmware image -specific configuration file can override default selections from the -Mainboard specific configuration. See above examples about -option on how to set them. - -\begin{itemize} - -\item \begin{verbatim}CC\end{verbatim} - -Target C Compiler. Default is \texttt{\$(CROSS\_COMPILE)gcc}. Set to -\texttt{gcc -m32} for compiling AMD64 coreboot images on an AMD64 -machine. - -\item \begin{verbatim}CONFIG_CHIP_CONFIGURE \end{verbatim} - -Use new \textit{chip\_configure} method for configuring (nonpci) -devices. Set to \texttt{1} for all AMD64 mainboards. - -\item \begin{verbatim}CONFIG_DEFAULT_CONSOLE_LOGLEVEL\end{verbatim} - -Console will log at this level unless changed. Default is \texttt{7}, -minimum is \texttt{0}, maximum is \texttt{10}. +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. -\item \begin{verbatim}CONFIG_CONSOLE_SERIAL8250\end{verbatim} +{ \small +\textcolor{blue} {Welcome to the} \textcolor{red} {coreboot} \textcolor{blue} {cross toolchain builder v1.23 (September 20th, 2013)} -Log messages to 8250 uart based serial console. Default is \texttt{0} -(don't log to serial console). This value should be set to \texttt{1} -for all AMD64 builds. +Target arch is now i386-elf -\item \begin{verbatim}CONFIG_ROM_SIZE\end{verbatim} +Will skip GDB ... ok -Size of final ROM image. This option has no default value. +Downloading tar balls ... -\item \begin{verbatim}CONFIG_FALLBACK_SIZE\end{verbatim} + * gmp-5.1.2.tar.bz2 (cached) -Fallback image size. Defaults to \texttt{65536} bytes. \textbf{NOTE:} -This does not include the fallback payload. + * mpfr-3.1.2.tar.bz2 (cached) -\item \begin{verbatim}CONFIG_HAVE_OPTION_TABLE\end{verbatim} + * mpc-1.0.1.tar.gz (cached) -Export CMOS option table. Default is \texttt{0}. Set to \texttt{1} if -your mainboard has CMOS memory and you want to use it to store -coreboot parameters (Loglevel, serial line speed, ...) + * libelf-0.8.13.tar.gz (cached) -\item \begin{verbatim}CONFIG_ROM_PAYLOAD\end{verbatim} + * gcc-4.7.3.tar.bz2 (cached) -Boot image is located in ROM (as opposed to \texttt{CONFIG\_IDE\_PAYLOAD}, which -will boot from an IDE disk) + * binutils-2.23.2.tar.bz2 (cached) -\item \begin{verbatim}CONFIG_HAVE_FALLBACK_BOOT\end{verbatim} + * acpica-unix-20130626.tar.gz (cached) -Set to \texttt{1} if fallback booting is required. Defaults to -\texttt{0}. +Downloaded tar balls ... \textcolor {green}{ok} -\end{itemize} +Unpacking and patching ... + * gmp-5.1.2.tar.bz2 -The following options should be used within a romimage section: + * mpfr-3.1.2.tar.bz2 -\begin{itemize} + * mpc-1.0.1.tar.gz -\item \begin{verbatim}CONFIG_USE_FALLBACK_IMAGE\end{verbatim} + * libelf-0.8.13.tar.gz -Set to \texttt{1} to build a fallback image. Defaults to \texttt{0} + * gcc-4.7.3.tar.bz2 -\item \begin{verbatim}CONFIG_ROM_IMAGE_SIZE\end{verbatim} + * binutils-2.23.2.tar.bz2 -Default image size. Defaults to \texttt{65535} bytes. + o binutils-2.23.2\_arv7a.patch -\item \begin{verbatim}COREBOOT_EXTRA_VERSION\end{verbatim} + o binutils-2.23.2\_no-bfd-doc.patch -coreboot extra version. This option has an empty string as default. Set -to any string to add an extra version string to your coreboot build. + * acpica-unix-20130626.tar.gz -\end{itemize} - -\newpage +Unpacked and patched ... \textcolor {green}{ok} -\subsection{Mainboard specific configuration} +Building GMP 5.1.2 ... \textcolor {green}{ok} -Mainboard specific configuration files describe the onboard -mainboard components, i.e. bridges, number and type of CPUs. They also -contain rules for building the low level start code which is translated -using romcc and/or the GNU assembler. This code enables caches and -registers, early mtrr settings, fallback mechanisms, dram init and -possibly more. +Building MPFR 3.1.2 ... \textcolor {green}{ok} -\textbf{NOTE:} The \texttt{option} keyword can not be used in mainboard -specific configuration files. Options shall instead be set using the -\texttt{default} keyword so that they can be overridden by the image -specific configuration files if needed. +Building MPC 1.0.1 ... \textcolor {green}{ok} -\subsubsection{Mainboard specific keywords} +Building libelf 0.8.13 ... \textcolor {green}{ok} -The following statements are used in mainboard specific configuration -files: +Building binutils 2.23.2 ... \textcolor {green}{ok} -\begin{itemize} -\item \begin{verbatim}arch\end{verbatim} +Building GCC 4.7.3 ... ok -Sets the CPU architecture. This should be \texttt{i386} for AMD64 boards.\\ -Example: +Skipping Expat (Python scripting not enabled) -\begin{verbatim} - arch i386 end -\end{verbatim} +Skipping Python (Python scripting not enabled) -\item \begin{verbatim}cpu\end{verbatim} +Skipping GDB (GDB support not enabled) -The cpu statement is needed once per possibly available CPU. In a -one-node system, write: +Building IASL 20130626 ... \textcolor {green}{ok} -\begin{verbatim} - cpu k8 "cpu0" end -\end{verbatim} +Cleaning up... \textcolor {green}{ok} -\item \begin{verbatim}driver\end{verbatim} +\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. -The \texttt{driver} keyword adds an object file to the driver section of a -coreboot image. This means it can be used by the PCI device -initialization code. Example: +% +% Build Coreboot +% +\section{Building Coreboot} +\subsection{Build main module of Coreboot} +{ \small \begin{verbatim} - driver mainboard.o +$ 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. -Each \texttt{makerule} section contains file dependencies (using the -texttt{depends} keyword) and an action that is taken when the dependencies -are satisfied (using the \texttt{action} keyword). - -\item \begin{verbatim}mainboardinit\end{verbatim} - -With the mainboardinit keyword it's possible to include assembler code -directly into the coreboot image. This is used for early infrastructure -initialization, i.e. to switch to protected mode. Example: +\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} - mainboardinit cpu/i386/entry16.inc -\end{verbatim} - -\item \begin{verbatim}ldscript\end{verbatim} - -The GNU linker ld is used to link object files together to a coreboot -ROM image. - -Since it is a lot more comfortable and flexible to use the GNU linker -with linker scripts (ldscripts) than to create complex command line -calls, coreboot features including linker scripts to control image -creation. Example: - ++------------------------------- 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) | | +| | | | +| | | | +| | | | +| | | | +| | | | +| | | | +| +----------------------------------------------------------------------+ | ++--------------------------------------------------------------------------+ +|