Update: March 4, 2009
- make versions more explicit
- fix broken links
- add contact info (at bottom)
Building gPXE For Coreboot
Please find below some notes on how I put together an experimental gPXE
payload for coreboot. I'm sure there are other ways to accomplish
the result I wanted, but these procedures worked for me.
These notes only cover the building of the
gPXE coreboot payload ELF. After you have the ELF you may try
putting it into your coreboot ROM.
Warning! Do not use these notes
to create and use a gPXE coreboot payload unless you know what you are
doing with coreboot, and have access to hardware-based re-flashing
tools. These notes are provided as a courtesy. You are
responsible for your own results, etc, blah blah blah.
Approach
- download libpayload
- modify libpayload to produce an extra library with some alternate
symbol names to avoid conflict
with gPXE symbols
- build libpayload
- download gPXE snapshot
- modify gPXE so 16-bit code need not be compiled
- customize gPXE configuration
- add a
libpayload-based console to gPXE
- add a libpayload-based memory map to gPXE
- modify gPXE's ELF support to actually execute the downloaded ELF
image
- build gPXE's blib.a archive
- trim out the 16-bit stuff from blib.a
- make a small C-start so coreboot starts up gPXE okay
- link a coreboot-friendly gPXE ELF
Getting libpayload
$ svn co svn://coreboot.org/repos/trunk/payloads/libpayload -r3473
Add gPXE-friendly library target to libpayload
$ wget http://www.whiterocker.com/gpxe/libpayload-lplconsole.patch
$ patch -p0 < libpayload-lplconsole.patch
Build libpayload
$ make -C libpayload menuconfig # make selections, save and exit
$ make -C libpayload
Getting gPXE
$ wget http://kernel.org/pub/software/utils/boot/gpxe/Old/gpxe-0.9.3.tar.bz2
$ tar xjf gpxe-0.9.3.tar.bz2
Patching gPXE to avoid 16-bit code in mandatory object files
$ wget http://www.whiterocker.com/gpxe/no-16bit.patch
$ patch -p0 < no-16bit.patch
Customizing the gPXE configuration
Here gPXE is configured for ELF image support. Most other types
cannot be supported in my approach because 16-bit code has been
trimmed. Check gpxe-0.9.3/src/config.h for other possible options.
$ wget http://www.whiterocker.com/gpxe/coreboot_config.patch
$ patch -p0 < coreboot_config.patch
Adding a libpayload console to gPXE
$ wget http://www.whiterocker.com/gpxe/coreboot_console.patch
$ patch -p0 < coreboot_console.patch
Making gPXE aware of the coreboot memory map
$ wget http://www.whiterocker.com/gpxe/coreboot_memmap.patch
$ patch -p0 < coreboot_memmap.patch
Coercing gPXE to execute an ELF image
$ wget http://www.whiterocker.com/gpxe/elf-image-exec.patch
$ patch -p0 < elf-image-exec.patch
Making gPXE's blib.a
$ make -C gpxe-0.9.3/src bin/blib.a
Trimming 16-bit stuff from gPXE's blib.a
$ mkdir -p blib
$ cd blib
$ ar xf ../gpxe-0.9.3/src/bin/blib.a
$ rm -f abft.o basemem_packet.o bImageprefix.o bios_console.o biosint.o \
bios.o bootsector.o bzimage.o comprefix.o dskprefix.o e820mangler.o \
elf_dprefix.o exeprefix.o gateA20.o gdbsym.o hdprefix.o hidemem.o \
ibft.o int13.o kpxeprefix.o libkir.o libprefix.o librm.o lkrnprefix.o \
lmelf_dprefix.o lmelf_prefix.o memmap.o multiboot.o nbi.o nbiprefix.o \
nullprefix.o pcibios.o pxe_call.o pxe_entry.o pxe_loader.o pxe_preboot.o \
pxeprefix.o pxe_undi.o romprefix.o stack16.o undiisr.o undiload.o \
undinet.o undi.o undionly.o undipreload.o elfprefix.o
$ ar q trimmed-gpxe-blib.a *.o
$ cd ..
A small C-start for gPXE under coreboot
$ wget http://www.whiterocker.com/gpxe/gpxe-coreboot-cstart.S
$ gcc -c gpxe-coreboot-cstart.S
Linking the gPXE payload
You will want to choose a specific ethernet controller driver. I
show pcnet32 in the example final link below, consult the gPXE sources
for others.
$ wget http://www.whiterocker.com/gpxe/gpxe-coreboot-payload.lds
$ ld -N -T gpxe-coreboot-payload.lds \
-u obj_pcnet32 --defsym check_obj_pcnet32=obj_pcnet32 \
-u obj_config --defsym check_obj_config=obj_config \
-u obj_stack --defsym check_obj_stack=obj_stack \
--defsym pci_vendor_id=0x1022 --defsym pci_device_id=0x2000 \
gpxe-coreboot-cstart.o \
libpayload/lib/lplconsole.o \
blib/trimmed-gpxe-blib.a \
-o gpxe-coreboot-payload-debug.elf
$ objcopy -j .data gpxe-coreboot-payload-debug.elf gpxe-coreboot-payload.elf
Contact Info
Chris Kilgour
(technical, mailing list address): techie at this domain