Difference between revisions of "Build from Windows"

From coreboot
Jump to: navigation, search
(Created page with "(work in progress)")
 
Line 1: Line 1:
(work in progress)
+
Coreboot firmware is most often built from the linux environment. Because many bios developers are more familiar with Windows than linux, it is useful to know how to build coreboot on a Windows system.
 +
 
 +
==Setup the coreboot build environment (long method)==
 +
 
 +
The gnu tools needed to build coreboot have already been ported to Windows. They must be downloaded, customized, and installed. Here are the steps:
 +
 
 +
#Download and install a native msys+mingw environment on your Windows computer.
 +
#Build and install cross compile versions of binutils and gcc that run on Windows and target 32-bit x86 linux.
 +
 
 +
 
 +
Step 1 involves downloading and decompressing mingw and msys, both of which contain several components. See [http://mingw.org/ mingw.org] for details.
 +
 
 +
Step 2: Once msys+mingw is installed, download and build cross compiler versions of gcc and binutils that produce elf output for 32-bit x86 linux. This example uses binutils 2.20.51 and gcc 4.5.0 source code from the mingw [http://sourceforge.net/projects/mingw/files/ download site]. Here are the configure and build commands for the cross binutils included in the sample build environment:
 +
 
 +
'''binutils-2.20.51'''
 +
$ configure --target=i686-pc-linux --disable-nls --disable-shared --disable-threads --with-gcc --with-gnu-as --with-gnu-ld
 +
$ make all
 +
$ make install
 +
 
 +
 
 +
Here are the configure and build commands for the cross gcc included in the sample build environment:
 +
 
 +
'''gcc-4.5.0'''
 +
$ configure --target=i686-pc-linux --enable-languages=c,c++ --with-gcc --with-gnu-ld --with-gnu-as --disable-shared -- disable-threads --disable-win32-registry --disable-nls --without-headers
 +
$ make all-gcc
 +
$ make install-gcc
 +
 
 +
==Setup the coreboot build environment (shortcut method)==
 +
 
 +
Getting through steps 1 and 2 from scratch takes a bit of work. As a shortcut, a coreboot-ready msys+mingw is included in the  [http://notabs.org/coreboot/win-build-env-001.7z sample project]. Decompress the sample project into any directory on your Windows computer. Note: Avoid the use of spaces in the project path and directory name. In the top level of the sample project is directory <tt>msys</tt>. This is the complete coreboot-ready msys+mingw. The <tt>msys.bat</tt> file in this directory starts the msys+mingw build environment. The standard tool names target the local Windows environment. To invoke tools that target linux, use tool names with prefix <tt>i686-pc-linux-</tt>. For example, <tt>gcc -c hello.c</tt> builds a Windows object, while <tt>i686-pc-linux-gcc hello.c</tt> builds a linux object.
 +
 
 +
In addition to the coreboot ready msys+mingw build environment, the sample project contains:
 +
 
 +
#'''coreboot''' directory. Replace this sample coreboot source code with the one you want to build.
 +
#'''payloads''' directory. This directory contains seabios binary <tt>bios.bin.elf-0.6.0</tt>, used as a sample payload.
 +
#'''tools''' directory. This directory contains needed tools that are not part of coreboot, msys, or mingw.
 +
#'''go.bat'''. This batch file sets up environment variables needed for cross compiling, and switches to the coreboot directory.
 +
 
 +
==Build the coreboot project==
 +
Here are step-by-step instructions for building a coreboot based bios on a windows machine using the shortcut build environment setup method:
 +
 
 +
:1.Decompress the [http://notabs.org/coreboot/win-build-env-001.7z sample project] into any directory. Note: Avoid the use of spaces in the project path and directory name. Use [http://7-zip.org/ 7-zip] for decompression.
 +
:2.Replace the sample <tt>coreboot</tt> [svn://coreboot.org/coreboot/trunk source code] (rev 5775) with your own. The directory must be named <tt>coreboot</tt>.
 +
:3.Using Windows explorer, click on <tt>go.bat</tt> to start the build environment. It will look something like this:
 +
[[Image:winbuild-msys-prompt.png|left]]
 +
<br clear="all"/>
 +
 
 +
:4. At the <tt>$</tt> prompt, type <tt>make oldconfig</tt>. Answer the configuration questions. For this example, defaults were used for all questions except:
 +
mainboard vendor        : 3 AMD
 +
mainboard model          : 9 Serengeti Cheetah (Fam10)
 +
rom chip size            : 3 512 KB
 +
add a payload            : 2 An ELF executable payload
 +
Payload path and filename: ../payloads/bios.bin.elf-0.6.0
 +
 
 +
:5. At the <tt>$</tt> prompt, type <tt>make</tt>. After a few seconds, the build should complete:
 +
[[Image:winbuild-build-complete.png|left]]
 +
<br clear="all"/>
 +
 
 +
The final bios image is in file coreboot\build\coreboot.rom:
 +
<pre>
 +
Directory of D:\tmp\win-build-env-001\coreboot\build
 +
 
 +
09/03/10  12:23 PM          524,288 coreboot.rom
 +
</pre>
 +
==Test using simnow (optional, AMD projects only)==
 +
The AMD simnow application is a software simulation of an AMD processor and reference board. Its accuracy is impressive, allowing it to boot an unmodified bios and operating system. To test the bios, download and install the public version of AMD's [http://developer.amd.com/cpu/simnow/Pages/default.aspx simnow]. This example uses version <tt>simnow-win64-4.6.2pub.exe</tt>, a recent public version for Windows. Note that simnow requires a 64-bit operation system. Add an environment variable named <tt>simnow</tt> that points to the directory where simnow is installed:
 +
[[Image:winbuild-simnow-env.png|left]]
 +
<br clear="all"/>
 +
 
 +
From Windows explorer, launch <tt>coreboot\simnow\simnow.bat</tt>. This will open 3 windows:
 +
[[Image:winbuild-simnow-main.png|left]]
 +
<br clear="all"/>
 +
[[Image:winbuild-simnow-cmd.png|left]]
 +
<br clear="all"/>
 +
[[Image:winbuild-putty0.png|left]]
 +
<br clear="all"/>
 +
 
 +
Optionally, setup a boot cd-rom, floppy, or hard disk image:
 +
[[Image:winbuild-drive-image.png|left]]
 +
<br clear="all"/>
 +
 
 +
Now, start the simulation by clicking the 'Run Simulation' button.
 +
[[Image:winbuild-simnow-run.png|left]]
 +
<br clear="all"/>
 +
 
 +
Putty will capture serial debug messages:
 +
[[Image:winbuild-putty-output.png|left]]
 +
<br clear="all"/>
 +
 
 +
After a few seconds, video will appear:
 +
[[Image:winbuild-vbios-banner.png|left]]
 +
<br clear="all"/>
 +
 
 +
At this point, the simulation hesitates while waiting for a keyboard response. Press a key while the mouse cursor is in the simnow window to avoid the delay. Alternatively, modify [http://www.coreboot.org/pipermail/coreboot/2010-September/060046.html keyboard.c].
 +
 
 +
Next, the seabios payload executes:
 +
[[Image:winbuild-seabios.png|left]]
 +
<br clear="all"/>
 +
 
 +
If the optional disk image was supplied, seabios will attempt to boot it:
 +
[[Image:winbuild-windows1.png|left]]
 +
<br clear="all"/>
 +
 
 +
Looking good...
 +
[[Image:winbuild-windows2.png|left]]
 +
<br clear="all"/>
 +
 
 +
Oops, some ACPI debugging is needed here...
 +
[[Image:winbuild-windows3.png|left]]
 +
<br clear="all"/>
 +
 
 +
===Known problems with this demo===
 +
 
 +
#An unwanted stack access by an AP core during cache as ram disable causes a crash. The work-around used in the sample project is to remove AP cores from the simnow model. A proper fix is being [http://www.coreboot.org/pipermail/coreboot/2010-September/060090.html developed].
 +
#PS/2 Keyboard init timeout causes boot delay ([http://www.coreboot.org/pipermail/coreboot/2010-September/060046.html workaround]).
 +
#PS/2 keyboard not working.
 +
 
 +
===Known problems with windows building===
 +
 
 +
#Libncurses is not available, which prevents <tt>make menuconfig</tt> from building. Work-around: use <tt>make oldconfig</tt> instead.

Revision as of 20:27, 3 September 2010

Coreboot firmware is most often built from the linux environment. Because many bios developers are more familiar with Windows than linux, it is useful to know how to build coreboot on a Windows system.

Setup the coreboot build environment (long method)

The gnu tools needed to build coreboot have already been ported to Windows. They must be downloaded, customized, and installed. Here are the steps:

  1. Download and install a native msys+mingw environment on your Windows computer.
  2. Build and install cross compile versions of binutils and gcc that run on Windows and target 32-bit x86 linux.


Step 1 involves downloading and decompressing mingw and msys, both of which contain several components. See mingw.org for details.

Step 2: Once msys+mingw is installed, download and build cross compiler versions of gcc and binutils that produce elf output for 32-bit x86 linux. This example uses binutils 2.20.51 and gcc 4.5.0 source code from the mingw download site. Here are the configure and build commands for the cross binutils included in the sample build environment:

binutils-2.20.51
$ configure --target=i686-pc-linux --disable-nls --disable-shared --disable-threads --with-gcc --with-gnu-as --with-gnu-ld
$ make all
$ make install


Here are the configure and build commands for the cross gcc included in the sample build environment:

gcc-4.5.0
$ configure --target=i686-pc-linux --enable-languages=c,c++ --with-gcc --with-gnu-ld --with-gnu-as --disable-shared -- disable-threads --disable-win32-registry --disable-nls --without-headers
$ make all-gcc
$ make install-gcc

Setup the coreboot build environment (shortcut method)

Getting through steps 1 and 2 from scratch takes a bit of work. As a shortcut, a coreboot-ready msys+mingw is included in the sample project. Decompress the sample project into any directory on your Windows computer. Note: Avoid the use of spaces in the project path and directory name. In the top level of the sample project is directory msys. This is the complete coreboot-ready msys+mingw. The msys.bat file in this directory starts the msys+mingw build environment. The standard tool names target the local Windows environment. To invoke tools that target linux, use tool names with prefix i686-pc-linux-. For example, gcc -c hello.c builds a Windows object, while i686-pc-linux-gcc hello.c builds a linux object.

In addition to the coreboot ready msys+mingw build environment, the sample project contains:

  1. coreboot directory. Replace this sample coreboot source code with the one you want to build.
  2. payloads directory. This directory contains seabios binary bios.bin.elf-0.6.0, used as a sample payload.
  3. tools directory. This directory contains needed tools that are not part of coreboot, msys, or mingw.
  4. go.bat. This batch file sets up environment variables needed for cross compiling, and switches to the coreboot directory.

Build the coreboot project

Here are step-by-step instructions for building a coreboot based bios on a windows machine using the shortcut build environment setup method:

1.Decompress the sample project into any directory. Note: Avoid the use of spaces in the project path and directory name. Use 7-zip for decompression.
2.Replace the sample coreboot source code (rev 5775) with your own. The directory must be named coreboot.
3.Using Windows explorer, click on go.bat to start the build environment. It will look something like this:
Winbuild-msys-prompt.png


4. At the $ prompt, type make oldconfig. Answer the configuration questions. For this example, defaults were used for all questions except:
mainboard vendor         : 3 AMD
mainboard model          : 9 Serengeti Cheetah (Fam10)
rom chip size            : 3 512 KB
add a payload            : 2 An ELF executable payload
Payload path and filename: ../payloads/bios.bin.elf-0.6.0
5. At the $ prompt, type make. After a few seconds, the build should complete:
Winbuild-build-complete.png


The final bios image is in file coreboot\build\coreboot.rom:

 Directory of D:\tmp\win-build-env-001\coreboot\build

09/03/10  12:23 PM           524,288 coreboot.rom

Test using simnow (optional, AMD projects only)

The AMD simnow application is a software simulation of an AMD processor and reference board. Its accuracy is impressive, allowing it to boot an unmodified bios and operating system. To test the bios, download and install the public version of AMD's simnow. This example uses version simnow-win64-4.6.2pub.exe, a recent public version for Windows. Note that simnow requires a 64-bit operation system. Add an environment variable named simnow that points to the directory where simnow is installed:

Winbuild-simnow-env.png


From Windows explorer, launch coreboot\simnow\simnow.bat. This will open 3 windows:

Winbuild-simnow-main.png


Winbuild-simnow-cmd.png


Winbuild-putty0.png


Optionally, setup a boot cd-rom, floppy, or hard disk image:

Winbuild-drive-image.png


Now, start the simulation by clicking the 'Run Simulation' button.

Winbuild-simnow-run.png


Putty will capture serial debug messages:

Winbuild-putty-output.png


After a few seconds, video will appear:

Winbuild-vbios-banner.png


At this point, the simulation hesitates while waiting for a keyboard response. Press a key while the mouse cursor is in the simnow window to avoid the delay. Alternatively, modify keyboard.c.

Next, the seabios payload executes:

Winbuild-seabios.png


If the optional disk image was supplied, seabios will attempt to boot it:

Winbuild-windows1.png


Looking good...

Winbuild-windows2.png


Oops, some ACPI debugging is needed here...

Winbuild-windows3.png


Known problems with this demo

  1. An unwanted stack access by an AP core during cache as ram disable causes a crash. The work-around used in the sample project is to remove AP cores from the simnow model. A proper fix is being developed.
  2. PS/2 Keyboard init timeout causes boot delay (workaround).
  3. PS/2 keyboard not working.

Known problems with windows building

  1. Libncurses is not available, which prevents make menuconfig from building. Work-around: use make oldconfig instead.