Difference between revisions of "FreeBSD"

From coreboot
Jump to: navigation, search
(Mention the final LinuxBIOS image.)
m
(17 intermediate revisions by 3 users not shown)
Line 1: Line 1:
This article describes how to build LinuxBIOS v2 on FreeBSD and boot FreeBSD using LinuxBIOS and ADLO inside Qemu.
+
This article describes how to build coreboot v2 on FreeBSD and boot FreeBSD using coreboot and [[ADLO]] inside [[QEMU]].
  
 
= Requirements =
 
= Requirements =
All steps outlined in this article have been performed using FreeBSD 7.0-BETA1. Other versions of FreeBSD might work, too, but have not been tested. The patches mentioned in this article have been created against LinuxBIOSv2, Revision 2897.
+
All steps outlined in this article have been performed using FreeBSD 7.0-BETA1/i386. Other versions or architectures of FreeBSD might work, too, but have not been tested. The patches mentioned in this article have been created against coreboot v2, revision 2897.
  
 
In order to build ADLO on FreeBSD, you need the following ports installed:
 
In order to build ADLO on FreeBSD, you need the following ports installed:
  
 
* <tt>devel/gmake</tt>
 
* <tt>devel/gmake</tt>
* <tt>devel/dev86</tt>. See [[Booting_FreeBSD_using_LinuxBIOS#Building_the_8086_development_environment | details below]].
+
* <tt>devel/dev86</tt>. See [[#Building the 8086 development environment|details below]].
  
To build LinuxBIOS on FreeBSD, you need
+
To build coreboot on FreeBSD, you need
  
 
* <tt>devel/gmake</tt>
 
* <tt>devel/gmake</tt>
* <tt>lang/python</tt>. At the time of writing this article, that port installs Python 2.4. Possibly other version of Python also work but haven't been tried.
+
* <tt>lang/python</tt>. At the time of writing this article, that port installs Python 2.4. Possibly other versions of Python also work but haven't been tried.
  
 
To boot FreeBSD in QEMU you need
 
To boot FreeBSD in QEMU you need
  
* <tt>emulators/qemu</tt> with modifications. Please refer to the [[QEMU_Build_Tutorial#Building_Qemu_on_FreeBSD | QEMU Build Tutorial]] for details.
+
* <tt>emulators/qemu</tt> with modifications. Please refer to the [[QEMU Build Tutorial]] for details. Please note that QEMU versions later than 0.9.0 do not seem to work correctly (require the vgabios-cirrus.bin even when started with -nographic and output does not work after ADLO is started).
  
= Obtaining LinuxBIOS =
+
= Obtaining coreboot =
  
See [[Download_LinuxBIOS | this page]] on how to download LinuxBIOS. I recomment you checkout the latest Version of LinuxBIOS v2 using Subversion.
+
See [[Download coreboot|this page]] on how to download coreboot. I recommend you checkout the latest version of coreboot v2 using Subversion.
  
 
== Applying the required patches ==
 
== Applying the required patches ==
  
The LinuxBIOS build process assumes that the <tt>make</tt> utility is GNU make. This isn't true on FreeBSD (or the other BSDs for that matter), where GNU make is installed as <tt>gmake</tt>.
+
The coreboot build process currently assumes that the <tt>make</tt> utility is GNU make. This isn't true on FreeBSD (or the other BSDs for that matter), where GNU make is installed as <tt>gmake</tt>.
  
A patch which addresses this can be found [http://linuxbios.org/images/b/b6/LinuxBIOS_ADLO_FreeBSD.tgz here]. To download and apply this patch, run the following commands from the top-level directory of your LinuxBIOS source tree (e.g. /home/phs/LinuxBIOSv2):
+
A patch which addresses this can be found [http://www.coreboot.org/images/b/b6/LinuxBIOS_ADLO_FreeBSD.tgz here]. To download and apply this patch, run the following commands from the top-level directory of your coreboot source tree (e.g. /home/phs/LinuxBIOSv2):
  
  $ ftp http://linuxbios.org/images/b/b6/LinuxBIOS_ADLO_FreeBSD.tgz
+
  $ ftp http://www.coreboot.org/images/b/b6/LinuxBIOS_ADLO_FreeBSD.tgz
 
  $ tar xzf LinuxBIOS_ADLO_FreeBSD.tgz
 
  $ tar xzf LinuxBIOS_ADLO_FreeBSD.tgz
 
  $ patch -p0 < LinuxBIOS_ADLO_FreeBSD.diff
 
  $ patch -p0 < LinuxBIOS_ADLO_FreeBSD.diff
 +
 +
Alternatively, the patch [http://www.linuxbios.org/pipermail/linuxbios/attachments/20071105/923a1f3f/attachment.bat attached] to this [http://www.coreboot.org/pipermail/linuxbios/2007-November/026759.html message] can be used. An updated patch that applies cleanly to Revision 3066 can be downloaded [http://www.coreboot.org/images/0/0e/Coreboot_ADLO_FreeBSD-r3066.tgz here].
  
 
= Building ADLO =
 
= Building ADLO =
  
In order to boot FreeBSD using LinuxBIOS, ADLO is used as a payload. Therefore, it must be build before the LinuxBIOS image can be built. Building ADLO on FreeBSD requires that the 8086 development environment is installed. See the [[Booting_FreeBSD_using_LinuxBIOS#Building_the_8086_development_environment | following section]] for details.  
+
In order to boot FreeBSD using coreboot, ADLO is used as a payload. Therefore, it must be built before the coreboot image can be built. Building ADLO on FreeBSD requires that the 8086 development environment is installed. See the [[#Building the 8086 development environment|following section]] for details.  
  
ADLO is part of the LinuxBIOS v2 source tree. Assuming you have [[Booting_FreeBSD_using_LinuxBIOS#Applying_the_required_patches | applied the required patches]], it can be build by issuing the following commands from the top-level directory of your LinuxBIOS v2 source tree:
+
ADLO is part of the coreboot v2 source tree. Assuming you have [[#Applying the required patches|applied the required patches]], it can be built by issuing the following commands from the top-level directory of your local source tree:
  
 
  $ cd util/ADLO
 
  $ cd util/ADLO
Line 54: Line 56:
 
This has to be done only once, before building ADLO. You don't have to reinstall the port if you rebuild ADLO.
 
This has to be done only once, before building ADLO. You don't have to reinstall the port if you rebuild ADLO.
  
= Building LinuxBIOS =
+
= Building coreboot =
  
The [[QEMU_Build_Tutorial | QEMU build tutorial]] covers all steps required to build LinuxBIOS for QEMU. As a quick reference, assuming you have [[Booting_FreeBSD_using_LinuxBIOS#Applying_the_required_patches | applied the required patches]] do:
+
The [[QEMU_Build_Tutorial|QEMU build tutorial]] covers all steps required to build coreboot for QEMU. As a quick reference, assuming you have [[#Applying the required patches|applied the required patches]] do:
  
 
  $ cd targets
 
  $ cd targets
Line 72: Line 74:
  
 
= Booting FreeBSD inside QEMU =
 
= Booting FreeBSD inside QEMU =
If you already have a FreeBSD installation inside QEMU, you can boot it using LinuxBIOS with the following command:
+
If you already have a FreeBSD installation inside QEMU, you can boot it using coreboot with the following command:
  
  $ qemu -kernel-kqemu -hda freebsd.img -nographic -L .
+
  $ qemu -kernel-kqemu -hda freebsd.img -nographic -L ~
  
This assumes, that there is a file called <tt>bios.bin</tt> in the current working directory that contains LinuxBIOS with an ADLO payload. The file <tt>freebsd.img</tt> should contain your FreeBSD installation. Make sure it uses the serial console, though, as graphical output will not work when booted using LinuxBIOS.
+
This assumes, that there is a file called <tt>bios.bin</tt> in your home directory that contains coreboot with an ADLO payload. The file <tt>freebsd.img</tt> should contain your FreeBSD installation. Make sure it uses the serial console, though, as graphical output will not work when booted using coreboot.
  
 
== Installing FreeBSD inside QEMU ==
 
== Installing FreeBSD inside QEMU ==
Line 89: Line 91:
 
  $ qemu -kernel-kqemu -hda freebsd.img -cdrom 7.0-BETA1-i386-bootonly.iso -boot d
 
  $ qemu -kernel-kqemu -hda freebsd.img -cdrom 7.0-BETA1-i386-bootonly.iso -boot d
  
Inside the QEMU, perform an installation as you normally would. See the [http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/install.html FreeBSD Handbook] for details. After the installation has finished, boot up FreeBSD once <i>without</i> using LinuxBIOS.
+
Inside QEMU, perform an installation as you normally would. See the [http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/install.html FreeBSD Handbook] for details. After the installation has finished, boot up FreeBSD once ''without'' using coreboot.
  
 
  $ qemu -kernel-kqemu -hda freebsd.img
 
  $ qemu -kernel-kqemu -hda freebsd.img
Line 95: Line 97:
 
In the FreeBSD installation running inside QEMU add the following to the file <tt>/boot/loader.conf</tt>:
 
In the FreeBSD installation running inside QEMU add the following to the file <tt>/boot/loader.conf</tt>:
  
<pre>
+
console=comconsole
console=comconsole
+
 
</pre>
+
This will cause FreeBSD to use the first serial port as a console. Both the Loader's and the Kernel's messages will end up there. This is important as graphical output won't work once FreeBSD is booted using coreboot and ADLO.
  
This will cause FreeBSD to use the first serial port as a console. Both the Loader's and the Kernel's messages will end up there. This is important as graphical output won't work once FreeBSD is booted using LinuxBIOS and ADLO.
+
{{Cc-by-sa-3.0}}

Revision as of 20:07, 24 September 2010

This article describes how to build coreboot v2 on FreeBSD and boot FreeBSD using coreboot and ADLO inside QEMU.

Requirements

All steps outlined in this article have been performed using FreeBSD 7.0-BETA1/i386. Other versions or architectures of FreeBSD might work, too, but have not been tested. The patches mentioned in this article have been created against coreboot v2, revision 2897.

In order to build ADLO on FreeBSD, you need the following ports installed:

To build coreboot on FreeBSD, you need

  • devel/gmake
  • lang/python. At the time of writing this article, that port installs Python 2.4. Possibly other versions of Python also work but haven't been tried.

To boot FreeBSD in QEMU you need

  • emulators/qemu with modifications. Please refer to the QEMU Build Tutorial for details. Please note that QEMU versions later than 0.9.0 do not seem to work correctly (require the vgabios-cirrus.bin even when started with -nographic and output does not work after ADLO is started).

Obtaining coreboot

See this page on how to download coreboot. I recommend you checkout the latest version of coreboot v2 using Subversion.

Applying the required patches

The coreboot build process currently assumes that the make utility is GNU make. This isn't true on FreeBSD (or the other BSDs for that matter), where GNU make is installed as gmake.

A patch which addresses this can be found here. To download and apply this patch, run the following commands from the top-level directory of your coreboot source tree (e.g. /home/phs/LinuxBIOSv2):

$ ftp http://www.coreboot.org/images/b/b6/LinuxBIOS_ADLO_FreeBSD.tgz
$ tar xzf LinuxBIOS_ADLO_FreeBSD.tgz
$ patch -p0 < LinuxBIOS_ADLO_FreeBSD.diff

Alternatively, the patch attached to this message can be used. An updated patch that applies cleanly to Revision 3066 can be downloaded here.

Building ADLO

In order to boot FreeBSD using coreboot, ADLO is used as a payload. Therefore, it must be built before the coreboot image can be built. Building ADLO on FreeBSD requires that the 8086 development environment is installed. See the following section for details.

ADLO is part of the coreboot v2 source tree. Assuming you have applied the required patches, it can be built by issuing the following commands from the top-level directory of your local source tree:

$ cd util/ADLO
$ gmake

You will now find the ADLO payload at util/ADLO/payload.

Building the 8086 development environment

ADLO requires the devel/dev86 port which installs the 8086 development environment. This is a new port not yet included in the FreeBSD Ports tree, see Problem Report ports/117480. To build the port, download and extract the shell archive attached to the problem report.

$ ftp -o devel_dev.shar http://www.freebsd.org/cgi/query-pr.cgi?prp=117480-1-shar
$ sh devel_dev.shar
$ cd dev86
$ su
# make install

This has to be done only once, before building ADLO. You don't have to reinstall the port if you rebuild ADLO.

Building coreboot

The QEMU build tutorial covers all steps required to build coreboot for QEMU. As a quick reference, assuming you have applied the required patches do:

$ cd targets
$ ./buildtarget emulation/qemu-i386
$ cd emulation/qemu-i386/qemu-i386
$ gmake

Make sure you use the gmake utility on FreeBSD!

This should give you a file called qemu-bios.rom in targets/emulation/qemu-i386/qemu-i386. Copy this file to a convenient location, e.g. your home directory, and rename it to bios.bin.

$ cp qemu-bios.rom ~/bios.bin

You will need it later.

Booting FreeBSD inside QEMU

If you already have a FreeBSD installation inside QEMU, you can boot it using coreboot with the following command:

$ qemu -kernel-kqemu -hda freebsd.img -nographic -L ~

This assumes, that there is a file called bios.bin in your home directory that contains coreboot with an ADLO payload. The file freebsd.img should contain your FreeBSD installation. Make sure it uses the serial console, though, as graphical output will not work when booted using coreboot.

Installing FreeBSD inside QEMU

Installing FreeBSD inside QEMU is pretty straight forward. If you already have a working installation, you can skip this section.

First you need to create a QEMU disk:

$ qemu-img create freebsd.img 1024M

This will create a QEMU virtual disk named freebsd.img with a capacity of 1 GByte. Next, install the base system using one of the ISO files provided by the FreeBSD Project at ftp://ftp.freebsd.org/pub/FreeBSD/ISO-IMAGES-i386 and have QEMU use it as the boot device. In this example, the FreeBSD 7.0-BETA1 bootonly disc [1] is used:

$ qemu -kernel-kqemu -hda freebsd.img -cdrom 7.0-BETA1-i386-bootonly.iso -boot d

Inside QEMU, perform an installation as you normally would. See the FreeBSD Handbook for details. After the installation has finished, boot up FreeBSD once without using coreboot.

$ qemu -kernel-kqemu -hda freebsd.img

In the FreeBSD installation running inside QEMU add the following to the file /boot/loader.conf:

console=comconsole

This will cause FreeBSD to use the first serial port as a console. Both the Loader's and the Kernel's messages will end up there. This is important as graphical output won't work once FreeBSD is booted using coreboot and ADLO.

Creative Commons License
Creative Commons Attribution iconCreative Commons Share Alike icon
This file is licensed under the Creative Commons Attribution ShareAlike 3.0 License.
In short: you are free to share and make derivative works of the file under the conditions that you appropriately attribute it, and that you distribute it only under a license identical to this one.